From 77d44129ad468581e860720ccdb7643d5bb25601 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 20 Jan 2021 20:15:00 +0100 Subject: fixed whitespaces in bash notes --- src/tools/bash.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/tools') diff --git a/src/tools/bash.md b/src/tools/bash.md index 15f455a..6217e8f 100644 --- a/src/tools/bash.md +++ b/src/tools/bash.md @@ -106,7 +106,7 @@ command 2>&1 >file The `getopts` builtin uses following global variables: - `OPTARG`, value of last option argument - `OPTIND`, index of the next argument to process (user must reset) -- `OPTERR`, display errors if set to `1` +- `OPTERR`, display errors if set to `1` ```bash getopts [] @@ -121,15 +121,15 @@ getopts [] ```bash #!/bin/bash function parse_args() { - while getopts "f:c" PARAM; do - case $PARAM in - f) echo "GOT -f $OPTARG";; - c) echo "GOT -c";; - *) echo "ERR: print usage"; exit 1;; - esac - done - # users responsibility to reset OPTIND - OPTIND=0 + while getopts "f:c" PARAM; do + case $PARAM in + f) echo "GOT -f $OPTARG";; + c) echo "GOT -c";; + *) echo "ERR: print usage"; exit 1;; + esac + done + # users responsibility to reset OPTIND + OPTIND=0 } parse_args -f xxx -c -- cgit v1.2.3