New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-interactive command substitution repeats subsequent commands twice #48

Closed
emersion opened this Issue Oct 11, 2018 · 1 comment

Comments

1 participant
@emersion
Copy link
Owner

emersion commented Oct 11, 2018

echo $(echo 1)
echo 2

Output:

1
2
2

@emersion emersion added the bug label Oct 11, 2018

@emersion

This comment has been minimized.

Copy link
Owner

emersion commented Nov 7, 2018

Tried to strace mrsh, but it's very weird, it looks like subsequent lines are read twice:

openat(AT_FDCWD, "test.sh", O_RDONLY)   = 3
fcntl(3, F_GETFD)                       = 0
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=19, ...}) = 0
read(3, "a=$(echo a)\necho b\n", 4096)  = 19
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
read(3, "echo b\n", 4096)               = 7
read(3, "", 4096)                       = 0
close(3)                                = 0

test.sh is:

a=$(echo a)
echo b

Full trace: https://sr.ht/vsDO.txt

@emersion emersion closed this in 51c7fe8 Nov 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment