From b1c5c32c538e3a56d9ae24c55b83bde7e224edbc Mon Sep 17 00:00:00 2001 From: Uggla Date: Tue, 19 Jan 2016 20:08:49 +0100 Subject: [PATCH 1/4] Add instructions to manage filenames with whitespaces --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c62dd30..d0eda11 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,9 @@ Notes: cat hosts | xargs -I{} ssh root@{} hostname ``` +- Use null character delimiter to manage filenames with whitespaces, example `locate -0 patern | xargs -0 ls -al` or `find / -print0 -type d | xargs -0 ls -al`. + To iterate on filenames containing whitespaces in a for loop, set your IFS to only '\n' using `IFS=$'\n'`. + - `pstree -p` is a helpful display of the process tree. - Use `pgrep` and `pkill` to find or signal processes by name (`-f` is helpful). From c73ddc08e64ab60c87580d6cb6077c585493f2cc Mon Sep 17 00:00:00 2001 From: Joshua Levy Date: Thu, 21 Jan 2016 09:20:42 -0800 Subject: [PATCH 2/4] Clarify language tags. Re #349 --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11d003d..fe1772a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ Translations to new languages are always welcome, especially if you can maintain - Check existing issues to see if a translation is in progress or stalled. If so, offer to help. - If it is not in progress, file an issue for your language so people know you are working on it and we can arrange. Confirm you are native level in the language and are willing to maintain the translation, so it's not orphaned. -- To get it started, fork the repo, then submit a PR with the single file README-xx.md added, where xx is the lowercase language code. (Use standard two-letter ISO language codes, i.e. the same as is used by Wikipedia, not the code for a single country.) +- To get it started, fork the repo, then submit a PR with the single file README-xx.md added, where xx is the language code. Use standard [IETF language tags](https://www.w3.org/International/articles/language-tags/), i.e. the same as is used by Wikipedia, *not* the code for a single country. These are usually just the two-letter lowercase code, for example, `fr` for French and `uk` for Ukrainian (not `ua`, which is for the country). For langauges that have variations, use the shortest tag, such as `zh-Hant`. - Invite friends to review if possible. If desired, feel free to invite friends to help your original translation by letting them fork your repo, then merging their PRs. - Add links to your translation at the top of every README*.md file. (For consistency, the link should be added in alphabetical order by ISO code, and the anchor text should be in the native language.) - When done, indicate on the PR that it's ready to be merged into the main repo. From 80d1bc91c6dd85b768a060995d3e0b0c64d5c111 Mon Sep 17 00:00:00 2001 From: Uggla Date: Fri, 22 Jan 2016 14:45:13 +0100 Subject: [PATCH 3/4] Update according to @jlevy suggestion into #350 --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index d0eda11..81e2443 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,7 @@ Notes: cat hosts | xargs -I{} ssh root@{} hostname ``` -- Use null character delimiter to manage filenames with whitespaces, example `locate -0 patern | xargs -0 ls -al` or `find / -print0 -type d | xargs -0 ls -al`. - To iterate on filenames containing whitespaces in a for loop, set your IFS to only '\n' using `IFS=$'\n'`. +- Prefer the `-0` or `-print0` options to enable null characters to delimit filenames. This better supports filenames with whitespace.Example : `locate -0 pattern | xargs -0 ls -al` or `find / -print0 -type d | xargs -0 ls -al`. To iterate on filenames containing whitespace in a for loop, set your IFS to only '\n' using `IFS=$'\n'`. Always surround your bash variables with `"`. - `pstree -p` is a helpful display of the process tree. From d91728e4a0307c28093cd8eb528d720a94bb638c Mon Sep 17 00:00:00 2001 From: Joshua Levy Date: Fri, 22 Jan 2016 13:25:15 -0800 Subject: [PATCH 4/4] Follow up on #350. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe04c78..c50a61e 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,6 @@ Notes: cat hosts | xargs -I{} ssh root@{} hostname ``` -- Prefer the `-0` or `-print0` options to enable null characters to delimit filenames. This better supports filenames with whitespace.Example : `locate -0 pattern | xargs -0 ls -al` or `find / -print0 -type d | xargs -0 ls -al`. To iterate on filenames containing whitespace in a for loop, set your IFS to only '\n' using `IFS=$'\n'`. Always surround your bash variables with `"`. - `pstree -p` is a helpful display of the process tree. @@ -111,6 +110,8 @@ Notes: - Use `alias` to create shortcuts for commonly used commands. For example, `alias ll='ls -latr'` creates a new alias `ll`. +- Understand that care is needed when variables and filenames include whitespace. Surround your Bash variables with quotes, e.g. `"$FOO"`. Prefer the `-0` or `-print0` options to enable null characters to delimit filenames, e.g. `locate -0 pattern | xargs -0 ls -al` or `find / -print0 -type d | xargs -0 ls -al`. To iterate on filenames containing whitespace in a for loop, set your IFS to to be a newline only using `IFS=$'\n'`. + - In Bash scripts, use `set -x` (or the variant `set -v`, which logs raw input, including unexpanded variables and comments) for debugging output. Use strict modes unless you have a good reason not to: Use `set -e` to abort on errors (nonzero exit code). Use `set -u` to detect unset variable usages. Consider `set -o pipefail` too, to on errors within pipes, too (though read up on it more if you do, as this topic is a bit subtle). For more involved scripts, also use `trap` on EXIT or ERR. A useful habit is to start a script like this, which will make it detect and abort on common errors and print a message: ```bash set -euo pipefail