[prev in list] [next in list] [prev in thread] [next in thread]
List: mingw-users
Subject: Re: [Mingw-users] Cross Platform Scripting Tip
From: Tomi Ollila <tomi.ollila () nixu ! com>
Date: 2011-01-30 15:34:40
Message-ID: yf6mxmiqub3.fsf () taco2 ! nixu ! fi
[Download RAW message or body]
On Sat 29 Jan 2011 21:28, Michael Sanders <bluelamp100@gmail.com> writes:
> According to MSDN, under Windows, the environmental variable named 'OS'
> has been available since 1995. With that info in hand, here a quick snippet
> (and there are likely other ways as well) I wanted to share with everyone:
>
>
> [ ${OS:0:3} == "Win" ] && win.cmd || nix.cmd
this will execute both win.cmd AND nix.cmd if win.cmd exits nonzero
therefore
[ x"${OS:0:3}" = x"Win" ] && { win.cmd; true; } || nix.cmd
(I just fixed something else having the same construct)
(Note the other changes (to make it bourne shell compatible)).
> The boolean construct above will:
>
> - branch true ('win.cmd') when running under Windows
>
> - branch false ('nix.cmd') when not
>
>
> Here's a usage example:
>
>
> [ ${OS:0:3} == "Win" ] && cls || clear
I'd use
case $OS in Win*) cls ;; *) clear ;; esac
> Hope it proves useful.
Yes it is, thanks for the tip.
>
> --
> later on,
> Mike
Tomi
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
MinGW-users mailing list
MinGW-users@lists.sourceforge.net
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same. Disregard for the list etiquette may \
cause your account to be moderated.
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@lists.sourceforge.net?subject=unsubscribe
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic