#!/bin/csh -f
#(ie run the cshell on this but don't read the .cshrc)

# nom: no ^M: remove control M's from a file!

#    version = 1.04 of nom 2022 Oct 29
# 2022 Oct 29, 1.04: use a variable for the control M to make editing easier
# 2018 Apr 17, 1.03: allow it to work with cut/paste buffer if no arguments
# 2015 Apr 01, 1.02: put quotes around the control-M
# 2009 nov 21, 1.01: avoid illegal byte sequence problem
# 2009 Jul 11 origin

# avoid Illegal byte problem on Macs:
setenv LC_ALL en_US.ISO8859-1

# The next line defines the control-M character:
set controlM = ''

if ($#argv == 2) then
   tr -d "$controlM" < $1 > $2
else
   set tmp = /tmp/`whoami`.nom
   pbpaste | tr -d "$controlM" > $tmp
   cat $tmp | pbcopy
endif
