Re: bash command alias has a problem in using brace.
On 8/27/21 9:47 PM, Dale R. Worley wrote: Hyunho Cho writes: 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$ @ 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. This is substantially correct. When the parser goes and collects the body of the here-document, it's still parsing the contents of the alias. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: bash command alias has a problem in using brace.
Hyunho Cho 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
bash command alias has a problem in using brace.
Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall uname output: Linux EliteBook 5.11.0-25-generic #27-Ubuntu SMP Fri Jul 9 23:06:29 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.1 Patch Level: 4 Release Status: release ### 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 > @