Skip to content

Commit

Permalink
Merge pull request #936 from yast/console_fixes
Browse files Browse the repository at this point in the history
Expert console: fixed "shell" command
  • Loading branch information
lslezak committed Mar 30, 2021
2 parents fdbead8 + a66eb60 commit 6a65846
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
10 changes: 10 additions & 0 deletions package/yast2-installation.changes
@@ -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
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
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
46 changes: 35 additions & 11 deletions src/lib/installation/console/plugins/shell_command.rb
Expand Up @@ -16,24 +16,48 @@ 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"
# "fbiterm" sets TERM to "iterm", the workaround is to override it
# to "vt100" (bsc#1183652)
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 6a65846

Please sign in to comment.