Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit COLUMNS and LINES at host #243

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions toolbox
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,28 @@ create_enter_command()


create_environment_options()
{
(
columns=""
lines=""

if terminal_size=$(stty size 2>&3); then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that just stty(1) isn't enough when toolbox(1) is invoked from inside a container. In that case stty(1) will get run against the inner pseudo-terminal pair created by podman exec --tty which doesn't have the right sizes. I think we should forward the COLUMNS and LINES variables from the outer environment created by toolbox(1).

columns=$(echo "$terminal_size" | cut --delimiter " " --fields 2 2>&3)
if ! is_integer "$columns"; then
echo "$base_toolbox_command: failed to parse the number of columns from the terminal size" >&3
columns=""
fi

lines=$(echo "$terminal_size" | cut --delimiter " " --fields 1 2>&3)
if ! is_integer "$lines"; then
echo "$base_toolbox_command: failed to parse the number of lines from the terminal size" >&3
lines=""
fi

environment_options="$environment_options --env=COLUMNS=$columns --env=LINES=$lines"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eek! This was a copy paste fiasco on my part. Embarassing. :(

else
echo "$base_toolbox_command: failed to read terminal size" >&3
fi

echo "$environment_variables" \
| sed "s/ \+/\n/g" 2>&3 \
| {
Expand All @@ -339,12 +360,20 @@ create_environment_options()
fi
done

if [ "$columns" != "" ] 2>&3; then
environment_options="$environment_options --env=COLUMNS=$columns"
fi

if [ "$lines" != "" ] 2>&3; then
environment_options="$environment_options --env=LINES=$lines"
fi

environment_options=${environment_options#" "}
echo "$base_toolbox_command: created options for environment variables to forward" >&3
echo "$environment_options" >&3
echo "$environment_options"
}
}
)


create_toolbox_container_name()
Expand Down