Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
A quick Mac OSX question
Albert Schlef
1/9/2009 11:11:00 AM
Does mac osx supports the "2>&1" syntax to redirect stderr?
In other words, does the following line of code work as expected in mac
osx?
output = `some_command 2>&1`
--
Posted via
http://www.ruby-...
.
2 Answers
Mike Stok
1/9/2009 11:24:00 AM
0
On Jan 9, 2009, at 6:11 AM, Albert Schlef wrote:
> Does mac osx supports the "2>&1" syntax to redirect stderr?
>
> In other words, does the following line of code work as expected in
> mac
> osx?
>
> output = `some_command 2>&1`
> --
> Posted via
http://www.ruby-...
.
Yes:
ratdog:~ mike$ uname -a
Darwin ratdog.local 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24
17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386
ratdog:~ mike$ irb
>> output = `perl -e 'die "Aaargh!"'`
Aaargh! at -e line 1.
=> ""
>> output = `perl -e 'die "Aaargh!"' 2>&1`
=> "Aaargh! at -e line 1.\n"
--
Mike Stok <mike@stok.ca>
http://www.stok...
The "`Stok' disclaimers" apply.
pjb
1/9/2009 12:28:00 PM
0
Albert Schlef <albertschlef@gmail.com> writes:
> Does mac osx supports the "2>&1" syntax to redirect stderr?
>
> In other words, does the following line of code work as expected in mac
> osx?
>
> output = `some_command 2>&1`
As long as you use bash instead of tcsh, yes.
bash -c ' output = `some_command 2>&1` ; echo "$output" '
Notice than nowdays we can use $(some_command 2>&1) instead of the
backquotes, which is nice because you can nest them:
bash -c ' msg=$(printf "%dnd result = %s" $(( 1 * 2 * 3 * 7 )) "$(echo "Do not panic")" ) ; echo "$msg" '
42nd result = Do not panic
Or use chsh to switch to bash:
http://www.macshadows.com/kb/index.php?title=Changing_your_shell_o...
--
__Pascal Bourguignon__
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
A quick Mac OSX question
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password