summaryrefslogtreecommitdiff
path: root/regress/sftp-glob.sh
diff options
context:
space:
mode:
Diffstat (limited to 'regress/sftp-glob.sh')
-rw-r--r--regress/sftp-glob.sh69
1 files changed, 53 insertions, 16 deletions
diff --git a/regress/sftp-glob.sh b/regress/sftp-glob.sh
index e238356a2..d5ebf9fd6 100644
--- a/regress/sftp-glob.sh
+++ b/regress/sftp-glob.sh
@@ -1,28 +1,65 @@
1# $OpenBSD: sftp-glob.sh,v 1.1 2004/12/10 01:31:30 fgsch Exp $ 1# $OpenBSD: sftp-glob.sh,v 1.2 2007/10/24 03:32:35 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="sftp glob" 4tid="sftp glob"
5 5
6sftp_ls() {
7 target=$1
8 errtag=$2
9 expected=$3
10 unexpected=$4
11 verbose "$tid: $errtag"
12 $ECHOE "ls -l ${target}" | \
13 ${SFTP} -b - -P ${SFTPSERVER} 2>/dev/null | \
14 grep -v "^sftp>" > ${RESULTS}
15 if [ $? -ne 0 ]; then
16 fail "$errtag failed"
17 fi
18 if test "x$expected" != "x" && \
19 ! fgrep "$expected" ${RESULTS} >/dev/null 2>&1 ; then
20 fail "$expected missing from $errtag results"
21 fi
22 if test "x$unexpected" != "x" && \
23 fgrep "$unexpected" ${RESULTS} >/dev/null 2>&1 ; then
24 fail "$unexpected present in $errtag results"
25 fi
26 rm -f ${RESULTS}
27}
28
6BASE=${OBJ}/glob 29BASE=${OBJ}/glob
30RESULTS=${OBJ}/results
7DIR=${BASE}/dir 31DIR=${BASE}/dir
8DATA=${DIR}/file 32DATA=${DIR}/file
9 33
34GLOB1="${DIR}/g-wild*"
35GLOB2="${DIR}/g-wildx"
36QUOTE="${DIR}/g-quote\""
37SLASH="${DIR}/g-sl\\ash"
38ESLASH="${DIR}/g-slash\\"
39QSLASH="${DIR}/g-qs\\\""
40SPACE="${DIR}/g-q space"
41
10rm -rf ${BASE} 42rm -rf ${BASE}
11mkdir -p ${DIR} 43mkdir -p ${DIR}
12touch ${DATA} 44touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}"
13 45touch "${QSLASH}" "${ESLASH}" "${SLASH}" "${SPACE}"
14verbose "$tid: ls file" 46
15echo "ls -l ${DIR}/fil*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ 47# target message expected unexpected
16 grep ${DATA} >/dev/null 2>&1 48sftp_ls "${DIR}/fil*" "file glob" "${DATA}" ""
17if [ $? -ne 0 ]; then 49sftp_ls "${BASE}/d*" "dir glob" "`basename ${DATA}`" ""
18 fail "globbed ls file failed" 50sftp_ls "${DIR}/g-wild\"*\"" "quoted glob" "g-wild*" "g-wildx"
19fi 51sftp_ls "${DIR}/g-wild\*" "escaped glob" "g-wild*" "g-wildx"
20 52sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" ""
21verbose "$tid: ls dir" 53sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" ""
22echo "ls -l ${BASE}/d*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ 54sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" ""
23 grep file >/dev/null 2>&1 55sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" ""
24if [ $? -ne 0 ]; then 56sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" ""
25 fail "globbed ls dir failed" 57sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" ""
26fi 58sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" ""
59sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" ""
60sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" ""
61sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" ""
62sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" ""
27 63
28rm -rf ${BASE} 64rm -rf ${BASE}
65