mirror of https://github.com/docker/docs.git
				
				
				
			Detect fish shell
Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
		
							parent
							
								
									32795c9d1f
								
							
						
					
					
						commit
						c07067c7e4
					
				|  | @ -261,5 +261,9 @@ func detectShell() (string, error) { | |||
| 		return "", ErrUnknownShell | ||||
| 	} | ||||
| 
 | ||||
| 	if os.Getenv("__fish_bin_dir") != "" { | ||||
| 		return "fish", nil | ||||
| 	} | ||||
| 
 | ||||
| 	return shell, nil | ||||
| } | ||||
|  |  | |||
|  | @ -547,3 +547,22 @@ func TestShellCfgUnset(t *testing.T) { | |||
| 		os.Setenv(test.noProxyVar, "") | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestDetectBash(t *testing.T) { | ||||
| 	original_shell := os.Getenv("SHELL") | ||||
| 	os.Setenv("SHELL", "/bin/bash") | ||||
| 	defer os.Setenv("SHELL", original_shell) | ||||
| 	shell, _ := detectShell() | ||||
| 	assert.Equal(t, "bash", shell) | ||||
| } | ||||
| 
 | ||||
| func TestDetectFish(t *testing.T) { | ||||
| 	original_shell := os.Getenv("SHELL") | ||||
| 	os.Setenv("SHELL", "/bin/bash") | ||||
| 	defer os.Setenv("SHELL", original_shell) | ||||
| 	original_fishdir := os.Getenv("__fish_bin_dir") | ||||
| 	os.Setenv("__fish_bin_dir", "/usr/local/Cellar/fish/2.2.0/bin") | ||||
| 	defer os.Setenv("__fish_bin_dir", original_fishdir) | ||||
| 	shell, _ := detectShell() | ||||
| 	assert.Equal(t, "fish", shell) | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue