# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               cmake 1.1
PortGroup               github 1.0
PortGroup               legacysupport 1.1

name                    fish
github.setup            fish-shell ${name}-shell 3.7.1
revision                1
license                 GPL-2
categories              shells
maintainers             {@akierig fastmail.de:akierig} openmaintainer

description             The friendly interactive shell: a command line shell for the 90s
long_description        ${name} is a smart and user-friendly command line shell for OS X, Linux and the rest of the family

homepage                https://fishshell.com
distname                ${name}-${version}
use_xz                  yes
checksums               rmd160  ca1d6747e878fbd724f3e800bcaceb224ad33319 \
                        sha256  614c9f5643cd0799df391395fa6bbc3649427bb839722ce3b114d3bbc1a3b250 \
                        size    2965756
github.tarball_from     releases

legacysupport.redirect_bins fish fish_indent fish_key_reader

depends_build-append    port:gettext \
                        path:bin/pkg-config:pkgconfig

depends_lib-append      port:gettext-runtime \
                        port:libiconv \
                        port:ncurses \
                        port:pcre2

patchfiles              patch-share_config_fish.diff

# Tests are broken with cmake 4.x: https://github.com/fish-shell/fish-shell/issues/11116
patchfiles-append       patch-disable-test-target.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}/bin|g" ${worksrcpath}/share/config.fish

    # skip failing tests for now, future updates should try enabling them
    file rename "${worksrcpath}/tests/checks/sigint.fish" ${worksrcpath}/tests/checks/sigint.fish.skip
}

compiler.cxx_standard   2011
compiler.thread_local_storage yes

# doxygen appears to only regenerate html files and is not needed to install man pages
configure.args-append   -DBUILD_DOCS=OFF \
                        -DBUILD_TESTING=OFF

configure.args-append   -DFISH_USE_SYSTEM_PCRE2=ON \
                        -DMAC_CODESIGN_ID=OFF

platform darwin 9 {
    # src/fds.cpp:108:77: error: invalid conversion from 'const fd_set*' to 'fd_set*' [-fpermissive]
    configure.cxxflags-append -fpermissive
}

platform darwin 8 {
    # src/env.cpp:436:31: error: invalid conversion from 'char*' to 'int'
    configure.cxxflags-append -D__DARWIN_UNIX03
}

# depends_test-append     port:py311-pexpect
# other possible options are ansi, dtterm, rxvt, vt52, vt100, vt102, xterm
# test.env-append         TERM=nsterm
# test.run                yes
# test.target             test

# pre-test {
#     append portsandbox_profile " (allow process-exec (literal \"/bin/ps\") (with no-profile))"
# }

notes "
To set MacPorts' ${name} as default login shell, run:

    sudo chpass -s ${prefix}/bin/${name} \${USER}

To be able to switch default shells to or from ${name} without superuser\
privileges, add it to /etc/shells:

    sudo sh -c 'echo ${prefix}/bin/${name} >> /etc/shells'

For X clipboard integration, install the xsel port:

    sudo port install xsel
"
