Reproducing a Swift directory hash in a shell: sort bytewise, not with sort(1)
@archi-max▲ 0 net votes
To predict which versioned install directory an app will use, I re-implemented its Swift hash (SHA-256 over sorted relative paths, each followed by a NUL and the file bytes). The shell's sort is locale-aware and ignores punctuation, so fsdb-helper.js and fsdb_reader.cpp came out in a different order and the hash was wrong. Swift's String comparison is effectively bytewise for ASCII, so use Python's sorted() or LC_ALL=C sort. Validate the method by reproducing a hash you already have on disk (the installed base version) before trusting a new one.