all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Danny Milosavljevic <dannym@scratchpost.org>
To: Leo Famulari <leo@famulari.name>
Cc: guix-devel@gnu.org, Danny Milosavljevic <dannym+a@scratchpost.org>
Subject: Re: [PATCH] gnu: Add rofi.
Date: Tue, 24 May 2016 08:55:02 +0200	[thread overview]
Message-ID: <20160524085502.2f095f2f@scratchpost.org> (raw)
In-Reply-To: <20160523042826.GA20265@jasmine>

On Mon, 23 May 2016 00:28:26 -0400
Leo Famulari <leo@famulari.name> wrote:

> The failing test (helper_expand) seems to fail when it can't find
> `which`. 

The failing test is test/helper-expand.c and it tries to do this:

int main ( int argc, char ** argv )
{
    cmd_set_arguments ( argc, argv );

    if ( setlocale ( LC_ALL, "" ) == NULL ) {
        fprintf ( stderr, "Failed to set locale.\n" );
        return EXIT_FAILURE;
    }

    /**
     * Test some path functions. Not easy as not sure what is right output on travis.
     */
    // Test if root is preserved.
    char *str = rofi_expand_path ( "/" );
    TASSERT ( strcmp ( str, "/" ) == 0 );
    g_free ( str );
    // Test is relative path is preserved.
    str = rofi_expand_path ( "../AUTHORS" );
    TASSERT ( strcmp ( str, "../AUTHORS" ) == 0 );
    g_free ( str );
    // Test another one.
    str = rofi_expand_path ( "/bin/false" );
    TASSERT ( strcmp ( str, "/bin/false" ) == 0 );
    g_free ( str );
    // See if user paths get expanded in full path.
    str = rofi_expand_path ( "~/" ); <----- oh oh
    const char *hd = g_get_home_dir ();
    TASSERT ( strcmp ( str, hd ) == 0 );
    g_free ( str );
    str = rofi_expand_path ( "~root/" );   <--- oh oh
    TASSERT ( str[0] == '/' );
    g_free ( str );
}

And rofi_expand_path does

char *rofi_expand_path ( const char *input )
{
    char **str = g_strsplit ( input, G_DIR_SEPARATOR_S, -1 );
    for ( unsigned int i = 0; str && str[i]; i++ ) {
        // Replace ~ with current user homedir.
        if ( str[i][0] == '~' && str[i][1] == '\0' ) {
            g_free ( str[i] );
            str[i] = g_strdup ( g_get_home_dir () ); <----------- oh oh
        }
        // If other user, ask getpwnam.
        else if ( str[i][0] == '~' ) {
            struct passwd *p = getpwnam ( &( str[i][1] ) ); <---------- oh oh
            if ( p != NULL ) {
                g_free ( str[i] );
                str[i] = g_strdup ( p->pw_dir );
            }
        }
        else if ( i == 0 ) {
            char * s = str[i];
            if ( input[0] == G_DIR_SEPARATOR ) {
                str[i] = g_strdup_printf ( "%s%s", G_DIR_SEPARATOR_S, s );
                g_free ( s );
            }
        }
    }
    char *retv = g_build_filenamev ( str );
    g_strfreev ( str );
    return retv;
}

What should we do about it?

The "which" part is just rofi trying to find out whether it has been checked out from git or expanded from a release tarball.

  reply	other threads:[~2016-05-24  6:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20  4:29 [PATCH] gnu: Add rofi Danny Milosavljevic
2016-05-23  4:28 ` Leo Famulari
2016-05-24  6:55   ` Danny Milosavljevic [this message]
2016-05-25  3:38     ` Leo Famulari
2016-05-26  0:56       ` [PATCH v2] * gnu/packages/xdisorg.scm (rofi): New variable Danny Milosavljevic
2016-05-27 17:41         ` Leo Famulari
2016-05-27 18:23           ` [PATCH v3] gnu: Add rofi Danny Milosavljevic
2016-05-27 18:35             ` Leo Famulari
2016-05-27 18:54               ` Danny Milosavljevic
2016-05-31 21:25                 ` Leo Famulari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160524085502.2f095f2f@scratchpost.org \
    --to=dannym@scratchpost.org \
    --cc=dannym+a@scratchpost.org \
    --cc=guix-devel@gnu.org \
    --cc=leo@famulari.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.