In Pure Bash (or any other pure shellscript), use
It's a tip that recomments using a file whose the program has. I have ever posted these answers that uses the tip:
- Implement a Truth-Machine
- 1, 2, Fizz, 4, Buzz
- Swap every two elements in a list
- Tips for golfing in Bash
- Print 0 to 100 without 1-9 characters
- Uncomment a COBOL program!
But I have thought that these situations can be thought:
- The program's file is placed on
/(root directory), which prevents from using
cd /to end the loop.
- The program's file is read-only, which prevents from using
>xto end the loop.
- The program is invoked from different directory, such as invoked with
- The program's directory has several files such as
rm -Rf /that can have arbitrary data such as different shell script so invoking things such as
for x in *; do ...; done,
. *results in several behaviours.
- The shell script is invoked with the flag such as
What assumptions must be given for such programs?