When the key cannot be retrieved while setting the value,
try to create it assuming the key doesn't exist.
Checking "No such file" log is not that robust way checking
if the key exist or not because it depends on "errno" which
can be changed by some libc apis.
Change-Id: I0231632a0df104030c90c9cd01af06d8a9d95552
Signed-off-by: Semun Lee <semun.lee@samsung.com>
[ -z "${TYPE}" ] && echo "Type '${OPT_TYPE}': Invalid type" && usage
RES=`${BUXTONTOOL} ${OPT_DIRECT} get ${LAYER} ${OPT_KEY} 2>&1`
- if [ $? -eq 0 ]; then
+ if [ $? -eq 0 ]
+ then
if [ ${OPT_FORCE} -eq 0 ]; then
echo "Key already exist. Use -f option to force update"
exit 1
fi
+ else
+ do_create
+ exit $?
fi
dbg ${BUXTONTOOL} ${OPT_DIRECT} ${OPT_INIT} set-${TYPE} \
RES=`${BUXTONTOOL} ${OPT_DIRECT} ${OPT_INIT} set-${TYPE} \
${LAYER} ${OPT_KEY} "${OPT_VAL}" 2>&1`
if [ $? -ne 0 ]; then
- echo "$RES" | grep -q "No such file"
- if [ $? -eq 0 ]; then
- do_create
- exit $?
- fi
-
echo "Error: $RES"
exit 1
fi