Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

noahgolm

macrumors member
Original poster
Aug 18, 2010
65
0
Hi, I was making a simple bash script which showed hidden files in finder, and apparently something went wrong. I tried to move the file into the /bin folder to make it executable without the ./, but i don't know if that's what is wrong here. It seems that whenever I open terminal now, it tries to run that script, then displaying the "process complete" line and staying there. I had quit the script once in the middle of it, and heard this can happen sometimes because of that. Is there any way of fixing this? I tried deleting the com.apple.Terminal.plist file, but it did no good...
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
Hi, I was making a simple bash script which showed hidden files in finder, and apparently something went wrong. I tried to move the file into the /bin folder to make it executable without the ./, but i don't know if that's what is wrong here. It seems that whenever I open terminal now, it tries to run that script, then displaying the "process complete" line and staying there. I had quit the script once in the middle of it, and heard this can happen sometimes because of that. Is there any way of fixing this? I tried deleting the com.apple.Terminal.plist file, but it did no good...

From the Finder, Click the Go menu and Go to Folder option. Put /bin or /usr/bin (whichever folder you made your script in) and click Go. Move your script to either the Trash or out of that folder to the Desktop or something.

Now when you start up the Terminal, it will give you an error until you remove the reference to the script from whichever file you put it in, but at least your terminal will load.

You could also tell Terminal to start with /bin/zsh instead of the default shell, but that would only work if you had put your reference to your broken script in once of the bash specific files like bashrc or bash_profile
 

noahgolm

macrumors member
Original poster
Aug 18, 2010
65
0
Aaaagh! I just looked at the /bin/bash script in my text editor, and its contents are the script I made! It's running that instead of the normal bash! Is there any way to restore this?
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
Aaaagh! I just looked at the /bin/bash script in my text editor, and its contents are the script I made! It's running that instead of the normal bash! Is there any way to restore this?

Ouch! You messed up.. What Mac OS version and computer type are you on? You are going to have to replace that it with the proper binary. Otherwise you'll have to switch from bash to zsh or something

I could send you my bash binary, but that will only work if you are on Snow Leopard.

I've attached it. Double click it to unzip and drag it to your /bin directory.
 

Attachments

  • bash.zip
    574 KB · Views: 51
Last edited:

noahgolm

macrumors member
Original poster
Aug 18, 2010
65
0
Well, I'm running Snow Leopard on a late 2008 Macbook. With a little bit of specifics, I'm running 10.6.4, have a 160GB hardrive, and 2GB of RAM. And a screwed up bash script. Thank you!
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
I edited my last post and attached a zip file containing that bash file. We appear to be on the same OS version
 

noahgolm

macrumors member
Original poster
Aug 18, 2010
65
0
Thank you so much! You're a real lifesaver here. Works just fine now!
 

mac2x

macrumors 65816
Sep 19, 2009
1,146
0
Case in point of why the command line can be dangerous. You simply have to pay attention to what you are doing where. Use the pwd command liberally! Common commands like ls conveniently echo $PWD automatically.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
Good to hear that it went well in the end. It's never a good idea to store your own scripts in /bin or other reserved places for os binaries. Use /usr/local/bin or your own purpose made folder that you then add to the PATH environment variable.
 
Last edited:

mac2x

macrumors 65816
Sep 19, 2009
1,146
0
Good to hear that it went well in the end. It's never a good idea to store your own scripts in /bin or other reserved places for os binaries. Use /usr/local/bin or your own folder that you then add to the PATH environment variable.

This.

I have my own bin in my home folder. Simply make one, and add this to your .bash_profile:

Code:
export PATH=$PATH:$HOME/bin
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.