Skip to content

Instantly share code, notes, and snippets.

@dongcarl
Created June 10, 2019 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongcarl/c1032fd0236efd62ebc369931c339577 to your computer and use it in GitHub Desktop.
Save dongcarl/c1032fd0236efd62ebc369931c339577 to your computer and use it in GitHub Desktop.
escaping should be added to list of hardest things in computer science
[dongcarl@dai tar-testing]$ REFERENCE_DATE=2019-01-01
[dongcarl@dai tar-testing]$ REFERENCE_TIME=00:00:00
[dongcarl@dai tar-testing]$ export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME""
[dongcarl@dai tar-testing]$ echo $TAR_OPTIONS
--mtime=2019-01-01\ 00:00:00
[dongcarl@dai tar-testing]$ tar -cf in.tar in/
[dongcarl@dai tar-testing]$ tar tvf in.tar
drwxr-xr-x dongcarl/dongcarl 0 2019-01-01 00:00 in/
-rw-r--r-- dongcarl/dongcarl 0 2019-01-01 00:00 in/hello
[dongcarl@dai tar-testing]$ unset TAR_OPTIONS
[dongcarl@dai tar-testing]$ rm in.tar
[dongcarl@dai tar-testing]$ tar --mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME" -cf in.tar in/
tar: Substituting -9223372036854775807 for unknown date format ‘2019-01-01\\\\ 00:00:00’
[dongcarl@dai tar-testing]$ echo "$REFERENCE_DATE\\\ $REFERENCE_TIME"
2019-01-01\\ 00:00:00
[dongcarl@dai tar-testing]$ tar tvf in.tar
drwxr-xr-x dongcarl/dongcarl 0 -9223372036854775808 in/
-rw-r--r-- dongcarl/dongcarl 0 -9223372036854775808 in/hello
[dongcarl@dai tar-testing]$ exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment