Bash Problem

View: New views
7 Messages — Rating Filter:   Alert me  

Bash Problem

by drjlevi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can someone on this list help me with the following problem with bash?

A simple bash script of mine reads:

#!/bin/bash
echo {1..3}

When I run it, it prints {1..3}, not 1 2 3 as I expect. My version of bash
is 4.0.33(1), and running "ls -l /bin/bash" gives

-rwxr-xr-x 1 root wheel 581636 Dec 13  2006 /bin/bash

Many thanks,

Jonathan


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Fink-users mailing list
Fink-users@...
https://lists.sourceforge.net/lists/listinfo/fink-users

Re: Bash Problem

by Peter O'Gorman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/11/2009 01:55 PM, drjlevi@... wrote:

> Can someone on this list help me with the following problem with bash?
>
> A simple bash script of mine reads:
>
> #!/bin/bash
> echo {1..3}
>
> When I run it, it prints {1..3}, not 1 2 3 as I expect. My version of bash
> is 4.0.33(1), and running "ls -l /bin/bash" gives
>
> -rwxr-xr-x 1 root wheel 581636 Dec 13  2006 /bin/bash
>

/sw/bin/bash may be 4.0.33, but /bin/bash isn't.

Did you try with fink's bash?

Peter

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Fink-users mailing list
Fink-users@...
https://lists.sourceforge.net/lists/listinfo/fink-users

Re: Bash Problem

by Mark J. Reed :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 11, 2009 at 3:23 PM, Peter O'Gorman <peter@...> wrote:

> On 11/11/2009 01:55 PM, drjlevi@... wrote:
>> Can someone on this list help me with the following problem with bash?
>>
>> A simple bash script of mine reads:
>>
>> #!/bin/bash
>> echo {1..3}
>>
>> When I run it, it prints {1..3}, not 1 2 3 as I expect. My version of bash
>> is 4.0.33(1), and running "ls -l /bin/bash" gives
>>
>> -rwxr-xr-x 1 root wheel 581636 Dec 13  2006 /bin/bash

