diff options
Diffstat (limited to 'regress/sftp-glob.sh')
-rw-r--r-- | regress/sftp-glob.sh | 69 |
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 | ||
4 | tid="sftp glob" | 4 | tid="sftp glob" |
5 | 5 | ||
6 | sftp_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 | |||
6 | BASE=${OBJ}/glob | 29 | BASE=${OBJ}/glob |
30 | RESULTS=${OBJ}/results | ||
7 | DIR=${BASE}/dir | 31 | DIR=${BASE}/dir |
8 | DATA=${DIR}/file | 32 | DATA=${DIR}/file |
9 | 33 | ||
34 | GLOB1="${DIR}/g-wild*" | ||
35 | GLOB2="${DIR}/g-wildx" | ||
36 | QUOTE="${DIR}/g-quote\"" | ||
37 | SLASH="${DIR}/g-sl\\ash" | ||
38 | ESLASH="${DIR}/g-slash\\" | ||
39 | QSLASH="${DIR}/g-qs\\\"" | ||
40 | SPACE="${DIR}/g-q space" | ||
41 | |||
10 | rm -rf ${BASE} | 42 | rm -rf ${BASE} |
11 | mkdir -p ${DIR} | 43 | mkdir -p ${DIR} |
12 | touch ${DATA} | 44 | touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}" |
13 | 45 | touch "${QSLASH}" "${ESLASH}" "${SLASH}" "${SPACE}" | |
14 | verbose "$tid: ls file" | 46 | |
15 | echo "ls -l ${DIR}/fil*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ | 47 | # target message expected unexpected |
16 | grep ${DATA} >/dev/null 2>&1 | 48 | sftp_ls "${DIR}/fil*" "file glob" "${DATA}" "" |
17 | if [ $? -ne 0 ]; then | 49 | sftp_ls "${BASE}/d*" "dir glob" "`basename ${DATA}`" "" |
18 | fail "globbed ls file failed" | 50 | sftp_ls "${DIR}/g-wild\"*\"" "quoted glob" "g-wild*" "g-wildx" |
19 | fi | 51 | sftp_ls "${DIR}/g-wild\*" "escaped glob" "g-wild*" "g-wildx" |
20 | 52 | sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" "" | |
21 | verbose "$tid: ls dir" | 53 | sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" "" |
22 | echo "ls -l ${BASE}/d*" | ${SFTP} -P ${SFTPSERVER} 2>/dev/null | \ | 54 | sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" "" |
23 | grep file >/dev/null 2>&1 | 55 | sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" "" |
24 | if [ $? -ne 0 ]; then | 56 | sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" "" |
25 | fail "globbed ls dir failed" | 57 | sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" "" |
26 | fi | 58 | sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" "" |
59 | sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" "" | ||
60 | sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" "" | ||
61 | sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" "" | ||
62 | sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" "" | ||
27 | 63 | ||
28 | rm -rf ${BASE} | 64 | rm -rf ${BASE} |
65 | |||