You are not logged in.

#1 2020-08-07 06:28:57

zhurik
Member
Registered: 2020-08-07
Posts: 10

[SOLVED] Invalid bash behavior

Hello, everybody! First time arch user here. I'm currently using bash 5.0.17. Whenever I cd into some directory it prints my PS1 like this:

[zhurik@godzilla ~]$ cd Projects/
[zhurik@godzilla ~]$ [zhurik@godzilla Projects]$

However I expect it to print something like this:

[zhurik@godzilla ~]$ cd Projects/
[zhurik@godzilla Projects]$

Or whenever I run some program I expect it to print it output and then print prompt.
How it is now:

[zhurik@godzilla test-1]$ python main.py
[zhurik@godzilla test-1]$ {"ts":123456,"updates":[]}

Finish
[zhurik@godzilla test-1]$

It's super inconvenient, because it prints prompt right away, like program has finished.
How it should be:

[zhurik@godzilla test-1]$ python main.py
{"ts":123456,"updates":[]}

Finish
[zhurik@godzilla test-1]$

And prompt should appear only after program has finished.
I don't think that it's the problem of my terminal (konsole), because in other tty's it's the same.
Sorry if duplicate, but I can't find it for the life of me.

Last edited by zhurik (2020-08-07 08:30:23)

Offline

#2 2020-08-07 06:59:07

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Invalid bash behavior

Paste your .bashrc...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2020-08-07 06:59:13

sincomil
Member
Registered: 2018-02-13
Posts: 118

Re: [SOLVED] Invalid bash behavior

Just copy /etc/bash.bashrc to ~/.bashrc:

cp /etc/bash.bashrc ~/.bashrc 

and source it:

source  ~/.bashrc

this should fix some mess around the PS1 variable.

Offline

#4 2020-08-07 07:40:24

zhurik
Member
Registered: 2020-08-07
Posts: 10

Re: [SOLVED] Invalid bash behavior

jasonwryan wrote:

Paste your .bashrc...

My .bashrc:

# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
fi

Last edited by zhurik (2020-08-07 07:55:05)

Offline

#5 2020-08-07 07:54:14

zhurik
Member
Registered: 2020-08-07
Posts: 10

Re: [SOLVED] Invalid bash behavior

sincomil wrote:

Just copy /etc/bash.bashrc to ~/.bashrc:

cp /etc/bash.bashrc ~/.bashrc 

and source it:

source  ~/.bashrc

this should fix some mess around the PS1 variable.

It didn't help

Offline

#6 2020-08-07 07:59:53

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Invalid bash behavior

pacman -Qkk bash

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2020-08-07 08:04:42

zhurik
Member
Registered: 2020-08-07
Posts: 10

Re: [SOLVED] Invalid bash behavior

jasonwryan wrote:
pacman -Qkk bash

[zhurik@godzilla ~]$ [zhurik@godzilla ~]$ pacman -Qkk bash
[zhurik@godzilla ~]$ bash: 241 total files, 0 altered files

Offline

#8 2020-08-07 08:20:46

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,702
Website

Re: [SOLVED] Invalid bash behavior

Post your ~/.bash_aliases, /etc/bash.bashrc and the output of

$ shopt checkwinsize

Last edited by schard (2020-08-07 08:24:34)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#9 2020-08-07 08:27:42

zhurik
Member
Registered: 2020-08-07
Posts: 10

Re: [SOLVED] Invalid bash behavior

schard wrote:

Post your ~/.bash_aliases, /etc/bash.bashrc and the output of

$ shopt checkwinsize

My .bash_aliases:

# Включаем цвета у разных команд
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# Разные варианты ls
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ld='ls -d */ 2> /dev/null'

# Чистим экран как в винде
alias cls='clear'

# Nuff said
alias starwars='telnet towel.blinkenlights.nl'

# Был какой-то, оставлю что ли
PS0='[\u@\h \W]\$ '

I commented last line (actually, I will delete it) and everything works as I want. Thanks!
P.S. Can somebody explaint what PS0 variable is?

Offline

#10 2020-08-07 08:32:37

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,702
Website

Re: [SOLVED] Invalid bash behavior

And there we have your $PS0 as the culprit.

https://www.gnu.org/software/bash/manual/html_node/Interactive-Shell-Behavior.html wrote:

Bash expands and displays PS0 after it reads a command but before executing it. See Controlling the Prompt, for a complete list of prompt string escape sequences.

Last edited by schard (2020-08-07 08:33:55)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#11 2020-08-07 13:38:52

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] Invalid bash behavior

Seems like you misspelled PS1 there. wink

(Although it is the default anyway.)

Your .bash_aliases file really should restrict itself to declaring aliases, not variables. Otherwise the code organization split is nonsensical.

sincomil wrote:

Just copy /etc/bash.bashrc to ~/.bashrc:

cp /etc/bash.bashrc ~/.bashrc 

and source it:

source  ~/.bashrc

this should fix some mess around the PS1 variable.

This makes absolutely zero sense, /etc/bash.bashrc is loaded already -- before ~/.bashrc is. If the error comes from elsewhere this won't help, and if it does come from there, deleting the file accomplishes the same goal.

The default ~/.bashrc for new profiles is copied from /etc/skel/.bashrc

Last edited by eschwartz (2020-08-07 13:39:48)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB