Platform Independent Script after Github Pull?

Discussion in 'Mac Programming' started by ArtOfWarfare, Jan 19, 2013.

  1. ArtOfWarfare macrumors G3


    Nov 26, 2007
    I have a text file containing a list of relative paths. The text file + the files those paths refer to are all on Github, and will be downloaded by both Windows and OS X users. How can I make it so that when Windows users get it, they'll see their correct path divider (\) and on OS X they'll get their correct path divider (/)?

    It seems to me there aught to be some sort of script I can include in my GitHub repository that automatically runs itself and fixes all the paths each time a pull request is completed or something, but I can't for the life of me find it by googling.

    Does anyone have any help?

    (For what it's worth, this is regarding Android development. The file is a plain text file that contains paths that the compiler needs so that it can find the correct source files... it requires that the path separators be correct.)
  2. chown33 macrumors 604

    Aug 9, 2009
    I think I'd just make two files, one with each type of separator. Given them slightly different names, like for the Windows-based one.

    Given a file in /-separated form, it should be simple to write a script that converts to \-separated form, including any \-escaping that might (or might not) need to occur.

    The 'tr' command can easily do single-character transliteration. So that would be my 1st choice for the / to \ conversion. If there were other things, like prepending C: or whatever, I might choose a different tool, or do the conversion in stages. Hard to say without seeing the actual data.

    Oh, and I might file a feature-request against the Android dev tool to add a platform-neutral pathname capability. This is a solved problem. See the RFC for URLs and URIs, where the separator is always /, even if the server uses something else natively.

Share This Page