comparison scripts/test/echo.test @ 294:3de1ea4d6b56

Fix command line option parsing so "echo -xen" actually prints "-xen". Add echo.test while I'm at it.
author Rob Landley <rob@landley.net>
date Sat, 17 May 2008 17:13:26 -0500
parents
children d3544d2cdb26
comparison
equal deleted inserted replaced
293:6baa13382880 294:3de1ea4d6b56
1 #!/bin/bash
2
3 [ -f testing.sh ] && . testing.sh
4
5 # This one's tricky both because echo is a shell builtin (so $PATH is
6 # irrelevant) and because the "result" field is parsed with echo -e.
7 # To make it work, "$CMD" is an explicit path to the command being tested,
8 # so "result" keeps using the shell builtin but we test the one in toybox.
9
10 CMD="$(which echo)"
11
12 #testing "name" "command" "result" "infile" "stdin"
13
14 testing "echo" "$CMD && echo yes" "\nyes\n" "" ""
15 testing "echo 1 2 3" "$CMD one two three" "one two three\n" "" ""
16 testing "echo with spaces" "$CMD 'one two three'" \
17 "one two three\n" "" ""
18 testing "echo -n" "$CMD -n" "" "" ""
19 testing "echo -n one" "$CMD -n one" "one" "" ""
20 testing "echo one -n" "$CMD one -n" "one -n\n" "" ""
21 testing "echo -en" "$CMD -en 'one\ntwo'" "one\ntwo" "" ""
22 testing "echo --hello" "$CMD --hello" "--hello\n" "" ""
23 testing "echo -e all" "$CMD -e '\a\b\c\f\n\r\t\v\\\0123'" \
24 "\a\b\c\f\n\r\t\v\\\0123\n" "" ""
25 testing "echo -nex hello" "$CMD -nex hello" "-nex hello\n" "" ""