Bug 463167

Summary: %M and %m expansions don't work anymore
Product: [Fedora] Fedora Reporter: Mathieu Chouquet-Stringer <mathieu-acct>
Component: zshAssignee: James Antill <james.antill>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-09-25 11:15:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mathieu Chouquet-Stringer 2008-09-22 13:36:32 UTC
Description of problem:
On a freshly installed F9, print -P "%M %m" returns nothing while on a RHEL 5.2 (for instance) it gives you the FQDN then the hostname.

Version-Release number of selected component (if applicable):
4.3.4-8.fc9

How reproducible:
Always

Steps to Reproduce:
1. print -P "%M %m"
  
Actual results:
Empty strings

Expected results:
As per the man page:

       %M     The full machine hostname.

       %m     The hostname up to the first ‘.’.  An integer may follow the ‘%’ to specify how many components of the hostname are desired.
              With a negative integer, trailing components of the hostname are shown.

Comment 1 James Antill 2008-09-22 14:17:04 UTC
% print -P "%M %m"                         
code.and.org code
% yum list zsh
Installed Packages
zsh.x86_64                         4.3.4-8.fc9                         installed

...got anymore info?

Comment 2 Mathieu Chouquet-Stringer 2008-09-22 14:27:15 UTC
zsh.i386                                 4.3.4-8.fc9            installed       

On my machine (I've got another one at home):

%hostname
foobar
%print -P "%M"

%


And foobar is in /etc/hosts (I mean a getent ahosts foobar works)...

I guess I'm going to dig in the source...

Comment 3 Mathieu Chouquet-Stringer 2008-09-22 14:42:28 UTC
BY the way I also tried to move my .zshrc out of the way, same result...

Comment 4 James Antill 2008-09-22 15:08:56 UTC
 Ok, interesting ... if I do "zsh -f" then print "%M" just prints %M.

PROMPT EXPANSION
       Prompt  sequences  undergo  a  special form of expansion.  This type of
       expansion is also available using the -P option to the print builtin.

...and print -P "%M" works in zsh -f.

Comment 5 Mathieu Chouquet-Stringer 2008-09-22 15:42:52 UTC
Nice find, with zsh -f, print -P "%M" works again...

Comment 6 Mathieu Chouquet-Stringer 2008-09-24 09:15:49 UTC
Found the culprit, I added this to zshrc:
--- zshrc.orig  2008-05-16 06:17:09.000000000 +0200
+++ zshrc       2008-09-24 11:10:39.000000000 +0200
@@ -26,7 +26,9 @@
     if [[ ! -o login ]]; then # We're not a login shell
         for i in /etc/profile.d/*.sh; do
            if [ -r "$i" ]; then
+               echo $i
                . $i
+               print -P "%M %m"
            fi
         done
         unset i

And basically it stops here:
tangerine tangerine
/etc/profile.d/keychain.sh

So keychain seems to be at fault.  The issue is this line:
    unset KCHOPTS SSHKEYS GPGKEYS HOST

If you unset HOST, print -P "%M" (or %m) fails...

%echo $HOST

%print -P "%m %M"
 
%HOST=foobar
%print -P "%m %M"
foobar foobar



Can we transfer this bug to keychain instead of rpm?

Comment 7 Mathieu Chouquet-Stringer 2008-09-24 09:23:05 UTC
I meant "transfer to keychain instead of zsh" of course...

Comment 8 Mathieu Chouquet-Stringer 2008-09-25 11:15:47 UTC
Closed (new bug is 463913).