cleaner way to set default values

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2012-02-03 20:55:24 +01:00
parent 85f7880c7e
commit 4628dad045
2 changed files with 6 additions and 11 deletions

View file

@ -21,11 +21,9 @@
# Get the current value of key or __NOTSET__ if the key doesn't exist. # Get the current value of key or __NOTSET__ if the key doesn't exist.
# #
if [ -f "$__object/parameter/key" ]; then key="$(cat "$__object/parameter/key" 2>/dev/null \
key="$(cat "$__object/parameter/key")" || echo "$__object_id")"
else
key="$__object_id"
fi
file="$(cat "$__object/parameter/file")" file="$(cat "$__object/parameter/file")"
delimiter="$(cat "$__object/parameter/delimiter")" delimiter="$(cat "$__object/parameter/delimiter")"

View file

@ -18,9 +18,6 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
if [ -f "$__object/parameter/key" ]; then # set defaults
key="$(cat "$__object/parameter/key")" [ -f "$__object/parameter/key" ] \
else || echo "$__object_id" > "$__object/parameter/key"
echo "$__object_id" > "$__object/parameter/key"
fi