environ #15
@ -219,17 +219,3 @@ void echo(StringArray *args) {
|
||||
}
|
||||
free_string_array(no_variables);
|
||||
}
|
||||
|
||||
char *remove_variable_symbol(char *original_variable) {
|
||||
char *variable = malloc((strlen(original_variable)) * sizeof(char *));
|
||||
if (variable == NULL) {
|
||||
perror("malloc");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
memset(variable, 0, strlen(original_variable));
|
||||
|
||||
for (size_t i = 0; i < strlen(original_variable); i++) {
|
||||
variable[i] = original_variable[i + 1];
|
||||
}
|
||||
return variable;
|
||||
}
|
||||
|
@ -62,11 +62,4 @@ void set_variable(StringArray *args);
|
||||
*/
|
||||
void echo(StringArray *args);
|
||||
|
||||
/**
|
||||
* Remove the $ symbol from a variable name.
|
||||
* @param original_variable The original variable name.
|
||||
* @return Returns the string without the $ symbool.
|
||||
*/
|
||||
char *remove_variable_symbol(char *original_variable);
|
||||
|
||||
#endif
|
||||
|
@ -27,4 +27,12 @@ void remove_new_line(char *line);
|
||||
* @return Returns the current working directory.
|
||||
*/
|
||||
char *get_working_directory();
|
||||
|
||||
/**
|
||||
* Remove the $ symbol from a variable name.
|
||||
* @param original_variable The original variable name.
|
||||
* @return Returns the string without the $ symbool.
|
||||
*/
|
||||
char *remove_variable_symbol(char *original_variable);
|
||||
|
||||
#endif
|
||||
|
14
src/utils.c
14
src/utils.c
@ -33,3 +33,17 @@ char *get_working_directory() {
|
||||
}
|
||||
return cwd;
|
||||
}
|
||||
|
||||
char *remove_variable_symbol(char *original_variable) {
|
||||
char *variable = malloc((strlen(original_variable)) * sizeof(char *));
|
||||
if (variable == NULL) {
|
||||
perror("malloc");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
memset(variable, 0, strlen(original_variable));
|
||||
|
||||
for (size_t i = 0; i < strlen(original_variable); i++) {
|
||||
variable[i] = original_variable[i + 1];
|
||||
}
|
||||
return variable;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user