aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-01-20 20:15:00 +0100
committerjohannst <johannes.stoelp@gmail.com>2021-01-20 20:15:00 +0100
commit77d44129ad468581e860720ccdb7643d5bb25601 (patch)
tree2ccf8205802f0998deb44b9011acdacf6ecd3fca
parent836b1874369fa47f37a71f2f04af18e7929567ce (diff)
downloadnotes-77d44129ad468581e860720ccdb7643d5bb25601.tar.gz
notes-77d44129ad468581e860720ccdb7643d5bb25601.zip
fixed whitespaces in bash notes
-rw-r--r--src/tools/bash.md20
1 files changed, 10 insertions, 10 deletions
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 <optstring> <param> [<args>]
@@ -121,15 +121,15 @@ getopts <optstring> <param> [<args>]
```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