Re: [LDAPsh-devel] Enhanced redirection
Status: Beta
Brought to you by:
rcorvalan
From: James D. <j-d...@us...> - 2003-09-21 02:10:52
|
Hi, In message <61F...@he...> on Fri, Sep 19, 2003 at 03:41:07PM +0200, Rafael Corvalan wrote: > Redirection is still difficult to understand, I think, for someone that > does not know internals... Mainly due to filehandles lifetime. I believe that if the user uses the "temporary redirect" syntax... ldapsh> ls ;| wc -c ---- 19 entries found. 319 ldapsh> ls ;| wc -c ---- 19 entries found. 319 ...then they will get what they want (i.e. wc will print its answer each time, since the handles are only open for the duration of ldapsh's ls). If the user uses the "permanent redirect" syntax: ldapsh> redir "| sort -u" ldapsh> ls ---- 19 entries found. ldapsh> ls ---- 19 entries found. ldapsh> noredir ...then it is a *feature* that unique, sorted results would be printed only after noredir. However, you are quite correct that this can be confusing for new users (esp. if they then want to invoke help). Also, it is not very convenient if I want `sort` filehandles to be opened/closed with every ls. Perhaps we could introduce an abbreviated redirection syntax ;| (with no trailing characters) to say "repeat the last redirection". Thus: ldapsh> ls ;| wc -c ---- 19 entries found. 319 ldapsh> ls ;| ---- 19 entries found. 319 > By the way, redir() is quite broken, I notice that "ls;|echo" causes an exit code 141 on one of my hosts. I don't know how to debug perl. > because command line parsing is > very simple. It would be interesting to have a "proper" command-line parser. I realise the convenience and magic of using the Perl interpreter, but I think it is a bit limiting for us, and can be a barrier for new users (well, it was for me). I am not very good at developing parsers, though. :( > cat 'cn=test' | grep -i last > > will give an error. If you use ;| instead of | then it will work. I.e.: cat 'cn=test' ;| grep -i last This is not ideal (as you have said) but it is what we have included in our documented example. PS. Actually, it will not work: grep will be invoked without the "-i last" options. This is because of the following line: if (s/;\s*([|>][\s\w\d_\/.-]+)//) { I am not sure of the purpose of that line, so you might like to make a decision about whether it should look more like this: if (s/;\s*([|>].+)//) { (The above line is what I, personally, use). |