From 7c54d24873877dfdf64ef0c71195925db2e6fb4b Mon Sep 17 00:00:00 2001 From: dtucker Date: Mon, 25 Mar 2024 03:30:31 +0000 Subject: [PATCH] Improve shell portability: grep -q is not portable so redirect stdout, and use printf instead of relying on echo to do \n substitution. Reduces diff vs Portable. --- regress/usr.bin/ssh/sftp-cmds.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/regress/usr.bin/ssh/sftp-cmds.sh b/regress/usr.bin/ssh/sftp-cmds.sh index 7f79b53b821..d742bb735a7 100644 --- a/regress/usr.bin/ssh/sftp-cmds.sh +++ b/regress/usr.bin/ssh/sftp-cmds.sh @@ -1,4 +1,4 @@ -# $OpenBSD: sftp-cmds.sh,v 1.15 2022/03/31 03:07:33 djm Exp $ +# $OpenBSD: sftp-cmds.sh,v 1.16 2024/03/25 03:30:31 dtucker Exp $ # Placed in the Public Domain. # XXX - TODO: @@ -22,12 +22,12 @@ rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 mkdir ${COPY}.dd verbose "$tid: lls" -echo "cd ${OBJ}\nlls" | ${SFTP} -D ${SFTPSERVER} 2>&1 | \ - grep -q copy.dd || fail "lls failed" +printf "cd ${OBJ}\nlls\n" | ${SFTP} -D ${SFTPSERVER} 2>&1 | \ + grep copy.dd >/dev/null || fail "lls failed" verbose "$tid: lls w/path" echo "lls ${OBJ}" | ${SFTP} -D ${SFTPSERVER} 2>&1 | \ - grep -q copy.dd || fail "lls w/path failed" + grep copy.dd >/dev/null || fail "lls w/path failed" verbose "$tid: ls" echo "ls ${OBJ}" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ @@ -110,13 +110,13 @@ done rm -f ${COPY}.dd/* verbose "$tid: get to local dir" -echo "lcd ${COPY}.dd\nget $DATA" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ +printf "lcd ${COPY}.dd\nget $DATA\n" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ || fail "get failed" cmp $DATA ${COPY}.dd/${DATANAME} || fail "corrupted copy after get" rm -f ${COPY}.dd/* verbose "$tid: glob get to local dir" -echo "lcd ${COPY}.dd\nget /bin/l*" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ +printf "lcd ${COPY}.dd\nget /bin/l*\n" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ || fail "get failed" for x in $GLOBFILES; do cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after get" @@ -156,13 +156,13 @@ done rm -f ${COPY}.dd/* verbose "$tid: put to local dir" -echo "cd ${COPY}.dd\nput $DATA" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ +printf "cd ${COPY}.dd\nput $DATA\n" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ || fail "put failed" cmp $DATA ${COPY}.dd/${DATANAME} || fail "corrupted copy after put" rm -f ${COPY}.dd/* verbose "$tid: glob put to local dir" -echo "cd ${COPY}.dd\nput /bin/l*" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ +printf "cd ${COPY}.dd\nput /bin/l*\n" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ || fail "put failed" for x in $GLOBFILES; do cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after put" -- 2.20.1