UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2008-10-13 07:24 PM

yurii
Member
Registered: 2005-07-27
Posts: 20

Re: man sh(1) question

Offline

#2 2008-10-14 01:45 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: man sh(1) question

Command parse time.

For example, if you run

sleep 2 && echo B & echo C

The output will be a C, the sleep and echo B will be run in the background,
with the B appearing after two seconds.

If & had higher precedence than && then the whole would sleep for two seconds,
then echo B would be run in the background more or less at the same time as the
echo C.

So precedence between different operations matters because it defines the
behaviour. You see it in other (script/programming) languages as well. If it
isn't defined then things get ambiguous, and you don't want that to happen,
because it causes confusion.

When things have an equal precedence in general the order in which they
appear defines the order. But it's a good practice to add parentheses to
make clear what exactly you mean, even if it's defined in the language.

Is that clear enough or do you want more explanation?

Offline

#3 2008-10-27 10:32 AM

yurii
Member
Registered: 2005-07-27
Posts: 20

Re: man sh(1) question

thanks. now it's clear:)

Offline

#4 2008-10-30 05:02 AM

zhuxiaonuan
Guest

Re: man sh(1) question

it also helped me thank you

Board footer

Powered by FluxBB