mirror of
				https://github.com/ohmyzsh/ohmyzsh.git
				synced 2024-05-11 05:55:17 +00:00 
			
		
		
		
	fix(cli): change unrecognized \s in BSD awk (#11146)
				
					
				
			In BSD awk, \s is not a valid sequence interchangeable with "space or tab characters" as it is in GNU awk. This fix uses [ \t] instead, which is all the possibilities that we need to contemplate when reading the .zshrc file. Fixes #11146
This commit is contained in:
		
							
								
								
									
										16
									
								
								lib/cli.zsh
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								lib/cli.zsh
									
									
									
									
									
								
							@@ -241,21 +241,21 @@ function _omz::plugin::disable {
 | 
			
		||||
 | 
			
		||||
  # Remove plugins substitution awk script
 | 
			
		||||
  local awk_subst_plugins="\
 | 
			
		||||
  gsub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before
 | 
			
		||||
  gsub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after
 | 
			
		||||
  gsub(/[ \t]+(${(j:|:)dis_plugins})/, \"\") # with spaces before
 | 
			
		||||
  gsub(/(${(j:|:)dis_plugins})[ \t]+/, \"\") # with spaces after
 | 
			
		||||
  gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
 | 
			
		||||
"
 | 
			
		||||
  # Disable plugins awk script
 | 
			
		||||
  local awk_script="
 | 
			
		||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
 | 
			
		||||
/^\s*plugins=\([^#]+\).*\$/ {
 | 
			
		||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
 | 
			
		||||
  $awk_subst_plugins
 | 
			
		||||
  print \$0
 | 
			
		||||
  next
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
 | 
			
		||||
/^\s*plugins=\(/ {
 | 
			
		||||
/^[ \t]*plugins=\(/ {
 | 
			
		||||
  multi=1
 | 
			
		||||
  $awk_subst_plugins
 | 
			
		||||
  print \$0
 | 
			
		||||
@@ -330,14 +330,14 @@ function _omz::plugin::enable {
 | 
			
		||||
  # Enable plugins awk script
 | 
			
		||||
  local awk_script="
 | 
			
		||||
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line
 | 
			
		||||
/^\s*plugins=\([^#]+\).*\$/ {
 | 
			
		||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
 | 
			
		||||
  sub(/\)/, \" $add_plugins&\")
 | 
			
		||||
  print \$0
 | 
			
		||||
  next
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# if plugins=() is in multiline form, enable multi flag
 | 
			
		||||
/^\s*plugins=\(/ {
 | 
			
		||||
/^[ \t]*plugins=\(/ {
 | 
			
		||||
  multi=1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -699,9 +699,9 @@ function _omz::theme::set {
 | 
			
		||||
 | 
			
		||||
  # Enable theme in .zshrc
 | 
			
		||||
  local awk_script='
 | 
			
		||||
!set && /^\s*ZSH_THEME=[^#]+.*$/ {
 | 
			
		||||
!set && /^[ \t]*ZSH_THEME=[^#]+.*$/ {
 | 
			
		||||
  set=1
 | 
			
		||||
  sub(/^\s*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`")
 | 
			
		||||
  sub(/^[ \t]*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`")
 | 
			
		||||
  print $0
 | 
			
		||||
  next
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user