If the name you type has slashes, the shell tries to access that pathname directly. When the shell finds an executable file, the shell forks itself into a second process and then tells the Unix/Linux kernel try to replace that second process with the executable code in the file, causing the file to execute.
How do I avoid accidental overwriting of a file on bash shell? You can tell bash shell not to delete file data / contents by mistake by setting noclobber variable. It can keep you from accidentally destroying your existing files by redirecting input over an already-existing file.
To end a shell script and set its exit status, use the exit command. Give exit the exit status that your script should have. If it has no explicit status, it will exit with the status of the last command run.
with the current version of bash, modifying a script on-disk while it is running will cause bash to "try" to load the changes into memory and take these on in the running script. if your changes come after the currently executing line, the new lines will be loaded and executed.
#beginning of bashscript1.sh
source bashscript2.sh
echo $variable
and here is the source file:
#beginning of bashscript2.sh
rm -f bashscript2.sh
variable = "integer of some kind"
How will the bash script be handled? Does it first load the source file and then deletes it, or will the variable have a value in bash script 1?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With