Last active
May 21, 2024 02:49
-
-
Save nasa9084/caee63465acb712d43301c488534e7b5 to your computer and use it in GitHub Desktop.
jq/jnv transparently
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
readonly version="0.0.1" | |
for opt in ${@} | |
do | |
case "${opt}" in | |
"-h") | |
echo A jq/jnv transparent wrapper | |
exit 0 | |
;; | |
"-v") | |
echo jq.sh version "${version}" | |
;; | |
esac | |
done | |
case "${#}" in | |
0) | |
if [ -t 0 ] | |
then | |
echo error: no argument is passed | |
exit 1 | |
else | |
cat | jnv | |
fi | |
;; | |
1) | |
if [ -t 0 ] | |
then | |
jnv "${1}" | |
else | |
cat | jq "${1}" | |
fi | |
;; | |
*) | |
if [ -t 0 ] | |
then | |
jq "${@}" | |
else | |
cat | jq "${@}" | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment