File: execdir-multiple.exp

package info (click to toggle)
findutils 4.10.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,108 kB
  • sloc: ansic: 126,635; sh: 11,486; yacc: 1,852; makefile: 844; exp: 839; python: 66; sed: 16
file content (58 lines) | stat: -rw-r--r-- 1,607 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# tests for -execdir ... \+

# Create 4 empty files in each of 6 directories.
# Also create a shell script in each of those 6 directories.
# Run a find command which runs the shell script for each empty file.
# Check to make sure that each file is mentioned exactly once, and that
# the command was run with the correct working directory.
#
# The output is a sequence of lines of this form:
#
# cwd ./basename
#
# cmd is the basename of the current directory at the time the command
# is run by -execidr.   ./basename is the name of the file that was matched
# (that is, it's the value passed in {}).

# $body is the body of a shell script we use for testing.
# It prints a series of lines of the form described above.
# One line is printed for each command-line argument.
set body {#! /bin/sh
set -e
here=`pwd`
d=`basename $here`

for arg;
do
  echo "$d" "$arg"
done | LC_ALL=C sort
}


if { [ safe_path ] } {
    global SKIP_OLD

    exec rm -rf tmp
    mkdir tmp

    # Put a copy of our shell script in each
    # directory, plus some files.
    foreach dir { a b c d e f } {
	mkdir "tmp/$dir"
	set script_name "tmp/$dir/runme"
	set f [open "$script_name" "w" 0700 ]
	puts $f "$body"
	close $f
	foreach item { one two three four } {
	    touch "tmp/$dir/$item"
	}
    }

    set SKIP_OLD 1
    find_start p {tmp -type f -empty -execdir sh ./runme  \{\} + } ""
    # We also repeat this test (with the same expected output) for the
    # non-multiple case (this detects Savannah bug #29949).
    find_start p {tmp -type f -empty -execdir sh ./runme  \{\} \; } ""
    set SKIP_OLD 0
    exec rm -rf tmp
}