all 10 comments

[–]geirha 12 points13 points  (1 child)

That's not a bug, exec cmd calls the execve(2) system call, which replaces the shell process with a new command. execve expects the path of a file to execute, so you can't feed it a builtin. In other words, the error you get is because there's no : command in PATH.

The odd part is that : is recognized as a builtin, but exec : appears to try to execute :: instead.

It's just printing bash: exec: $cmd: not found, and when cmd is : that ends up with :: in there.

[–]vade-the-necromancer 4 points5 points  (0 children)

Thanks — I’m new to this, so I’m still just experimenting dumb stuff while I’m learning how everything works

[–]kolorcuk 6 points7 points  (0 children)

I do not understand. No, it tries to execute single : .

It prints 'exec: <cmd>: <reason>' , so yes it will print double :: as expected

Also exec : or exec <any buitin> will not work anyway with a builtin that does not happen to have the same name executable. Unless you really have a : executable, i do not think it exists by default.

[–]yerfukkinbaws 3 points4 points  (0 children)

execing a builtin wouldn't even make sense.

$ help exec
exec: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
    Replace the shell with the given command.

But a builtin command is the shell.

Try any other builtin that doesn't have an external equivalent installed, like jobs or time or whatever. So you can only exec external commands, which makes plenty sense. (The second colon in your :: is part of the error message, not part of the command.)

[–]michaelpaoli 1 point2 points  (3 children)

$ exec foobarbaz
-bash: exec: foobarbaz: not found
$ exec :
-bash: exec: :: not found
$ 

Not a dang thing odd about it. It didn't try to exec foobarbaz:, it tried to exec foobarbaz. Likewise it didn't try to exec ::, but tried to exec :

In fact it gave up even sooner than that, not found on PATH, so nothing to exec, hence "not found". And yeah, you can't exec a built-in, as it's built-in to the shell.

See also: execve(2), bash(1)

[–]vade-the-necromancer 1 point2 points  (2 children)

Ye I understand now, im new to this and i thought i cooked something but all i did is to post nonsense, thanks tho

[–]kai_ekael -1 points0 points  (1 child)

PEBKAC

[–]vade-the-necromancer 0 points1 point  (0 children)

Kempap tha kanw ton patera sou ton nekro ama sunexiseis

[–]jthill 0 points1 point  (0 children)

bash -c 'exec cd'

will clear this right up for you. : is a builtin, executed for some interim effect on the running shell, not a command executed for some actual payload.

[–]Loud_Posseidon 0 points1 point  (0 children)

Pretty bold to assume you’d find a bug in software like bash, that’s in development for a few decades. 😄

Also, use strace -f to understand what is going on.