New answers tagged


If arguments do not have spaces or newlines. Transform the arguments into an string: "$*", and use that: f(){ docker exec -it $(docker-compose ps -q web) "$@"; } case "$*" in bash) f /bin/bash ;; shell) f python shell ;; test) f python test apps ;; test\ ?*) f python ...


You can just reset your args however you want using set ... case "$1" in #... test) [ $# -lt 2 ] && set test apps docker exec -it $(docker-compose ps -q web) python $@ ;; esac


I'd try to use bash variable substitution: test) shift docker exec -it $(docker-compose ps -q web) python test "${@-apps}" ;; Other way is to check $* instead of $1: case $* in bash) ... test) docker exec -it $(docker-compose ps -q web) python test apps ;; test\ *) ...


something like this would work well if [ -z "$2" ] then echo "No argument supplied" fi


POSIXly: for arg do shift [ "$arg" = "-inf" ] && continue set -- "$@" "$arg" done printf '%s\n' "$@" The above code even works in pre-POSIX shells, except the original Almquist shell (Read Endnote). Change the for loop to: for arg do ... done guarantee to work in all shells. Another POSIX one: for arg do shift case $arg in ...


You can achieve that by using the following notation: echo "${!index}" If you want to process positional arguments, I suggest to use getopt (not getopts), though.


Your requirements are logically contradictory. Given input like gitploy up -t 2.0.0 test_repo, you need to parse the options, and in particular notice the presence of the -t option and the fact that it takes one argument, in order to identify that the first non-option argument is test_repo. So first parse the options normally. Then you can know what the ...


You can't do it from the inside of your script. * has to be escaped, otherwise it will try to fit filenames (in your case x., then anything, as * is a glob operator that matches any string in filename). You can do it in, basically, three ways - enclose your string with single or double quotes: ./ "x.*" ./ 'x.*' Or prefix problematic ...


If your Linux distribution successfully EFI STUB boots, there is no need to use add_efi_memmap. This kernel command line option is rarely needed nowadays - UEFI firmware and Linux kernel support for same has significantly improved since 2009 era.

Top 50 recent answers are included