FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 03-14-2012, 04:00 AM
Chris Bannister
 
Default Unnecessary rebooting (was Bash argument expanded inside alias)

[Please, don't top post in this mailing list]

On Tue, Mar 13, 2012 at 02:47:27PM -0300, rcb wrote:
> seems to works inside .bashrc file! (Just 'seems' because I did not
> reboot, just typed in a terminal and it worked great!)

You shouldn't reboot for changes you make to your .bashrc
to take effect.

Just logout then log back in again, or even better, type:
"source .bashrc" at a command prompt.

--
"Religion is excellent stuff for keeping common people quiet."
-- Napoleon Bonaparte


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120314050023.GB2215@tal">http://lists.debian.org/20120314050023.GB2215@tal
 
Old 03-14-2012, 11:50 AM
rcb
 
Default Unnecessary rebooting (was Bash argument expanded inside alias)

> From: Chris Bannister <cbannister@slingshot.co.nz>, Date: Wed, 14 Mar 2012 18:00:24 +1300
>
> [Please, don't top post in this mailing list]
>
> Just logout then log back in again, or even better, type:
> "source .bashrc" at a command prompt.
> --
> "Religion is excellent stuff for keeping common people quiet."
> * -- Napoleon Bonaparte


Dear Chris,

Thanks for this great tip "source". I must admit I google for
something like that, but I was trying to find in "man bash" some
argument to let bash or sh to run in the same environment. I think its
an old trick, and 'source' is newer, but I'm not sure and I didn't
find anything.



Dear Camaleón,

Unfortunately, this nice command of yours doesn't seem to work. Is it
me typing something wrong, or there is really a problem?
:~$ alias muda='find $1 -name "*" -mtime $2'
:~$ muda /home/cheetara -4
find: invalid arg `-4' for `-mtime'

Funny is that no matter if I change $2 to $1, the error is the same. Look:
:~$ alias muda='find $2 -name "*" -mtime $1'
:~$ muda /home/aluno -4
find: invalid arg `-4' for `-mtime'

Even worse, I tell it to use $1, but give two args in the command line, and get:
:~$ alias muda='find . -name "*" -mtime $1'
:~$ muda /home/cruelbash -4
find: invalid arg `-4' for `-mtime'


That is just to chitchat, as for now the function solution works great!

Thanks,
Beco.

PS. Sorry for an earlier "top post", and an warning of "non html".
It'll not happen again.
PPS. I think I need to change the list subscription from digest to
normal emails. I tried subject:help to debian-user-request, but the
message that came back was of no help. (Maybe this is offtopic here --
in this email of course, and in the list in general)? A quick
indication will do.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CALuYw2wS1C=ieZrPfaooOvWTyH-rJrBgMvSoj2-xvsMQTm0mrA@mail.gmail.com">http://lists.debian.org/CALuYw2wS1C=ieZrPfaooOvWTyH-rJrBgMvSoj2-xvsMQTm0mrA@mail.gmail.com
 
Old 03-14-2012, 01:52 PM
Dom
 
Default Unnecessary rebooting (was Bash argument expanded inside alias)

On 14/03/12 12:50, rcb wrote:

Dear Camaleón,

Unfortunately, this nice command of yours doesn't seem to work. Is it
me typing something wrong, or there is really a problem?
:~$ alias muda='find $1 -name "*" -mtime $2'
:~$ muda /home/cheetara -4
find: invalid arg `-4' for `-mtime'


Command line paramaters aren't passed to the alias as arguments in $1,
$2 etc - those will expand to "". Instead your parameters are being
added to the end of the aliased command, giving you:


find -name "*" -mtime /home/cheetara -4

for both this and the following form:


Funny is that no matter if I change $2 to $1, the error is the same. Look:
:~$ alias muda='find $2 -name "*" -mtime $1'
:~$ muda /home/aluno -4
find: invalid arg `-4' for `-mtime'


You can get a better idea of what is happening by using "set -x" before
running your muda command, and "set +x" afterwards. The expanded aliases
will be displayed when they are executed.


Quoting the bash man page section on aliases:

"There is no mechanism for using arguments in the replacement text. If
arguments are needed, a shell function should be used"



That is just to chitchat, as for now the function solution works great!


Good to hear you got a result :-)

--
Dom


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4F60B09F.5000208@rpdom.net">http://lists.debian.org/4F60B09F.5000208@rpdom.net
 

Thread Tools




All times are GMT. The time now is 03:42 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org