bash script question
Rolf G Nielsen
lazlar at lazlarlyricon.com
Tue Dec 1 20:06:38 UTC 2009
Dánielisz László wrote:
> I just find out:
>
> #!/usr/local/bin/bash
> export IFS=" "
> cuc=$*
> mkdir "cuc"
>
> Thanks anyway!
>
> László
>
>
>
> ________________________________
> From: Dánielisz László <laszlo_danielisz at yahoo.com>
> To: freebsd-questions at freebsd.org
> Sent: Tue, December 1, 2009 8:37:04 PM
> Subject: bash script question
>
>
> Hello,
>
> I'd like to ask how can I read a variable in the same line when I launch a script?
> For example "./script.sh directory_name", and I want the script to creat the directory called "directory_name" or whatever I input there.
>
> Thank you!
> László
>
>
>
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>
>
>
Why are you using bash? To make a shell script as portable as possible,
use /bin/sh. Bash is a third party shell, that isn't included in a base
installation (you're not using bash as root's shell, are you?). By using
/bin/sh, you make sure the script will run without having to install any
ports.
Try this instead (check the "Special parameters" section in the sh(1)
man page to get the difference between $* and $@ and an explanation as
to why I quote the $@).
#!/bin/sh
mkdir "$@"
Cheers,
Rolf Nielsen
More information about the freebsd-questions
mailing list