Ian Kaufman <[email protected]> writes:

> Hi Dave,
>
>>
>> > Have you made any modifications to the script recently? It looks like
>> > something is inserting Windows carriage returns which show up as "\n\r"
>> in
>> > UNIX/Linux, which subsequently newlines the "\n", leaving a "\r" on the
>> > following empty line.
>>
>> Yes,

Actually, no -- I didn't read properly in two respects.  "DOS" (DEC)
line endings are CRLF, not LFCR.  I was assuming that

  #$

somehow got mangled to something like

  #^M
  $^M

but, as Reuti points out, it's probably complaining about a bash
construct, presumably trying to run it under a different shell.

For what it's worth, I have this JSV fragment, and probably should have
used the $'' construct in it -- clue?

      # Check for the common case of Windows-style line endings.
      # (NB requires fixed jsv_include.sh.)
      # The line endings lose typically with the #! shell line.
      cmd=$(jsv_get_param CMDNAME)
      case $(jsv_get_param b) in y|yes) binary=y;; esac
      # Fixme:  Are Mac-style endings relevant?
      # NB literal ^M below!
      [ "$cmd" != NONE -a "$cmd" != STDIN -a "$binary" != y ] &&
          [ -f "$cmd" ] &&
          head -n1 "$cmd" | grep -q '^M$' &&
          # Can't use multi-line messages, unfortunately.
          jsv_reject "\
  Script has Windows-style line endings; transfer in text mode or use dos2unix"

>> but from the posted example, it looks as if the lines are getting
>> broken.  The script needs checking for non-printing characters anyhow.

> Yes, indeed they are getting broken. Think about it, if modifications were
> made to the script using something like Notepad, and those changes were
> made only on lines 1 and 8, then UNIX will read the "\n\r" characters,
> insert the newline for "\n", and on the next line, you have a "\r" sitting
> by itself. That would generate the exact errors seen. And, as far as
> Reuti's comments -  there would be no "$" preceding the "\r" since the very
> next character after the newline gets interpreted is the "\r".
>
>
> Ian

-- 
Community Grid Engine:  http://arc.liv.ac.uk/SGE/
_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users

Reply via email to