Initial commit.
This commit is contained in:
commit
2dda2e227d
52 changed files with 2704 additions and 0 deletions
34
bits/quotes-sed.sh
Normal file
34
bits/quotes-sed.sh
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{ echo "keyname1 = line without quotes"
|
||||
echo "keyname2 = line with 1 \" double quote"
|
||||
echo "keyname3 = line with \" 2 double \" quotes"
|
||||
echo "keyname4 = line \\"
|
||||
echo "with continuation \\"
|
||||
echo "at end"
|
||||
echo "keyname5 = \"double quoted text, single line\""
|
||||
echo "keyname6 = 'single quoted text, single line'"
|
||||
echo "keyname7 = \"double quoted text"
|
||||
echo "over 1"
|
||||
echo "2"
|
||||
echo "3"
|
||||
echo "4 \""; } |
|
||||
sed -re "{
|
||||
# Insert [ at beginning of key
|
||||
s/^[[:blank:]]*/['/
|
||||
# Insert ] at end of key
|
||||
s/[[:blank:]]*=/']=/
|
||||
# Branch if there's a =<quote> ...
|
||||
/^.*[^\\]=[[:blank:]]*['\"]/ {
|
||||
p
|
||||
:x
|
||||
# Branch if there is no <quote> at end of line ...
|
||||
/.*['\"][[:blank:]]*\$/ ! {
|
||||
# Read new line
|
||||
N
|
||||
# Insert a \n
|
||||
s/\\\n//
|
||||
# Continue loop if s/ above was successful
|
||||
tx
|
||||
}
|
||||
}
|
||||
s/(^|$)/#/g
|
||||
}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue