Skip to content

echo 的行为 #187

@ccmywish

Description

@ccmywish

在 Zsh 中:

$ which echo
echo: shell built-in command

$ echo -e "hh" >> a.txt

# a.txt 文本
hh

在 Bash 中:

$ which echo
/usr/bin/echo

$ echo -e "hh" >> a.txt

# a.txt 文本
hh

在 sh 中:

$ which echo
/usr/bin/echo

$ echo -e "hh" >> a.txt

# a.txt 文本
-e hh


# 但是
$ /usr/bin/echo -e "hhc" >> a.txt

# a.txt 文本
hhc

综上,怀疑,在 sh 中调用的 echo 实际上是由 sh 实现的,并且未被 which 成功检测

Metadata

Metadata

Assignees

No one assigned

    Labels

    LinuxLinux相关

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions