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

Re: <> redirection and notations



> Again, I apologize for saying <> truncated in ksh. It does in bash, and I
> think bash is broken for doing it that way.  That mistake unfortunately added
> unnecessary fuel to the fire.
> 
I know this is not a bash group, but I think in bash-1.12, <> doesn't
truncate.  (try: echo hello >/tmp/xxx; exec 9<>/tmp/xxx; read a <&9; echo
bye >&9)

> 
> I had suggested multiple functions, Alan (I think) said why not just pass
> a mode to %open, and then Paul said sometimes one only wants to spoof one
> and not the other.  The way to go is to have our cake and eat it too:
> 
> Sugar	Meaning		Function	Implementation
> -----	-------		--------	--------------
> <	open ro		%open-ro	@{ %open r $* }
> >	open wo		%open-wo	@{ %open w $* }
> >>	open append	%open-app	@{ %open a $* }
> <>	open rw		%open-rw	@{ %open r+ $* }
> <>!	open rw+trun	%open-rw-trunc	@{ %open w+ $* }
> <>>	open rw+app	%open-rw-app	@{ %open a+ $* }

To allow spoofing of %create, %open and %append, why don't we let $&open do
the work of option processing instead.  So,
	fn %open { $&open -r $* }	# yep I think options should have a -
etc.  But then we still need a name for <>, well you can't win them all.

I'm not keen on having more syntax though, just makes es too `cluttered'.

> Now, as to how to replace <>{...}.  From the discussion, it sounds like we're
> going to need a two character glyph or else just %.  I'd rather see a
> two character glyph like :: but % will do the trick for me ok too.
> 
> Arnold
> 

I must be the only one on the list, but actually I quite like <>.  It's so
different that it reminds me that the the concept is different.  Using '%'
reminds me of csh job control, but I can live with that.

Pete.