Make a `ln -s` that checks for broken symbolic linksCreate symbolic links with wildcardsSeemingly...
How to pronounce 'c++' in Spanish
What is the philosophical significance of speech acts/implicature?
What term is being referred to with "reflected-sound-of-underground-spirits"?
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
Is there any official lore on the Far Realm?
Mistake in years of experience in resume?
A Note on N!
How to have a sharp product image?
How can I practically buy stocks?
How to not starve gigantic beasts
Relationship between strut and baselineskip
Do I have an "anti-research" personality?
Is it idiomatic to construct against `this`
Get consecutive integer number ranges from list of int
What's the polite way to say "I need to urinate"?
Why did C use the -> operator instead of reusing the . operator?
Can I grease a crank spindle/bracket without disassembling the crank set?
Like totally amazing interchangeable sister outfits II: The Revenge
Apply MapThread to all but one variable
How did Captain America manage to do this?
What does ゆーか mean?
How does Captain America channel this power?
How come there are so many candidates for the 2020 Democratic party presidential nomination?
Elements other than carbon that can form many different compounds by bonding to themselves?
Make a `ln -s` that checks for broken symbolic links
Create symbolic links with wildcardsSeemingly Inconsistent Behavior for “ln” & “ln -s”Too many levels of symbolic linksunderstand the designation of symbolic linksCreating symbolic linksWhy ln -s creates relative broken links?How to change ownership from symbolic links?Does `ln -sf` overwrite existing files which are only symbolic linksInconsistent behaviour creating symbolic links with relative and force flagShell script keeps making broken symbolic links
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am trying to write a function ln() (if it is not a good idea to call it ln, it may just be as well called myln() or whatever, but that is not important) in bash, such that,
- If the short option
-sdoes not exist, it simply performs whatcommand lndoes - If the short option
-sdoes exist, it performs whatcommand lndoes unless the symbolic link(s) to be created contain broken ones. In that case, it prints a warning to stderr and does not create the link (or create it and remove it afterwards immediately)
Since the command ln takes its option in various forms that are extremely versatile, I am not sure how to write such a function to cover all the possibilities. I do know how to write it for simple usage like ln -s [absolute path 1] [absolute path 2].
It is best if the function is able to cover the usages of ln in the newest version of GNU coreutils (at the time the question is asked the newest version is 8.31), but a function that just covers the usage in POSIX is fine too.
Side note: I have written a "failproof" rm as in https://codereview.stackexchange.com/a/215226/155325, I want to do something similar to make a "failproof" ln. I am using it myself and I know the consequences. I am not distributing it to someone not familiar with Linux and say "Hey you should use this rm from now on and you can forget the caveats of rm /*"
bash symlink ln
add a comment |
I am trying to write a function ln() (if it is not a good idea to call it ln, it may just be as well called myln() or whatever, but that is not important) in bash, such that,
- If the short option
-sdoes not exist, it simply performs whatcommand lndoes - If the short option
-sdoes exist, it performs whatcommand lndoes unless the symbolic link(s) to be created contain broken ones. In that case, it prints a warning to stderr and does not create the link (or create it and remove it afterwards immediately)
Since the command ln takes its option in various forms that are extremely versatile, I am not sure how to write such a function to cover all the possibilities. I do know how to write it for simple usage like ln -s [absolute path 1] [absolute path 2].
It is best if the function is able to cover the usages of ln in the newest version of GNU coreutils (at the time the question is asked the newest version is 8.31), but a function that just covers the usage in POSIX is fine too.
Side note: I have written a "failproof" rm as in https://codereview.stackexchange.com/a/215226/155325, I want to do something similar to make a "failproof" ln. I am using it myself and I know the consequences. I am not distributing it to someone not familiar with Linux and say "Hey you should use this rm from now on and you can forget the caveats of rm /*"
bash symlink ln
add a comment |
I am trying to write a function ln() (if it is not a good idea to call it ln, it may just be as well called myln() or whatever, but that is not important) in bash, such that,
- If the short option
-sdoes not exist, it simply performs whatcommand lndoes - If the short option
-sdoes exist, it performs whatcommand lndoes unless the symbolic link(s) to be created contain broken ones. In that case, it prints a warning to stderr and does not create the link (or create it and remove it afterwards immediately)
Since the command ln takes its option in various forms that are extremely versatile, I am not sure how to write such a function to cover all the possibilities. I do know how to write it for simple usage like ln -s [absolute path 1] [absolute path 2].
It is best if the function is able to cover the usages of ln in the newest version of GNU coreutils (at the time the question is asked the newest version is 8.31), but a function that just covers the usage in POSIX is fine too.
Side note: I have written a "failproof" rm as in https://codereview.stackexchange.com/a/215226/155325, I want to do something similar to make a "failproof" ln. I am using it myself and I know the consequences. I am not distributing it to someone not familiar with Linux and say "Hey you should use this rm from now on and you can forget the caveats of rm /*"
bash symlink ln
I am trying to write a function ln() (if it is not a good idea to call it ln, it may just be as well called myln() or whatever, but that is not important) in bash, such that,
- If the short option
-sdoes not exist, it simply performs whatcommand lndoes - If the short option
-sdoes exist, it performs whatcommand lndoes unless the symbolic link(s) to be created contain broken ones. In that case, it prints a warning to stderr and does not create the link (or create it and remove it afterwards immediately)
Since the command ln takes its option in various forms that are extremely versatile, I am not sure how to write such a function to cover all the possibilities. I do know how to write it for simple usage like ln -s [absolute path 1] [absolute path 2].
It is best if the function is able to cover the usages of ln in the newest version of GNU coreutils (at the time the question is asked the newest version is 8.31), but a function that just covers the usage in POSIX is fine too.
Side note: I have written a "failproof" rm as in https://codereview.stackexchange.com/a/215226/155325, I want to do something similar to make a "failproof" ln. I am using it myself and I know the consequences. I am not distributing it to someone not familiar with Linux and say "Hey you should use this rm from now on and you can forget the caveats of rm /*"
bash symlink ln
bash symlink ln
edited 16 mins ago
Weijun Zhou
asked 24 mins ago
Weijun ZhouWeijun Zhou
1,705427
1,705427
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f515810%2fmake-a-ln-s-that-checks-for-broken-symbolic-links%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f515810%2fmake-a-ln-s-that-checks-for-broken-symbolic-links%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown