Crates.io | unfold-symlinks |
lib.rs | unfold-symlinks |
version | |
source | src |
created_at | 2025-02-24 00:46:59.947327+00 |
updated_at | 2025-02-26 03:38:02.564446+00 |
description | unfold is a small command line utility that replaces symbolic links with their targets. |
homepage | |
repository | https://github.com/sqrtrae/unfold |
max_upload_size | |
id | 1566778 |
Cargo.toml error: | TOML parse error at line 20, column 1 | 20 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
unfold
is a command line utility for replacing symbolic links with their targets.
unfold
is available via cargo:
cargo install unfold-symlinks
For reference, below is the output of unfold -h
. For a more detailed output, run unfold --help
.
Unfold symbolic links to their targets.
Usage: unfold [OPTIONS] <SYMLINK>...
Arguments:
<SYMLINK>... Symbolic links to unfold
Options:
-f, --follow-to-source Follow symbolic links to their source
-n, --num-layers <NUM> Follow up to NUM symbolic links
-v, --verbose Set for verbose output
-h, --help Print help (see more with '--help')
-V, --version Print version
unfold
to replace a symbolic link to a file with a copy of said file:# setup
echo "Hello World!" > greeting.txt
ln -s greeting.txt second_greeting.txt
# unfold second_greeting.txt to replace w/ copy of greeting.txt
unfold second_greeting.txt
# change contents of the original file
echo "Hello There!" > greeting.txt
# verify second_greeting.txt hasn't changed
cat second_greeting.txt # output: 'Hello World!'
unfold
also works on symbolic links to directories. The contents of the new directory will be symbolic links to the contents of the target directory:# setup
mkdir secret_stuff
echo "Krabby Patty Formula" > secret_stuff/secret_recipe.txt
ln -s secret_stuff important_stuff
# unfold the important stuff
unfold important_stuff
# after unfolding, important_stuff will be a directory,
# containing symbolic links to the contents of the secret_stuff directory.
readlink important_stuff/secret_recipe.txt # output: 'documents/secret_recipe.txt'
unfold
will replace it
with a copy of that symbolic link (i.e. a new symbolic link with identical target to that symbolic link):# setup
echo "Trans rights are human rights!" > facts.txt
ln -s facts.txt laws_of_physics.txt
ln -s laws_of_physics.txt bridget_says.txt
# unfold
unfold bridget_says.txt
# verify symlink has changed to now target facts.txt
readlink bridget_says.txt # output: 'facts.txt'
unfold
multiple symbolic links in the same command:# setup
touch water earth fire air
ln -s water korra
ln -s earth kyoshi
ln -s fire roku
ln -s air aang
# unfold multiple symbolic links
unfold korra kyoshi roku aang
-f
option to unfold a symbolic link to the source file/directory (following all intermediate symbolic links).# setup
echo "Source of wisdom" > grandparent
ln -s grandparent parent
ln -s parent you
ln -s you child
ln -s child grandchild
# unfold, following symbolic links to their source.
unfold -f grandchild
# change contents of grandchild and verify the other files haven't changed.
echo "Source of hope" > grandchild
cat child # output: 'Source of wisdom'
cat grandparent # output: 'Source of wisdom'
-n <NUM>
option to unfold up to <NUM>
symbolic links in a chain of symbolic links (if chain length is less than <NUM>
, then this behaves identically to the option -f
):# setup
touch kanto
ln -s kanto johto
ln -s johto hoenn
ln -s hoenn sinnoh
ln -s sinnoh unova
# unfold up to 3 symbolic links in the chain
unfold -n 3 unova
readlink unova # output: 'kanto'
Please see CHANGELOG.md.