with-emacs.sh icon indicating copy to clipboard operation
with-emacs.sh copied to clipboard

Does not work with default Mac `getopt` version

Open Stwerp opened this issue 3 years ago • 2 comments

The Mac getopt is unable to parse long options and uses a slightly different syntax. I need to test this on a linux box, but I believe the following change will be sufficient.

getopt -T > /dev/null
if [ $? -eq 4 ]; then
    # GNU enhanced getopt available with long options
    args=$(getopt -n "$0" -o d:hi:OPR -l dir:,debug,help,install:,no-package,no-org-repo,no-refresh-packages -- "$@") || { usage; exit 1; }

else
    # Mac/BSD version
    args=$(getopt d:hi:OPR "$*")
fi
eval set -- "$args"

I did need to change the while [true] to while [ $# -gt 0 ]; at the top of the argument processing loop as well. I did have some trouble passing on arguments to emacs in the $rest variable, but it does let me quickly setup a sandbox.

Of course the other option is to just install getopt from homebrew, and this would all be moot :)

Stwerp avatar Mar 20 '21 19:03 Stwerp

Please see https://github.com/alphapapa/makem.sh/issues/26. The discussion there applies to this repo also.

alphapapa avatar Mar 20 '21 22:03 alphapapa

Hello! :)

This config worked here (macos)

But for some reason --dir doesnt work properly (macos). It somehow understands that the name of the directory is ir, probably because it thinks --dir is -d ir.

Works with -d tho.

viglioni avatar Sep 26 '21 19:09 viglioni