On 06:33 12 Jun 2002, rpjday <[EMAIL PROTECTED]> wrote:
| On Wed, 12 Jun 2002, Mike Martin wrote:
| >  --- John Horne <[EMAIL PROTECTED]> wrote: > Hello,
| > > Anyone want to tell me why a semicolon at the beginning of a shell
| > > line causes an error?

It's unexpected by the parser. Don't do it.

| > > The following work fine under sh, bash, ksh and csh (redhat 7.0):
| > >   date;ls -l
| > >   date;ls -l;
| > > but ';date;ls -l' fails under all shells except csh with the error:
| > >   sh: syntax error near unexpected token `;d'
| > >   bash: syntax error near unexpected token `;d'
| > >   pdksh: syntax error: `;' unexpected

Works under zsh. No matter.

| > > I see no real reason for this, and a semicolon at the end of the
| > > line seems to be accepted okay. Just curious.

The language parser author didn't think of it, or didn't want to
support it.  There's no technical reason it would be bad, but likewise
no technical reason it would be necessary either. (For the "placeholder
in constructed command string" argument I point the reader at the ":"
builtin).

| > Not certain about this but probably to do with the fact that the ;
| > usually acts as as a command  terminator.
| no, it normally acts as a command *separator* since, if you type
| $ date ; ls
| there is no need to terminate the *second* command.

There is a need to terminate it, but newline _also_ acts as a command
terminator. Let's be precise here.

|   a better guess would be that ";" does not correspond to a legitimate
| command, function or alias that bash is prepared to recognize.
|   technically, i guess there's no reason why bash shouldn't be able
| to handle a leading ";" -- it just doesn't.  so the simple answer
| here might just be: "because". :-)

Yep.
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

Achilles, a PHD student, had to choose between having a passionate but poor
life as an academic or a dull but rich life as a IT professional yuppie.
Legend has it that he chose poverty.



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to