From 2a8bd8d431928a33893356e04fcebf2aee9eeba4 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Wed, 29 Nov 2017 19:28:05 +0900 Subject: [PATCH] Fix vconftool set command 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 --- vconf-compat/vconftool | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vconf-compat/vconftool b/vconf-compat/vconftool index f178561..3ba8d33 100755 --- a/vconf-compat/vconftool +++ b/vconf-compat/vconftool @@ -132,11 +132,15 @@ do_set() { [ -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} \ @@ -144,12 +148,6 @@ do_set() { 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 -- 2.7.4