pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Linux bootstrap shell



    Date:        Thu, 17 Sep 2020 12:26:33 +0100
    From:        Jonathan Perkin <jperkin%joyent.com@localhost>
    Message-ID:  <20200917112633.GI10710%joyent.com@localhost>

  | FWIW I did have some patches to get rid of the requirement for a BSD
  | echo a while back when implementing dash as a bootstrap shell.  I have
  | a feeling they might only be required when using the legacy wrappers.

Try inserting this function into any script that you have that uses
echo, and needs to be portably the BSD version, regardless of what the
shell or /bin/echo on the system happen to be.

kre

echo()
{
	_e_nl=true
	case "$1" in
	-n)	_e_nl=false; shift;;
	esac

	case "$#" in
	[1-9]*)	printf %s "$1"; shift
		while [ $# -gt 0 ]
		do
			printf ' %s' "$1"
			shift
		done
		;;
	esac

	if ${_e_nl}; then printf '\n'; fi
}




Home | Main Index | Thread Index | Old Index