gpt4 book ai didi

bash - 最短的非空 bash quine

转载 作者:行者123 更新时间:2023-12-01 22:19:53 25 4
gpt4 key购买 nike

最短的 bash quine 是空字符串:

$ bash -c ''
$

生成自己的源代码作为输出的最短的非空 bash 脚本是什么?

最佳答案

19 个字符:

$echo 'echo $BASH_COMMAND' > quine
$ wc -c quine
19 quine
$ cat quine
echo $BASH_COMMAND
$ bash quine
echo $BASH_COMMAND
$

字符数包括源中的换行符(因为它是在输出中产生的)。


如果您之前没有听说过$BASH_COMMANDthe manual说:

BASH_COMMAND

The command currently being executed or about to be executed, unless the shell is executing a command as the result of a trap, in which case it is the command executing at the time of the trap.

关于bash - 最短的非空 bash quine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40933213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com