Some test cases for .SHELL target: builtin shell selection and

changing the path of a builtin shell.
This commit is contained in:
Hartmut Brandt 2005-05-19 11:23:01 +00:00
parent b4b4c81522
commit 56f5aba2ca
17 changed files with 179 additions and 0 deletions

View File

@ -0,0 +1,48 @@
#
# Change the path for builtin shells. There are two methods to do this.
# This is the first of them when the basename of the path is equal to
# one of the builtin shells so that the .SHELL target automatically
# also selectes the shell without specifying the name.
#
# Be sure to include a meta-character into the command line, so that
# really our shell is executed.
#
# $FreeBSD$
#
all: sh csh ksh
@${MAKE} sh_test
@${MAKE} csh_test
@if [ -x /bin/ksh ] ; then ${MAKE} ksh_test ; fi
sh: sh.sh
@cp ${.CURDIR}/sh.sh ${.OBJDIR}/sh
@chmod +x ${.OBJDIR}/sh
csh: sh.sh
@cp ${.CURDIR}/sh.sh ${.OBJDIR}/csh
@chmod +x ${.OBJDIR}/csh
ksh: sh.sh
@cp ${.CURDIR}/sh.sh ${.OBJDIR}/ksh
@chmod +x ${.OBJDIR}/ksh
.ifmake sh_test
.SHELL: path=${.OBJDIR}/sh
sh_test:
@: This is the shell.
.elifmake csh_test
.SHELL: path=${.OBJDIR}/csh
csh_test:
@: This is the C-shell.
.elifmake ksh_test
.SHELL: path=${.OBJDIR}/ksh
ksh_test:
@: This is the Korn-shell.
.endif

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1 @@
make: don't know how to make sh.sh. Stop

View File

@ -0,0 +1,6 @@
#!/bin/sh
# $FreeBSD$
echo $@
if ! test -t 0 ; then
cat
fi

View File

@ -0,0 +1,13 @@
#!/bin/sh
# $FreeBSD$
cd `dirname $0`
. ../../common.sh
desc_test()
{
echo "New path for builtin shells."
}
eval_cmd $1

View File

@ -0,0 +1,40 @@
#
# Change the path for builtin shells. There are two methods to do this.
# This is the second of them when both a path and a name are specified.
# This selects a builtin shell according to the name, but executes it
# from the specified path.
#
# Be sure to include a meta-character into the command line, so that
# really our shell is executed.
#
# $FreeBSD$
#
all: shell
@${MAKE} sh_test
@${MAKE} csh_test
@if [ -x /bin/ksh ] ; then ${MAKE} ksh_test ; fi
shell: sh.sh
@cp ${.CURDIR}/sh.sh ${.OBJDIR}/shell
@chmod +x ${.OBJDIR}/shell
.ifmake sh_test
.SHELL: name=sh path=${.OBJDIR}/shell
sh_test:
@: This is the shell.
.elifmake csh_test
.SHELL: name=csh path=${.OBJDIR}/shell
csh_test:
@: This is the C-shell.
.elifmake ksh_test
.SHELL: name=ksh path=${.OBJDIR}/shell
ksh_test:
@: This is the Korn-shell.
.endif

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1 @@
make: don't know how to make sh.sh. Stop

View File

@ -0,0 +1,6 @@
#!/bin/sh
# $FreeBSD$
echo $@
if ! test -t 0 ; then
cat
fi

View File

@ -0,0 +1,13 @@
#!/bin/sh
# $FreeBSD$
cd `dirname $0`
. ../../common.sh
desc_test()
{
echo "New path for builtin shells (2)."
}
eval_cmd $1

View File

@ -0,0 +1,33 @@
#
# We just select the builtin shells and check whether it is really
# executed. This should print just the shell paths. Because we
# normally don't have a ksh, we make this test conditional. This means
# one has to recreate the test results once ksh is installed.
#
# $FreeBSD$
#
all:
@${MAKE} sh
@${MAKE} csh
@if [ -x /bin/ksh ] ; then ${MAKE} ksh ; fi
.ifmake sh
.SHELL: name=sh
sh: print_path
.elifmake csh
.SHELL: name=csh
csh: print_path
.elifmake ksh
.SHELL: name=ksh
ksh: print_path
.endif
print_path:
@ps -opid,command | awk '$$1=='$$$$' { print $$2; }'

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,2 @@
/bin/sh
/bin/csh

View File

@ -0,0 +1,13 @@
#!/bin/sh
# $FreeBSD$
cd `dirname $0`
. ../../common.sh
desc_test()
{
echo "Select the builtin sh shell."
}
eval_cmd $1