Vous êtes sur la page 1sur 2

#!

/bin/bash
# Illustrates ABS Guide Section 9.2
# Default value will be a literal: "default"
clear
echo "Using the - and :- operators; Use the default value if variable is unset o
r [null]"
unset paramvalue
echo "paramValue is unset:"
echo " operator is -, The value used is ${paramvalue-default}; paramValue is $
paramvalue"
echo " operator is :-, The value used is ${paramvalue:-default}; paramValue is
$paramvalue"
paramvalue=
echo "paramValue is nul"
echo " operator is -, The value used is ${paramvalue-default}; paramValue is $
paramvalue"
echo " operator is :-, The value used is ${paramvalue:-default}; paramValue is
$paramvalue"
paramvalue="a Value"
echo "paramValue is $paramvalue"
echo " operator is =, The value used is ${paramvalue-default}; paramValue is $
paramvalue"
echo " operator is :=, The value used is ${paramvalue:-default}; paramValue is
$paramvalue"

echo
echo
echo "Using the = and := operators; Set the variable value to default if the var
iable is unset or [null]"
unset paramvalue
echo "paramValue is unset:"
echo " operator is =, The value used is ${paramvalue=default}; paramValue is $
paramvalue"
echo " operator is :=, The value used is ${paramvalue:=default}; paramValue is
$paramvalue"
paramvalue=
echo "paramValue is nul"
echo " operator is =, The value used is ${paramvalue=default}; paramValue is $
paramvalue"
echo " operator is :=, The value used is ${paramvalue:=default}; paramValue is
$paramvalue"
paramvalue="a Value"
echo "paramValue is $paramvalue"
echo " operator is =, The value used is ${paramvalue=default}; paramValue is $
paramvalue"
echo " operator is :=, The value used is ${paramvalue:=default}; paramValue is
$paramvalue"
echo
echo
echo "Using the + and :+ operators; If the variable is set, use the default"
unset paramvalue
echo "paramValue is unset:"
echo " operator is +, The value used is ${paramvalue+default}; paramValue is $
paramvalue"
echo " operator is :+, The value used is ${paramvalue:+default}; paramValue is
$paramvalue"
paramvalue=
echo "paramValue is nul"
echo " operator is +, The value used is ${paramvalue+default}; paramValue is $
paramvalue"
echo " operator is :+, The value used is ${paramvalue:+default}; paramValue is
$paramvalue"
paramvalue="a Value"
echo "paramValue is $paramvalue"
echo " operator is +, The value used is ${paramvalue+default}; paramValue is $
paramvalue"
echo " operator is :+, The value used is ${paramvalue:+default}; paramValue is
$paramvalue"
[root@redrobin ~]#

Vous aimerez peut-être aussi