[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ed: please give me a little control over appending final newlines
From: |
Andreas Schwab |
Subject: |
Re: ed: please give me a little control over appending final newlines |
Date: |
Fri, 01 Mar 2002 18:13:53 +0100 |
User-agent: |
Gnus/5.090005 (Oort Gnus v0.05) Emacs/21.2.50 (ia64-suse-linux) |
address@hidden (Andrew L. Moore) writes:
|> Format conversion is better handled separately:
|>
|> #!/bin/sh -
|> #
|> # @(#)jed
|> #
|> # This script is an ed(1) front-end for handling arbitrary file formats.
|> #
|> umask 077
|> PATH=/bin:/usr/bin:/usr/local/bin
|>
|> TMP="unix-format.$$"
|>
|> argv=""
|> while [ $# -ne 1 ]; do argv="$argv \"$1\""; shift; done
|> pathname="$1"
|>
|> eval set -- "$argv"
This will treat all $ and \ and " that occured in the original arg list as
meta characters.
|>
|> case $(file "$pathname") in
|> *'CRLF line terminators'*)
|> trap 'rm -f "$TMP"; exit' 0 1 2 15
|> msdos2unix <"$pathname" >"$TMP"
|> if [ ."$@" = . ]; then ed "$TMP"; else ed "$@" "$TMP"; fi
^^^^
This will expand to more than one word if $# > 1, probably giving a
syntax error from test. The test is not nessary at all, just use the
else branch unconditionally.
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."