On Tue, Nov 23, 2010 at 4:44 PM, James Bowlin <[email protected]> wrote:
> I see the same problem in Gentoo using fish-1.23.1 and on antiX using
> fish version 1.23.1-2 (from Debian repos I believe).
>
> For some reason fish_indent prepends a "1" in front of the ">"
> redirection symbol. It also swallows a leading space.
>
> This means that using funced tends replace working functions with
> broken ones.
>
> Compare the output of:
>
>> functions help | grep ">"
>
> to the output of:
>
>> functions help | fish_indent | grep ">"
>
> or:
>
>> functions help | fish_indent | fish_indent | grep ">"
>
> The following function is a quick and dirty fix that could cause other
> breakage (when someone wants to use "1>" inside of a function):
>
> function fish_indent
> command fish_indent | sed 's/1\+>/ >/'
> end
>
>
> Peace, James
(Sorry that I forgot to reply to all again... Just a re-send)
A '1' placed before '>' is reasonable because 1 is stand for stdout ;)
But it's redundant since we use ^ to do stderr redirection. And there
is not space before the file descriptor. I've seen your patch for this
issue but as Dylan said, I don't think it's a right fix. Here is my
patch which is far from perfect:
======================================
diff --git a/fish_indent.c b/fish_indent.c
index 5e709f2..a1eda61 100644
--- a/fish_indent.c
+++ b/fish_indent.c
@@ -167,33 +167,72 @@ static int indent( string_buffer_t *out, wchar_t
*in, int flags )
}
case TOK_REDIRECT_OUT:
+ {
+ switch( *last)
+ {
+ case L'1':
+ {
+ sb_append( out, L" >" );
+ break;
+ }
+
+ case L'2':
+ {
+ sb_append( out, L" ^" );
+ break;
+ }
+
+ default:
+ sb_append(
out, L" ", last , L">");
+ }
+ break;
+ }
+
case TOK_REDIRECT_APPEND:
+ {
+ switch( *last)
+ {
+ case L'1':
+ {
+ sb_append(
out, L" >>" );
+ break;
+ }
+
+ case L'2':
+ {
+ sb_append(
out, L" ^^" );
+ break;
+ }
+
+ default:
+ sb_append(
out, L" ", last , L">>");
+ }
+ break;
+ }
+
case TOK_REDIRECT_IN:
- case TOK_REDIRECT_FD:
{
- sb_append( out, last );
- switch( type )
+ switch( *last )
{
- case TOK_REDIRECT_OUT:
- sb_append( out, L"> " );
- break;
-
- case TOK_REDIRECT_APPEND:
- sb_append( out, L">> " );
- break;
-
- case TOK_REDIRECT_IN:
- sb_append( out, L"< " );
- break;
-
- case TOK_REDIRECT_FD:
- sb_append( out, L">& " );
+ case L'0':
+ {
+ sb_append( out, L" <" );
break;
+ }
+ default:
+ sb_append( out, L" ",
last, L"<" );
}
break;
}
+ case TOK_REDIRECT_FD:
+ {
+ // FIXME
+ sb_append( out, L" ", last, L">&" );
+ break;
+ }
+
case TOK_BACKGROUND:
{
======================================
It can yield pretty result:
~/grissioms-fish-shell> echo 'echo >/dev/null' | ./fish_indent
echo > /dev/null
~/grissioms-fish-shell> echo 'echo 2>/dev/null' | ./fish_indent
echo ^ /dev/null
~/grissioms-fish-shell> echo 'echo 2>>/dev/null' | ./fish_indent
echo ^^ /dev/null
~/grissioms-fish-shell> echo 'echo >>/dev/null' | ./fish_indent
echo >> /dev/null
~/grissioms-fish-shell> echo 'echo 3>>/dev/null' | ./fish_indent
echo 3>> /dev/null
~/grissioms-fish-shell> echo 'echo 3>/dev/null' | ./fish_indent
echo 3> /dev/null
~/grissioms-fish-shell> echo 'echo </dev/null' | ./fish_indent
echo < /dev/null
~/grissioms-fish-shell> echo 'echo 2</dev/null' | ./fish_indent
echo 2< /dev/null
The only thing to do is deal with TOK_REDIRECT_FD. fish tokenizer
treat _all_ TOK_REDIRECT_FD as output redirect. I'm not familiar with
this area and have nothing to say now.
It's too late to go to bed and my bran refuse to run... Take your own
risk to apply the patch :D
--
Cheers,
Grissiom
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users