LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 07: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, 08:54 PM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
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, 05: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:35 AM
variable expansion in bash coolhandluke1 Programming 4 01-09-2008 04:45 PM
Variable expansion in BASH champak Programming 5 11-26-2007 03:44 AM
Bash variables expansion olaola Linux - Newbie 4 10-16-2006 12:45 PM
macro expansion program ? MichaelH23 Linux - Software 1 07-01-2004 09:21 PM

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

All times are GMT -5. The time now is 12:42 AM.

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