tarjoilija / zgen

A lightweight and simple plugin manager for ZSH
BSD 2-Clause "Simplified" License
1.5k stars 99 forks source link

Use file creation and changedate to detect change #51

Closed m42e closed 8 years ago

m42e commented 8 years ago

shasum is to slow, and creation and changedate seems to be exactly enough. See #46

tarjoilija commented 8 years ago

stat -f "%m %c" produces strange output for me. GNU stat differs from the mac version of stat and I think we can't use it to produce timestamp. However the REALFILE thing seems quite handy and it could be used to figure out ZGEN_SOURCE.

pearofducks commented 8 years ago

Fixing the "strange output" is trivial, just detect if it's GNU's stat? (not 100% tested, but should be right):

`stat --version` && stat_cmd="stat -c '%Y %W'" || stat_cmd="stat -f '%m %B'"
CHANGESHA=`$stat_cmd ${REALFILE}`
echo "if [[ \"\`$stat_cmd ${REALFILE}\`\" != \"$CHANGESHA\" ]]; then" >> "${ZGEN_INIT}"
m42e commented 8 years ago

Fixed it as @pearofducks suggested.

tarjoilija commented 8 years ago

We got a (somewhat) working implementation merged on #60