Comments on: `cat` as a shell builtin https://www.ohnekontur.de/2013/02/17/making-cat-a-shell-builtin/ ohne Linien und Kanten und trotzdem gefangen Fri, 28 Nov 2014 09:53:25 +0000 hourly 1 https://wordpress.org/?v=6.4.5 By: Lolly https://www.ohnekontur.de/2013/02/17/making-cat-a-shell-builtin/comment-page-1/#comment-1453 Thu, 07 Mar 2013 19:48:05 +0000 http://www.ohnekontur.de/?p=2259#comment-1453 Thanks for the post I really appreciate it it was very interessting

]]>
By: Andreas Schiermeier https://www.ohnekontur.de/2013/02/17/making-cat-a-shell-builtin/comment-page-1/#comment-1180 Wed, 20 Feb 2013 23:28:23 +0000 http://www.ohnekontur.de/?p=2259#comment-1180 ; missing:

function cat { echo "$(< $1)"; }

Fixes some issues, but also breaks while reading binary files:

function cat {
if [ $# -eq 1 -a "${1:0:1}" != "-" ]
then
exec 3< "${1:-/dev/stdin}"
while read -r -u3 line
do
echo -E ''"${line}";
done
echo -nE ''"${line}";
exec 3<&-
else
/bin/cat "$@"
fi
}

]]>