argv0(1)

πŸ“¦
version 0.88 Β· 2 versions
, in debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– argv0(1) β€” the glow-up πŸ’–

okay bestie, welcome to argv0, a lil cutie from the General Commands Manual section 1, and honestly? she's serving. this is the page that teaches you how to run a program with a specified 0th argument, which sounds nerdy but is lowkey iconic once you get it. iykyk πŸ’…


✨ NAME ✨

argv0 β€” runs a program with a specified 0th argument. that's the whole vibe. short, sweet, powerful. periodt.


🌸 SYNOPSIS 🌸

argv0 realname zero args

three things, bestie: a real name, a zero, and then however many args your heart desires 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so listen up, here's the tea β˜•

  • realname is one argument. just one. don't be greedy.
  • zero is one argument. also just one.
  • args is any number of arguments. go wild, go feral, bring the whole group chat.

and then argv0 does its main character thing: it runs the program stored as realname on disk, with zero as the 0th argument (rather than realname) and args as the remaining arguments. literally switching up the identity of the program before it even wakes up. the way that it just does that 😭


πŸŽ€ APPLICATIONS πŸŽ€

so why do we even care? because some programs pay special attention to the 0th argument, and argv0 makes these programs usable from shell scripts. it's giving ✨adaptable✨

for example, this:

argv0 /bin/csh -csh

runs /bin/csh with a 0th argument of -csh. and /bin/csh will think it is a login shell and behave accordingly. like bestie just put on a costume and fully committed to the role πŸ‘‘

as another example, the command:

tcpserver 0 ftp argv0 tcpd ftpd -l -A

has a similar effect to the line:

ftp stream tcp nowait root tcpd ftpd -l -A

in /etc/inetd.conf. the tcpd program is run with 0th argument ftpd and remaining arguments -l -A. no cap.

⚠️ note that tcpd can and should be replaced by the -x option of tcpserver(1) β€” bestie said don't do the old way, do this instead:
tcpserver -x ftp.tcp 0 ftp ftpd -l -A

slay. upgrade your life. πŸ’œ


πŸ’œ SEE ALSO πŸ’œ

the whole friend group, gather round 🫢:

and if you wanna go down the rabbit hole (and you should, bestie):

http://cr.yp.to/ucspi-tcp.html


and that's the whole page, mwah πŸ’‹ this was argv0(1) from the General Commands Manual β€” that's the title card and the lil sign-off footer, same name top and bottom like a lil signature. no date or version was listed, so we keep it mysterious. stay iconic, go run some programs with fake 0th arguments, and remember: the 0th argument is the moment before the plot twist 🌈

πŸ“¦ where this page comes from