Editing
Integration of CodeRunner with MAMP
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Why <code>$filename</code> uses that odd quoting pattern == CodeRunner handles <code>$filename</code> by directly replacing the text <code>$filename</code> in the Run Command field with the actual file path string — it's not spawning a shell first and passing in a variable. In other words, CodeRunner does '''text substitution''', not shell variable expansion. Since the whole command is wrapped in single quotes <code>'...'</code> for <code>sh -c</code>, the shell won't expand anything inside those single quotes at all. If <code>$filename</code> were left inside the single quotes, it would be treated as the '''literal text''' <code>$filename</code>, not the actual path CodeRunner substitutes in. The fix is to "step out" of the single-quoted string right where <code>$filename</code> needs to go, let CodeRunner substitute it outside the quotes, then step back into the single-quoted string: <pre> "'"$filename"'" </pre> Broken down: <pre> "' → closing double quote + closing single quote (temporarily exits the string) "$filename" → outside the single quotes, so CodeRunner replaces it with the actual file path '" → opening single quote + opening double quote (re-enters the string) </pre> This is a common shell trick: '''inserting content that needs to be expanded in the middle of a single-quoted string'''. Since single quotes never expand anything inside them, the only way to splice in something that needs expanding is to end the single-quoted string, insert the piece, then start a new single-quoted string right after.
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information