maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Can't cd in bash script (https://talk.maemo.org/showthread.php?t=67836)

fgevaerts 2011-01-04 17:14

Re: Can't cd in bash script
 
One way would be
tr -d '\015' < yourfile.sh > yournewfile.sh

(\015 means "octal 13", which is the CR or \r character)

Or use an editor that can control this. I can't really recommend one though (I know vim can do it, but vim isn't really a good editor to recommend to someone who likes leafpad...)

kureyon 2011-01-04 17:25

Re: Can't cd in bash script
 
Quote:

Originally Posted by FRuMMaGe (Post 911569)
How do I correct this?

You can remove the CRs (\r):
Code:

tr -d "\r" < oldname.sh > newname.sh
Or configure leafpad to save in unix format?

gregoranderson 2011-01-04 17:25

Re: Can't cd in bash script
 
Quote:

Originally Posted by fgevaerts (Post 911574)
One way would be
Or use an editor that can control this. I can't really recommend one though (I know vim can do it, but vim isn't really a good editor to recommend to someone who likes leafpad...)

Just for completeness, in vim you would use the set fileformat instruction:

Code:

:se ff=unix
Vim on the old N900 keyboard is tricky, but it's been your main tool for year then you get used to it (especially if you have gathered together a hefty vimrc file in that time).

http://vim.wikia.com/wiki/File_format

gregoranderson 2011-01-04 17:40

Re: Can't cd in bash script
 
1 Attachment(s)
I've compiled flip for you (see https://ccrma.stanford.edu/~craig/utility/flip/). Dead easy to check for file formats and flip between them.

Code:

[sbox-FREMANTLE_ARMEL: ~] > ./flip

Usage: ./flip [-t|-u|-d|-m] filename[s]
  Converts ASCII files between Unix, MS-DOS/Windows, or Macintosh newline formats

  Options:
      -u  =  convert file(s) to Unix newline format (newline)
      -d  =  convert file(s) to MS-DOS/Windows newline format (linefeed + newline)
      -m  =  convert file(s) to Macintosh newline format (linefeed)
      -t  =  display current file type, no file modifications

[sbox-FREMANTLE_ARMEL: ~] >


FRuMMaGe 2011-01-04 19:27

Re: Can't cd in bash script
 
Quote:

Originally Posted by kureyon (Post 911582)
You can remove the CRs (\r):
Code:

tr -d "\r" < oldname.sh > newname.sh
Or configure leafpad to save in unix format?

Thanks to everyone, this method worked.

Just out of interest, wtf? :p

Late to the party 2011-01-06 09:38

Re: Can't cd in bash script
 
Quote:

Originally Posted by FRuMMaGe (Post 911652)
Thanks to everyone, this method worked.

Just out of interest, wtf? :p

Historical reasons:

http://en.wikipedia.org/wiki/Newline#History

FRuMMaGe 2011-01-06 17:30

Re: Can't cd in bash script
 
Quote:

Originally Posted by Late to the party (Post 913036)

Thanks. Very informative


All times are GMT. The time now is 08:02.

vBulletin® Version 3.8.8