https://github.com/tkuchiki/bash-get-long-opts
Get long options for bash.
https://github.com/tkuchiki/bash-get-long-opts
Last synced: 2 months ago
JSON representation
Get long options for bash.
- Host: GitHub
- URL: https://github.com/tkuchiki/bash-get-long-opts
- Owner: tkuchiki
- License: mit
- Created: 2014-05-08T01:51:46.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-08T05:54:38.000Z (about 11 years ago)
- Last Synced: 2025-01-25T09:11:09.674Z (4 months ago)
- Language: Shell
- Size: 137 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bash-get-long-opts
==================Get long options for bash.
This script run on the bash.# Functions
## usage
Print command usage.
## parse_options
Parse `-abc` style options.
~~~~
$ parse_options --foo -abc -s bar
--foo -a -b -c -s bar
~~~~## get_long_options
Get long options.
~~~~
$ get_long_options $(parse_options --foo -abc -s bar)
~~~~# Example
[example.sh](https://github.com/tkuchiki/bash-get-long-opts/blob/master/example.sh)
## Non-option
~~~~
$ ./example.sh
VAL is empty.
~~~~## Normal options
~~~~
$ ./example.sh -v -d -s foobar
use verbose mode.
use debug mode.
set VAL=foobar.
~~~~## -abc style options
~~~~
$ ./example.sh -vd -s foobar
use verbose mode.
use debug mode.
set VAL=foobar.
~~~~## Short and long options.
~~~~
$ ./example.sh -d --set foobar --verbose
use verbose mode.
use debug mode.
set VAL=foobar.
~~~~## Error
~~~~
$ ./example.sh --badopt
example.sh: error - unrecognized option --badopt
~~~~