Learn about Centmin Mod LEMP Stack today
Become a Member

ZSH & Oh My Zsh

Discussion in 'Bug Reports' started by JoeDer, Sep 29, 2019.

  1. JoeDer

    JoeDer Member

    82
    19
    8
    Feb 22, 2015
    Ratings:
    +48
    Local Time:
    4:52 AM
    Nginx 1.21.x
    MariaDB 10.3.x
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: 1.17.4
    • PHP Version Installed: 7.3.10
    • MariaDB MySQL Version Installed: 10.3
    • When was last time updated Centmin Mod code base ? : 28 Sep 2019
    I think a bug came on /etc/profile.d/dmotd.sh file after ZSH & Oh My Zsh installation.
    When I'm login in via SSH a message appears about an error in dmotd.sh file.
    Code (Text):
    /etc/profile.d/dmotd.sh:3: parse error near `>'
    

    Untitled.png

    If I comment the 3rd line in /etc/profile.d/dmotd.sh then everything looks good but I don't know if it's the right way (probably not).
    Code (Text):
    # if echo $0 | grep -e ^\- 2>&1>/dev/null; then login='login'; else login='non-login'; fi;
    


     
  2. eva2000

    eva2000 Administrator Staff Member

    54,384
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    12:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod doesn't support nor has it been tested with ZSH unfortunately right now. Wouldn't be advisable to use ZSH as no idea how Centmin Mod bash shell scripting will respond and interpret ZSH versus BASH.
     
  3. JoeDer

    JoeDer Member

    82
    19
    8
    Feb 22, 2015
    Ratings:
    +48
    Local Time:
    4:52 AM
    Nginx 1.21.x
    MariaDB 10.3.x
    Oh ok, I'll revert back to default shell, thank you!
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,384
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    12:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yeah ZSH looks nice and fancy compared to BASH. Just minor differences between them for shell scripting, could result in different results or outcomes in Centmin Mod that are unforseen.
     
  5. BobbyWibowo

    BobbyWibowo Active Member

    197
    42
    28
    Jul 30, 2015
    Indonesia
    Ratings:
    +71
    Local Time:
    9:52 AM
    1.17.x
    10.3.x
    For ZSH, it's good enough to edit
    Code (Text):
    grep -e ^\- 2>&1>/dev/null;
    into
    Code (Text):
    grep -e ^\- 2>&1 > /dev/null;

    While I was at it, I also commented out the 2nd line to prevent the MOTD stuff from being executed on non-root users. I don't particularly fancy being prompted for sudo password every time I login to my regular user, lmao. Considering I already used private key for auth to eliminate password prompts in the first place.

    Anyway, of course I'd still use BASH on root user, with which I'd do anything Centmin-related.
    But I'd still rather use ZSH on my regular user, with which I'd do everything else that wouldn't really need root access (i.e. node servers). Even when I needed root access, it'd be good enough with sudo/sudoedit anyway, as at most I'd just need to edit some nginx configs or restart nginx. Also, sudo -i would use BASH just fine, whenever I couldn't be bothered to launch another ssh terminal to instead login as root.
     
    Last edited: Apr 7, 2020
  6. eva2000

    eva2000 Administrator Staff Member

    54,384
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    12:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    thanks i updated 123.09beta01 for that :)

    current /etc/profile.d/dmotd.sh now looks like
    Code (Text):
    #!/bin/bash
    if tty -s; then type='interactive'; if [[ "$(id -u)" = '0' && -f /usr/local/bin/dmotd ]]; then /usr/local/bin/dmotd; fi; else type='non-interactive'; fi;
    if echo $0 | grep -e ^\- 2>&1 > /dev/null; then login='login'; else login='non-login'; fi;