debug notes:
$ cat << eof > /root/outfile
hello
eof
minishell: open: Permission denied
minishell: hello: command not found
==42382==
==42382== FILE DESCRIPTORS: 9 open (3 std) at exit.
==42382== Open file descriptor 8: /dev/pts/3
==42382== at 0x49A8C1B: dup (in /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libc.so.6)
==42382== by 0x10C9CC: handle_redirections (src/executing/simple_cmd/handle_redirections.c:65)
==42382== by 0x10CBF6: simple_cmd_execute (src/executing/simple_cmd/simple_cmd_execute.c:91)
==42382== by 0x10B10C: cmd_execute (src/executing/cmd/cmd_execute.c:23)
==42382== by 0x10A4DD: execute_command (src/minishell.c:37)
==42382== by 0x10A3A2: main (src/minishell.c:89)
==42382==
==42382== Open file descriptor 7: /dev/pts/3
==42382== at 0x49A8C1B: dup (in /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libc.so.6)
==42382== by 0x10C9B9: handle_redirections (src/executing/simple_cmd/handle_redirections.c:64)
==42382== by 0x10CBF6: simple_cmd_execute (src/executing/simple_cmd/simple_cmd_execute.c:91)
==42382== by 0x10B10C: cmd_execute (src/executing/cmd/cmd_execute.c:23)
==42382== by 0x10A4DD: execute_command (src/minishell.c:37)
==42382== by 0x10A3A2: main (src/minishell.c:89)
==42382==
==42382== Open file descriptor 6: /dev/pts/3
==42382== at 0x49A8C1B: dup (in /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libc.so.6)
==42382== by 0x10C9CC: handle_redirections (src/executing/simple_cmd/handle_redirections.c:65)
==42382== by 0x10CBF6: simple_cmd_execute (src/executing/simple_cmd/simple_cmd_execute.c:91)
==42382== by 0x10B10C: cmd_execute (src/executing/cmd/cmd_execute.c:23)
==42382== by 0x10A4DD: execute_command (src/minishell.c:37)
==42382== by 0x10A3A2: main (src/minishell.c:89)
==42382==
==42382== Open file descriptor 5: /dev/pts/3
==42382== at 0x49A8C1B: dup (in /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libc.so.6)
==42382== by 0x10C9B9: handle_redirections (src/executing/simple_cmd/handle_redirections.c:64)
==42382== by 0x10CBF6: simple_cmd_execute (src/executing/simple_cmd/simple_cmd_execute.c:91)
==42382== by 0x10B10C: cmd_execute (src/executing/cmd/cmd_execute.c:23)
==42382== by 0x10A4DD: execute_command (src/minishell.c:37)
==42382== by 0x10A3A2: main (src/minishell.c:89)
==42382==
==42382== Open file descriptor 4: /dev/pts/3
==42382== at 0x49A8C1B: dup (in /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libc.so.6)
==42382== by 0x10C9A6: handle_redirections (src/executing/simple_cmd/handle_redirections.c:63)
==42382== by 0x10CBF6: simple_cmd_execute (src/executing/simple_cmd/simple_cmd_execute.c:91)
==42382== by 0x10B10C: cmd_execute (src/executing/cmd/cmd_execute.c:23)
==42382== by 0x10A4DD: execute_command (src/minishell.c:37)
==42382== by 0x10A3A2: main (src/minishell.c:89)
==42382==
==42382== Open file descriptor 3: /tmp/minishell_here_doc_78Ak8J9TeVu (deleted)
==42382== at 0x49A8C1B: dup (in /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libc.so.6)
==42382== by 0x10C9A6: handle_redirections (src/executing/simple_cmd/handle_redirections.c:63)
==42382== by 0x10CBF6: simple_cmd_execute (src/executing/simple_cmd/simple_cmd_execute.c:91)
==42382== by 0x10B10C: cmd_execute (src/executing/cmd/cmd_execute.c:23)
==42382== by 0x10A4DD: execute_command (src/minishell.c:37)
==42382== by 0x10A3A2: main (src/minishell.c:89)
This caused redirections to keep stdout redirected to the outfile, which caused
problems with displaying the prmpt.
The shell hangs, but exits with C-d
Builtins affected:
echo hi > outfile
pwd > outfile
env > outfile