On 3/20/21 4:38 PM, Bruce Dubbs wrote:
On 3/20/21 10:44 AM, Pierre Labastie wrote:
Anyway, I hope you are now convinced that the right command for
testing script
status is:
if ! check_script_status; then continue; fi
I agree with the syntax, but have a problem with the name. What are
we checking the script status for? complete? error? Perhaps
if is_valid_script; then continue; fi
that should be
if ! is_valid_script; then continue; fi
It skips nonexistent scripts and/or if they are not executable
Rewriting the function, it only needs to do this:
function check_script_status {
if [[ ! -x ${1} ]]; then
log_warning_msg "${1} does not exist or is not executable,
skipping."
return 1
else
return 0
fi
}
Or if one want to drop the !
function check_script_status {
if [[ -x ${1} ]]; then
return 0
else
log_warning_msg "${1} does not exist or is not executable,
skipping."
return 1
fi
}
No need to see if the symlink exists or points to the a file/script
-x does it all
called like this
check_script_status <filespec> || continue
It isn't really validating the script.
It only checks that if the file or the file pointed to by the symlink
exists and has the execute flag/bit set.
maybe call it if_script_exist_executable
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
Do not top post on this list.
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
http://en.wikipedia.org/wiki/Posting_style