« Using OpenAI's ChatGPT API, iTerm2 can now write commands for you, interpret the output of commands, and guide you towards a goal. See the AI section below for details. » iTerm…

how much you wanna bet ChatGPT is trained on GNU utilities and the things it suggest do something entirely different on BSD‐based platforms like macOS

“chatgpt how to get the last modified time of a file using only posix commandline utilities”

Follow

if you were wondering, apparently the answer is

if test ! -f build/.mtime; then printf '%b' '\n' > build/.mtime; fi; touch -r "$FILE" build/.mtime; TZ=UTC0 diff -u build/.mtime /dev/null | sed '1!d;s/.*\t\([^ ]\) \([^ ]\).*/\1T\2Z/'

(replacing \t with a tab character)

BUT this requires version 7 of POSIX

BUT it should still work in e·g Macintosh even tho they’re not strictly conformant

apparently the answer if you want to limit yourself to v6 in theory is to do the same thing but tarball the temporary file with pax and then read out the modified time in list mode with -o 'listopt=%(mtime=%Y-%m-%dT%H:%M:%SZ)T'

if you want to limit yourself to v6 in practice (nobody actually implements listopt), same thing but manually parse the tarball

anyway an L·L·M would never give you this code and if it did you wouldn’t trust it

(funnily, Macintosh is conformant in legacy mode)

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.