The First Three Minutes Pdf Free Download
LINK ->->->-> https://urlgoal.com/2tcjBC
Q: Bash function with if statements keeps dashing the loop i'm trying to make a bash function that, when called followed by a certain string, will echo a greeting, followed by a phrase and then a set of commands. Currently it just echoes the "hello world" entry followed by the rest of the commands. Here is my function: function perform_commands() { cat > /dev/null 2>&1 echo while read -r line do echo "$line" if [ "$line" == "test" ] then echo "Test" fi done < /dev/tty } Basically, when i call that function with test, it outputs: perform_commands test test After this I can simply do all the commands i want, but the "test" line doesn't get cleared before running the commands, which is not what i want. would really appreciate your help. A: I just added the wait command to your function to prevent it from running if no input is provided. function perform_commands() { cat > /dev/null 2>&1 echo while read -r line do echo "$line" if [ "$line" == "test" ] then echo "Test" fi wait done < /dev/tty } When called with test it will print: perform_commands Hello, World! Test dang it you beat me!... To return a string, "done" needs to be changed to a comma :D perform_commands Hello, World! Test Normally you shouldn't pass a while loop to a function like this. d2c66b5586