Skip to content

feat(echo): RUST-2 add echo command

JayceCao requested to merge echo into main

Implement echo command in coreutils. The key point is how to process escape sequences. After testing echo command in coreutils, \x and \0 behave differently. If there are no any characters after both of them, \x still be printed, but not \0:

$ /bin/echo -e "wtfwtf\x\0" "lalala"
wtfwtf\x lala
$ /bin/echo -e "wtfwtf\x" "lalala"
wtfwtf\x lala
$ /bin/echo -e "wtfwtf\0" "lalala"
wtfwtf lala

But in our implementation, both have the same behavior that we just remove them:

$ /bin/echo -e "wtfwtf\x\0" "lalala"
wtfwtf lala
$ /bin/echo -e "wtfwtf\x" "lalala"
wtfwtf lala
$ /bin/echo -e "wtfwtf\0" "lalala"
wtfwtf lala

Merge request reports