How to pass an argument to subshell of bash?

How to pass an argument to subshell of bash?

Post by Vladimir Savino » Wed, 04 Aug 1993 07:38:10



   I have an alias in csh:

alias ed "emacs \!* &"

it allows me to start emacs in the background using

ed myfile

I'm trying to write an alias for bash and can't:

alias ed="emacs \!* &"
It doesn't work properly: I can't pass argument (file name) to the subshell
where emacs is executed in that case.
Does anyone know how to fight the problem?
Thanks in advance, Vladimir

 
 
 

How to pass an argument to subshell of bash?

Post by David W. Tamk » Wed, 04 Aug 1993 09:55:46




frequently:

|    I have an alias in csh:
|
| alias ed "emacs \!* &"
|
| I'm trying to write an alias for bash and can't:
|
| alias ed="emacs \!* &"
| It doesn't work properly: I can't pass argument (file name) to the subshell
| where emacs is executed in that case.
| Does anyone know how to fight the problem?

In ksh -- and I'm quite sure it's the same for bash -- an alias does a simple
text substitution, and csh's "\!*" construction doesn't apply.  To pass a
parameter, you must use a function instead of an alias, and the same would
work in sh as well (if the function definition is understandable by sh),
like this:


Quote:}

Note that there must be a space or a newline after the left brace and a
newline or a semicolon before the right brace.

David W. Tamkin  Box 3284  Skokie, Illinois  60076-6284  312-714-5610


 
 
 

How to pass an argument to subshell of bash?

Post by Spencer S » Thu, 05 Aug 1993 03:38:44



[wants a function to run emacs in the background on cmd line args]

Quote:>I'm trying to write an alias for bash and can't:

>alias ed="emacs \!* &"
>It doesn't work properly: I can't pass argument (file name) to the subshell
>where emacs is executed in that case.

Picky point, since DWT has already given a solution for sh-like shells:
after alias substitution the command line still gets executed in the
current shell, not a subshell.

____                         : A friend is someone who understands your past,
\  / sss / PU Class of '94   : believes in your future, and accepts you just
 \/ Dept of Computer Science : the way you are today.  [source unknown]

 
 
 

1. Cygwin:Bash: Preserve '\' in cmdline arg to pass to subshell?

I've been working on Unix for 15 years, and quoting problems still give me a
headache.  It's even worse when I'm working on a script on NT, using Cygwin, as
NT seems delighted to use backslashes as ordinary characters.

I have an "lp" script, which takes a printer name as a command-line parameter,
which will have multiple backslashes in it.  I need to take that exact
parameter and eventually pass it to the DOS "print" command.  This has to
happen without losing any of the backslashes.

Is there a straightforward way to do this, using bash on Cygwin?

2. Port 113 IDENT Do I need it open if I am running a Web/Mail Sever?

3. Bashing bash (Was Re: bash or user error with set -e and subshells)

4. windowmaker question

5. BASH BASH BASH BASH BASH BASH BASH BASH BASH BASH

6. Bug in the mount! invalid date returned

7. Passing arguments from the form via BASH script

8. virtual servers and mosaic

9. script questions - passing argument as argument to another program

10. How to pass arguments passed in ''s

11. Passing information from a subshell to its parent

12. pass array value to subshell ?

13. Passing commands to subshell