Created
July 3, 2023 15:21
-
-
Save crischutu07/5f1bd44468147e21629802dc45ef00f8 to your computer and use it in GitHub Desktop.
handle function arguments with read statements
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
#!/usr/bin/env bash | |
source cmdHandler.sh | |
echo 'hello' | |
function test (){ | |
local args=$1 | |
echo "Test args: $args" | |
} | |
while true; do | |
read -p "> " maininput | |
# only use the first args (group) | |
fixedinput=$(echo ${maininput%% *}) | |
case "$(echo ${fixedinput})" in | |
[Tt]est) test "$maininput";; | |
[Ee]xit) exit;; | |
[Rr]estart) exit; bash '$0.sh';; | |
'');; # '' not found fix | |
[Aa]rgs) echo $fixedinput;; | |
*) echo "'$maininput' is not found";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use for fix