version 1.320, 2017/10/08 00:45:25 |
version 1.321, 2017/10/08 01:05:13 |
|
|
eval "$1='$2'; export $1" |
eval "$1='$2'; export $1" |
makeenv="${makeenv} $1" |
makeenv="${makeenv} $1" |
} |
} |
|
safe_setmakeenv() |
|
{ |
|
case "$1" in |
|
|
|
# Look for any vars we want to prohibit here, like: |
|
# Bad | Dangerous) usage "Cannot override $1 with -V";; |
|
|
|
# That first char is OK has already been verified. |
|
*[!A-Za-z0-9_]*) usage "Bad variable name (-V): '$1'";; |
|
esac |
|
setmakeenv "$@" |
|
} |
|
|
unsetmakeenv() |
unsetmakeenv() |
{ |
{ |
eval "unset $1" |
eval "unset $1" |
makeenv="${makeenv} $1" |
makeenv="${makeenv} $1" |
} |
} |
|
safe_unsetmakeenv() |
|
{ |
|
case "$1" in |
|
|
|
# Look for any vars user should not be able to unset |
|
# Needed | Must_Have) usage "Variable $1 cannot be unset";; |
|
|
|
[!A-Za-z_]* | *[!A-Za-z0-9_]*) usage "Bad variable name (-Z): '$1'";; |
|
esac |
|
unsetmakeenv "$1" |
|
} |
|
|
# Given a variable name in $1, modify the variable in place as follows: |
# Given a variable name in $1, modify the variable in place as follows: |
# For each space-separated word in the variable, call resolvepath. |
# For each space-separated word in the variable, call resolvepath. |
|
|
eval ${optargcmd} |
eval ${optargcmd} |
case "${OPTARG}" in |
case "${OPTARG}" in |
# XXX: consider restricting which variables can be changed? |
# XXX: consider restricting which variables can be changed? |
[a-zA-Z_][a-zA-Z_0-9]*=*) |
[a-zA-Z_]*=*) |
setmakeenv "${OPTARG%%=*}" "${OPTARG#*=}" |
safe_setmakeenv "${OPTARG%%=*}" "${OPTARG#*=}" |
|
;; |
|
[a-zA-Z_]*) |
|
safe_setmakeenv "${OPTARG}" "" |
;; |
;; |
*) |
*) |
usage "-V argument must be of the form 'var=[value]'" |
usage "-V argument must be of the form 'var=[value]'" |
|
|
-Z) |
-Z) |
eval ${optargcmd} |
eval ${optargcmd} |
# XXX: consider restricting which variables can be unset? |
# XXX: consider restricting which variables can be unset? |
unsetmakeenv "${OPTARG}" |
safe_unsetmakeenv "${OPTARG}" |
;; |
;; |
|
|
--) |
--) |