DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 25th March 2011
cq04cw cq04cw is offline
New User
 
Join Date: Sep 2010
Posts: 5
Question declare same alias twice, alias values are different, why ?

Recently, i have learnd sh(1) manpages, and i have a doubt for an 'alias' command. there's an example below.



Code:
> sh
$ set -E
$ echo $-
imsE
$ alias
$ alias aa='cmd_a -a -b'
$ alias
aa='cmd_a -a -b'
this first time is ok
$ alias aa='cmd_a -a -b' $ alias aa='cmd_a -a -'
second time to declare the same alias to override the old one, but the option -b is gone, why is it?
$ uname -a FreeBSD foo.bar.com 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 $ ident /bin/sh /bin/sh: $FreeBSD: src/lib/csu/i386-elf/crti.S,v 1.7.22.1.6.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/lib/csu/i386-elf/crtn.S,v 1.6.22.1.6.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/lib/csu/i386-elf/crt1_s.S,v 1.1.2.3.2.2 2011/01/22 17:49:37 kib Exp $ $FreeBSD: src/lib/csu/common/crtbrand.c,v 1.6.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/alias.c,v 1.25.2.3.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/arith.y,v 1.22.2.3.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/arith_lex.l,v 1.24.10.2.4.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/cd.c,v 1.36.2.5.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/bltin/echo.c,v 1.14.30.1.6.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/error.c,v 1.26.10.3.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/eval.c,v 1.64.2.5.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/exec.c,v 1.34.2.5.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/expand.c,v 1.55.2.10.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/histedit.c,v 1.31.2.6.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/input.c,v 1.25.2.4.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/jobs.c,v 1.72.10.6.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/mail.c,v 1.14.10.3.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/main.c,v 1.31.2.6.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/memalloc.c,v 1.28.2.4.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/miscbltin.c,v 1.41.2.3.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/mystring.c,v 1.13.30.2.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/options.c,v 1.27.2.4.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/output.c,v 1.21.2.3.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/parser.c,v 1.63.2.10.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/redir.c,v 1.27.2.2.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/show.c,v 1.23.10.3.2.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/test/test.c,v 1.54.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/trap.c,v 1.34.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $ $FreeBSD: src/bin/sh/var.c,v 1.39.2.6.2.1 2010/12/21 17:09:25 kensmith Exp $ $
Reply With Quote
  #2   (View Single Post)  
Old 25th March 2011
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default

I can repeat this on
Code:
]$ uname -a
FreeBSD hercules.utp.xnet 8.2-RC3 FreeBSD 8.2-RC3 #0: Sun Jan 30 06:52:51 UTC 2011
root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
Code:
$ alias aa='cmd_a -a -b'
$ alias
aa='cmd_a -a -b'
g='egrep -i'
h='fc -l'
j=jobs
l='ls -l'
ll='ls -laFo'
m=more

$ alias aa='cmd_a -a -b'
$ alias
aa='cmd_a -a -'
g='egrep -i'
[snip]
Very strange indeed
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 25th March 2011
rocket357's Avatar
rocket357 rocket357 is offline
Real Name: Jonathon
Wannabe OpenBSD porter
 
Join Date: Jun 2010
Location: 127.0.0.1
Posts: 429
Default

Quote:
Originally Posted by J65nko View Post
Very strange indeed
I'll second that...I tried to reproduce on OpenBSD-CURRENT to see if it was just FreeBSD that was affected, and I couldn't replicate it. I was going to download FreeBSD and try it out but you beat me to it.
Reply With Quote
  #4   (View Single Post)  
Old 25th March 2011
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default

I also have bash installed on that FreeBSD machine and bash shows the correct behaviour.

The only way you can redefine that alias with the native /bin/sh, is to unalias it before redefining. Then it works correctly.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #5   (View Single Post)  
Old 25th March 2011
cq04cw cq04cw is offline
New User
 
Join Date: Sep 2010
Posts: 5
Default

Quote:
Originally Posted by J65nko View Post
The only way you can redefine that alias with the native /bin/sh, is to unalias it before redefining. Then it works correctly.
yes, thank you all.
Reply With Quote
  #6   (View Single Post)  
Old 29th March 2011
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

This looks like a bug ... Maybe a pr might be in order?
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Reply

Tags
alias, sh

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make delays between multiple commands in an alias (ircII) guitarscn Programming 3 23rd September 2010 12:36 AM
Changing MAC address to an alias interface? DNAeon FreeBSD General 6 20th January 2009 04:48 PM
pf tables how long values stored ijk FreeBSD Security 3 12th August 2008 11:45 AM
Mounting NAS as apache alias directory Yuka FreeBSD General 7 18th July 2008 02:58 PM
ip alias confusion hamba FreeBSD General 2 5th June 2008 10:23 AM


All times are GMT. The time now is 06:38 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick