Re: Could alias include the condition structure?
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Sat, 30 Dec 2006 23:10:32 -0500
On 2006-12-31, sealo wrote:
Hello,
I want to use the alias as the macro in the function. But when I give
the "if; then fi" structure into the alias, the execution was failed.
The original code like this.
<code>
#!/usr/bin/bash:
alias entry='if [ $DEBUG -eq 1 ]; then echo $FUNCNAME; fi";
Your quotes are mismatched; you open with a single quote and close
with a double.
function Test
That is a non-standard syntax. The portable syntax for defining a
function is:
Test()
{
entry;
# Other Something
}
</code>
The execution was report error. If I remove the if structure to the
"entry", it was working fine. How can I add the condition judgement in
the alias ?
Note the bash man page:
Aliases are not expanded when the shell is not interactive,
unless the expand_aliases shell option is set using shopt (see
the description of shopt under SHELL BUILTIN COMMANDS below).
...
For almost every purpose, aliases are superseded by shell
functions.
...
Aliases are confusing in some uses.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.
- Follow-Ups:
- Re: Could alias include the condition structure?
- From: sealo
- Re: Could alias include the condition structure?
- References:
- Could alias include the condition structure?
- From: sealo
- Could alias include the condition structure?
- Prev by Date: Could alias include the condition structure?
- Next by Date: Re: Could alias include the condition structure?
- Previous by thread: Could alias include the condition structure?
- Next by thread: Re: Could alias include the condition structure?
- Index(es):
Relevant Pages
|