diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bcf744..2b20659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 4.3.1 + +- Fixed #10 in math namespace. +- Some enhancements in math namespace. + ## 4.3.0 - Process commands `process ...` diff --git a/COMMANDS.md b/COMMANDS.md index 3ba6a2a..4342ae8 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -264,14 +264,24 @@ - [math +](#math-+) +- [math +=](#math-+=) + - [math -](#math--) +- [math -=](#math--=) + - [math *](#math-*) +- [math *=](#math-*=) + - [math /](#math-/) +- [math /=](#math-/=) + - [math %](#math-%) +- [math %=](#math-%=) + - [math ^](#math-^) - [math random](#math-random) @@ -1572,7 +1582,7 @@ expr 2 ${2|+,-,\*,/,%|} 3 increment variable [↑](#Commands) ```bash -$((${1|var++,++var|})) +((${1|var++,++var|})) ``` ## `math --` @@ -1580,47 +1590,87 @@ $((${1|var++,++var|})) decrement variable [↑](#Commands) ```bash -$((${1|var--,--var|})) +((${1|var--,--var|})) ``` ## `math +` -add two variables (+= assign result to var1) [↑](#Commands) +add two variables [↑](#Commands) + +```bash +result=$((var1 + var2)) +``` + +## `math +=` + +add var1 and var2 and assign the result to var1 [↑](#Commands) ```bash -$((var1 ${2|+,+=|} var2)) +((var1 += var2)) ``` ## `math -` -subtract var2 from var1 (-= assign result to var1) [↑](#Commands) +subtract var2 from var1 [↑](#Commands) + +```bash +result=$((var1 - var2)) +``` + +## `math -=` + +subtract var2 from var1 and assign the result to var1 [↑](#Commands) ```bash -$((var1 ${2|-,-=|} var2)) +((var1 -= var2)) ``` ## `math *` -multiply var1 and var2 (*= assign result to var1) [↑](#Commands) +multiply var1 by var2 [↑](#Commands) ```bash -$((var1 ${2|*,*=|} var2)) +result=$((var1 * var2)) +``` + +## `math *=` + +multiply var1 by var2 and assign the result to var1 [↑](#Commands) + +```bash +((var1 *= var2)) ``` ## `math /` -divide var1 by var2 (/= assign result to var1) [↑](#Commands) +divide var1 by var2 [↑](#Commands) ```bash -$((var1 ${2|/,/=|} var2)) +result=$((var1 / var2)) +``` + +## `math /=` + +divide var1 by var2 and assign the result to var1 [↑](#Commands) + +```bash +((var1 /= var2)) ``` ## `math %` -reminder of dividing var1 by var2 (%= assign result to var1) [↑](#Commands) +reminder of dividing var1 by var2 (modulus) [↑](#Commands) ```bash -$((var1 ${2|%,%=|} var2)) +result=$((var1 % var2)) +``` + +## `math %=` + +divide var1 by var2 and assign the reminder to var1 [↑](#Commands) + +```bash +((var1 %= var2)) ``` ## `math ^` @@ -1628,15 +1678,15 @@ $((var1 ${2|%,%=|} var2)) exponentiate base to power [↑](#Commands) ```bash -$((base ** power)) +result=$((base ** power)) ``` ## `math random` -generate random integer x such as min < x < max [↑](#Commands) +generate random integer x such as min <= x <= max [↑](#Commands) ```bash -echo $((min + RANDOM % $((max-min)))) +result=$((min + RANDOM % $((max-min)))) ``` ## `math √` @@ -2307,4 +2357,3 @@ call scan function to scan a host over a port range [↑](#Commands) ```bash scan ${1|tcp,udp|} host fromPort toPort ``` - diff --git a/README.md b/README.md index 23ba9a6..2e2c4f5 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,11 @@ Call function which is declared by `fn...` ## Release Notes +### 4.3.1 + +- Fixed #10 in math namespace. +- Some enhancements in math namespace. + ### 4.3.0 - Process commands `process ...` diff --git a/package-lock.json b/package-lock.json index 6117241..b8b6446 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "shellman", - "version": "4.3.0", + "version": "4.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/runtime-corejs2": { - "version": "7.3.1", - "resolved": "http://localhost:8081/repository/npm-registry/@babel/runtime-corejs2/-/runtime-corejs2-7.3.1.tgz", - "integrity": "sha512-YpO13776h3e6Wy8dl2J8T9Qwlvopr+b4trCEhHE+yek6yIqV8sx6g3KozdHMbXeBpjosbPi+Ii5Z7X9oXFHUKA==", + "version": "7.4.3", + "resolved": "http://localhost:8081/repository/npm-registry/@babel/runtime-corejs2/-/runtime-corejs2-7.4.3.tgz", + "integrity": "sha512-anTLTF7IK8Hd5f73zpPzt875I27UaaTWARJlfMGgnmQhvEe1uNHQRKBUbXL0Gc0VEYiVzsHsTPso5XdK8NGvFg==", "dev": true, "requires": { - "core-js": "^2.5.7", - "regenerator-runtime": "^0.12.0" + "core-js": "^2.6.5", + "regenerator-runtime": "^0.13.2" } }, "ansi-styles": { @@ -101,9 +101,9 @@ } }, "core-js": { - "version": "2.6.4", - "resolved": "http://localhost:8081/repository/npm-registry/core-js/-/core-js-2.6.4.tgz", - "integrity": "sha512-05qQ5hXShcqGkPZpXEFLIpxayZscVD2kuMBZewxiIPPEagukO4mqgPA9CWhUvFBJfy3ODdK2p9xyHh7FTU9/7A==", + "version": "2.6.5", + "resolved": "http://localhost:8081/repository/npm-registry/core-js/-/core-js-2.6.5.tgz", + "integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==", "dev": true }, "crypto-random-string": { @@ -113,16 +113,16 @@ "dev": true }, "cspell": { - "version": "3.2.1", - "resolved": "http://localhost:8081/repository/npm-registry/cspell/-/cspell-3.2.1.tgz", - "integrity": "sha512-VjEcxU+WUfJn1/ShgYVsH4fdT8MaOBmLATKZ2DpsY+zdh5i07NmC8fVlsF56F4rE5Ybz2e9KHMi+HcNN08ruEg==", + "version": "3.2.2", + "resolved": "http://localhost:8081/repository/npm-registry/cspell/-/cspell-3.2.2.tgz", + "integrity": "sha512-IRylgPXAipr4HLKOTYcr2EGC5DM33DdtmTxqdJU2VxZcuuI4pT8jcinfvYq38t076e0hZ34UiiMCQ19TPu9tSA==", "dev": true, "requires": { "chalk": "^2.4.2", "commander": "^2.19.0", "comment-json": "^1.1.3", "configstore": "^4.0.0", - "cspell-dict-companies": "^1.0.3", + "cspell-dict-companies": "^1.0.4", "cspell-dict-cpp": "^1.1.11", "cspell-dict-django": "^1.0.7", "cspell-dict-elixir": "^1.0.4", @@ -131,7 +131,7 @@ "cspell-dict-fullstack": "^1.0.6", "cspell-dict-golang": "^1.1.8", "cspell-dict-java": "^1.0.5", - "cspell-dict-latex": "^1.0.6", + "cspell-dict-latex": "^1.0.7", "cspell-dict-lorem-ipsum": "^1.0.4", "cspell-dict-php": "^1.0.7", "cspell-dict-python": "^1.0.8", @@ -149,18 +149,18 @@ } }, "cspell-dict-companies": { - "version": "1.0.4", - "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-companies/-/cspell-dict-companies-1.0.4.tgz", - "integrity": "sha512-Rvt1QorVrTaCMqqZwUzr8PgguQ1MvqwJJXH7z3xm4+omnZNvjBkku3xnGUS11zDO6/FtLRVe/Qm4HuOvfYuOFA==", + "version": "1.0.5", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-companies/-/cspell-dict-companies-1.0.5.tgz", + "integrity": "sha512-GcHLevnkE89Gy/4DqMafiqWFOKAejysV4WXwLRj5jXje7WidT4KFvOy0CEkGcLSGoTMORuwqyQXCPTsbaHGyyw==", "dev": true, "requires": { "configstore": "^4.0.0" } }, "cspell-dict-cpp": { - "version": "1.1.11", - "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-cpp/-/cspell-dict-cpp-1.1.11.tgz", - "integrity": "sha512-FWiOe6nntT1k4r/CkSo8qG6Ib4phu3WXGPqg6txOw+e9wlojzXN7rND2Z8AHt4TUA36h3lHpk/y7gTBgJgR+lw==", + "version": "1.1.12", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-cpp/-/cspell-dict-cpp-1.1.12.tgz", + "integrity": "sha512-f3ADByqOWiDezYKMousqmLrnop6NjcM3t5kuTVmDvvKMbRCkCH6Ez445kPnR5vdBx/CYkl6HLXZyqvVasQNHvw==", "dev": true, "requires": { "configstore": "^4.0.0" @@ -203,9 +203,9 @@ } }, "cspell-dict-fullstack": { - "version": "1.0.6", - "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-fullstack/-/cspell-dict-fullstack-1.0.6.tgz", - "integrity": "sha512-40rQ/6E5erZC4ZS7uQ8Q93M0VrFuqFhcGCup/ZrO2lRHsRPj5+iVeX80VY1jl/gPmG2H/pnJ5+oC5CJkgEBGVw==", + "version": "1.0.7", + "resolved": "http://localhost:8081/repository/npm-registry/cspell-dict-fullstack/-/cspell-dict-fullstack-1.0.7.tgz", + "integrity": "sha512-X3DxBm+KBAp9xLdD4tkLeFMrIRzSbXOn5mdur7vcuiimIsu1m8EBvBwYgHOfcMsaWVjPrg9eX2sVuveo/UwqeA==", "dev": true, "requires": { "configstore": "^4.0.0" @@ -509,9 +509,9 @@ "dev": true }, "regenerator-runtime": { - "version": "0.12.1", - "resolved": "http://localhost:8081/repository/npm-registry/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", - "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==", + "version": "0.13.2", + "resolved": "http://localhost:8081/repository/npm-registry/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz", + "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==", "dev": true }, "rxjs": { diff --git a/package.json b/package.json index 2733f35..2a702b5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "shellman", "displayName": "shellman", "description": "Bash script snippet", - "version": "4.3.0", + "version": "4.3.1", "publisher": "Remisa", "icon": "images/icon.png", "license": "SEE LICENSE IN LICENSE.md", @@ -29,7 +29,7 @@ ] }, "devDependencies": { - "cspell": "^3.2.1", + "cspell": "^3.2.2", "fs": "0.0.1-security", "path": "^0.12.7" }, diff --git a/snippets/snippets.json b/snippets/snippets.json index afba366..77886bb 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -860,62 +860,87 @@ "prefix": "expr", "body": "expr ${1:2} ${2|+,-,\\*,/,%|} ${3:3}\n", "description": "arithmetic operations" - }, - "math_inc": { - "prefix": "math ++", - "body": "\\$((${1|var++,++var|}))\n", - "description": "increment variable" + }, + "math_inc": { + "prefix": "math ++", + "body": "((${1|var++,++var|}))\n", + "description": "increment variable" }, "math_dec": { "prefix": "math --", - "body": "\\$((${1|var--,--var|}))\n", + "body": "((${1|var--,--var|}))\n", "description": "decrement variable" - }, + }, "math_add": { "prefix": "math +", - "body": "\\$((${1:var1} ${2|+,+=|} ${3:var2}))\n", - "description": "add two variables (+= assign result to var1)" - }, + "body": "${1:result}=\\$((${2:var1} + ${3:var2}))\n", + "description": "add two variables" + }, + "math_plus_equal": { + "prefix": "math +=", + "body": "((${1:var1} += ${2:var2}))\n", + "description": "add var1 and var2 and assign the result to var1" + }, "math_subtract": { "prefix": "math -", - "body": "\\$((${1:var1} ${2|-,-=|} ${3:var2}))\n", - "description": "subtract var2 from var1 (-= assign result to var1)" - }, + "body": "${1:result}=\\$((${2:var1} - ${3:var2}))\n", + "description": "subtract var2 from var1" + }, + "math_minus_equal": { + "prefix": "math -=", + "body": "((${1:var1} -= ${2:var2}))\n", + "description": "subtract var2 from var1 and assign the result to var1" + }, "math_multiply": { "prefix": "math *", - "body": "\\$((${1:var1} ${2|*,*=|} ${3:var2}))\n", - "description": "multiply var1 and var2 (*= assign result to var1)" - }, + "body": "${1:result}=\\$((${2:var1} * ${3:var2}))\n", + "description": "multiply var1 by var2" + }, + "math_multiply_equal": { + "prefix": "math *=", + "body": "((${1:var1} *= ${2:var2}))\n", + "description": "multiply var1 by var2 and assign the result to var1" + }, "math_divide": { "prefix": "math /", - "body": "\\$((${1:var1} ${2|/,/=|} ${3:var2}))\n", - "description": "divide var1 by var2 (/= assign result to var1)" - }, + "body": "${1:result}=\\$((${2:var1} / ${3:var2}))\n", + "description": "divide var1 by var2" + }, + "math_divide_equal": { + "prefix": "math /=", + "body": "((${1:var1} /= ${2:var2}))\n", + "description": "divide var1 by var2 and assign the result to var1" + }, "math_modulus": { "prefix": "math %", - "body": "\\$((${1:var1} ${2|%,%=|} ${3:var2}))\n", - "description": "reminder of dividing var1 by var2 (%= assign result to var1)" - }, + "body": "${1:result}=\\$((${2:var1} % ${3:var2}))\n", + "description": "reminder of dividing var1 by var2 (modulus)" + }, + "math_modulus_equal": { + "prefix": "math %=", + "body": "((${1:var1} %= ${2:var2}))\n", + "description": "divide var1 by var2 and assign the reminder to var1" + }, "math_power": { "prefix": "math ^", - "body": "\\$((${1:base} ** ${2:power}))\n", + "body": "${1:result}=\\$((${2:base} ** ${3:power}))\n", "description": "exponentiate base to power" - }, - "random_number": { - "prefix": "math random", - "body": "echo \\$((${1:min} + RANDOM % \\$((${2:max}-${1:min}))))\n", - "description": "generate random integer x such as min < x < max" - }, + }, + "random_number": { + "prefix": "math random", + "body": "${1:result}=\\$((${2:min} + RANDOM % \\$((${3:max}-${2:min}))))\n", + "description": "generate random integer x such as min <= x <= max" + }, "math_sqrt": { "prefix": "math √", "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};sqrt(${3:\\$var})\" | bc`\n", "description": "square root of var up to scale decimal places" - }, + }, "math_float": { "prefix": "math 0.00", "body": "${1:result}=`echo \"scale=${2|0,1,2,3,4,5,6,7,8,9|};(${3:\\$var1} ${4|+,-,*,/,^|} ${5:\\$var2})\" | bc`\n", "description": "math operations with up to scale decimal places precision" - }, + }, "math_const_pi": { "prefix": "math const π", "body": "MATH_PI='3.14159265358979323846264338327950288'\n",