On 2025-09-12 22:01:47 +0200, noneofyourbusiness via Tinycc-devel wrote:
> Vincent Lefevre <[email protected]> wrote:
> > These lines do not support program arguments.
> > https://wiki.gentoo.org/wiki/Tcc gives
> >
> > //usr/bin/env tcc -run "$0" "$@" ; exit $?
> Funny, I added that to the wiki in 2023
> >
> > So, likewise, I would prefer
> >
> > // 2> /dev/null ; exec tcc -run "$0" "$@"
> I agree that this is a more portable option, which even helps when
> /usr/bin/env is missing.
> In that order, options like -h won't work
> // 2>/dev/null ; exec tcc "$@" -run "$0"
> enables options to work
No, the "$@" needs to be at the end:
// 2>/dev/null ; exec tcc -run "$0" "$@"
#include <stdio.h>
int main (int argc, char **argv)
{
int i;
for (i = 0; i < argc; i++)
printf ("argv[%d]: %s\n", i, argv[i]);
return 0;
}
$ ./args.c ab cd
argv[0]: ./args.c
argv[1]: ab
argv[2]: cd
Otherwise this gives
tcc: error: file 'ab' not found
--
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel