shelljs / shx

Portable Shell Commands for Node
MIT License
1.73k stars 45 forks source link

Feature request: generic OR #83

Closed kirly-af closed 8 years ago

kirly-af commented 8 years ago

It would be very convenient to have a portable OR operator. I have no idea about the syntax, maybe a --or flag:

$> shx foo --or bar

would execute:

node -e "require('child_process').exec('foo || bar')"
nfischer commented 8 years ago

Doesn't the built-in or operator work the same way? || Is supported on UNIX and windows, I didn't see any difference in its behavior as far as I remember

nfischer commented 8 years ago

To clarify, I think this should be achievable with shx cp foo bar || shx rm -r mightNotExist || someExternalCommand || .... The same should be the case with &&.

If this is supported by UNIX and Windows already, I'd rather defer to what the OS does. If this is inconsistent however, we can look at what it would take to put it in this project.

kirly-af commented 8 years ago

My bad, I was convinced || didn't exist on Windows. It turns out it's definitely working.

nfischer commented 8 years ago

No worries. Glad it worked out for you!