Page MenuHomeFreeBSD

Collapse $HOME into "~" in PS1.
ClosedPublic

Authored by trasz on Dec 27 2018, 2:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 2, 8:04 PM
Unknown Object (File)
Tue, Apr 30, 6:49 AM
Unknown Object (File)
Mar 8 2024, 9:11 AM
Unknown Object (File)
Jan 17 2024, 10:24 PM
Unknown Object (File)
Jan 8 2024, 12:50 PM
Unknown Object (File)
Dec 22 2023, 5:03 AM
Unknown Object (File)
Dec 21 2023, 5:47 PM
Unknown Object (File)
Dec 20 2023, 2:46 AM
Subscribers

Details

Summary

Make sh(1) collapse $HOME into "~" in PS1.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 21739
Build 21017: arc lint + arc unit

Event Timeline

jilles requested changes to this revision.Dec 27 2018, 3:07 PM
jilles added inline comments.
bin/sh/parser.c
2045–2046

A path /home/user1 will match /home/user here.

Also, if HOME is /, results will be strange and the substitution should probably be disabled.

2049–2051

The buffer length passed to strlcpy seems one byte too long.

Also, is it valid to calculate &ps[i + 1]?

This revision now requires changes to proceed.Dec 27 2018, 3:07 PM
trasz added inline comments.
bin/sh/parser.c
2049–2051

Hm, I'm not much of a C lawyer, but I've used that syntax since... ever. What's wrong with it?

jilles added inline comments.
bin/sh/parser.c
2049–2051

The syntax is fine, but I wondered whether ps[i + 1] is always within bounds. It turns out that it is because the i < PROMPTLEN - 1 check above.

This revision is now accepted and ready to land.Dec 28 2018, 1:16 PM
This revision was automatically updated to reflect the committed changes.