Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 Dec 2009 21:06:34 +0100
From:      Rolf G Nielsen <lazlar@lazlarlyricon.com>
To:        =?ISO-8859-1?Q?D=E1nielisz_L=E1szl=F3?= <laszlo_danielisz@yahoo.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: bash script question
Message-ID:  <4B15774A.5040700@lazlarlyricon.com>
In-Reply-To: <560275.79074.qm@web30808.mail.mud.yahoo.com>
References:  <560275.79074.qm@web30808.mail.mud.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
D=E1nielisz L=E1szl=F3 wrote:
> I just find out:
>=20
> #!/usr/local/bin/bash
> export IFS=3D" "
> cuc=3D$*
> mkdir "cuc"
>=20
> Thanks anyway!
>=20
> L=E1szl=F3
>=20
>=20
>=20
> ________________________________
> From: D=E1nielisz L=E1szl=F3 <laszlo_danielisz@yahoo.com>
> To: freebsd-questions@freebsd.org
> Sent: Tue, December 1, 2009 8:37:04 PM
> Subject: bash script question
>=20
>=20
> Hello,
>=20
> I'd like to ask how can I read a variable in the same line when I launc=
h a script?
> For example "./script.sh directory_name", and I want the script to crea=
t the directory called "directory_name" or whatever I input there.
>=20
> Thank you!
> L=E1szl=F3
>=20
>=20
>=20
>      =20
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd=
=2Eorg"
>=20
>=20
>=20

Why are you using bash? To make a shell script as portable as possible,=20
use /bin/sh. Bash is a third party shell, that isn't included in a base=20
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)=20
man page to get the difference between $* and $@ and an explanation as=20
to why I quote the $@).

#!/bin/sh
mkdir "$@"


Cheers,

Rolf Nielsen




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B15774A.5040700>