bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash command alias has a problem in using brace.


From: Dale R. Worley
Subject: Re: bash command alias has a problem in using brace.
Date: Fri, 27 Aug 2021 21:47:29 -0400

Hyunho Cho <mug896@gmail.com> writes:
> If i enter a command line like below then '>' prompt appears for the
> input of here document.
>
> bash$ { cat <<\@ > foo ;} 2> /dev/null
>> 111
>> 222                      # '>' prompt
>> @
>
>
> but if i use alias then '>' prompt does not appear and default bash
> prompt appears
>
> bash$ alias myalias='{ cat <<\@ > foo ;} 2> /dev/null'
> bash$ myalias
> bash$ 111
> bash$ 222              # bash$ prompt
> bash$ @
>
>
> this only occurs in brace
>
> bash$ alias myalias='( cat <<\@ > foo ) 2> /dev/null'
> bash$ myalias
>> 111
>> 222                   # '>' prompt
>> @

I don't know the details, but it must have something to do with what
event triggers the reading of the here-document.  That event isn't the
execution of the command containing it, I don't think, but more like
when the here-document-redirection is parsed.  Note that in your first
example, << is parsed after you type RET.  In the second two, the << is
inside quotes, and those characters are parsed only when "myalias" is
discovered in an input line and the alias definition is substituted for
it.

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]