mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 01:45:50 +08:00 
			
		
		
		
	[Fix] nvm_supports_source_options: work around a bug in bash 3.2
				
					
				
			See https://github.com/creationix/nvm/issues/1978#issuecomment-453480231 Fixes #1978.
This commit is contained in:
		
							
								
								
									
										27
									
								
								test/fast/Unit tests/nvm_supports_source_options
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										27
									
								
								test/fast/Unit tests/nvm_supports_source_options
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| die () { echo "$@" ; exit 1; } | ||||
|  | ||||
| \. ../../../nvm.sh | ||||
|  | ||||
| x=0 | ||||
| i=0 | ||||
| runs=5 | ||||
| calls=500 | ||||
| first_result=false | ||||
| if (nvm_supports_source_options && printf .); then | ||||
|   first_result=true | ||||
| fi | ||||
| while [ $x -le $runs ]; do | ||||
|   y=$x | ||||
|   x=$(( x + 1 )) | ||||
|   while [ $i -le $calls ]; do | ||||
|     this_result=false | ||||
|     if (nvm_supports_source_options && printf .); then | ||||
|       this_result=true | ||||
|     fi | ||||
|     [ $this_result = $first_result ] || die "call ${i}, run ${y} got ${this_result}; expected ${first_result}" | ||||
|     i=$(( i + 1 )) | ||||
|   done | ||||
| done | ||||
| echo "${runs} runs of ${calls} calls succeeded" | ||||
		Reference in New Issue
	
	Block a user