LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-05-2009, 06:51 PM   #1
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
Bash macro expansion in aliases


I thought I used to know how to do this, but appear to have forgotten. I beg re-enlightenment from the elders in the Community.

Code:
alias some_command='./some_command --with-custom-flags && echo !!'
What I want the above to do is print out my alias (the !! history substitution) so that I know exactly what __real__ command was issued. But the above just prints the literal !! without doing a substitution.

Thoughts? Ruminations? Solutions?
 
Old 06-05-2009, 07:54 PM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Use double quotes instead of single ones. Single quotes prevent any expansion.

However, that's not going to help you, if I am not mistaken it will only print the name of the alias (because that's the last command you issued, duh?
 
Old 06-10-2009, 04:13 PM   #3
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Original Poster
Rep: Reputation: 211Reputation: 211Reputation: 211
The last command issued would be the one before the echo, evaluated inside the alias string, ostensibly. However, neither your proposal nor that I've just stated are accurate. The !! evaluates before everything in the line, so it gets whatever you'd typed before:
Code:
$ This is the last thing I typed.
$ alias ham="echo ham && echo !!"
Results in
This is the last thing I typed.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
macro expansion in vi editor cleopard Linux - General 0 05-02-2008 07:35 AM
variable expansion in bash coolhandluke1 Programming 4 01-09-2008 03:45 PM
Variable expansion in BASH champak Programming 5 11-26-2007 02:44 AM
Bash variables expansion olaola Linux - Newbie 4 10-16-2006 11:45 AM
macro expansion program ? MichaelH23 Linux - Software 1 07-01-2004 08:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration