Menu

#282 Losing correct line ending format - Unix lf becomes windows crlf

2.x
closed-fixed
None
5
2014-01-07
2013-03-01
Steve
No

Version 2.6.1.27
I have a number of php cronjob scripts that MUST be saved with Unix LF line endings. Recently Dev-PHP has "lost" the correct setting, and saved the files with CRLF. I found out when various jobs stopped running ar the CR is an invalid charater. I am afraid I am not sure how to replicate this as now I have re-saved them all with the format set to Unix (LF) they seem to be fine. It seems to be associated with a recent upgrade I did about a month ago. Does Dev-PHP store which files are which line endings somewhere, or does it try to work it out on the fly as a file is opened?

Anyway - all my php cronjobs have lost the correct line ending format, so I suspect its to do with the upgrade.

It may be worth asking the user if they wish to have Unix line endings if they are saving a file that starts with a hash bang #! - e.g.

#!/usr/bin/php

as this is almost certainly a script designed to be run as a cronjob or command line script under X operating systems.

Discussion

  • Steve

    Steve - 2013-03-01

    The board has converted the #!/usr/bin/php to a big font

     
  • Pierre Fauconnier

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,5 +4,5 @@
     Anyway - all my php cronjobs have lost the correct line ending format, so I suspect its to do with the upgrade.
    
     It may be worth asking the user if they wish to have Unix line endings if they are saving a file that starts with a hash bang #! - e.g. 
    -#!/usr/bin/php
    +<pre>#!/usr/bin/php</pre>
     as this is almost certainly a script designed to be run as a cronjob or command line script under X operating systems.
    
    • status: open --> open-accepted
    • assigned_to: Pierre Fauconnier
     
  • Pierre Fauconnier

    1 bug + 1 feature request about shebang (the initial two characters on the initial line of a script are #!)

    Does Dev-PHP store which files are which line endings somewhere, or does it try to work it out on the fly as a file is opened?

    You're right, now this check is made on the fly by the SynEdit component, previously (I don't remember the revision number) this setting was coded inside Dev-PHP itself.

     
  • Pierre Fauconnier

    Well, I've not been able to reproduce this bug.
    Anyway, I've set the default file format to sffUnix. New revision: see menu Options/Check before update...

    Moreover, there's an undocumented setting in the file %APPDATA%/devphp/devphp.ini
    In section [Options], the key "SaveType" defines the default file format to use
    (0=DOS: CRLF, 1=*Nix: LF, 2=Mac: CR, 3=Unicode: 0x2028)
    Maybe there's a
    SaveType=0 into this devphp.ini

    Furthermore, there could be another side effect (sorry). I changed the FTP file transfer mode to binary. This could explain the bug because the file transfer protocol is supposed to convert the file format (sftp does no change).

    Last, about the feature request. I understand the need, I could add a check on each save/save as... like: "Are you sure you want a msdos file format? Because your file begins with a shebang, it should be a *Nix format..."
    Comments, please :)

     
    • Steve

      Steve - 2013-03-05

      Moreover, there's an undocumented setting in the file %APPDATA%/devphp/devphp.ini

      I had this in the old version, thus I suspect it was an upgrade issue. Maybe the old version had saved it incorrectly in th epast and I hadn't noticed until now.

      I changed the FTP file transfer mode to binary.

      Haven't tested this as I use FileZilla which doesn't mess with line endings (At least not with my settings)

      Are you sure you want a msdos file format?

      Only comment is the format menu uses the phrases "Windows (CRLF)" and "Unix (LF)" and here you use "msdos" and "*Nix" format. Suggest you use the same on both to avoid confusion. "Windows" is maybe better as younger programmers think "dos" is something you do when the boss isn't looking!

       

      Last edit: Steve 2013-03-05
      • Pierre Fauconnier

        Shebang checked.
        Version >= 2.6.1.29

        The dialog message is:
        SHEBANG detected! Keep current format?

        Yes - will keep the current format,
        No - will force using the Unix(LF) format

        Of course, the dialog default button is No.

         
    • Pierre Fauconnier

      I've been able to reproduce this bug.
      And I nailed it.

      version 2.6.1.28

       
  • Steve

    Steve - 2013-05-13

    Hi Pierre. Is it fixed in a newer version? I have 2.6.1.28 and still have issues.

    When I save (ctrl-S usually) it still says Unix format on the status bar and the 'Format' menu, but when I upload and run I get errors. I am having to change from Unix to some other format and back again then save before uploading to ensure correct line endings. If I close then re-open it tells me its windows/DOS on the status bar.

    Oh well ...

     
  • Pierre Fauconnier

    Hi Steve,
    I really thought this line ending issue was gone away.
    Did you make a "fresh install" (I've built several 2.6.1.28 - sorry)?

     
  • Pierre Fauconnier

    • status: open-accepted --> pending-fixed
     
  • Pierre Fauconnier

    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.