Class: Ukiryu::Shell::Zsh
- Defined in:
- lib/ukiryu/shell/zsh.rb
Overview
Zsh shell implementation
Zsh uses the same quoting and escaping rules as Bash.
Constant Summary collapse
- SHELL_NAME =
:zsh- EXECUTABLE =
'zsh'
Constants inherited from UnixBase
Constants inherited from Base
Base::PLATFORM, Base::SPECIAL_CHARS_PATTERN, Base::WHITESPACE_PATTERN
Class Method Summary collapse
-
.detect_alias(command_name) ⇒ Hash?
Detect if a command is a Zsh alias.
Instance Method Summary collapse
-
#env_var(name) ⇒ String
Format an environment variable reference.
-
#escape(string) ⇒ Object
Zsh uses the same escaping as Bash.
-
#join(executable, *args) ⇒ String
Join executable and arguments into a command line.
- #name ⇒ Object
-
#quote(string) ⇒ Object
Zsh uses the same quoting as Bash.
-
#shell_command ⇒ String
Get the zsh command name to search for.
Methods inherited from UnixBase
#execute_command, #execute_command_with_stdin, #shell_executable
Methods inherited from Base
#capabilities, #encoding, #environment_to_h, #execute_command, #execute_command_with_stdin, #format_environment, #format_path, #headless_environment, #needs_quoting?, #supports?
Class Method Details
.detect_alias(command_name) ⇒ Hash?
Detect if a command is a Zsh alias
Zsh uses the same ‘type’ builtin as Bash.
18 19 20 21 |
# File 'lib/ukiryu/shell/zsh.rb', line 18 def self.detect_alias(command_name) # Zsh uses the same 'type' builtin as Bash Bash.detect_alias(command_name) end |
Instance Method Details
#env_var(name) ⇒ String
Format an environment variable reference
48 49 50 |
# File 'lib/ukiryu/shell/zsh.rb', line 48 def env_var(name) "$#{name}" end |
#escape(string) ⇒ Object
Zsh uses the same escaping as Bash
35 36 37 |
# File 'lib/ukiryu/shell/zsh.rb', line 35 def escape(string) string.to_s.gsub("'") { "'\\''" } end |
#join(executable, *args) ⇒ String
Join executable and arguments into a command line
57 58 59 |
# File 'lib/ukiryu/shell/zsh.rb', line 57 def join(executable, *args) [quote(executable), *args.map { |a| quote(a) }].join(' ') end |
#name ⇒ Object
23 24 25 |
# File 'lib/ukiryu/shell/zsh.rb', line 23 def name :zsh end |
#quote(string) ⇒ Object
Zsh uses the same quoting as Bash
40 41 42 |
# File 'lib/ukiryu/shell/zsh.rb', line 40 def quote(string) "'#{escape(string)}'" end |
#shell_command ⇒ String
Get the zsh command name to search for
30 31 32 |
# File 'lib/ukiryu/shell/zsh.rb', line 30 def shell_command 'zsh' end |