2 Copyright (C) 1995-2011, The AROS Development Team. All rights reserved.
9 /* subsitute one script argument and leaves the input after .ket */
10 LONG
convertArg(ShellState
*ss
, Buffer
*in
, Buffer
*out
, BOOL
*quoted
)
12 STRPTR s
= in
->buf
+ in
->cur
;
16 BOOL scriptarg
= FALSE
;
18 if (s
[0] == ss
->dollar
&& s
[1] == ss
->dollar
&& s
[2] == ss
->ket
)
21 LONG len
= l2a(ss
->cliNumber
, buf
);
22 bufferAppend(buf
, len
, out
, SysBase
);
27 if (!*quoted
&& *p
== '<' && *q
== '>') /* Run <>NIL: ... */
28 return convertRedir(ss
, in
, out
);
30 for (; *q
!= ss
->ket
&& *q
!= ss
->dollar
&& *q
!= '\0'; ++q
)
37 if (*p
== '<') /* input redirection */
38 return convertRedir(ss
, in
, out
);
40 bufferAppend(s
, q
- s
, out
, SysBase
);
45 for (i
= 0; i
< ss
->argcount
; ++i
)
47 struct SArg
*a
= ss
->args
+ i
;
49 IPTR val
= ss
->arg
[i
];
51 LONG j
, len
= a
->namelen
;
56 if (strncmp(s
, a
->name
, len
) != 0)
64 arg
= val
? a
->name
: NULL
;
67 arg
= val
? "1" : "0";
70 else if (t
& MULTIPLE
)
72 STRPTR
*m
= (STRPTR
*) val
;
74 for (j
= 0; (arg
= m
[j
]); ++j
)
77 bufferAppend(" ", 1, out
, SysBase
);
80 bufferAppend(arg
, len
, out
, SysBase
);
89 else if (s
[len
] == ss
->dollar
) /* default arg */
96 arg
= (STRPTR
) a
->def
;
101 bufferAppend(arg
, len
, out
, SysBase
);
107 while (*q
!= '\0' && *q
++ != ss
->ket
);
108 in
->cur
= q
- in
->buf
;
111 bufferCopy(in
, out
, 1, SysBase
);