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!
== Step 1: Finding the newest php executable == <pre lang="bash"> php=$(ls -d /Applications/MAMP/bin/php/php*/bin/php | sort -V | tail -1) </pre> <table class="wikitable"> <tr> <td> Segment </td> <td> What it does </td> </tr> <tr> <td> <code>ls -d /Applications/MAMP/bin/php/php*/bin/php</code> </td> <td> Lists all files matching this path pattern </td> </tr> <tr> <td> <code>sort -V</code> </td> <td> Sorts by '''version number''' </td> </tr> <tr> <td> <code>tail -1</code> </td> <td> Takes the last line of the sorted output — the newest version </td> </tr> <tr> <td> <code>php=$(...)</code> </td> <td> Stores the result into the variable <code>php</code> </td> </tr> </table> '''What <code>ls -d</code> does''': Normally, <code>ls</code> on a directory lists its contents, but <code>-d</code> makes it list the matching path itself without descending into it. <code>php*</code> is a wildcard matching every folder under <code>php</code> that starts with <code>php</code>, for example: <pre> /Applications/MAMP/bin/php/php8.1.33/bin/php /Applications/MAMP/bin/php/php8.2.29/bin/php /Applications/MAMP/bin/php/php8.3.14/bin/php </pre> '''What <code>sort -V</code> does''': Regular <code>sort</code> sorts as plain strings, which causes problems — <code>php8.10.0</code> would sort ''before'' <code>php8.2.0</code> (since character <code>1</code> is less than <code>2</code>). <code>-V</code> (version sort) understands version-number semantics and correctly places <code>8.10.0</code> after <code>8.2.0</code>. '''<code>tail -1</code>''': Takes the last line of the sorted result — the entry with the highest version number. So the whole <code>$(...)</code> expression captures the full path to the newest installed MAMP php version. After this line runs, the <code>php</code> variable holds something like: <pre> /Applications/MAMP/bin/php/php8.2.29/bin/php </pre>
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