Use 'printf %s' instead of 'echo -n' for compatibility

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
This commit is contained in:
Igor K 2019-03-14 04:39:12 +03:00 committed by Brian Behlendorf
parent 1af240f3b5
commit 508c5527d0
3 changed files with 8 additions and 5 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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