WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: bash issues  (Read 3746 times)

Offline Jeff W

  • Newbie
  • *
  • Posts: 5
bash issues
« on: March 01, 2010, 12:43:04 PM »
I have installed bash.tcz and the bash-locale.tcz but I'm having issues running existing bash scripts.  It appears when I try to run them they continue to have problems interpreting for loops so I converted those to while loops and changed all of my

x++

to

x=`expr $x +1`

which seems to have solved those issues.  Other syntax issues keep popping up.  These bash scripts were working on DSL and I'm converting to TC for some functionality provided by the updated kernel (specifically ease of wireless USB support).  Other than installing the bash.tcz and bash-local.tcz would there be anything else necessary to support bash scripts within TC?  Bash is present in /bin and my path is valid in the script.  It just appears to me perhaps it's attempting to process using ash rather than bash.  Is there a symlink that needs to change?  I'm fairly novice at linux administration and know just about enough to be dangerous at this point.
If at first you don't suceed skydiving is not for you.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: bash issues
« Reply #1 on: March 01, 2010, 12:55:38 PM »
Do you have a small example script which describes the issue you are having? I know the busybox /bin/sh is insufficient sometimes, and I execute "rm /bin/sh; ln -s ../usr/local/bin/bash /bin/sh" to address that.

Offline Jeff W

  • Newbie
  • *
  • Posts: 5
Re: bash issues
« Reply #2 on: March 01, 2010, 02:54:44 PM »
I execute "rm /bin/sh; ln -s ../usr/local/bin/bash /bin/sh" to address that.
 

That seems to have done the trick.  Thank you sir.  Now I just need to work out all my other script dependencies and change file targets and it looks like I should be good.
If at first you don't suceed skydiving is not for you.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: bash issues
« Reply #3 on: March 01, 2010, 07:15:04 PM »
I intentionally left /bin/sh alone as busybox ash instead of making it a bash symlink.  Putting the #!/bin/bash shebang will of course call up bash while /bin/sh calls ash.

I origionally had /bih/sh symlinked to /bin/bash, but opted for choice instead.  Though bash should be totally sh compliant.  I will ponder whether to symlink /bin/sh to /bin/bash to avoid confusion once bash has been installed.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: bash issues
« Reply #4 on: March 01, 2010, 08:50:27 PM »
IMHO a script with a '#!/bin/sh' shebang should not use any bash-isms at all.

So, I'd suggest NOT to link /bin/sh to /bin/bash

BTW, the bash.tcz extension appears to be a bit "confused" about the proper location of the .bashrc (and maybe also the bashrc) file. When doing 'tce-load -wi bash' one gets:
    cp: cannot stat '/usr/local/etc/.bashrc': No such file or directory
    chown: /home/tc/.bashrc: No such file or directory

It might be that the '.../tce.installed/bash' script needs just a careful review.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: bash issues
« Reply #5 on: March 01, 2010, 10:47:14 PM »
That is how I was leaning.

And I fixed the typo in the startup script.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: bash issues
« Reply #6 on: March 01, 2010, 11:28:11 PM »
Quote
IMHO a script with a '#!/bin/sh' shebang should not use any bash-isms at all.

Bash will act like a Bourne shell when called as /bin/sh, and in this case it is a better Bourne shell than busybox ash. There are times when the softlink has caused me problems, though, so I agree with omitting it in the startup script. Indeed, making this change could have an adverse affect on the numerous scripts which make up Tiny Core, so one need exercise caution when doing so.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: bash issues
« Reply #7 on: March 02, 2010, 07:16:10 AM »
Having the /bin/sh symlinked to bash did cause me some issues, causing me to leave it ash.  I can't remember exactly what the issues were as it was well over a year ago, but I do remember issues though they could have been extension issues rather than bash issues.  I may symlink bash to /bin/sh on my own system for a while just to see as I am curious as it is supposed to not cause an issue.