Bash - read as a fallback to $@
- by user137369
I have a working bash script (working on OSX) that takes files and directories as input and does something like
for inputFile in $@
do
[someStuff]
done
but I want to provide a “fallback”, meaning, if the script is started with no arguments (double-clicked, for example), it can take input at that time, by letting the user drop the files directly on the terminal (possibly through read but not mandatory, I'm open to better/different solutions).
I'm guessing I should use some kind of if statement, but I'm not sure how. I'd like to not have to essentially duplicate the script's size by two by repeating [someStuff] for each case.
Thank you.