andresgongora / synth-shell

Boost your terminal, script by script
GNU General Public License v3.0
937 stars 237 forks source link

Syntax error when loading bash console #232

Open Nachiten opened 1 year ago

Nachiten commented 1 year ago

Describe the bug I get a strange error when loading my bash.

The error is:

(standard_in) 1: syntax error
(standard_in) 1: syntax error

My system specs are:

OS              Linux Mint 20.3
Kernel          5.15.0-46-generic
CPU             AMD Ryzen 5 3600 6-Core Processor
GPU             NVIDIA Device 2487 

To Reproduce Steps to reproduce the behavior: I just open my terminal and this error appears

Expected behavior This error not happening

Screenshots image

Additional context Here is my .bashrc complete file:

#!/bin/bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy 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

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

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

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

##-----------------------------------------------------
## synth-shell-greeter.sh
if [ -f /home/nachiten/.config/synth-shell/synth-shell-greeter.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /home/nachiten/.config/synth-shell/synth-shell-greeter.sh
fi

##-----------------------------------------------------
## synth-shell-prompt.sh
if [ -f /home/nachiten/.config/synth-shell/synth-shell-prompt.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /home/nachiten/.config/synth-shell/synth-shell-prompt.sh
fi

##-----------------------------------------------------
## better-ls
if [ -f /home/nachiten/.config/synth-shell/better-ls.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /home/nachiten/.config/synth-shell/better-ls.sh
fi

##-----------------------------------------------------
## alias
if [ -f /home/nachiten/.config/synth-shell/alias.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /home/nachiten/.config/synth-shell/alias.sh
fi

##-----------------------------------------------------
## better-history
if [ -f /home/nachiten/.config/synth-shell/better-history.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /home/nachiten/.config/synth-shell/better-history.sh
fi

Here is my /etc/bash.barshrc complete file:

# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
# but only if not SUDOing and have SUDO_PS1 set; then assume smart user.
if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then
  PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne ""'
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
#if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
#fi

# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
    case " $(groups) " in *\ admin\ *|*\ sudo\ *)
    if [ -x /usr/bin/sudo ]; then
    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.

    EOF
    fi
    esac
fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
    function command_not_found_handle {
            # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
           /usr/lib/command-not-found -- "$1"
                   return $?
                elif [ -x /usr/share/command-not-found/command-not-found ]; then
           /usr/share/command-not-found/command-not-found -- "$1"
                   return $?
        else
           printf "%s: command not found
" "$1" >&2
           return 127
        fi
    }
fi

##-----------------------------------------------------
## better-ls
if [ -f /usr/local/bin/better-ls.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /usr/local/bin/better-ls.sh
fi

##-----------------------------------------------------
## alias
if [ -f /usr/local/bin/alias.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /usr/local/bin/alias.sh
fi

##-----------------------------------------------------
## better-history
if [ -f /usr/local/bin/better-history.sh ] && [ -n "$( echo $- | grep i )" ]; then
    source /usr/local/bin/better-history.sh
fi
andresgongora commented 1 year ago

I do get those errors myself sometimes. I guess I have to make the script a bit more resilient to accommodate different environments. The culprit is usually one of the monitors in the greeter; which in your case seems to be the temperature monitor since it is not displayed. Try disabling it in the configuration. If the error then disappears (we confirm its the temperature monitor) you might be able to fix it installing lm-sensors, which includes the sensors command (I'm writing from memory). Let me know if you make any progress ;)

On Wed, Aug 31, 2022 at 5:52 PM Ignacio Baptista @.***> wrote:

Describe the bug I get a strange error when loading my bash.

The error is:

(standard_in) 1: syntax error (standard_in) 1: syntax error

My system specs are:

OS Linux Mint 20.3 Kernel 5.15.0-46-generic CPU AMD Ryzen 5 3600 6-Core Processor GPU NVIDIA Device 2487

To Reproduce Steps to reproduce the behavior: I just open my terminal and this error appears

Expected behavior This error not happening

Screenshots [image: image] https://user-images.githubusercontent.com/39410888/187721870-88684bf3-4642-4713-bafe-07b5c8a2297d.png

Additional context Here is my .bashrc complete file:

!/bin/bash# ~/.bashrc: executed by bash(1) for non-login shells.# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)# for examples

If not running interactively, don't do anythingcase $- in

*i*) ;;
  *) return;;esac

don't put duplicate lines or lines starting with space in the history.# See bash(1) for more options

HISTCONTROL=ignoreboth

append to the history file, don't overwrite itshopt -s histappend

for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

HISTSIZE=1000 HISTFILESIZE=2000

check the window size after each command and, if necessary,# update the values of LINES and COLUMNS.shopt -s checkwinsize

If set, the pattern "**" used in a pathname expansion context will# match all files and zero or more directories and subdirectories.#shopt -s globstar

make less more friendly for non-text input files, see lesspipe(1)

[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

set variable identifying the chroot you work in (used in the prompt below)if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then

debian_chroot=$(cat /etc/debian_chroot)fi

set a fancy prompt (non-color, unless we know we "want" color)case "$TERM" in

xterm-color|*-256color) color_prompt=yes;;esac

uncomment for a colored prompt, if the terminal has the capability; turned# off by default to not distract the user: the focus in a terminal window# should be on the output of commands, not on the prompt#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then

We have color support; assume it's compliant with Ecma-48

# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fifi

if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]\$ 'else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ 'fiunset color_prompt force_color_prompt

If this is an xterm set the title to @.***:dircase "$TERM" in

xterm|rxvt) PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1" ;;*) ;;esac

enable color support of ls and also add handy aliasesif [ -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

colored GCC warnings and errors#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

some more ls aliasesalias ll='ls -alF'alias la='ls -A'alias l='ls -CF'

Add an "alert" alias for long running commands. Use like so:# sleep 10; alertalias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s[0-9]+\s//;s/[;&|]\s*alert$//'\'')"'

Alias definitions.# You may want to put all your additions into a separate file like# ~/.bash_aliases, instead of adding them here directly.# See /usr/share/doc/bash-doc/examples in the bash-doc package.

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

enable programmable completion features (you don't need to enable# this, if it's already enabled in /etc/bash.bashrc and /etc/profile# sources /etc/bash.bashrc).if ! shopt -oq posix; then

if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fifi export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion

-----------------------------------------------------## synth-shell-greeter.shif [ -f /home/nachiten/.config/synth-shell/synth-shell-greeter.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /home/nachiten/.config/synth-shell/synth-shell-greeter.shfi

-----------------------------------------------------## synth-shell-prompt.shif [ -f /home/nachiten/.config/synth-shell/synth-shell-prompt.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /home/nachiten/.config/synth-shell/synth-shell-prompt.shfi

-----------------------------------------------------## better-lsif [ -f /home/nachiten/.config/synth-shell/better-ls.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /home/nachiten/.config/synth-shell/better-ls.shfi

-----------------------------------------------------## aliasif [ -f /home/nachiten/.config/synth-shell/alias.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /home/nachiten/.config/synth-shell/alias.shfi

-----------------------------------------------------## better-historyif [ -f /home/nachiten/.config/synth-shell/better-history.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /home/nachiten/.config/synth-shell/better-history.shfi

Here is my /etc/bash.barshrc complete file:

System-wide .bashrc file for interactive bash(1) shells.

To enable the settings / commands in this file for login shells as well,# this file has to be sourced in /etc/profile.

If not running interactively, don't do anything

[ -z "$PS1" ] && return

check the window size after each command and, if necessary,# update the values of LINES and COLUMNS.shopt -s checkwinsize

set variable identifying the chroot you work in (used in the prompt below)if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then

debian_chroot=$(cat /etc/debian_chroot)fi

set a fancy prompt (non-color, overwrite the one in /etc/profile)# but only if not SUDOing and have SUDO_PS1 set; then assume smart user.if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ 'fi

Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.# If this is an xterm set the title to @.**:dir#case "$TERM" in#xterm|rxvt)# PROMPT_COMMAND='echo -ne ""'# ;;#)# ;;#esac

enable bash completion in interactive shells#if ! shopt -oq posix; then# if [ -f /usr/share/bash-completion/bash_completion ]; then# . /usr/share/bash-completion/bash_completion# elif [ -f /etc/bash_completion ]; then# . /etc/bash_completion# fi#fi

sudo hintif [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then

case " $(groups) " in *\ admin\ *|*\ sudo\ *)
if [ -x /usr/bin/sudo ]; then

cat <<-EOF To run a command as administrator (user "root"), use "sudo ". See "man sudo_root" for details. EOF fi esacfi

if the command-not-found package is installed, use itif [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then

function command_not_found_handle {

check because c-n-f could've been removed in the meantime

            if [ -x /usr/lib/command-not-found ]; then
     /usr/lib/command-not-found -- "$1"
               return $?
            elif [ -x /usr/share/command-not-found/command-not-found ]; then
     /usr/share/command-not-found/command-not-found -- "$1"
               return $?
  else
     printf "%s: command not found" "$1" >&2
     return 127
  fi

}fi

-----------------------------------------------------## better-lsif [ -f /usr/local/bin/better-ls.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /usr/local/bin/better-ls.shfi

-----------------------------------------------------## aliasif [ -f /usr/local/bin/alias.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /usr/local/bin/alias.shfi

-----------------------------------------------------## better-historyif [ -f /usr/local/bin/better-history.sh ] && [ -n "$( echo $- | grep i )" ]; then

source /usr/local/bin/better-history.shfi

— Reply to this email directly, view it on GitHub https://github.com/andresgongora/synth-shell/issues/232, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC36INRA3YPDLV7WEX4BRUTV355TZANCNFSM6AAAAAAQBQLEFA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Nachiten commented 1 year ago

I have good news and bad news:

The good news is, disabling CPUTEMP in my user solved the problem, so it seems like your asumption is right.

The bad news is, when I try installing "lm-sensors" I already have it installed and updated image

The other bad news is, I dont know where to change the greeter config for my root user. I already changed the file /etc/synth-shell/synth-shell-greeter.config but that didnt work, I still get the default config.

image

So, I still have the default config on my root user, and I also have the error. I have been able to fix it only for my user.

Thanks for you answers :)

andresgongora commented 1 year ago

I'm glad one issue is solved! :) I might not have the time until this weekend, but I'll try to find where to root config is supposed to be. Maybe it's pointing at /root/.config/synth-shell/synth-shell-greeter.config? Also, I'll try to come up with a quick test do determine what is malformed in the sensors call; I might have to ask you to run one or two alternatives for me :) Cheers!

Nachiten commented 1 year ago

I already tried that directory, but /root/.config/synth-shell does not exist here :(

image

So my two questions now are: 1) How can I change my root user config (its always using the default) 2) How can I make the cpu temp sensor work correctly

I would be glad to test some options to help you out

Thanks :)

derekscha commented 1 year ago

Just to chime in with some additional information. I'm experiencing the same issue with similar cause. In my case, the output of sensors does not include a CPU temp. In your code for synth-shell-greeter.sh where you're grepping for Core to get 'temp_line', I have no string "Core" or any CPU information in my output:

iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:            N/A  

nvme-pci-0400
Adapter: PCI adapter
Composite:    +36.9°C  (low  = -273.1°C, high = +84.8°C)
                       (crit = +84.8°C)
Sensor 1:     +36.9°C  (low  = -273.1°C, high = +65261.8°C)
Sensor 2:     +35.9°C  (low  = -273.1°C, high = +65261.8°C)

k10temp-pci-00c3
Adapter: PCI adapter
Tctl:         +47.5°C  

amdgpu-pci-0500
Adapter: PCI adapter
vddgfx:      706.00 mV 
vddnb:       749.00 mV 
edge:         +35.0°C  
PPT:           0.00 W  

BAT0-acpi-0
Adapter: ACPI interface
in0:          16.91 V  
curr1:         0.00 A  

Raw output:

iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:
ERROR: Can't get value of subfeature temp1_input: Can't read

nvme-pci-0400
Adapter: PCI adapter
Composite:
  temp1_input: 36.850
  temp1_max: 84.850
  temp1_min: -273.150
  temp1_crit: 84.850
  temp1_alarm: 0.000
Sensor 1:
  temp2_input: 36.850
  temp2_max: 65261.850
  temp2_min: -273.150
Sensor 2:
  temp3_input: 36.850
  temp3_max: 65261.850
  temp3_min: -273.150

k10temp-pci-00c3
Adapter: PCI adapter
Tctl:
  temp1_input: 42.875

amdgpu-pci-0500
Adapter: PCI adapter
vddgfx:
  in0_input: 0.706
vddnb:
  in1_input: 0.743
edge:
  temp1_input: 34.000
PPT:
  power1_average: 0.000

BAT0-acpi-0
Adapter: ACPI interface
in0:
  in0_input: 16.913
curr1:
  curr1_input: 0.000
andresgongora commented 1 year ago

Hi all. Let's solve one problem at a time. First the CPU temp issue.

Thanks @derekscha for your output. I'll try to edit the script to make it handle odd situation like yours. Can you please confirm that none of those temps are related to the CPU? I'm seeing PCI stuff, GPU stuff and battery stuff... is that correct?

As for the root issue, @Nachiten , can you try to create the root config folder+file manually? I'm 99% sure (from memory) that I made the script look at the aforementioned path. If the script does not find a config file, then it will revert to defaults. My take (to make it super easy) would be to copy your normal user's synth-shell config folder under ~/.config/and just copy it to/root/.config/`. Let me know if that works. If not, maybe we should create a separate issue for this matter

Nachiten commented 1 year ago

Hi all. Let's solve one problem at a time. First the CPU temp issue.

Thanks @derekscha for your output. I'll try to edit the script to make it handle odd situation like yours. Can you please confirm that none of those temps are related to the CPU? I'm seeing PCI stuff, GPU stuff and battery stuff... is that correct?

As for the root issue, @Nachiten , can you try to create the root config folder+file manually? I'm 99% sure (from memory) that I made the script look at the aforementioned path. If the script does not find a config file, then it will revert to defaults. My take (to make it super easy) would be to copy your normal user's synth-shell config folder under ~/.config/and just copy it to/root/.config/`. Let me know if that works. If not, maybe we should create a separate issue for this matter

Hi, doing this copy command solved the issue cp /home/nachiten/.config/synth-shell/synth-shell-greeter.config /root/.config/synth-shell/synth-shell-greeter.config (after creating the folders manually)

Now my root loads the same config as my user, I can change it if needed.

Now my last problem would be, being able to show my cpu temp. Thanks!