/bin/bash is not 4.0.33(1), then.  4.0.33 is much more recent than
2006!  You must have be running a different bash when you check the
version - /sw/bin/bash, maybe? If you put that in your script (e.g.
#!/sw/bin/bash instead of #!/bin/bash), it should work.

Or you should update to a newer version of OS X.  Snow Leopard still
doesn't have 4.x in /bin, but it does have 3.2.48, which is new enough
for brace ranges to work.

--
Mark J. Reed <markjreed@...>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Fink-users mailing list
Fink-users@...
https://lists.sourceforge.net/lists/listinfo/fink-users

Re: Bash Problem

by Martin Costabel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark J. Reed wrote:

> On Wed, Nov 11, 2009 at 3:23 PM, Peter O'Gorman <peter@...> wrote:
>> On 11/11/2009 01:55 PM, drjlevi@... wrote:
>>> Can someone on this list help me with the following problem with bash?
>>>
>>> A simple bash script of mine reads:
>>>
>>> #!/bin/bash
>>> echo {1..3}
>>>
>>> When I run it, it prints {1..3}, not 1 2 3 as I expect. My version of bash
>>> is 4.0.33(1), and running "ls -l /bin/bash" gives
>>>
>>> -rwxr-xr-x 1 root wheel 581636 Dec 13  2006 /bin/bash
>
> /bin/bash is not 4.0.33(1), then.  4.0.33 is much more recent than
> 2006!  You must have be running a different bash when you check the
> version - /sw/bin/bash, maybe? If you put that in your script (e.g.
> #!/sw/bin/bash instead of #!/bin/bash), it should work.
>
> Or you should update to a newer version of OS X.  Snow Leopard still
> doesn't have 4.x in /bin, but it does have 3.2.48, which is new enough
> for brace ranges to work.

In Leopard's /bin/bash, which is version 3.2.17 and was last updated in
2008 with 10.5.3, it works, too. Jonathan's /bin/bash from December 2006
is Tiger's bash version 2.05b.0.

--
Martin


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Fink-users mailing list
Fink-users@...
https://lists.sourceforge.net/lists/listinfo/fink-users

Re: Bash Problem

by drjlevi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

At 3:30 PM -0500 11/11/09, Mark J. Reed wrote:

>On Wed, Nov 11, 2009 at 3:23 PM, Peter O'Gorman <peter@...> wrote:
>>  On 11/11/2009 01:55 PM, drjlevi@... wrote:
>>>  Can someone on this list help me with the following problem with bash?
>>>
>>>  A simple bash script of mine reads:
>>>
>>>  #!/bin/bash
>>>  echo {1..3}
>>>
>>>  When I run it, it prints {1..3}, not 1 2 3 as I expect. My version of bash
>>>  is 4.0.33(1), and running "ls -l /bin/bash" gives
>>>
>>>  -rwxr-xr-x 1 root wheel 581636 Dec 13  2006 /bin/bash
>
>/bin/bash is not 4.0.33(1), then.  4.0.33 is much more recent than
>2006!  You must have be running a different bash when you check the
>version - /sw/bin/bash, maybe? If you put that in your script (e.g.
>#!/sw/bin/bash instead of #!/bin/bash), it should work.

Thank you all for your help. "#!/sw/bin/bash" did the trick. To avoid
this confusion in the future, is there any reason I shouldn't move
/bin/bash to, say, /bin/bash.ori and replace it with a link? Or is
there a better solution, assuming I want to stay with OS X 10.4 for
now?--Jonathan

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Fink-users mailing list
Fink-users@...
https://lists.sourceforge.net/lists/listinfo/fink-users

Re: Bash Problem

by Alexander Hansen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jonathan Levi, M.D. wrote:

> At 3:30 PM -0500 11/11/09, Mark J. Reed wrote:
>> On Wed, Nov 11, 2009 at 3:23 PM, Peter O'Gorman <peter@...> wrote:
>>>  On 11/11/2009 01:55 PM, drjlevi@... wrote:
>>>>  Can someone on this list help me with the following problem with bash?
>>>>
>>>>  A simple bash script of mine reads:
>>>>
>>>>  #!/bin/bash
>>>>  echo {1..3}
>>>>
>>>>  When I run it, it prints {1..3}, not 1 2 3 as I expect. My version of bash
>>>>  is 4.0.33(1), and running "ls -l /bin/bash" gives
>>>>
>>>>  -rwxr-xr-x 1 root wheel 581636 Dec 13  2006 /bin/bash
>> /bin/bash is not 4.0.33(1), then.  4.0.33 is much more recent than
>> 2006!  You must have be running a different bash when you check the
>> version - /sw/bin/bash, maybe? If you put that in your script (e.g.
>> #!/sw/bin/bash instead of #!/bin/bash), it should work.
>
> Thank you all for your help. "#!/sw/bin/bash" did the trick. To avoid
> this confusion in the future, is there any reason I shouldn't move
> /bin/bash to, say, /bin/bash.ori and replace it with a link? Or is
> there a better solution, assuming I want to stay with OS X 10.4 for
> now?--Jonathan
>
>

I'd strongly recommend _against_ messing with the system files.  Why not
just modify your scripts to use Fink's bash?

- --
Alexander Hansen
Fink User Liaison
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkr7d2oACgkQB8UpO3rKjQ9pEwCaAnN0CgykcTKQ3TPgO0QTnDYu
+uYAoKCcOV8IGlKpmtweGCW2WW9nLW/6
=1J8A
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Fink-users mailing list
Fink-users@...
https://lists.sourceforge.net/lists/listinfo/fink-users

Re: Bash Problem

by James Bunton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 11, 2009 at 09:24:11PM -0500, Jonathan Levi, M.D. wrote:
> Thank you all for your help. "#!/sw/bin/bash" did the trick. To avoid
> this confusion in the future, is there any reason I shouldn't move
> /bin/bash to, say, /bin/bash.ori and replace it with a link? Or is
> there a better solution, assuming I want to stay with OS X 10.4 for
> now?--Jonathan

I wouldn't do that.

You could try:
#!/usr/bin/env bash
to pick the first bash from your PATH. Don't use this for system
scripts, but it should work just fine for utilities, etc

---

James



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Fink-users mailing list
Fink-users@...
https://lists.sourceforge.net/lists/listinfo/fink-users

attachment0 (497 bytes) Download Attachment