Skip to content

Commit

Permalink
Expert console: fixed "shell" command
Browse files Browse the repository at this point in the history
- Run X terminal in GUI instead of "dash" (related to the previous
  fix for job control error messages bsc#1183648)
- Override TERM to "vt100" when running in fbiterm,
  a workaround for frozen vim (bsc#1183652)
- 4.3.36
  • Loading branch information
lslezak committed Mar 29, 2021
1 parent fdbead8 commit f31fec9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
10 changes: 10 additions & 0 deletions package/yast2-installation.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
-------------------------------------------------------------------
Mon Mar 29 16:25:00 UTC 2021 - Ladislav Slezák <lslezak@suse.cz>

- Expert console: fixed "shell" command
- Run X terminal in GUI instead of "dash" (related to the previous
fix for job control error messages bsc#1183648)
- Override TERM to "vt100" when running in fbiterm,
a workaround for frozen vim (bsc#1183652)
- 4.3.36

-------------------------------------------------------------------
Wed Mar 17 16:53:42 UTC 2021 - Ladislav Slezák <lslezak@suse.cz>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-installation
Version: 4.3.35
Version: 4.3.36
Release: 0
Group: System/YaST
License: GPL-2.0-only
Expand Down
2 changes: 1 addition & 1 deletion src/lib/installation/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Console
class << self
# open a console and run an interactive IRB session in it
# testing in installed system:
# ruby -I src/lib -r installation/console.rb -e ::Installation::Console.run
# Y2DIR=./src ruby -I src/lib -r installation/console.rb -e ::Installation::Console.run
def run
console = Yast::UI.TextMode ? Console::Tui.new : Console::Gui.new
console.run do
Expand Down
45 changes: 34 additions & 11 deletions src/lib/installation/console/plugins/shell_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,47 @@ module Console
# define the "shell" command in the expert console
class Commands
def shell
# dash is a simple shell and needs less memory, also it does not complain
# about missing job control terminal
if File.exist?("/bin/dash")
system("/bin/dash")
# use full featured bash
elsif File.exist?("/bin/bash")
system("/bin/bash")
# fallback
if Yast::UI.TextMode
tui_shell
else
system("/bin/sh")
gui_shell
end
end

private

def tui_shell
puts quit_hint

# some interactive tools like "vim" get stuck when running in "fbiterm",
# the workaround is to override TERM to "vt100"
term = ENV["TERM"] == "iterm" ? "TERM=vt100" : ""

system("#{term} /bin/bash")
end

def gui_shell
terms = ["/usr/bin/xterm", "/usr/bin/konsole", "/usr/bin/gnome-terminal"]
cmd = terms.find { |s| File.exist?(s) }

if cmd
puts "Starting a terminal application (#{cmd})..."
puts quit_hint
puts
# hide possible errors, xterm complains about some missing fonts
# in the inst-sys
system("#{cmd} 2> /dev/null")
else
puts "ERROR: Cannot find any X terminal application"
end
end

def quit_hint
"Use the \"exit\" command or press Ctrl+D to return back to the YaST console."
end

def shell_description
"Starts a shell session, use the \"exit\" command\n" \
"or press Ctrl+D to return back to the YaST console"
"Starts a shell session.\n#{quit_hint}"
end
end
end
Expand Down

0 comments on commit f31fec9

Please sign in to comment.