]> granicus.if.org Git - zfs/commitdiff
Use 'printf %s' instead of 'echo -n' for compatibility
authorIgor K <igor@dilos.org>
Thu, 14 Mar 2019 01:39:12 +0000 (04:39 +0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 14 Mar 2019 01:39:12 +0000 (18:39 -0700)
The ksh 'echo -n' behavior on Illumos and Linux differs.  For
compatibility with others platforms switch to "printf '%s' ".

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <guss80@gmail.com>
Signed-off-by: Igor Kozhukhov <igor@dilos.org>
Closes #8501

tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_format.ksh
tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_crypt_combos.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_crypt_combos.ksh

index af5e145f9bdd32c3278fc4596d4ae9e598f211ce..6344b8d05a20ffd40c5a1cc9fcf5960c2a901994 100755 (executable)
@@ -16,6 +16,7 @@
 
 #
 # Copyright (c) 2017 Datto, Inc. All rights reserved.
+# Copyright (c) 2019 DilOS
 #
 
 . $STF_SUITE/include/libtest.shlib
@@ -61,11 +62,11 @@ log_must verify_keyformat $TESTPOOL/$TESTFS1 "hex"
 log_must zfs unload-key $TESTPOOL/$TESTFS1
 log_must eval "echo $HEXKEY | zfs load-key $TESTPOOL/$TESTFS1"
 
-log_must eval "echo -n $RAWKEY | zfs change-key -o keyformat=raw" \
+log_must eval "printf '%s' $RAWKEY | zfs change-key -o keyformat=raw" \
        "$TESTPOOL/$TESTFS1"
 log_must verify_keyformat $TESTPOOL/$TESTFS1 "raw"
 
 log_must zfs unload-key $TESTPOOL/$TESTFS1
-log_must eval "echo -n $RAWKEY | zfs load-key $TESTPOOL/$TESTFS1"
+log_must eval "printf '%s' $RAWKEY | zfs load-key $TESTPOOL/$TESTFS1"
 
 log_pass "'zfs change-key -o' changes the key format"
index d915c5f57a08f5e8dc3966b11bec5579628cd7f9..a46cb55f3662635e68e1c3623b7bf00963138bf4 100755 (executable)
@@ -16,6 +16,7 @@
 
 #
 # Copyright (c) 2017, Datto, Inc. All rights reserved.
+# Copyright (c) 2019, DilOS
 #
 
 . $STF_SUITE/include/libtest.shlib
@@ -75,7 +76,7 @@ typeset -i i=0
 while (( i < ${#ENCRYPTION_ALGS[*]} )); do
        typeset -i j=0
        while (( j < ${#KEYFORMATS[*]} )); do
-               log_must eval "echo -n ${USER_KEYS[j]} | zfs create" \
+               log_must eval "printf '%s' ${USER_KEYS[j]} | zfs create" \
                        "-o ${ENCRYPTION_ALGS[i]} -o ${KEYFORMATS[j]}" \
                        "$TESTPOOL/$TESTFS1"
 
index 8b7ca4799c5ecf6ba5ddf2a18b6d8e6821fde728..d28d5953c5b18e8eb9e644bf326562a19d6276d3 100755 (executable)
@@ -16,6 +16,7 @@
 
 #
 # Copyright (c) 2017, Datto, Inc. All rights reserved.
+# Copyright (c) 2019, DilOS
 #
 
 . $STF_SUITE/include/libtest.shlib
@@ -70,13 +71,13 @@ typeset -i i=0
 while (( i < ${#ENCRYPTION_ALGS[*]} )); do
        typeset -i j=0
        while (( j < ${#KEYFORMATS[*]} )); do
-               log_must eval "echo -n ${USER_KEYS[j]} | zpool create" \
+               log_must eval "printf '%s' ${USER_KEYS[j]} | zpool create" \
                "-O ${ENCRYPTION_ALGS[i]} -O ${KEYFORMATS[j]}" \
                "$TESTPOOL $DISKS"
 
                propertycheck $TESTPOOL ${ENCRYPTION_PROPS[i]} || \
                        log_fail "failed to set ${ENCRYPTION_ALGS[i]}"
-               propertycheck $TESTPOOL ${KEY_FORMATS[j]} || \
+               propertycheck $TESTPOOL ${KEYFORMATS[j]} || \
                        log_fail "failed to set ${KEYFORMATS[j]}"
 
                log_must zpool destroy $TESTPOOL