Skip to content

Commit

Permalink
echo(1): Add EXAMPLES
Browse files Browse the repository at this point in the history
While here add CAVEAT section and promote the use of printf(1)

Reviewed by:		gbe@, imp@
Approved by:		manpages (gbe)
Differential Revision:	https://reviews.freebsd.org/D43493
  • Loading branch information
fernape committed Apr 8, 2024
1 parent 60d8dbb commit 7e68976
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bin/echo/echo.1
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ Consult the
manual page.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Special treatment of options and backslashes:
.Bd -literal -offset indent
$ /bin/echo "-hello\\tworld"
-hello\tworld
.Ed
.Pp
Avoid new line character:
.Bd -literal -offset indent
$ /bin/echo -n hello;/bin/echo world
helloworld
.Ed
.Pp
Or to achieve the same result:
.Bd -literal -offset indent
$ /bin/echo "hello\\c";/bin/echo world
helloworld
.Ed
.Sh SEE ALSO
.Xr builtin 1 ,
.Xr csh 1 ,
Expand All @@ -105,3 +123,14 @@ The
.Nm
command appeared in
.At v2 .
.Sh CAVEATS
The
.Nm
command behaves differently with regards to the built-in
.Nm
shell command in a number of ways including escaped characters handling.
It also differs in behavior between different systems hence complicating writing
portable scripts.
It is advised to use the
.Xr printf 1
command to avoid these shortcomings.

0 comments on commit 7e68976

Please sign in to comment.