diff options
author | P. J. McDermott <pjm@nac.net> | 2012-09-28 22:58:22 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-09-28 22:58:22 (EDT) |
commit | 96fdd7d8843c2b76332f255728708bd83a8418d2 (patch) | |
tree | 1e112dcff8cad461c835ff0aff4cd602dba68319 | |
parent | 7494dc3e62f6623d63e1b9a086fb5266d8bcbce4 (diff) |
Add a function to validate shell variable names.
-rw-r--r-- | lib/common.sh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/common.sh b/lib/common.sh index 22b017c..ee5dcb5 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -38,3 +38,13 @@ _ob_return() return ${1} } + +_ob_validate_var_name() +{ + case "${1}" in + [!a-zA-Z_]*|*[!a-zA-Z0-9_]*) + return 1 + ;; + esac + return 0 +} |