When coding for Unix/Linux is it convention to use a trailing slash on path names, or to omit it?Avoid a...
How to deal with a colleague who is being aggressive?
How to patch glass cuts in a bicycle tire?
How did NASA Langley end up with the first 737?
Why would Ryanair allow me to book this journey through a third party, but not through their own website?
What does ${!#} mean in Shell scripting?
Count rotary dial pulses in a phone number (including letters)
Can a British citizen living in France vote in both France and Britain in the European Elections?
Where have Brexit voters gone?
How to respond to upset student?
Can I summon an otherworldly creature with the Gate spell without knowing its true name?
In general, would I need to season a meat when making a sauce?
In the 3D Zeldas, is it faster to roll or to simply walk?
Is there an online tool which supports shared writing?
Who decides how to classify a novel?
Best material to absorb as much light as possible
How to politely tell someone they did not hit "reply to all" in an email?
Why are GND pads often only connected by four traces?
Can I connect my older mathematica front-end to the free wolfram engine?
Compaq Portable vs IBM 5155 Portable PC
Why did Jon Snow do this immoral act if he is so honorable?
Specifying background color seen through semi-transparent surface
Website returning plaintext password
Popcorn is the only acceptable snack to consume while watching a movie
Question in discrete mathematics about group permutations
When coding for Unix/Linux is it convention to use a trailing slash on path names, or to omit it?
Avoid a trailing slash in bash when completing a directory name (like zsh)How to fix Linux filename tab autocomplete that is appending a space instead of trailing slash on directories?Use the terminal's autocomplete path feature for input to a shell scriptUse of find in unix on strange file/directory namesHow to handle spaces in path names when variable contains multiple pathsShould I use a slash at the end of path variables in shell script or not?Bash converting path names for sed so they escapepractice linux for practical useHow to omit the character $ when entering a path stored in a variable?How to use array values as substitutes for names of other arrays
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
When programming for Unix/Linux, is it best practice to use a trailing slash, or to omit it?
For example:
Trailing slash
baseDir="/path/to/dir/"
#code#
outPath=${baseDir}addition/to/path/
No Trailing Slash
baseDir="/path/to/dir"
#code#
outPath=${baseDir}/addition/to/path
#or:
outPath=$baseDir/additon/to/path
I know that technically using the trailing slash explicitly indicates the path refers to a directory, but I also know that in practice it rarely matters (and is often omitted when working at the command line). I also like that omitting the trailing slash makes it more explicit when I am appending to the path in a script.
Despite all this, I want to know if there is an explicit convention most people would expect my code to follow, or if this is a matter of personal taste.
bash shell-script standard
New contributor
add a comment |
When programming for Unix/Linux, is it best practice to use a trailing slash, or to omit it?
For example:
Trailing slash
baseDir="/path/to/dir/"
#code#
outPath=${baseDir}addition/to/path/
No Trailing Slash
baseDir="/path/to/dir"
#code#
outPath=${baseDir}/addition/to/path
#or:
outPath=$baseDir/additon/to/path
I know that technically using the trailing slash explicitly indicates the path refers to a directory, but I also know that in practice it rarely matters (and is often omitted when working at the command line). I also like that omitting the trailing slash makes it more explicit when I am appending to the path in a script.
Despite all this, I want to know if there is an explicit convention most people would expect my code to follow, or if this is a matter of personal taste.
bash shell-script standard
New contributor
add a comment |
When programming for Unix/Linux, is it best practice to use a trailing slash, or to omit it?
For example:
Trailing slash
baseDir="/path/to/dir/"
#code#
outPath=${baseDir}addition/to/path/
No Trailing Slash
baseDir="/path/to/dir"
#code#
outPath=${baseDir}/addition/to/path
#or:
outPath=$baseDir/additon/to/path
I know that technically using the trailing slash explicitly indicates the path refers to a directory, but I also know that in practice it rarely matters (and is often omitted when working at the command line). I also like that omitting the trailing slash makes it more explicit when I am appending to the path in a script.
Despite all this, I want to know if there is an explicit convention most people would expect my code to follow, or if this is a matter of personal taste.
bash shell-script standard
New contributor
When programming for Unix/Linux, is it best practice to use a trailing slash, or to omit it?
For example:
Trailing slash
baseDir="/path/to/dir/"
#code#
outPath=${baseDir}addition/to/path/
No Trailing Slash
baseDir="/path/to/dir"
#code#
outPath=${baseDir}/addition/to/path
#or:
outPath=$baseDir/additon/to/path
I know that technically using the trailing slash explicitly indicates the path refers to a directory, but I also know that in practice it rarely matters (and is often omitted when working at the command line). I also like that omitting the trailing slash makes it more explicit when I am appending to the path in a script.
Despite all this, I want to know if there is an explicit convention most people would expect my code to follow, or if this is a matter of personal taste.
bash shell-script standard
bash shell-script standard
New contributor
New contributor
New contributor
asked 39 mins ago
ColeCole
1
1
New contributor
New contributor
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
});
}
});
Cole is a new contributor. Be nice, and check out our Code of Conduct.
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%2f520770%2fwhen-coding-for-unix-linux-is-it-convention-to-use-a-trailing-slash-on-path-name%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
Cole is a new contributor. Be nice, and check out our Code of Conduct.
Cole is a new contributor. Be nice, and check out our Code of Conduct.
Cole is a new contributor. Be nice, and check out our Code of Conduct.
Cole is a new contributor. Be nice, and check out our Code of Conduct.
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%2f520770%2fwhen-coding-for-unix-linux-is-it-convention-to-use-a-trailing-slash-on-path-name%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