Bug 228123 - date command gives wrong time when used in tcsh aliases
Summary: date command gives wrong time when used in tcsh aliases
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 11.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2018-05-10 17:24 UTC by Dan MacDonald
Modified: 2021-04-20 12:55 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Dan MacDonald 2018-05-10 17:24:45 UTC
I am running a fully up to date FreeBSD 11.1-RELEASE-p10 / amd64 and I am using tcsh for my shell. I created a couple of aliases to create date and timestamped ZFS snapshots and added them to my ~/.cshrc but the time output by my custom `date` format command is always behind the actual time. If I run my aliases straight after booting, they are only about 1m behind but the longer my machine is turned on, the more the time in the aliases gets out of sync with the actual time.

If I run just `date` or if I run the date command using my formatted output from the command line, I get the correct time. It is only when date is executed via my aliases that the time falls behind.

One of my aliases that exhibits this issue:

alias zsd	 sudo zfs snapshot -r data/media@`date +%d-%m-%Y-%T`
Comment 1 Ceri Davies 2021-04-20 12:55:01 UTC
Can you share the extract of your .cshrc please?
It seems that you may be capturing the time when your shell is first starting in the alias definition.