Re: Bash: (foo==0)?foo=1:foo=0 valid?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2011-07-02 at 14:31 -0700, Daniel B. Thurman wrote:
> On 07/02/2011 02:15 PM, Robert Nichols wrote:
> > On 07/02/2011 02:11 PM, inode0 wrote:
> >> On Sat, Jul 2, 2011 at 2:07 PM, Daniel B. Thurman<dant@xxxxxxxxx>  wrote:
> >>> I used:  (((foo==0)?foo=1:0)) and it works in a bash script!
> >> I don't think that is quite the same as what I'm guessing your
> >> original attempt intended. In this case if foo does not equal 0 to
> >> begin with it won't be set to 0. Perhaps that doesn't matter in your
> >> particular case.
> > Indeed, I got it wrong too.  Looks like it needs to be:
> >
> >      (((foo==0)?(foo=1):(foo=0)))
> >
> > Frankly, I don't think I'll be using that syntax much.  Too many ways
> > to get it wrong.
> >
> Yeah, you guys are correct, it does not toggle
> which was my intent.  So I basically went back
> to the trusty if-else-fi statement of which anyone
> can read without much obscurity. :P
> 
> Thanks to all, for contributing!
> 

((foo=!foo))

or if using an interactive Shell:

((foo=\!foo))

poc

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux