getopt '::' in --longoptions, seems to default to "no argument" [solved]
Posted: Sat Feb 06, 2021 3:01 pm
This stumped me for a little bit (maybe 30m to an hour) but I couldn't figure out why getopt was rearranging the input argument that followed a long option with "::". For instance:
Code: Select all
getopt -o c:,e:,n: --long chroot-cmd::,chroot-command::,cmd::,::command::,no-exit::,source-subdir:,dest-subdir: -- --source-subdir /cont/01firstrib_lgo_rootfs --chroot-command /bin/sh
becomes:
Code: Select all
declare -a 'options= --source-subdir '\''/cont/01firstrib_lgo_rootfs'\'' --chroot-command '\'''\'' -- '\''/bin/sh'\'''
Notice that the argument for --chroot-command gets moved after the "--". I think the solution is to use an equal sign "=" rather than a space " " to separate the option and its argument.
Edit: That seemed to work. I wonder if this behavior is version dependent.