From abe8f7845b046aca197092b28ad0639fe312fbcd Mon Sep 17 00:00:00 2001 From: Matthias Morin <14804833+TangoMan75@users.noreply.github.com> Date: Sat, 13 Feb 2021 22:18:28 +0100 Subject: [PATCH] revert change, sorry --- SC2001.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SC2001.md b/SC2001.md index 0fb2229..8942b07 100644 --- a/SC2001.md +++ b/SC2001.md @@ -3,13 +3,13 @@ ### Problematic code: ```sh -string="string" ; echo "$string" | sed -e "s/ir/ri/" +string="stirng" ; echo "$string" | sed -e "s/ir/ri/" ``` ### Correct code: ```sh -string="string" ; echo "${string//ir/ri}" +string="stirng" ; echo "${string//ir/ri}" ``` ### Rationale: @@ -21,7 +21,7 @@ Let's assume somewhere earlier in your code you have put data into a variable (E Occasionally a more complex sed substitution is required. For example, getting the last character of a string. ```sh -string="string" ; echo "$string" | sed -e "s/^.*\(.\)$/\1/" +string="stirng" ; echo "$string" | sed -e "s/^.*\(.\)$/\1/" ``` This is a bit simple for the example and there are alternative ways of doing this in the shell, but this SC2001 flags on several of my crazy complex sed commands which are beyond the scope of this example. Utilizing some of the more complex capabilities of sed is required occasionally and it is safe to ignore SC2001.