shell - Prevent a command in a shellscript from being executed inside another shellscript -
i invoking shellscript inside shellscript, , invoked 1 has command delete folder, don't want executed, this
$ rm ../temp -rf is there way prevent command being executed without changing invoked script contents?
you can define alias in script:
alias rm='echo safe' by default aliases work in interactive shells, must change behaviour with:
shopt -s expand_aliases in script , source other script (the 1 cannot change):
source the_other_script.sh or
. the_other_script.sh this work unless other script runs rm in sub-shell.
another, safer method create own rm command nothing (or prints out argument know what's going on), put directory , put directory first 1 in path environment variable (korn shell syntax):
$ export path=/path/to/your/dummy/rm/replacement:$path
Comments
Post a Comment