You should use the command-line argument variables $1, $2, $3, etc. $1 is automatically set to the first word after the command on the command line. $2 is the second word. $3$3 is the third, etc. You can also use the variable $#, which contains the number of arguments on the command line, to see if there are any arguments.
So your script would be:
#!/bin/bash if [ $# -gt 0 ]; then var="$1" else read var fi if [ "$var" == upd ]; then sudo pacman -Syyu; yay -Syu fi Note: You should ALWAYS put quotation marks around any variable that could contain spaces, especially if the variable might come from user input.