Had this annoying message popping up when running a script on Ubuntu 8.0.4 LTS. The message read:
shift: N: can't shift that many
On Debian it works fine. The reason for this is the use of different shells in Debian and Ubuntu. Debian is using bash and Ubuntu is using dash. Check the symlink /bin/sh on the different distributions.
To reproduce save the following to a file named test_shift.sh:
#!/bin/sh while shift; do echo $1 done
Running the script emits on Ubuntu emits the following message on Ubuntu 8.0.4 LTS:
user@server:~$ ./test_shift.sh test1 test2 test3 test4 test5 test2 test3 test4 test5 shift: 7: can't shift that many
On Debian Lenny it runs without a fuzz. So, what to do? Well, one could either do an ugly hack like this:
#!/bin/sh shift 1; while [ "$#" != "0" ]; do echo $1; shift; done
or just change the shebang to point to bash, ie #!/bin/bash. I will choose the latter way.
// John
Comments
Post new comment