Bug 173418

Summary: /bin/sh - Alias breaks if set twice.
Product: Base System Reporter: GNATS administrator <gnats-admin>
Component: binAssignee: Jilles Tjoelker <jilles>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 9.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description GNATS administrator freebsd_committer freebsd_triage 2012-11-06 10:20:01 UTC
Function setalias() in alias.c of bin/sh uses a hack to avoid alias recursion by appending a single space character to alias value. This does not happen when we're redefining already existing alias.

When we execute or view aliases, the last character gets stripped in order to get rid of the extra space. In case of redefined alias this will become a problem.

Fix: Use the hack in part of code where it checks if alias already exists.

Patch attached with submission follows:
How-To-Repeat: $/bin/sh
$alias a=b
$alias a=b
$alias

Or by sourcing a file with alias definitions, twice.
Comment 1 Jilles Tjoelker freebsd_committer freebsd_triage 2012-11-07 23:29:38 UTC
Responsible Changed
From-To: freebsd-bugs->jilles

I'll take it.
Comment 2 Jilles Tjoelker freebsd_committer freebsd_triage 2012-11-08 13:36:59 UTC
State Changed
From-To: open->patched

Applied to 10-current, thanks.
Comment 3 Jilles Tjoelker freebsd_committer freebsd_triage 2013-06-28 22:54:04 UTC
State Changed
From-To: patched->closed

Fixed in 10-current (r242766) and 9-stable (r243402). Thanks!