source_win_bat 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/Rakefile +0 -0
- data/lib/source_win_bat.rb +8 -2
- data/source_win_bat.gemspec +1 -1
- data/test/setenv.cmd +0 -0
- data/test/test_diffrent_case_envvar_bug.bash +6 -6
- data/test/test_whiteblacklist.bash +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d7befa3e0e53ef178d19b02ae51d9f3324ec900eee92722dadc0f6e58285eca
|
4
|
+
data.tar.gz: 3d3a29032861702d4a2dddf7eb0239d53d2807897bebff1f78409aa6f501dd7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7f0806dc5d4534b4e7a35384b141b804b13179b62d2a1d633a3e57504d2a95f4dd39c5f8fff0b81afae319963c67e667fc9d8a3866433b4072b56732c73c94
|
7
|
+
data.tar.gz: 4971afcd9597fb9036063d10482c46c826af4a7e2c02b89f2b7e17dd38ba51e90fa0a7d545a3dc5795b2f0fc1a8f36c3eb2e827a202ca706273f5adb86522b32
|
data/README.md
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
# SourceWinBat - Source a Windows Batch in Bash!
|
2
2
|
|
3
|
-
`sw`, or SourceWinBat is a CLI utility to run Windows batch files
|
4
|
-
and sync the shell environments of Bash and the Windows
|
3
|
+
`sw`, or SourceWinBat is a CLI utility to run Windows batch files in WSL/MSYS2/Cygwin,
|
4
|
+
and sync the shell environments of Bash and the Windows command line, including
|
5
5
|
* Environment variables
|
6
6
|
* Doskeys
|
7
7
|
* Working directories
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
## Why? What is that useful for?
|
10
|
+
|
11
|
+
By environment syncing of SourceWinBat, you can run your Windows batch scripts in
|
12
|
+
WSL, MSYS2, and Cygwin!
|
13
|
+
That helps you do your daily job's Windows work in your favorite UNIX-compatible environment,
|
14
|
+
avoiding the complexity of Windows command line.
|
15
|
+
SourceWinBat lets you run Windows initialization scripts in Bash, as if you run `source`
|
16
|
+
command for Bash scripts.
|
12
17
|
|
13
18
|
|
14
19
|
## Usage
|
data/Rakefile
CHANGED
File without changes
|
data/lib/source_win_bat.rb
CHANGED
@@ -161,10 +161,16 @@ class SourceWindowsBatch
|
|
161
161
|
wslenvs
|
162
162
|
end
|
163
163
|
|
164
|
+
def reg_exact_match(reg, str)
|
165
|
+
m = Regexp.new(reg).match(str)
|
166
|
+
return false if m.nil?
|
167
|
+
m[0] == str
|
168
|
+
end
|
169
|
+
|
164
170
|
def whitelist_block?(envvar_name)
|
165
171
|
return false if !ENV["SWB_WHITELIST"]
|
166
172
|
ENV["SWB_WHITELIST"].split(":").each do |name_regexp|
|
167
|
-
return false if
|
173
|
+
return false if reg_exact_match(name_regexp, envvar_name)
|
168
174
|
end
|
169
175
|
true
|
170
176
|
end
|
@@ -172,7 +178,7 @@ class SourceWindowsBatch
|
|
172
178
|
def blacklist_block?(envvar_name)
|
173
179
|
return false if !ENV["SWB_BLACKLIST"]
|
174
180
|
ENV["SWB_BLACKLIST"].split(":").each do |name_regexp|
|
175
|
-
return true if
|
181
|
+
return true if reg_exact_match(name_regexp, envvar_name)
|
176
182
|
end
|
177
183
|
false
|
178
184
|
end
|
data/source_win_bat.gemspec
CHANGED
data/test/setenv.cmd
CHANGED
File without changes
|
@@ -18,9 +18,9 @@ sw set_diff_case_env.cmd
|
|
18
18
|
[[ "$DiffCase3" =~ BAR ]]; tap_okif $? "Test a variable of different cases is modified in Windows 3"
|
19
19
|
[[ -z "$DIFFCASE3" ]]; tap_okif $? "Test a variable is undefined 3"
|
20
20
|
|
21
|
-
unset
|
22
|
-
|
23
|
-
|
24
|
-
[[ $(echo
|
25
|
-
[[
|
26
|
-
|
21
|
+
unset TMP # "TMP" is defined in Windows as cmd.exe's prompt string
|
22
|
+
unset WSLENV # Reset WSLENV to reset sync of TMP
|
23
|
+
export tmp="test"
|
24
|
+
[[ "$(sw echo %TMP%)" =~ "test" ]]; tap_okif $? "Test a variable of different cases merges 1"
|
25
|
+
[[ $(echo "$tmp") =~ "test" ]]; tap_okif $? "Test a variable of different cases merges 2"
|
26
|
+
[[ -z "$TMP" ]]; tap_okif $? "Test a variable of different cases merges 3"
|
@@ -1,13 +1,14 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
3
|
source ./setup_test.bash
|
4
|
-
tap_tests
|
4
|
+
tap_tests 11
|
5
5
|
|
6
6
|
export SWB_BLACKLIST="SWB_FOO:SWB_BLACK_.*:SWB_BAR"
|
7
7
|
[[ -z "$(sw set SWB_FOO=FOO; echo $SWB_FOO)" ]]; tap_okif $?
|
8
8
|
[[ -z "$(sw set SWB_BLACK_FOO=FOO; echo $SWB_BLACK_FOO)" ]]; tap_okif $?
|
9
9
|
[[ -z "$(sw set SWB_BAR=BAR; echo $SWB_BAR)" ]]; tap_okif $?
|
10
10
|
[[ $(sw set SWB_BAZ=BAZ; echo $SWB_BAZ) = BAZ ]]; tap_okif $?
|
11
|
+
[[ $(sw set SWB_FOO_BAR=BAZ; echo $SWB_FOO_BAR) = BAZ ]]; tap_okif $? "Test regexp match is exact matching"
|
11
12
|
|
12
13
|
|
13
14
|
export SWB_WHITELIST="SWB_W1:SWB_WHITE_.*:SWB_W2"
|
@@ -20,5 +21,7 @@ export SWB_W2="bar"
|
|
20
21
|
[[ -z "$(sw set SWB_W3=baz; echo $SWB_W3)" ]]; tap_okif $?
|
21
22
|
|
22
23
|
export SWB_W1=
|
24
|
+
export SWB_FOO=FOO
|
23
25
|
export SWB_BLACKLIST="${SWB_BLACLIST}:SWB_W1"
|
24
26
|
[[ -z "$(sw set SWB_W1=W1; echo $SWB_W1)" ]]; tap_okif $?
|
27
|
+
[[ "$(sw echo %SWB_FOO%)" =~ "ECHO" ]]; tap_okif $?
|