Re: [9fans] late to the party - Here docs
- From: quanstro@xxxxxxxxxxxx (erik quanstrom)
- Date: Wed, 7 Nov 2007 20:21:52 GMT
Exactly: they are an aesthetic convenience compared with multiple
echo invocations
but so are quotes compared with multiple backslashes.
though it is annoying they can't be used in fn definitions.
That's a bug which could be fixed ...
i was thinking about this topic again the other day during an
idle moment. here documents are part of the parsing routine.
but they don't end up in rc's machine language.
Does this mean they don't work in loops too?
it could be fixed. there must be a reason duff never made here
documents work. i think they just don't fit the pattern. one
justification i've seen for them is that they don't require the whole
here doc to be in the shell's memory. the other is that "quoting
is easier". unfortunately, to have here documents work within
functions, the whole here doc needs to be in the shell's memory.
so much for reason #1. and one of the reasons for developing
rc was to cut down on the different quoting rules. the bourne shell
has \-quoting, "-quoting, '-quoting and here document quoting
rules. rc has ' quoting, \ quoting (only at the end of lines) and
here document quoting.
from your example, i'm not so sure why this
{
echo select $blah blah';'
echo $imbibe_rat_urine
}|mysql --blah-blah
is so terrible.
it turns out that you can use a here document in a loop
; for(i in 1 2 3)
cat <<!
fu
!
fu
fu
fu
but it doesn't work if you use curly braces
; for(i in 1 2 3){
cat <<!
fu
!
}
<hangs>
!
}
fu: '/bin/fu' directory entry not found
}
fu: '/bin/fu' directory entry not found
}
fu: '/bin/fu' directory entry not found
since nobody's bothered to fix this, it's likely that it's just not used
very much.
- erik
.
- Follow-Ups:
- Re: [9fans] late to the party - Here docs
- From: dave . l
- Re: [9fans] late to the party - Here docs
- From: geoff
- Re: [9fans] late to the party - Here docs
- References:
- Re: [9fans] late to the party - Here docs
- From: dave . l
- Re: [9fans] late to the party - Here docs
- Prev by Date: Re: [9fans] Font
- Next by Date: [9fans] wiki question
- Previous by thread: Re: [9fans] late to the party - Here docs
- Next by thread: Re: [9fans] late to the party - Here docs
- Index(es):
Relevant Pages
|