Arc Forumnew | comments | leaders | submitlogin
3 points by lojic 6147 days ago | link | parent

Ok, here's the patch:

  --- arc1/arc.arc        2008-02-13 11:27:37.000000000 -0500
  +++ ../arc1/arc.arc     2008-02-23 21:14:50.000000000 -0500
  @@ -1195,11 +1195,24 @@
   
   (def ensure-dir (path)
     (unless (dir-exists path)
  -    (system (string "mkdir -f " path))))
  +    (system (string "mkdir -p " path))))
  +
  +(def uname nil 
  +  (let val (tostring (system "uname"))
  +  (cut val 0 (- (len val) 1))))
   
   (def date ((o time (seconds)))
  -  (let val (tostring (system (string "date -u -r " time " \"+%Y-%m-%d\"")))
  -    (cut val 0 (- (len val) 1))))
  +  (let val (tostring (system 
  +                      (string
  +                       "date -u "
  +                       (if 
  +                        (is (uname) "Linux")
  +                        ;; Linux wants -d and an interval
  +                        (string "-d \"" (- 1 (since time)) " seconds\"")
  +                        ;; BSD wants -r and epoch seconds
  +                        (string "-r " time))
  +                       " \"+%Y-%m-%d\"")))
  +     (cut val 0 (- (len val) 1))))
   
   (def count (test x)
     (with (n 0 testf (testify test))


7 points by kens 6147 days ago | link

There was an earlier patch (first comment under http://arclanguage.org/item?id=155) that used mzscheme's date operators and avoided the platform-dependent system insanity. I advocate stamping out use of "system" from the Arc code, as it's almost guaranteed to break on different platforms. If mzscheme has taken care of platform dependence, Arc might as well take advantage of it.

As an aside, I notice that both the OpenID and "Arc at work" use system to do the heavy lifting. I propose a law that any sufficiently complicated Arc application requires use of "system" to get things done.

-----

7 points by almkglor 6145 days ago | link

kens' law: Any sufficiently complicated Arc application requries the use of 'system to get things done.

-----

3 points by lojic 6146 days ago | link

I was hoping that pg could simply put the fix in the arc source, so we don't have to keep patching with each release.

-----

1 point by sjs 6147 days ago | link

This code can be simplified a little bit:

    (let val (tostring (system 
                        (string "date -u "
                               (if  (is (uname) "Linux") "-r @" "-r ")
                               time " \"+%Y-%m-%d\"")))
But it's still fragile and non-portable so go with kens suggestion.

-----