New answers tagged

1

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 manage.py shell ;; test) f python manage.py test apps ;; test\ ?*) f python ...


2

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 manage.py $@ ;; esac


7

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


2

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


6

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 ...


3

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.


1

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 ...


2

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: ./script.sh "x.*" ./script.sh 'x.*' Or prefix problematic ...


0

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