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

Re: weird behaviour of quotes in dash variable assignments



On Mon 21 Sep 2020 at 12:43:52 (-0400), Greg Wooledge wrote:
> On Mon, Sep 21, 2020 at 12:34:20PM -0400, Gary Dale wrote:
> > As an FYI, the scripts were the same on both servers because I had ssh
> > sessions on both and copy/pasted the script from one to the other. (cat
> > <script> on server 1, then use Konsole's copy and paste to select and paste
> > it into nano on server 2).
> 
> Copy and paste doesn't always preserve the actual contents of a file.
> What you get depends on several factors, including the behavior of the
> terminal emulator that you're copying from.  Tabs may be converted to
> spaces, and I have no idea what other changes may occur.
> 
> […]
> 
> If your original script contained non-breaking spaces, or curly quotes,
> or literal tabs, or who knows what else, then there's a nonzero chance
> it will be altered by the copy/paste.
> 
> This is why you need to *verify* that the two scripts are the same, not
> just assume that pasting did what you thought it did.

Perhaps this paragraph illustrates the problems that can arise
with quotation marks, hyphens, etc:

#!/bin/sh
report=”/root/clamscan-report”
subject=$HOSTNAME” clamscan report: “

mv $report $report.prev
/usr/bin/clamscan –quiet -i -r -l $report /home
sed -i ‘/———– SCAN SUMMARY ———–/,$d’ $report
diff $report $report.prev > $report.diff

if [ -s $report.diff ] ; then
    subject=$subject”ALERT – NEW VIRUSES FOUND”
else
    subject=$subject”no new viruses”
fi
mail -r “<sender>” -s “$subject” <to e-mail> < $report.diff

Copied and pasted from firefox to emacs -nw, but checked
against the saved web page:

https://garydale.wordpress.com/

Cheers,
David.


Reply to: