Problem with aliases

May 20, 2008
604
0
Sammamish, WA
TCC 10.00.60 Windows XP [Version 5.1.2600]
TCC Build 60 Windows XP Build 2600 Service Pack 3

Empty tcmd.ini and tcstart.btm

When I make an alias that contains multiple commands and "the rest" of
the parameters and try to redirect the output, the redirected output
is just part of the alias.

How can I redirect everything that the alias outputs?

[D:\]alias foo `(echo all="%1$" %+ echo first="%1")`

[D:\]foo a b
all="a b"
first="a"

[D:\]foo a b > test.txt
all="a b > test.txt"
first="a"

[D:\]dir /k /m test.txt
TCC: (Sys) The system cannot find the file specified.
"D:\test.txt"

[D:\]foo > test.txt
all="> test.txt"
first=">"

[D:\]foo
all=""
first=""

--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 

samintz

Scott Mintz
May 20, 2008
1,322
12
Solon, OH, USA
If you know ahead of time how many arguments you will have you could
append the magical %n$ to the end of the alias.

Otherwise, make the alias a script file instead. You probably won't
notice a speed difference.

-Scott

Jim Cook <> wrote on 03/17/2009 12:35:13 PM:


> TCC 10.00.60 Windows XP [Version 5.1.2600]
> TCC Build 60 Windows XP Build 2600 Service Pack 3
>
> Empty tcmd.ini and tcstart.btm
>
> When I make an alias that contains multiple commands and "the rest" of
> the parameters and try to redirect the output, the redirected output
> is just part of the alias.
>
> How can I redirect everything that the alias outputs?
>
> [D:\]alias foo `(echo all="%1$" %+ echo first="%1")`
>
> [D:\]foo a b
> all="a b"
> first="a"
>
> [D:\]foo a b > test.txt
> all="a b > test.txt"
> first="a"
>
> [D:\]dir /k /m test.txt
> TCC: (Sys) The system cannot find the file specified.
> "D:\test.txt"
>
> [D:\]foo > test.txt
> all="> test.txt"
> first=">"
>
> [D:\]foo
> all=""
> first=""
>
> --
> Jim Cook
> 2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
> Next year they're Sunday.
>
>
>
>
>
>
 
May 20, 2008
604
0
Sammamish, WA
On Tue, Mar 17, 2009 at 10:10 AM, samintz <> wrote:

> If you know ahead of time how many arguments you will have you could
> append the magical %n$ to the end of the alias.
I do not know how many arguments, hence the %n$ syntax is exactly my
problem when used as %2$ the way I need. My alias uses the first
argument for one thing, and anything else, if specified, as optional
arguments to another command.

I may have to convert to a .BTM file -- thanks for the suggestion.

--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
May 29, 2008
536
3
Groton, CT
TCC 10.00.60 Windows XP [Version 5.1.2600]
TCC Build 60 Windows XP Build 2600 Service Pack 3

Empty tcmd.ini and tcstart.btm

When I make an alias that contains multiple commands and "the rest" of
the parameters and try to redirect the output, the redirected output
is just part of the alias.

How can I redirect everything that the alias outputs?

[D:\]alias foo `(echo all="%1$" %+ echo first="%1")`

[D:\]foo a b
all="a b"
first="a"

[D:\]foo a b > test.txt
all="a b > test.txt"
first="a"

[D:\]dir /k /m test.txt
TCC: (Sys) The system cannot find the file specified.
"D:\test.txt"

[D:\]foo > test.txt
all="> test.txt"
first=">"

[D:\]foo
all=""
first=""

This looks strange to me, but I found that an extra pair of parentheses works:

> (foo a b) > test.txt

> type test.txt
all="a b"
first="a"

Also, it works the same way whether there are parentheses as part of the alias or not.
 
May 20, 2008
604
0
Sammamish, WA
On Tue, Mar 17, 2009 at 10:44 AM, dcantor <> wrote:

> This looks strange to me, but I found that an extra pair of parentheses works:
>
>> (foo a b) > test.txt
That's at least a reasonable work-around.

It really looks like a bug in the alias expansion, though. I don't
think that %1 (etc.) ever ought to match the redirection symbol or
filename.

--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 

samintz

Scott Mintz
May 20, 2008
1,322
12
Solon, OH, USA
Oh yeah... I remember doing that once...

It's a pain the butt to remember though, especially if you don't use it
often and/or your fingers type on auto-pilot like mine tend to do at
times.

-Scott


dcantor <> wrote on 03/17/2009 01:44:52 PM:


> ---Quote (Originally by Jim Cook)---
> TCC 10.00.60 Windows XP [Version 5.1.2600]
> TCC Build 60 Windows XP Build 2600 Service Pack 3
>
> Empty tcmd.ini and tcstart.btm
>
> When I make an alias that contains multiple commands and "the rest" of
> the parameters and try to redirect the output, the redirected output
> is just part of the alias.
>
> How can I redirect everything that the alias outputs?
>
> [D:\]alias foo `(echo all="%1$" %+ echo first="%1")`
>
> [D:\]foo a b
> all="a b"
> first="a"
>
> [D:\]foo a b > test.txt
> all="a b > test.txt"
> first="a"
>
> [D:\]dir /k /m test.txt
> TCC: (Sys) The system cannot find the file specified.
> "D:\test.txt"
>
> [D:\]foo > test.txt
> all="> test.txt"
> first=">"
>
> [D:\]foo
> all=""
> first=""
> ---End Quote---
>
> This looks strange to me, but I found that an extra pair of parentheses
works:

>
> > (foo a b) > test.txt
>
> > type test.txt
> all="a b"
> first="a"
>
> Also, it works the same way whether there are parentheses as part of
> the alias or not.
>
>
>
>
 
May 20, 2008
3,520
3
Elkridge, MD, USA
samintz wrote:
| Oh yeah... I remember doing that once...
|
| It's a pain the butt to remember though, especially if you don't use
| it often and/or your fingers type on auto-pilot like mine tend to do
| at
| times.

I often redirect the output of FOR and GLOBAL, thus I had learned long ago
that it works properly only if the whole command to be redirected is
parenthesized, e.g.:

( GLOBAL work-command ) > target

( FOR %xxx IN (*) DO command ) > target

which is documented in these commands' respective help topics. It is not a
surprise that some complicated aliases require the same approach.
--
Steve