~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to ftsh/test/functions.ftsh

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#
 
3
# Test a simple function to copy some files around.
 
4
#
 
5
 
 
6
function copy_and_compress
 
7
        echo "Removing ${2}.gz..."
 
8
        rm -f ${2}.gz
 
9
        echo "Copying ${1} to ${2}..."
 
10
        cp ${1} ${2}
 
11
        echo "Compressing ${1}..."
 
12
        gzip ${2}
 
13
end
 
14
 
 
15
for name in /etc/hosts /etc/passwd
 
16
        basename ${name} -> bname
 
17
        copy_and_compress ${name} /tmp/${bname}
 
18
end
 
19
 
 
20
#
 
21
# Check that argument passing respects quotation.
 
22
#
 
23
 
 
24
function print_args
 
25
        echo ${1}
 
26
        echo ${2}
 
27
        echo ${3}
 
28
end
 
29
 
 
30
print_args foo bar baz
 
31
print_args "foo bar baz"
 
32
print_args 'foo bar baz' "three blind mice" monkey\ shines
 
33
 
 
34
#
 
35
# Make sure that recursion is stopped at a respectable limit.
 
36
#
 
37
 
 
38
function endless_recursion
 
39
        endless_recursion
 
40
end
 
41
 
 
42
try
 
43
        endless_recursion
 
44
        echo "Zoiks, endless recursion should have failed..."
 
45
catch
 
46
        echo "Endless recursion was stopped correctly."
 
47
end
 
48
 
 
49