by
3 8
0
3
2,063
0
Top 1% !
Famous
Specified
Popularity: 9866th place

Published on:

No tags for this snippet yet.
LanguageShell
SourceGitHub
SourceMyGists

Canonical shell argument parsing.

Canonical shell argument parsing.: 
argparse.zsh
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/660841/Canonical-shell-argument-parsing-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
#!/usr/bin/env zsh # Print usage information if there are no arguments on the command line. [ "$#" = "0" ] && echo 'Usage: via-ssh.sh [ -v ] [ -d ] [USER@]SERVER[:PORT]' && exit 1 # Process the command line parameters. while [ "$#" != '0' ] ; do case "$1" in -v) VERBOSE=1 ; shift ;; -d) DNS=1 ; shift ;; *) SSH_PORT=${1##*:} SSH_USER_SERVER=${1%%:*} [ "$SSH_USER_SERVER" = "$SSH_PORT" ] && SSH_PORT=22 shift ;; esac done
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus