bsh project
This commit is contained in:
8
tests/functions/arguments.sh
Normal file
8
tests/functions/arguments.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
foo()
|
||||
{
|
||||
echo $@
|
||||
echo $#
|
||||
echo $2
|
||||
}
|
||||
|
||||
foo salut je suis un argument
|
||||
9
tests/functions/arguments_hard.sh
Normal file
9
tests/functions/arguments_hard.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
foo()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
foo arguments de la fonction
|
||||
echo $@
|
||||
foo "d'autres" arguments
|
||||
exit 4
|
||||
6
tests/functions/basic.sh
Normal file
6
tests/functions/basic.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
foo()
|
||||
{
|
||||
echo "foo"
|
||||
}
|
||||
|
||||
foo
|
||||
8
tests/functions/declaration_in_if.sh
Normal file
8
tests/functions/declaration_in_if.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
if true
|
||||
then
|
||||
foo() {
|
||||
echo 'I am in foo function'
|
||||
}
|
||||
fi
|
||||
|
||||
foo
|
||||
11
tests/functions/function_in_function.sh
Normal file
11
tests/functions/function_in_function.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
foo()
|
||||
{
|
||||
bar()
|
||||
{
|
||||
echo "bar"
|
||||
echo $@
|
||||
}
|
||||
}
|
||||
|
||||
foo salut je suis un argument
|
||||
bar salut
|
||||
9
tests/functions/multiple_calls.sh
Normal file
9
tests/functions/multiple_calls.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
foo()
|
||||
{
|
||||
echo "this is a test"
|
||||
echo $@
|
||||
}
|
||||
|
||||
foo salut
|
||||
foo
|
||||
foo foo foo; foo a
|
||||
11
tests/functions/recursive_call.sh
Normal file
11
tests/functions/recursive_call.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
test()
|
||||
{
|
||||
if $@; then
|
||||
test false
|
||||
else
|
||||
echo end
|
||||
fi
|
||||
}
|
||||
|
||||
test true
|
||||
echo "did this work ?"
|
||||
6
tests/functions/use_fun_in_other_cmd.sh
Normal file
6
tests/functions/use_fun_in_other_cmd.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
fun() {
|
||||
echo "fun"
|
||||
}
|
||||
|
||||
echo fun
|
||||
echo; fun
|
||||
11
tests/functions/variable_in_fun.sh
Normal file
11
tests/functions/variable_in_fun.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
a=12
|
||||
|
||||
fun()
|
||||
{
|
||||
a=42
|
||||
echo "$a"
|
||||
}
|
||||
|
||||
echo $a
|
||||
fun
|
||||
echo $a
|
||||
Reference in New Issue
Block a user