Skip to contentSkip to conversation

CodingGuidelines: Fix a typo

PATCH In review [email protected] 3 participants 5 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CodingGuidelines: Fix a typo

From: Štěpán Němec <[email protected]>

${parameter/pattern/string}' shell expansion uses glob patterns, so talking about regexp' is confusing.

---
 Documentation/CodingGuidelines |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/CodingGuidelines +1 -1
index 8346c19..df50ccf 100644
@@ -53,7 +53,7 @@ For shell scripts specifically (not exhaustive):
 
  - No strlen ${#parameter}.
 
- - No regexp ${parameter/pattern/string}.
+ - No substitution ${parameter/pattern/string}.
 
  - We do not use Process Substitution <(list) or >(list).
 
Signature · 1 line
1.7.3.rc2.221.gbf93f.dirty
#1 lore raw
Quoted 2 lines · [email protected] wrote:

${parameter/pattern/string}' shell expansion uses glob patterns, so talking about regexp' is confusing.

Okay.

Quoted 2 lines

- - No regexp ${parameter/pattern/string}.
+ - No substitution ${parameter/pattern/string}.

A bit confusing, since ${parameter%word} and $parameter are substitutions, too.

Maybe

- No pattern substitution ${parameter/pattern/string}.

to match the bash manual, would be clearer?

#2 lore raw
Quoted 5 lines · Jonathan Nieder
Quoted 2 lines · [email protected] wrote:

${parameter/pattern/string}' shell expansion uses glob patterns, so talking about regexp' is confusing.

Quoted 7 lines

Okay.

Quoted 2 lines

- - No regexp ${parameter/pattern/string}.
+ - No substitution ${parameter/pattern/string}.

A bit confusing, since ${parameter%word} and $parameter are substitutions, too.

I had the same reaction. Perhaps moving other parameter substitions closer to these two would help?

	Side note: this is totally unrelated, but the below is --patience;
	our output without --patience is almost unreadable in this case.
 Documentation/CodingGuidelines |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)
Documentation/CodingGuidelines +15 -12
index 8346c19..09ffc46 100644
@@ -35,11 +35,22 @@ For shell scripts specifically (not exhaustive):
    properly nests.  It should have been the way Bourne spelled
    it from day one, but unfortunately isn't.
 
- - We use ${parameter-word} and its [-=?+] siblings, and their
-   colon'ed "unset or null" form.
+ - We use POSIX compliant parameter substitutions and avoid bashisms;
+   namely:
 
- - We use ${parameter#word} and its [#%] siblings, and their
-   doubled "longest matching" form.
+   - We use ${parameter-word} and its [-=?+] siblings, and their
+     colon'ed "unset or null" form.
+
+   - We use ${parameter#word} and its [#%] siblings, and their
+     doubled "longest matching" form.
+
+   - No "Substring Expansion" ${parameter:offset:length}.
+
+   - No shell arrays.
+
+   - No strlen ${#parameter}.
+
+   - No pattern replacement ${parameter/pattern/string}.
 
  - We use Arithmetic Expansion $(( ... )).
 
@@ -47,14 +58,6 @@ For shell scripts specifically (not exhaustive):
    of them, as some shells do not grok $((x)) while accepting $(($x))
    just fine (e.g. dash older than 0.5.4).
 
- - No "Substring Expansion" ${parameter:offset:length}.
-
- - No shell arrays.
-
- - No strlen ${#parameter}.
-
- - No regexp ${parameter/pattern/string}.
-
  - We do not use Process Substitution <(list) or >(list).
 
  - We prefer "test" over "[ ... ]".
#4 lore raw
In reply to Jonathan Nieder
Quoted 5 lines · Jonathan Nieder
Quoted 2 lines · [email protected] wrote:

${parameter/pattern/string}' shell expansion uses glob patterns, so talking about regexp' is confusing.

Quoted 7 lines

Okay.

Quoted 2 lines

- - No regexp ${parameter/pattern/string}.
+ - No substitution ${parameter/pattern/string}.

A bit confusing, since ${parameter%word} and $parameter are substitutions, too.

Not really. They are all parameter expansions. The former a "pattern removal", the latter a plain expansion (yeah I know you can _call_ it a substitution anyway, but I assume you were trying to be precise/match the Bash manual wording here).

But I agree "pattern substitution" is even clearer, thanks.

BTW, when we continue on this slightly bike-shedding note, it would make sense to unify the capitalisation of those termini technici in there ("Arithmetic Expansion", "Process Substitution"). Personally I would prefer having them all in lower-case; it feels a bit funny to read "We use Arithmetic Expansion". WDYT?

I hope the whitespace goes through undisturbed this time:

--- 8< ---
Subject: CodingGuidelines: Fix a typo

${parameter/pattern/string}' shell expansion uses glob patterns, so talking about regexp' is confusing.

---
 Documentation/CodingGuidelines |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/CodingGuidelines +1 -1
index 8346c19..e52474b 100644
@@ -53,7 +53,7 @@ For shell scripts specifically (not exhaustive):
 
  - No strlen ${#parameter}.
 
- - No regexp ${parameter/pattern/string}.
+ - No pattern substitution ${parameter/pattern/string}.
 
  - We do not use Process Substitution <(list) or >(list).
 

--

#3 lore raw
In reply to Junio C Hamano
Quoted 2 lines · Junio C Hamano

I had the same reaction. Perhaps moving other parameter substitions closer to these two would help?

Yes, that looks like a definite improvement.