flatcar-scripts/namevalue
Don Garrett 234d3b7528 These files are required by 'pushimage'.
I missed two library dependancies for pushimage when I moved it from
crostools to src/script. Moving them now.

BUG=chromiumos:14372
TEST=None

Change-Id: I47fffa3c09d8eb0d119b9c8732fcf4e1ce149189
Reviewed-on: http://gerrit.chromium.org/gerrit/1120
Reviewed-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
2011-05-18 11:52:32 -07:00

33 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
########################################################################
#- PROGRAM NAME: namevalue
#- AUTHOR & DT : David McMahon
#- RCS Ident :
#+ USAGE : . namevalue
#+ DESCRIPTION : Set local shell environment from arguments name=value
#+ or -name=value or --name=value
########################################################################
# XXX: At some point, this should find all --whatever args without an =
# and set then to true, but this will mess with all existing independent
# handling of --whatever args passed through current with LOOSEARGS.
# but a nice exercise to simplify and centralize cmd-line processing.
ORIG_CMDLINE="$*"
for arg in "$@"
do
case $arg in
*=*) # Strip off any leading -*
arg=$(echo $arg |sed 's,^-*,,g')
# "set" any arguments that have = in them
NAMEX=${arg%%=*}
# change -'s to _ for legal vars in bash
NAMEX=${NAMEX/-/_}
VALUEX=${arg#*=}
eval export $NAMEX=\""$VALUEX"\"
;;
*) LOOSEARGS="$LOOSEARGS $arg"
;;
esac
done