/bin/sh - aliases

Hi,

I've started to use FreeBSD recently, and so far I think I can ditch the alternatives! I didn't even want to install bash, but to try use the default shell instead, just for the kicks. There's a small issue with aliases though, and I'm sorry if this has already been ranted before.

Code:
$alias ls='ls -G'
$alias
ls='ls -G'
$ls
...
$alias ls='ls -G'
$alias
ls='ls -'
$ls
ls -: command not found.

Happens on FreeBSD-9.0 RELEASE, and 9.1-RC3 source seems the same. This is especially nasty after re-sourcing ~/.profile, or where ever you keep aliases, you will notice that all previously hashed aliases are now broken. Oddly there was fairly simple way of seemingly fix it, but I can't stop thinking that this would have been done unless it was just dumb :r So if anyone is interested to check it out, be my guest.
 

Attachments

  • patch-alias.c
    433 bytes · Views: 213
sh(1) is very bare-bones. It only recently got command history.

You don't have to use the same shell for scripting and interactive use. Many of us like csh(1) for interactive use. Write your shell scripts in sh(1) (as they should be) and you've got the best of both.
 
df said:
If that's right, I'll jump in to the wagon and check out csh.

Cheers!

Zsh is a nice alternative to bash for a third party bourne compatible shell. I may start playing with csh again soon. Set some completions for when I'm root.

You may want to post your patch to http://www5.us.freebsd.org/send-pr.html

Curious though. Is there an option to compile ash without the new interactive features though make.conf. sh used to be around 90k. Now it's 140k. The little buggers getting kinda unnecessarily fat.
 
UNIXgod said:
sh used to be around 90k. Now it's 140k. The little buggers getting kinda unnecessarily fat.

It isn't 140k and get just a little fat (3.5kb difference between FreeBSD 7 and 9). ;)

FreeBSD 7.4-RELEASE
[cmd=""]# ls -laoFG /bin/sh
-r-xr-xr-x 1 root wheel - 116584 Jan 1 2012 /bin/sh*
[/cmd]

FreeBSD 8.3-RELEASE
[cmd=""]# ls -laoFG /bin/sh
-r-xr-xr-x 1 root wheel - 118512 Apr 22 2012 /bin/sh*
[/cmd]

FreeBSD 9.0-RELEASE
[cmd=""]# ls -laoFG /bin/sh
-r-xr-xr-x 1 root wheel - 120056 Jan 3 2012 /bin/sh*
[/cmd]
 
AlexJ said:
FreeBSD 9.0-RELEASE
[cmd=""]# ls -laoFG /bin/sh
-r-xr-xr-x 1 root wheel - 120056 Jan 3 2012 /bin/sh*
[/cmd]

Ha. I betcha used clang. Mine was compiled with gcc. There is something different here:

% uname -sr
FreeBSD 9.0-RELEASE

% du -h `which sh`
140k /bin/sh

% ls -laoFG /bin/sh
-r-xr-xr-x 1 root wheel - 142976 Apr 16 2012 /bin/sh


It's nice to know the compiler upgrade will also bring in some benefits with world binaries =)
 
Back
Top