Skip to content

zshrc: add special code for cdt() for FreeBSD #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moviuro
Copy link
Contributor

@moviuro moviuro commented Jul 3, 2025

While there, fix whitespace

--

root@fbsd ~ # which cdt
cdt () {
        local -a cdttemplate
        if [ "$#" -eq 1 ]
        then
                if isfreebsd
                then
                        cdttemplate=(-t "$1") 
                else
                        cdttemplate=(-t "$1".XXXXXXX) 
                fi
        fi
        builtin cd "$(mktemp -d ${cdttemplate[@]})"
        builtin pwd
}
root@fbsd ~ # cdt grml
/tmp/grml.YFIkcJQw71
root@fbsd /tmp/grml.YFIkcJQw71 # uname -a
FreeBSD fbsd.local 14.2-RELEASE-p1 FreeBSD 14.2-RELEASE-p1 GENERIC amd64

Improves #203

@zeha
Copy link
Member

zeha commented Jul 3, 2025

Could I ask you explain the FreeBSD behaviour? From just the manual page link I don't understand what the difference is between coreutils mktemp and freebsd mktemp.

@zeha
Copy link
Member

zeha commented Jul 3, 2025

okay, i got myself a freebsd VM.

the problem is:

root@freebsd:~ # mktemp -d -t test.XXXXXX
/tmp/test.XXXXXX.Z0aj1NfauX

where with coreutils:

% mktemp -d -t test.XXXXXX
/tmp/test.Wi46it

what an annoying difference. should probably still put some details into the comment

Copy link
Member

@mika mika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, TIL. LGTM, though I'm a huge fan of having details like "what's broken/why this change/..." in the commit message! :) (Please consider this a nitpick from my side only :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants