/dev/stdout 何も印刷しない">

echo "Hello World" > /dev/stdout 何も印刷しない

echo /dev/stdout 何も印刷しない">

想像する:

$ echo "Hello World" > /dev/stderr
Hello World

$ echo "Hello World" > /dev/stdout

$ uname -a
CYGWIN_NT-10.0 xxx 3.3.4(0.341/5/3) 2022-01-31 19:35 x86_64 Cygwin

なぜecho "Hello World" > /dev/stdout何も印刷されないのですか?問題を解決するには?

UPD。

印刷は正常になりますecho "Hello World"か?

例:

$ echo "Hello World"
Hello World

そうでない場合は、exec >/dev/nullシェルまたは同様の方法で呼び出しましたか?

いいえ。

UPD2。動作が停止する場所を探します。

$ clang t554.c -std=c11 -pedantic -Wall -Wextra -c -S -O3 -o /dev/stdout
        .text
        <asm code>

# "exxxtern" was a typo
$ clang t554.c -std=c11 -pedantic -Wall -Wextra -c -S -O3 -o /dev/stdout
t554.c:6:3: error: use of undeclared identifier 'exxxtern'
                exxxtern int xxx;
                ^
1 error generated.


TASKING+pavel.morozkin@SPBPC023 ~
$ clang t554.c -std=c11 -pedantic -Wall -Wextra -c -S -O3 -o /dev/stdout
# nothing is printed for the 1st time

UPD3。他のコンピュータでclangを使用して再現できます。

$ clang t455.c -S -o /dev/stdout
        .text
        <asm code>

# introduce the error

$ clang t455.c -S -o /dev/stdout
t455.c:26:1: error: unknown type name 'x'
x
^
t455.c:26:2: error: expected identifier or '('
x
 ^
2 errors generated.

# fix the error

$ clang t455.c -S -o /dev/stdout
# nothing is printed

$ clang --version
clang version 8.0.1 (tags/RELEASE_801/final)

ベストアンサー1

これは、次の問題が原因で発生します。https://github.com/llvm/llvm-project/issues/54086:

"-o" がシンボリックリンクを指定した場合、clang が何かをコンパイルしてコンパイルするとシンボリックリンクのターゲットに書き込まれますが、コンパイルに失敗した場合はシンボリックリンク自体を削除します。

おすすめ記事