Page 1 of 1

[Solved] gedit / bash version issue

Posted: 2022/05/10 18:21:46
by lightman47
{all machines/versions update weekly}

I have RHEL 8 and am writing scripts for all my machines, usually with gedit. My only two CentOS 7 machines (1 local, 1 remote) have been 'choking' on these shared scripts. Investigation reveals that my RHEL 8 gedit is now creating files whose lines end in CR/LF - and CentOS 7 bash doesn't like that additional "CR"!

I've looked on-line and in dconf-editor for how to "turn off" the creation of the 'carriage-return' to no avail. While I could spend hours and write something to go through the shared scripts and delete all the CRs, -- why?

Does anyone know how to:

1. get CentOS 7 bash to not 'choke' on the CRs

2. set (RHEL 8) gedit to NOT insert the CR's (which I assume is their attempt to 'become generic')

??

Thank you.

Re: gedit / bash version issue

Posted: 2022/05/10 18:52:17
by TrevorH
It's an option on the Save As... dialog pane. Down the bottom, next to Character Encoding, it says Line Ending and has choices for Unix/Linux, MAC OS Classic and Windows.

Re: gedit / bash version issue

Posted: 2022/05/13 16:57:16
by lightman47
I did find and set that. Thank you.

For a while thereafter I researched, with no luck, on how to make that setting the default. A number of file edits later, it seems to now be the default! I can only conclude that Gedit defaults to the last setting used. From that, it's reasonable to assume I edited/saved a Windows file with it a few months ago (I likely did - though I'll never remember it now!).

Marking this solved. Thanks again.

INCIDENTALLY - what drove me to discover all this was script error messages: line {n}: $'\r': command not found on my CentOS 7 machines.
During script execution, CentOS 7 bash runs into a line terminated with a 'Windows style' CR/LF pair, as opposed to an expected LF.

I posted to CentOS 8 {RHEL 8} because that's what I am using, and in which I write scripts for both version systems thinking initially it might be some gedit or bash 'bug'.