git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] cogito: try harder to find gnu date

From
Bryan Larsen <bryanlarsen@yahoo.com>
Date
Jul 18, 2005, 02:51 UTC
Message-ID
<20050718025107.11198.93279.sendpatchset@bryan-larsens-ibook-g4.local>
In-Reply-To
<20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>
Look harder for gnu date, use if available.
Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
 cg-Xlib |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -70,7 +70,7 @@ showdate () {
 	secs=$(($secs + $tzhours * 3600 + $tzmins * 60))
 	[ "$format" ] || format="+%a, %d %b %Y %H:%M:%S $2"
 	if [ "$has_gnudate" ]; then
-		LANG=C date -ud "1970-01-01 UTC + $secs sec" "$format"
+		LANG=C ${has_gnudate} -ud "1970-01-01 UTC + $secs sec" "$format"
 	else
 		LANG=C date -u -r $secs "$format"
 	fi
@@ -241,4 +241,12 @@ for stat in "$(which gnustat)" "$(which 
     fi
 done
 
-has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)
+has_gnudate=
+for date in "$(which gnudate)" "$(which gdate)" "$(which date)" ; do
+    if ( [ $date ] && $date -Rud  "1970-01-01 UTC" 2> /dev/null >&2 ) ; then
+	has_gnudate=$date
+	break
+    fi
+done
+
+
Previous: Bryan LarsenNext: Bryan Larsen
Message 5 of 8 in “cogito: compatibility with OS X”
  1. 0/6 cogito: compatibility with OS XBryan Larsen, Jul 18, 2005
  2. 1/6 cogito: remove use of xargs -r, a non-portable GNU extensionBryan Larsen, Jul 18, 2005
  3. 2/6 cogito: remove use of cp -a, a non-portable GNU extensionBryan Larsen, Jul 18, 2005
  4. 3/6 cogito: try harder to find gnu statBryan Larsen, Jul 18, 2005
  5. 4/6 cogito: try harder to find gnu dateBryan Larsen, Jul 18, 2005
  6. 5/6 cogito: remove findutils dependency from PortfileBryan Larsen, Jul 18, 2005
  7. 6/6 cogito: update documentationBryan Larsen, Jul 18, 2005
  8. Petr BaudisJul 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.