diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2021-09-04 20:05:00 +0300 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2021-09-04 20:05:00 +0300 |
| commit | 13fd601d0bbd31fd75ec1667d83716a97b28283d (patch) | |
| tree | 65cdbe53fb6f800cfdd7a38f4a718c3f848b9c4a | |
| parent | 99ba07c5cde8a4b2cabec76a6e34b6f92c4a6c5a (diff) | |
| download | pfetch-13fd601d0bbd31fd75ec1667d83716a97b28283d.tar.gz | |
better argument handling. closes #135
| -rwxr-xr-x | pfetch | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -1742,16 +1742,29 @@ get_ascii() { } main() { - [ "$1" = --version ] && { - printf 'pfetch 0.7.0\n' - exit 0 - } + case $* in + -v) + printf '%s 0.7.0\n' "${0##*/}" + return 0 + ;; - # Hide 'stderr' unless the first argument is '-v'. This saves - # polluting the script with '2>/dev/null'. - [ "$1" = -v ] || { - exec 2>/dev/null - } + -d) + # Below exec is not run, stderr is shown. + ;; + + '') + exec 2>/dev/null + ;; + + *) + cat <<EOF +${0##*/} show system information +${0##*/} -d show stderr (debug mode) +${0##*/} -v show version information +EOF + return 0 + ;; + esac # Hide 'stdout' and selectively print to it using '>&6'. # This gives full control over what it displayed on the screen. |
