src/Pure/General/file.ML
changeset 62854 d8cf59edf819
parent 62551 df62e1ab7d88
child 63668 5efaa884ac6c
equal deleted inserted replaced
62853:8e54fd480809 62854:d8cf59edf819
    44 (* system path representations *)
    44 (* system path representations *)
    45 
    45 
    46 val standard_path = Path.implode o Path.expand;
    46 val standard_path = Path.implode o Path.expand;
    47 val platform_path = ML_System.platform_path o standard_path;
    47 val platform_path = ML_System.platform_path o standard_path;
    48 
    48 
    49 val bash_string =
    49 fun bash_string "" = "\"\""
    50   translate_string (fn ch =>
    50   | bash_string str =
    51     let val c = ord ch in
    51       str |> translate_string (fn ch =>
    52       (case ch of
    52         let val c = ord ch in
    53         "\t" => "$'\\t'"
    53           (case ch of
    54       | "\n" => "$'\\n'"
    54             "\t" => "$'\\t'"
    55       | "\f" => "$'\\f'"
    55           | "\n" => "$'\\n'"
    56       | "\r" => "$'\\r'"
    56           | "\f" => "$'\\f'"
    57       | _ =>
    57           | "\r" => "$'\\r'"
    58           if Symbol.is_ascii_letter ch orelse Symbol.is_ascii_digit ch orelse
    58           | _ =>
    59             exists_string (fn c => c = ch) "-./:_" then ch
    59               if Symbol.is_ascii_letter ch orelse Symbol.is_ascii_digit ch orelse
    60           else if c < 16 then "$'\\x0" ^ Int.fmt StringCvt.HEX c ^ "'"
    60                 exists_string (fn c => c = ch) "-./:_" then ch
    61           else if c < 32 orelse c >= 127 then "$'\\x" ^ Int.fmt StringCvt.HEX c ^ "'"
    61               else if c < 16 then "$'\\x0" ^ Int.fmt StringCvt.HEX c ^ "'"
    62           else "\\" ^ ch)
    62               else if c < 32 orelse c >= 127 then "$'\\x" ^ Int.fmt StringCvt.HEX c ^ "'"
    63     end);
    63               else "\\" ^ ch)
       
    64         end);
    64 
    65 
    65 val bash_args = space_implode " " o map bash_string;
    66 val bash_args = space_implode " " o map bash_string;
    66 
    67 
    67 val bash_path = bash_string o standard_path;
    68 val bash_path = bash_string o standard_path;
    68 
    69