git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] shell portability: Use sed instead of non-portable variable expansion

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Sep 5, 2011, 07:54 UTC
Message-ID
<4E648031.6050607@viscovery.net>
In-Reply-To
<7vbouzxy7g.fsf@alter.siamese.dyndns.org>
Am 9/5/2011 9:09, schrieb Junio C Hamano:
> By the way, t9010 uses ${#parameter} (strlen) which is bashism we forbid,
> and it needs to be rewritten (David CC'ed).
Actually, no. It is perfectly valid POSIX. So we would need this patch.
--- 8< ---
From: Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH] CodingGuidelines: ${#parameter} is POSIX and should be allowed
See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 Documentation/CodingGuidelines |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index fe1c1e5..df0b620 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -52,8 +52,6 @@ For shell scripts specifically (not exhaustive):
 
    - No shell arrays.
 
-   - No strlen ${#parameter}.
-
    - No pattern replacement ${parameter/pattern/string}.
 
  - We use Arithmetic Expansion $(( ... )).
-- 
1.7.7.rc0.211.g5ac7e
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 19 in “shell portability: Use sed instead of non-portable variable expansion”
  1. shell portability: Use sed instead of non-portable variable expansionNaohiro Aota, Sep 5, 2011
  2. Johannes SixtSep 5, 2011
  3. Junio C HamanoSep 5, 2011
  4. Johannes SixtSep 5, 2011
  5. Junio C HamanoSep 5, 2011
  6. Johannes SixtSep 5, 2011
  7. Johannes SixtSep 5, 2011
  8. Naohiro AotaSep 5, 2011
  9. Junio C HamanoSep 5, 2011
  10. Johannes SixtSep 5, 2011
  11. Junio C HamanoSep 5, 2011
  12. Junio C HamanoSep 5, 2011
  13. Makefile: abort on shells that do not support ${parameter%word} expansionBrandon Casey, Sep 6, 2011
  14. Brandon CaseySep 6, 2011
  15. Brandon CaseySep 6, 2011
  16. Junio C HamanoSep 6, 2011
  17. Brandon CaseySep 6, 2011
  18. Junio C HamanoSep 6, 2011
  19. Brandon CaseySep 6, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.