Archived
1
0
Fork 0

Fixed the trains script to handle canceled trains and wrote the help command.

This commit is contained in:
julien 2009-07-07 16:38:54 +02:00
parent d44fb2f6ba
commit 24e26c2b66
3 changed files with 19 additions and 1 deletions

View file

@ -15,7 +15,7 @@ do
if [ "$CMD" = "trains" ]; then
./shtrains.sh ${ARGS[*]}
elif [ "$CMD" = "help" ]; then
echo "Help"
./shhelp.sh $ARGS
else
echo "Use \"shcmd help\" to list available commands."
fi

14
shhelp.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash -ex
case "$1" in
"help") echo "help <TOPIC> : Prints help about TOPIC."
;;
"trains") echo "trains [STATION] : Prints the next trains that will stop at Courbevoie's station."
echo " When provided, only results that concerns STATION are advertised."
;;
*) echo "The following commands are available : help trains"
;;
esac
exit 0

View file

@ -9,6 +9,10 @@ do
read STATION || break
read UGUU || break
[[ $PATTERN =~ \ *[A-Z]{4}\ *(.*) ]] && PATTERN=${BASH_REMATCH[1]}
if [[ $UGUU =~ Supprime ]]; then
read UGUU || break
continue
fi
if [ -n "$*" ]; then
[[ $STATION =~ $@ ]] && echo "$PATTERN $STATION"
else