- (dtucker) [openbsd-compat/readpassphrase.c] Resync against OpenBSD's r1.18: ...
[openssh-git.git] / regress / sftp-glob.sh
blob72bb17d75336a1f04ada48a560f683360c7224d4
1 # $OpenBSD: sftp-glob.sh,v 1.4 2009/08/13 01:11:55 djm Exp $
2 # Placed in the Public Domain.
4 tid="sftp glob"
6 sftp_ls() {
7 target=$1
8 errtag=$2
9 expected=$3
10 unexpected=$4
11 verbose "$tid: $errtag"
12 printf "ls -l %s" "${target}" | \
13 ${SFTP} -b - -D ${SFTPSERVER} 2>/dev/null | \
14 grep -v "^sftp>" > ${RESULTS}
15 if [ $? -ne 0 ]; then
16 fail "$errtag failed"
18 if test "x$expected" != "x" ; then
19 if fgrep "$expected" ${RESULTS} >/dev/null 2>&1 ; then
21 else
22 fail "$expected missing from $errtag results"
25 if test "x$unexpected" != "x" && \
26 fgrep "$unexpected" ${RESULTS} >/dev/null 2>&1 ; then
27 fail "$unexpected present in $errtag results"
29 rm -f ${RESULTS}
32 BASE=${OBJ}/glob
33 RESULTS=${OBJ}/results
34 DIR=${BASE}/dir
35 DATA=${DIR}/file
37 GLOB1="${DIR}/g-wild*"
38 GLOB2="${DIR}/g-wildx"
39 QUOTE="${DIR}/g-quote\""
40 SLASH="${DIR}/g-sl\\ash"
41 ESLASH="${DIR}/g-slash\\"
42 QSLASH="${DIR}/g-qs\\\""
43 SPACE="${DIR}/g-q space"
45 rm -rf ${BASE}
46 mkdir -p ${DIR}
47 touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}"
48 touch "${QSLASH}" "${ESLASH}" "${SLASH}" "${SPACE}"
50 # target message expected unexpected
51 sftp_ls "${DIR}/fil*" "file glob" "${DATA}" ""
52 sftp_ls "${BASE}/d*" "dir glob" "`basename ${DATA}`" ""
53 sftp_ls "${DIR}/g-wild\"*\"" "quoted glob" "g-wild*" "g-wildx"
54 sftp_ls "${DIR}/g-wild\*" "escaped glob" "g-wild*" "g-wildx"
55 sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" ""
56 sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" ""
57 sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" ""
58 sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" ""
59 sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" ""
60 sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" ""
61 sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" ""
62 sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" ""
63 sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" ""
64 sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" ""
65 sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" ""
67 rm -rf ${BASE}