SHTK_FS_NORMALIZE_PATH(3)
πΈ NAME πΈ
Hiiii bestie π this is SHTK_FS_NORMALIZE_PATH(3), a page straight out of the Library Functions Manual, and it's here to explain shtk_fs_normalize_path β the function that Returns a normalized form of a path. Slay. β¨
π LIBRARY π
You import it with:
shtk_import fs
β SYNOPSIS β
shtk_fs_normalize_path path
π¦ DESCRIPTION π¦
Okay so shtk_fs_normalize_path takes the given path and prints its normalized form to stdout. That's the whole vibe. π
This process involves the following:
- Collapsing multiple consecutive forward slashes into one.
- Adding a
.component at the beginning of the path if it is relative. - Removing any
.components, except for the first one. - Removing any trailing slashes.
No cap, important caveat: the normalization happens without performing any file system operations. Therefore, it is perfectly possible for two normalized paths that look different to point to the same file system entry. In particular, this is because normalization does not take into account links nor .. components. π
π RETURN VALUES π
shtk_fs_normalize_path returns 0. Periodt. π«Ά
π₯ EXAMPLES π₯
These little glow-ups are everything:
shtk_fs_normalize_path /foo/bar # Prints /foo/bar
shtk_fs_normalize_path foo/bar # Prints ./foo/bar
shtk_fs_normalize_path foo///bar/./baz// # Prints ./foo/bar/baz
π SEE ALSO π
shtk(3), shtk_fs(3) β go read those too, bestie π
π HISTORY π
shtk_fs_normalize_path first appeared in shtk 1.7. Iconic behavior since day one π
Source/version + date sign-off: this page is from Debian, dated September 18, 2016 β mwah, kisses ππ
π¦ where this page comes from
- nixos 26.05: shtk 1.7
- nixpkgs unstable: shtk 1.7
- Copyright 2016 Google Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms