MiniDevil As beautiful as a shell
tilde_expand.c File Reference

Tilde expansion: converts ~ to $HOME in unquoted words. More...

#include "token.h"
#include "env.h"
#include "libft.h"
+ Include dependency graph for tilde_expand.c:

Detailed Description

Tilde expansion: converts ~ to $HOME in unquoted words.

Definition in file tilde_expand.c.

Functions

static char * expand_tilde (char *str, t_env *env_list, t_quote_type quote_type)
 Expand leading ~ to $HOME. More...
 
char * expand_full (char *str, t_env *env, t_quote_type qt, int exit_status)
 Handles variable expansion and tilde expansion. More...
 

Function Documentation

◆ expand_tilde()

static char* expand_tilde ( char *  str,
t_env env_list,
t_quote_type  quote_type 
)
static

Expand leading ~ to $HOME.

Handles ~ ($HOME) and ~/path ($HOME/path)

Parameters
strInput string
env_listEnvironment list (for HOME lookup)
quote_typeQuote context
Returns
Expanded string

Definition at line 27 of file tilde_expand.c.

References get_env_value(), and QUOTE_NONE.

Referenced by expand_full().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expand_full()

char* expand_full ( char *  str,
t_env env,
t_quote_type  qt,
int  exit_status 
)

Handles variable expansion and tilde expansion.

Tilde expansions run first to conform with BASH and correctly handling:

  • export TEST="~"
  • echo $TEST
Parameters
strInput string
envEnvironment list
qtQuote type
exit_statusExit status for $?
Returns
Fully expanded string or NULL on failure

Definition at line 60 of file tilde_expand.c.

References expand_tilde(), and expand_variables().

Referenced by expand_all_tokens().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Go to the source code of this file.