From 3a9a7eff84b2fa505d02e77fa33a0917e3ca77c6 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Tue, 12 May 2020 13:09:25 +0800 Subject: [PATCH] Updated SC2155 (markdown) --- SC2155.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SC2155.md b/SC2155.md index 5a78c0f..537ca05 100644 --- a/SC2155.md +++ b/SC2155.md @@ -71,13 +71,13 @@ readonly foo A serious quoting problem with dash is another reason to declare and assign separately. Dash is the [default, `/bin/sh` shell on Ubuntu](https://wiki.ubuntu.com/DashAsBinSh). More specifically, dash version 0.5.8-2.10 and others cannot run this code: ```sh f(){ local e=$1; } -g(){ local g=$(printf '%s' "foo 2"); } f "1 2" -g +export g=$(printf '%s' "foo 2") ``` While this runs fine in other shells, [dash doesn't treat this as an assignment](http://mywiki.wooledge.org/BashPitfalls#local_var.3D.24.28cmd.29) and fails like this: ``` local: 2: bad variable name +export: 2: bad variable name ``` The direct workaround to this bug is to quote the right-hand-side of the assignment. Separating declaraction and assignment also makes this runs fine in any shell.