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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 124a161b8c1f79c0be6b1e9093929776da276aa2f6877477887153266929a075
4
- data.tar.gz: 832bee8c90c33ba7b4cfbc157b7fbbd4b1727cdac4c6f6e3d2f6a099de9040c1
3
+ metadata.gz: 6d7befa3e0e53ef178d19b02ae51d9f3324ec900eee92722dadc0f6e58285eca
4
+ data.tar.gz: 3d3a29032861702d4a2dddf7eb0239d53d2807897bebff1f78409aa6f501dd7d
5
5
  SHA512:
6
- metadata.gz: 8378f7c810a1570633f2f727b4c425f80410e0283b4cdc8cf15ef3ade5f4fa4d9b39c2dd384f72193c704384a459a435805dedea51648e7422b6200064d34be5
7
- data.tar.gz: 59325860b1d3fc11828def95aa2735a4cff93142ce96da76c67c380828d4ef023f1929fe8ba73f40d1030351e506831be00007a67429c2f438ca92581c871315
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 from WSL/MSYS2/Cygwin,
4
- and sync the shell environments of Bash and the Windows batch files, including
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
- By SourceWinBat, you can execute Windows initialization scripts in Bash as if you use `source`
10
- command for initialization Bash scripts.
11
- SourceWinBat helps you do your daily Windows work in your favorite UNIX-compatible environment.
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
@@ -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 Regexp.new(name_regexp) =~ envvar_name
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 Regexp.new(name_regexp) =~ envvar_name
181
+ return true if reg_exact_match(name_regexp, envvar_name)
176
182
  end
177
183
  false
178
184
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'source_win_bat'
3
- s.version = '0.4.0'
3
+ s.version = '0.4.1'
4
4
  s.date = '2019-02-06'
5
5
  s.summary = "'source' Windows bat files in your UNIX compatible shell in Windows"
6
6
  s.description = <<EOS
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 DiffCase3
22
- export DIFFCASE3=BAZ
23
- [[ $(sw echo %DiffCase3%) =~ BAZ ]]; tap_okif $? "Test a variable of different cases merges 1"
24
- [[ $(echo $DIFFCASE3) =~ BAZ ]]; tap_okif $? "Test a variable of different cases merges 2"
25
- [[ -z "$DiffCase3" ]]; tap_okif $? "Test a variable of different cases merges 3"
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 9
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 $?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: source_win_bat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takaya Saeki