yash-2.35/0000755000175000017500000000000012154557026012546 5ustar magicantmagicantyash-2.35/input.h0000644000175000017500000000644112154557026014063 0ustar magicantmagicant/* Yash: yet another shell */ /* input.h: functions for input of command line */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_INPUT_H #define YASH_INPUT_H #include #include struct promptset_T { wchar_t *main, *right, *styler; }; #define PROMPT_RESET L"\\fD" extern struct promptset_T get_prompt(int type); static inline void free_prompt(struct promptset_T prompt); extern void print_prompt(const wchar_t *s) __attribute__((nonnull)); extern _Bool unset_nonblocking(int fd); /* Frees the specified prompt set. */ void free_prompt(struct promptset_T prompt) { free(prompt.main); free(prompt.right); free(prompt.styler); } /* The result type of `inputfunc_T'. */ typedef enum inputresult_T { INPUT_OK, /* A line was read successfully. */ INPUT_EOF, /* The end of file was reached. */ INPUT_INTERRUPTED, /* SIGINT was received (interactive shell only) */ INPUT_ERROR, /* Other error was encountered. */ } inputresult_T; struct xwcsbuf_T; struct input_file_info_T; extern inputresult_T read_input( struct xwcsbuf_T *buf, struct input_file_info_T *info, _Bool trap) __attribute__((nonnull)); /* The type of input functions. * An input function reads input and appends it to buffer `buf'. * Input is done line-wise: the buffer contents are always terminated by a * newline character (L'\n') except when the end of file is reached and the last * line does not have a newline. * The result is indicated by a value of the `inputresult_T' type. If the return * value is other than INPUT_OK, the buffer is unchanged. * The input function may be called even after it returned a value other than * INPUT_OK. */ typedef inputresult_T inputfunc_T(struct xwcsbuf_T *buf, void *inputinfo); /* input functions */ extern inputresult_T input_wcs(struct xwcsbuf_T *buf, void *inputinfo) __attribute__((nonnull)); extern inputresult_T input_file(struct xwcsbuf_T *buf, void *inputinfo) __attribute__((nonnull)); extern inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo) __attribute__((nonnull)); /* to be used as `inputinfo' for `input_wcs' */ struct input_wcs_info_T { const wchar_t *src; /* the input source code */ }; /* to be used as `inputinfo' for `input_file' */ struct input_file_info_T { int fd; mbstate_t state; size_t bufpos, bufmax, bufsize; char buf[]; }; /* `bufsize' is the size of `buf', which must be at least one byte. */ /* to be used as `inputinfo' for `input_interactive' */ struct input_interactive_info_T { struct input_file_info_T *fileinfo; int prompttype; }; #endif /* YASH_INPUT_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/expand.h0000644000175000017500000000565212154557026014206 0ustar magicantmagicant/* Yash: yet another shell */ /* expand.h: word expansion */ /* (C) 2007-2010 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_EXPAND_H #define YASH_EXPAND_H #include #define DEFAULT_IFS L" \t\n" /* characters that have special meanings in brace expansion and glob. */ #define CHARS_ESCAPED L"\\{,}" /* characters that can be escaped with a backslash inside double-quotes. */ #define CHARS_ESCAPABLE L"$`\"\\" /* type of tilde expansion */ typedef enum { TT_NONE, TT_SINGLE, TT_MULTI, } tildetype_T; struct wordunit_T; struct plist_T; extern _Bool expand_line( void *const *restrict args, int *restrict argcp, void ***restrict argvp) __attribute__((nonnull)); extern _Bool expand_multiple( const struct wordunit_T *restrict w, struct plist_T *restrict list) __attribute__((nonnull(2))); extern wchar_t *expand_single(const struct wordunit_T *arg, tildetype_T tilde) __attribute__((malloc,warn_unused_result)); extern char *expand_single_with_glob( const struct wordunit_T *arg, tildetype_T tilde) __attribute__((malloc,warn_unused_result)); extern wchar_t *expand_string(const struct wordunit_T *w, _Bool esc) __attribute__((malloc,warn_unused_result)); extern wchar_t *split_next_field( const wchar_t **sp, const wchar_t *ifs, _Bool noescape) __attribute__((nonnull(1),malloc,warn_unused_result)); extern void trim_trailing_spaces( wchar_t *restrict s, const wchar_t *restrict ifs) __attribute__((nonnull(1))); extern wchar_t *escape(const wchar_t *restrict s, const wchar_t *restrict t) __attribute__((nonnull(1),malloc,warn_unused_result)); extern wchar_t *escapefree( wchar_t *restrict s, const wchar_t *restrict t) __attribute__((nonnull(1),malloc,warn_unused_result)); extern wchar_t *unescape(const wchar_t *s) __attribute__((nonnull,malloc,warn_unused_result)); extern wchar_t *unescapefree(wchar_t *s) __attribute__((nonnull,malloc,warn_unused_result)); extern wchar_t *quote_sq(const wchar_t *s) __attribute__((nonnull,malloc,warn_unused_result)); extern wchar_t *unquote(const wchar_t *s) __attribute__((nonnull,malloc,warn_unused_result)); extern wchar_t *parse_and_expand_string( const wchar_t *s, const char *name, _Bool esc) __attribute__((nonnull(1),malloc,warn_unused_result)); #endif /* YASH_EXPAND_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtin.h0000644000175000017500000000465712154557026014401 0ustar magicantmagicant/* Yash: yet another shell */ /* builtin.h: built-in commands */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_BUILTIN_H #define YASH_BUILTIN_H #include typedef int main_T(int argc, void **argv) __attribute__((nonnull)); typedef enum builtintype_T { BI_SPECIAL, BI_SEMISPECIAL, BI_REGULAR, } builtintype_T; typedef struct builtin_T { main_T *body; builtintype_T type; #if YASH_ENABLE_HELP const char *help_text, *syntax_text; const struct xgetopt_T *options; #endif } builtin_T; extern void init_builtin(void); extern const builtin_T *get_builtin(const char *name) __attribute__((pure)); extern int mutually_exclusive_option_error(wchar_t opt1, wchar_t opt2); extern _Bool validate_operand_count(size_t count, size_t min, size_t max); extern int insufficient_operands_error(size_t min_required_operand_count); extern int too_many_operands_error(size_t max_accepted_operand_count); extern int special_builtin_syntax_error(int exitstatus); struct xgetopt_T; extern int print_builtin_help(const wchar_t *name) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern _Bool print_shopts(_Bool include_normal_options); extern _Bool print_option_list(const struct xgetopt_T *options) __attribute__((nonnull)); #endif extern int true_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char colon_help[], colon_syntax[], true_help[], true_syntax[]; #endif extern int false_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char false_help[], false_syntax[]; #endif extern int help_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char help_help[], help_syntax[]; #endif #endif /* YASH_BUILTIN_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/strbuf.c0000644000175000017500000004573612154557026014236 0ustar magicantmagicant/* Yash: yet another shell */ /* strbuf.c: modifiable string buffer */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "strbuf.h" #include #include #include #include #include #include #include #include #include #include "util.h" #if HAVE_WCSNRTOMBS && !defined(wcsnrtombs) size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict src, size_t nwc, size_t len, mbstate_t *restrict ps); #endif #ifndef XSTRBUF_INITSIZE #define XSTRBUF_INITSIZE 15 #endif #ifndef XWCSBUF_INITSIZE #define XWCSBUF_INITSIZE 15 #endif /* If the type of the return value of the functions below is string buffer, * the return value is the argument buffer. */ /********** Multibyte String Buffer **********/ /* Initializes the specified string buffer as an empty string. */ xstrbuf_T *sb_init(xstrbuf_T *buf) { // buf->contents = xmallocn(XSTRBUF_INITSIZE + 1, sizeof (char)); buf->contents = xmalloc(XSTRBUF_INITSIZE + 1); buf->contents[0] = '\0'; buf->length = 0; buf->maxlength = XSTRBUF_INITSIZE; return buf; } /* Initializes the specified multibyte string buffer with the specified string. * String `s' must be `free'able. * After calling this function, the string is used as the buffer, so you must * not touch or `free' it any more. */ xstrbuf_T *sb_initwith(xstrbuf_T *restrict buf, char *restrict s) { buf->contents = s; buf->length = buf->maxlength = strlen(s); return buf; } /* Changes the maximum length of the specified buffer. * If `newmax' is less than the current length of the buffer, the end of * the buffer contents is truncated. */ xstrbuf_T *sb_setmax(xstrbuf_T *buf, size_t newmax) { // buf->contents = xreallocn(buf->contents, newmax + 1, sizeof (char)); buf->contents = xrealloc(buf->contents, newmax + 1); buf->maxlength = newmax; buf->contents[newmax] = '\0'; if (newmax < buf->length) buf->length = newmax; return buf; } /* If `buf->maxlength' is less than `max', reallocates the buffer so that * `buf->maxlength' is no less than `max'. */ xstrbuf_T *sb_ensuremax(xstrbuf_T *buf, size_t max) { if (max <= buf->maxlength) return buf; size_t len15 = buf->maxlength + (buf->maxlength >> 1); if (max < len15) max = len15; if (max < buf->maxlength + 10) max = buf->maxlength + 10; return sb_setmax(buf, max); } /* Replaces the specified part of the buffer with another string. * `bn' characters starting at offset `i' in buffer `buf' is removed and * the first `sn' characters of `s' take place of them. * No boundary checks are done and null characters are not considered special. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_replace_force( xstrbuf_T *restrict buf, size_t i, size_t bn, const char *restrict s, size_t sn) { size_t newlength = buf->length - bn + sn; sb_ensuremax(buf, newlength); memmove(buf->contents + i + sn, buf->contents + i + bn, buf->length - (i + bn) + 1); memcpy(buf->contents + i, s, sn); buf->length = newlength; return buf; } /* Replaces the specified part of the buffer with another string. * `bn' characters starting at offset `i' in buffer `buf' is removed and * the first `sn' characters of `s' take place of them. * If (strlen(s) < sn), the whole of `s' is replaced with. * If (buf->length < i + sn), all the characters after offset `i' in the buffer * is replaced. Especially, if (buf->length <= i), `s' is appended. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_replace( xstrbuf_T *restrict buf, size_t i, size_t bn, const char *restrict s, size_t sn) { sn = xstrnlen(s, sn); if (i > buf->length) i = buf->length; if (bn > buf->length - i) bn = buf->length - i; return sb_replace_force(buf, i, bn, s, sn); } /* Appends byte `c' to the end of string buffer `buf'. * The byte is appended even if it is a null byte. */ xstrbuf_T *sb_ccat(xstrbuf_T *buf, char c) { sb_ensuremax(buf, buf->length + 1); buf->contents[buf->length++] = c; buf->contents[buf->length] = '\0'; return buf; } /* Appends `n' bytes of `c' to the end of buffer `buf'. * The bytes are appended even if `c' is a null byte. */ xstrbuf_T *sb_ccat_repeat(xstrbuf_T *buf, char c, size_t n) { sb_ensuremax(buf, buf->length + n); memset(&buf->contents[buf->length], c, n); buf->length += n; buf->contents[buf->length] = '\0'; return buf; } /* Converts wide character `c' into a multibyte string and appends it to buffer * `buf'. Shift state `ps' is used for the conversion. * If `c' is a null character, the shift state is reset to the initial state but * the null character is not appended to the buffer. * Returns true iff successful. On error, `errno' is set to EILSEQ and the state * is left undefined. */ bool sb_wccat(xstrbuf_T *restrict buf, wchar_t c, mbstate_t *restrict ps) { size_t count; sb_ensuremax(buf, buf->length + MB_CUR_MAX); count = wcrtomb(&buf->contents[buf->length], c, ps); if (count == (size_t) -1) { buf->contents[buf->length] = '\0'; return false; } assert(0 < count && count <= buf->maxlength - buf->length); buf->length += count; if (c == L'\0') buf->length--; else buf->contents[buf->length] = '\0'; assert(buf->contents[buf->length] == '\0'); return true; } /* Appends first `n' characters of wide string `s' to multibyte buffer `buf'. * The wide string is converted to multibyte string using shift state `ps'. * If `n' is larger than the length of `s', the whole string is appended and * the shift state is reset to the initial shift state. * Returns NULL if the string is converted and appended successfully, * otherwise a pointer to the character in `s' that caused the error. * A partial result may be left in the buffer on error. */ wchar_t *sb_wcsncat(xstrbuf_T *restrict buf, const wchar_t *restrict s, size_t n, mbstate_t *restrict ps) { #if HAVE_WCSNRTOMBS for (;;) { const wchar_t *saves = s; size_t count = wcsnrtombs(&buf->contents[buf->length], (const wchar_t **) &s, n, buf->maxlength - buf->length, ps); if (count == (size_t) -1) { buf->contents[buf->length] = '\0'; break; } buf->length += count; if (s == NULL) break; assert((size_t) (s - saves) <= n); n -= s - saves; if (n == 0) { buf->contents[buf->length] = '\0'; s = NULL; break; } sb_ensuremax(buf, buf->maxlength + MB_CUR_MAX); } assert(buf->contents[buf->length] == '\0'); return (wchar_t *) s; #else while (n > 0) { if (!sb_wccat(buf, *s, ps)) return (wchar_t *) s; if (*s == L'\0') return NULL; s++, n--; } return NULL; #endif } /* Appends wide string `s' to multibyte buffer `buf'. The wide string is * converted to multibyte string using shift state `ps'. After successful * conversion, the shift state is reset to the initial shift state. * Returns NULL if the whole string is converted and appended successfully, * otherwise a pointer to the character in `s' that caused the error. * A partial result may be left in the buffer on error. */ #if !HAVE_WCSNRTOMBS wchar_t *sb_wcscat(xstrbuf_T *restrict buf, const wchar_t *restrict s, mbstate_t *restrict ps) { for (;;) { size_t count = wcsrtombs(&buf->contents[buf->length], (const wchar_t **) &s, buf->maxlength - buf->length, ps); if (count == (size_t) -1) { buf->contents[buf->length] = '\0'; break; } buf->length += count; if (s == NULL) break; sb_ensuremax(buf, buf->maxlength + MB_CUR_MAX); } assert(buf->contents[buf->length] == '\0'); return (wchar_t *) s; } #endif /* Appends the result of `vsprintf' to the specified buffer. * `format' and the following arguments must not be part of `buf->contents'. * Returns the number of appended bytes if successful. * On error, the buffer is not changed and -1 is returned. */ int sb_vprintf(xstrbuf_T *restrict buf, const char *restrict format, va_list ap) { va_list copyap; va_copy(copyap, ap); int rest = buf->maxlength - buf->length + 1; int result = vsnprintf(&buf->contents[buf->length], rest, format, ap); if (result >= rest) { /* If the buffer is too small... */ sb_ensuremax(buf, buf->length + result); rest = buf->maxlength - buf->length + 1; result = vsnprintf(&buf->contents[buf->length], rest, format, copyap); } assert(result < rest); if (result >= 0) buf->length += result; else buf->contents[buf->length] = '\0'; assert(buf->contents[buf->length] == '\0'); va_end(copyap); return result; } /* Appends the result of `sprintf' to the specified buffer. * `format' and the following arguments must not be part of `buf->contents'. * Returns the number of appended bytes if successful. * On error, the buffer is not changed and -1 is returned. */ int sb_printf(xstrbuf_T *restrict buf, const char *restrict format, ...) { va_list ap; int result; va_start(ap, format); result = sb_vprintf(buf, format, ap); va_end(ap); return result; } /********** Wide String Buffer **********/ /* Initializes the specified wide string buffer as an empty string. */ xwcsbuf_T *wb_init(xwcsbuf_T *buf) { buf->contents = xmallocn(XWCSBUF_INITSIZE + 1, sizeof (wchar_t)); buf->contents[0] = L'\0'; buf->length = 0; buf->maxlength = XWCSBUF_INITSIZE; return buf; } /* Initializes the specified wide string buffer with the specified string. * String `s' must be `free'able. * After calling this function, the string is used as the buffer, so you must * not touch or `free' it any more. */ xwcsbuf_T *wb_initwith(xwcsbuf_T *restrict buf, wchar_t *restrict s) { buf->contents = s; buf->length = buf->maxlength = wcslen(s); return buf; } /* Changes the maximum length of the specified buffer. * If `newmax' is less than the current length of the buffer, the end of * the buffer contents is truncated. */ xwcsbuf_T *wb_setmax(xwcsbuf_T *buf, size_t newmax) { buf->contents = xreallocn(buf->contents, newmax + 1, sizeof (wchar_t)); buf->maxlength = newmax; buf->contents[newmax] = L'\0'; if (newmax < buf->length) buf->length = newmax; return buf; } /* If `buf->maxlength' is less than `max', reallocates the buffer so that * `buf->maxlength' is no less than `max'. */ xwcsbuf_T *wb_ensuremax(xwcsbuf_T *buf, size_t max) { if (max <= buf->maxlength) return buf; size_t len15 = buf->maxlength + (buf->maxlength >> 1); if (max < len15) max = len15; if (max < buf->maxlength + 8) max = buf->maxlength + 8; return wb_setmax(buf, max); } /* Replaces the specified part of the buffer with another string. * `bn' characters starting at offset `i' in buffer `buf' is removed and * the first `sn' characters of `s' take place of them. * No boundary checks are done and null characters are not considered special. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_replace_force( xwcsbuf_T *restrict buf, size_t i, size_t bn, const wchar_t *restrict s, size_t sn) { size_t newlength = buf->length - bn + sn; wb_ensuremax(buf, newlength); wmemmove(buf->contents + i + sn, buf->contents + i + bn, buf->length - (i + bn) + 1); wmemcpy(buf->contents + i, s, sn); buf->length = newlength; return buf; } /* Replaces the specified part of the buffer with another string. * `bn' characters starting at offset `i' in buffer `buf' is removed and * the first `sn' characters of `s' take place of them. * If (wcslen(s) < sn), the whole of `s' is replaced with. * If (buf->length < i + sn), all the characters after offset `i' in the buffer * is replaced. Especially, if (buf->length <= i), `s' is appended. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_replace( xwcsbuf_T *restrict buf, size_t i, size_t bn, const wchar_t *restrict s, size_t sn) { sn = xwcsnlen(s, sn); if (i > buf->length) i = buf->length; if (bn > buf->length - i) bn = buf->length - i; return wb_replace_force(buf, i, bn, s, sn); } /* Appends wide character `c' to the end of buffer `buf'. * The character is appended even if it is a null wide character. */ xwcsbuf_T *wb_wccat(xwcsbuf_T *buf, wchar_t c) { wb_ensuremax(buf, buf->length + 1); buf->contents[buf->length++] = c; buf->contents[buf->length] = L'\0'; return buf; } /* Converts multibyte string `s' into a wide string and appends it to buffer * `buf'. The multibyte string is assumed to start in the initial shift state. * Returns NULL if the whole string is converted and appended successfully, * otherwise a pointer to the character in `s' that caused the error. * A partial result may be left in the buffer on error. */ char *wb_mbscat(xwcsbuf_T *restrict buf, const char *restrict s) { mbstate_t state; size_t count; memset(&state, 0, sizeof state); // initialize as the initial shift state for (;;) { count = mbsrtowcs(&buf->contents[buf->length], (const char **) &s, buf->maxlength - buf->length + 1, &state); if (count == (size_t) -1) break; buf->length += count; if (s == NULL) break; wb_ensuremax(buf, buf->maxlength + 1); } buf->contents[buf->length] = L'\0'; return (char *) s; } /* Appends the result of `vswprintf' to the specified buffer. * `format' and the following arguments must not be part of `buf->contents'. * Returns the number of appended characters if successful. * On error, the buffer is not changed and -1 is returned. */ int wb_vwprintf( xwcsbuf_T *restrict buf, const wchar_t *restrict format, va_list ap) { va_list copyap; int rest, result; for (int i = 0; i < 20; i++) { va_copy(copyap, ap); rest = buf->maxlength - buf->length + 1; result = vswprintf(&buf->contents[buf->length], rest, format, copyap); va_end(copyap); if (0 <= result && result < rest) break; /* According to POSIX, if the buffer is too short, `vswprintf' returns * a negative integer. On some systems, however, it returns a desired * buffer length as `vsprintf' does, which is rather preferable. */ wb_ensuremax(buf, buf->length + (result < 0 ? 2 * rest : result)); } if (result >= 0) buf->length += result; else buf->contents[buf->length] = L'\0'; assert(buf->contents[buf->length] == L'\0'); return result; } /* Appends the result of `swprintf' to the specified buffer. * `format' and the following arguments must not be part of `buf->contents'. * Returns the number of appended characters if successful. * On error, the buffer is not changed and -1 is returned. */ int wb_wprintf(xwcsbuf_T *restrict buf, const wchar_t *restrict format, ...) { va_list ap; int result; va_start(ap, format); result = wb_vwprintf(buf, format, ap); va_end(ap); return result; } /********** Multibyte-Wide Conversion Utilities **********/ /* Converts the specified wide string into a newly malloced multibyte string. * Only the first `n' characters of `s' is converted at most. * Returns NULL on error. * The resulting string starts and ends in the initial shift state.*/ char *malloc_wcsntombs(const wchar_t *s, size_t n) { xstrbuf_T buf; mbstate_t state; sb_init(&buf); memset(&state, 0, sizeof state); // initialize as the initial shift state if (sb_wcsncat(&buf, s, n, &state) == NULL) { return sb_tostr(&buf); } else { sb_destroy(&buf); return NULL; } } /* Converts the specified wide string into a newly malloced multibyte string. * Returns NULL on error. * The resulting string starts and ends in the initial shift state.*/ #if !HAVE_WCSNRTOMBS char *malloc_wcstombs(const wchar_t *s) { xstrbuf_T buf; mbstate_t state; sb_init(&buf); memset(&state, 0, sizeof state); // initialize as the initial shift state if (sb_wcscat(&buf, s, &state) == NULL) { return sb_tostr(&buf); } else { sb_destroy(&buf); return NULL; } } #endif /* Converts the specified multibyte string into a newly malloced wide string. * Returns NULL on error. */ wchar_t *malloc_mbstowcs(const char *s) { xwcsbuf_T buf; wb_init(&buf); if (wb_mbscat(&buf, s) == NULL) { return wb_towcs(&buf); } else { wb_destroy(&buf); return NULL; } } /********** Formatting Utilities **********/ /* Returns the result of `vsprintf' as a newly malloced string. * An error message is printed on error. The return value is non-NULL anyway. */ char *malloc_vprintf(const char *format, va_list ap) { xstrbuf_T buf; sb_init(&buf); if (sb_vprintf(&buf, format, ap) < 0) xerror(errno, Ngt("unexpected error")); return sb_tostr(&buf); } /* Returns the result of `sprintf' as a newly malloced string. * An error message is printed on error. The return value is non-NULL anyway. */ char *malloc_printf(const char *format, ...) { va_list ap; char *result; va_start(ap, format); result = malloc_vprintf(format, ap); va_end(ap); return result; } /* Returns the result of `vswprintf' as a newly malloced string. * An error message is printed on error. The return value is non-NULL anyway. */ wchar_t *malloc_vwprintf(const wchar_t *format, va_list ap) { xwcsbuf_T buf; wb_init(&buf); if (wb_vwprintf(&buf, format, ap) < 0) xerror(errno, Ngt("unexpected error")); return wb_towcs(&buf); } /* Returns the result of `swprintf' as a newly malloced string. * An error message is printed on error. The return value is non-NULL anyway. */ wchar_t *malloc_wprintf(const wchar_t *format, ...) { va_list ap; wchar_t *result; va_start(ap, format); result = malloc_vwprintf(format, ap); va_end(ap); return result; } /********** String Creating Utilities **********/ /* Joins the wide-character strings in the specified NULL-terminated array. The * array elements are considered pointers to wide strings. * If `padding' is non-NULL, `padding' is padded between each joined element. * Returns a newly malloced string. */ wchar_t *joinwcsarray(void *const *array, const wchar_t *padding) { size_t elemcount, ccount = 0; /* count the full length of the resulting string */ for (elemcount = 0; array[elemcount] != NULL; elemcount++) ccount += wcslen(array[elemcount]); if (padding != NULL && elemcount > 0) ccount += wcslen(padding) * (elemcount - 1); /* do copying */ wchar_t *const result = xmallocn(ccount + 1, sizeof *result); wchar_t *s = result; for (size_t i = 0; i < elemcount; i++) { wchar_t *elem = array[i]; while (*elem != L'\0') *s++ = *elem++; if (i + 1 < elemcount) { const wchar_t *pad = padding; while (*pad != L'\0') *s++ = *pad++; } } *s = L'\0'; return result; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/xfnmatch.c0000644000175000017500000005064712154557026014536 0ustar magicantmagicant/* Yash: yet another shell */ /* xfnmatch.c: regex matching wrapper as a replacement for fnmatch */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "xfnmatch.h" #include #include #include #include #include #include #include "strbuf.h" #include "util.h" struct xfnmatch_T { xfnmflags_T flags; union { regex_t regex; xwcsbuf_T literal; } value; }; /* The flags are logical OR of the followings: * XFNM_SHORTEST: do shortest match * XFNM_HEADONLY: only match at the beginning of the string * XFNM_TAILONLY: only match at the end of the string * XFNM_PERIOD: don't match with a string that starts with a period * XFNM_CASEFOLD: ignore case while matching * XFNM_compiled: use `regex' rather than `literal' * When XFNM_SHORTEST is specified, either (but not both) of XFNM_HEADONLY and * XFNM_TAILONLY must be also specified. When XFNM_PERIOD is specified, * XFNM_HEADONLY must be also specified. */ #define XFNM_HEADTAIL (XFNM_HEADONLY | XFNM_TAILONLY) #define MISMATCH ((xfnmresult_T) { (size_t) -1, (size_t) -1, }) static bool is_matching_pattern_bracket(const wchar_t *pat) __attribute__((nonnull,pure)); static xfnmatch_T *try_compile_literal(const wchar_t *pat, xfnmflags_T flags) __attribute__((malloc,warn_unused_result,nonnull)); static xfnmatch_T *try_compile_regex(const wchar_t *pat, xfnmflags_T flags) __attribute__((malloc,warn_unused_result,nonnull)); static void encode_pattern(const wchar_t *restrict pat, xstrbuf_T *restrict buf) __attribute__((nonnull)); static const wchar_t *encode_pattern_bracket(const wchar_t *restrict pat, xstrbuf_T *restrict buf, mbstate_t *restrict state) __attribute__((nonnull)); static const wchar_t *encode_pattern_bracket2(const wchar_t *restrict pat, xstrbuf_T *restrict buf, mbstate_t *restrict state) __attribute__((nonnull)); static void append_as_collating_symbol(wchar_t c, xstrbuf_T *restrict buf, mbstate_t *restrict state) __attribute__((nonnull)); static xfnmresult_T wmatch_literal( const xfnmatch_T *restrict xfnm, const wchar_t *restrict s) __attribute__((nonnull)); static wchar_t *last_wcsstr( const wchar_t *restrict s, const wchar_t *restrict sub) __attribute__((nonnull)); static xfnmresult_T wmatch_headtail( const regex_t *restrict regex, const wchar_t *restrict s) __attribute__((nonnull)); static xfnmresult_T wmatch_shortest_head( const regex_t *restrict regex, const wchar_t *restrict s) __attribute__((nonnull)); static xfnmresult_T wmatch_shortest_tail( const regex_t *restrict regex, const wchar_t *restrict s) __attribute__((nonnull)); static xfnmresult_T wmatch_longest( const regex_t *restrict regex, const wchar_t *restrict s) __attribute__((nonnull)); /* Checks if there is L'*' or L'?' or a bracket expression in the pattern. * If the result is false, the pattern is not a filename expansion pattern. */ /* This function treats L'/' as an ordinary character. */ bool is_matching_pattern(const wchar_t *pat) { for (;;) { switch (*pat) { case L'\0': return false; case L'\\': pat++; if (*pat == L'\0') return false; pat++; break; case L'*': case L'?': return true; case L'[': if (is_matching_pattern_bracket(pat)) return true; /* falls thru! */ default: pat++; break; } } } /* Checks if the specified string is a syntactically valid bracket expression. * The string must start with L'['. * Backslash escapes are recognized in the bracket expression. */ bool is_matching_pattern_bracket(const wchar_t *pat) { assert(*pat == L'['); pat++; const wchar_t *const savepat = pat; for (;;) { switch (*pat) { case L'\0': return false; case L'[': pat++; const wchar_t *p; switch (*pat) { case L'.': p = wcsstr(&pat[1], L".]"); break; case L':': p = wcsstr(&pat[1], L":]"); break; case L'=': p = wcsstr(&pat[1], L"=]"); break; default: continue; } if (p == NULL) return false; pat = &p[2]; continue; case L']': if (pat > savepat) return true; break; case L'\\': pat++; if (*pat == L'\0') return false; break; } pat++; } } /* Checks if there is L'*' or L'?' or a bracket expression in the pattern. * If the result is false, the pattern is not a filename expansion pattern. * If the pattern contains slashes, components separated by the slashes are each * checked by the `is_matching_pattern' function. */ bool is_pathname_matching_pattern(const wchar_t *pat) { const wchar_t *p; while ((p = wcschr(pat, L'/')) != NULL) { wchar_t buf[p - pat + 1]; wmemcpy(buf, pat, p - pat); buf[p - pat] = L'\0'; if (is_matching_pattern(buf)) return true; pat = &p[1]; } return is_matching_pattern(pat); } /* Compiles the specified pattern. * The flags are logical OR of the followings: * XFNM_SHORTEST: do shortest match * XFNM_HEADONLY: only match at the beginning of string * XFNM_TAILONLY: only match at the end of string * XFNM_PERIOD: force explicit match for a period at the beginning * XFNM_CASEFOLD: ignore case while matching * When XFNM_SHORTEST is specified, either (but not both) of XFNM_HEADONLY and * XFNM_TAILONLY must be also specified. When XFNM_PERIOD is specified, * XFNM_HEADONLY must be also specified. * Returns NULL on failure. */ /* Argument `flags' must not contain XFNM_compiled, XFNM_headstar, or * XFNM_tailstar, which are for internal use only */ xfnmatch_T *xfnm_compile(const wchar_t *pat, xfnmflags_T flags) { if (flags & XFNM_SHORTEST) { if (flags & XFNM_HEADONLY) assert(!(flags & XFNM_TAILONLY)); else assert(flags & XFNM_TAILONLY); } if (flags & XFNM_PERIOD) { assert(flags & XFNM_HEADONLY); if (pat[0] == L'.' || pat[0] == L'\\') flags &= ~XFNM_PERIOD; } if (!(flags & XFNM_CASEFOLD)) { xfnmatch_T *result = try_compile_literal(pat, flags); if (result != NULL) return result; } return try_compile_regex(pat, flags); } /* Checks if the specified pattern is a literal pattern and if so compiles it. * If not a literal pattern, NULL is returned. */ xfnmatch_T *try_compile_literal(const wchar_t *pat, xfnmflags_T flags) { xfnmflags_T oldflags = flags; xfnmatch_T *xfnm = xmalloc(sizeof *xfnm); wb_init(&xfnm->value.literal); while (*pat == L'*') { flags &= ~XFNM_HEADONLY; flags |= XFNM_headstar; pat++; } for (;;) { switch (*pat) { case L'\0': goto success; case L'?': goto fail; case L'*': flags &= ~XFNM_TAILONLY; flags |= XFNM_tailstar; do pat++; while (*pat == L'*'); if (*pat == L'\0') goto success; else goto fail; case L'[': if (wcschr(pat + 1, L']')) goto fail; else goto ordinary; case L'\\': pat++; if (*pat == L'\0') goto success; /* falls thru */ default: ordinary: wb_wccat(&xfnm->value.literal, *pat); break; } pat++; } success: if (oldflags & XFNM_SHORTEST) { if (oldflags & XFNM_HEADONLY) flags &= ~XFNM_tailstar; else flags &= ~XFNM_headstar; } xfnm->flags = flags; return xfnm; fail: wb_destroy(&xfnm->value.literal); free(xfnm); return NULL; } /* Compiles the specified pattern. * Returns NULL on error. */ xfnmatch_T *try_compile_regex(const wchar_t *pat, xfnmflags_T flags) { xstrbuf_T buf; sb_init(&buf); if (flags & XFNM_HEADONLY) sb_ccat(&buf, '^'); encode_pattern(pat, &buf); if (flags & XFNM_TAILONLY) sb_ccat(&buf, '$'); xfnmatch_T *xfnm = xmalloc(sizeof *xfnm); xfnm->flags = flags | XFNM_compiled; int regexflags = 0; if (flags & XFNM_CASEFOLD) regexflags |= REG_ICASE; if ((flags & XFNM_HEADTAIL) == XFNM_HEADTAIL) regexflags |= REG_NOSUB; int err = regcomp(&xfnm->value.regex, buf.contents, regexflags); sb_destroy(&buf); if (err != 0) { free(xfnm); xfnm = NULL; } return xfnm; } /* Converts the specified pathname matching pattern into a regex pattern. * The result is appended to `buf', which must be in the initial shift state. * When this function returns, the buffer is reset to the initial shift state.*/ /* A trailing backslash, escaping the terminating null character, is ignored. * This is useful for pathname expansion since, for example, the pattern * "f*o\/b?r" is separated into "f*o\" and "b?r", one of which has a trailing * backslash that should be ignored. */ void encode_pattern(const wchar_t *restrict pat, xstrbuf_T *restrict buf) { mbstate_t state; memset(&state, 0, sizeof state); /* initial shift state */ for (;;) { switch (*pat) { case L'?': sb_wccat(buf, L'.', &state); break; case L'*': sb_wccat(buf, L'.', &state); sb_wccat(buf, L'*', &state); break; case L'[': pat = encode_pattern_bracket(pat, buf, &state); break; case L'\\': switch (*++pat) { case L'.': case L'*': case L'[': case L'^': case L'$': case L'\\': goto escape; default: goto ordinary; } case L'.': case L'^': case L'$': escape: sb_wccat(buf, L'\\', &state); /* falls thru */ default: ordinary: sb_wccat(buf, *pat, &state); if (*pat == L'\0') return; break; } pat++; } } /* Converts the specified bracket pattern of pathname matching pattern into that * of regex. * Backslash escapes are recognized in the original pattern. * Pointer `pat' must point to the opening bracket '['. * If the bracket pattern was successfully converted, a pointer to the closing * bracket ']' is returned. Otherwise, an escaped bracket character '\[' is * appended to `buf' and `pat' is returned. */ const wchar_t *encode_pattern_bracket(const wchar_t *restrict pat, xstrbuf_T *restrict buf, mbstate_t *restrict state) { const wchar_t *const savepat = pat; size_t const savelength = buf->length; mbstate_t const savestate = *state; assert(*pat == L'['); sb_wccat(buf, L'[', state); pat++; if (*pat == L'!' || *pat == L'^') { sb_wccat(buf, L'^', state); pat++; } if (*pat == L']') { sb_wccat(buf, L']', state); pat++; } for (;;) { switch (*pat) { case L'\0': goto fail; case L'[': pat = encode_pattern_bracket2(pat, buf, state); if (pat == NULL) goto fail; break; case L'\\': pat++; switch (*pat) { case L'\0': goto fail; case L'[': case L'^': case L'-': case L']': append_as_collating_symbol(*pat, buf, state); break; default: sb_wccat(buf, *pat, state); break; } break; default: sb_wccat(buf, *pat, state); if (*pat == L']') return pat; break; } pat++; } fail: sb_truncate(buf, savelength); *state = savestate; sb_wccat(buf, L'\\', state); sb_wccat(buf, L'[', state); return savepat; } /* Converts the collating symbol, equivalence class, or character class pattern * that starts with the opening bracket '[' pointed to by `pat'. * If the pattern is successfully converted, a pointer to the corresponding * closing bracket ']' is returned. If `*pat' is not followed by any of '.', ':' * and '=', then a single bracket character is appended to `buf' and `pat' is * returned. If no corresponding closing bracket is found, NULL is returned. */ const wchar_t *encode_pattern_bracket2(const wchar_t *restrict pat, xstrbuf_T *restrict buf, mbstate_t *restrict state) { const wchar_t *p; assert(*pat == L'['); switch (pat[1]) { case L'.': p = wcsstr(&pat[2], L".]"); break; case L':': p = wcsstr(&pat[2], L":]"); break; case L'=': p = wcsstr(&pat[2], L"=]"); break; default: /* not a valid bracket pattern */ sb_wccat(buf, L'[', state); return pat; } if (p == NULL) return NULL; for (;;) { if (*pat == L'\\') pat++; sb_wccat(buf, *pat, state); if (pat > p) break; pat++; } assert(*pat == L']'); return pat; } void append_as_collating_symbol(wchar_t c, xstrbuf_T *restrict buf, mbstate_t *restrict state) { sb_wccat(buf, L'[', state); sb_wccat(buf, L'.', state); sb_wccat(buf, c, state); sb_wccat(buf, L'.', state); sb_wccat(buf, L']', state); } /* Performs matching on string `s' using pre-compiled pattern `xfnm'. * Returns zero on successful match. On mismatch, the error number that was * returned by `regexec' is returned. * This function does not support the XFNM_SHORTEST flag. The given pattern must * have been compiled without the XFNM_SHORTEST flag. */ int xfnm_match(const xfnmatch_T *restrict xfnm, const char *restrict s) { assert(!(xfnm->flags & XFNM_SHORTEST)); if (xfnm->flags & XFNM_PERIOD) if (s[0] == '.') return REG_NOMATCH; if (xfnm->flags & XFNM_compiled) { return regexec(&xfnm->value.regex, s, 0, NULL, 0); } else { wchar_t *ws = malloc_mbstowcs(s); if (ws != NULL) { xfnmresult_T result = xfnm_wmatch(xfnm, ws); free(ws); if (result.start != (size_t) -1) return 0; } return REG_NOMATCH; } } /* Performs matching on string `s' using pre-compiled pattern `xfnm'. * On match, returns an xfnmresult_T structure which shows the character offsets * of the matched range in `s'. On mismatch, returns { -1, -1 }. * If the pattern was compiled with both XFNM_HEADONLY and XFNM_TAILONLY flags * specified, only the `start' member of the returned structure is meaningful * and the `end' member's value is unspecified. */ xfnmresult_T xfnm_wmatch( const xfnmatch_T *restrict xfnm, const wchar_t *restrict s) { xfnmflags_T flags = xfnm->flags; if (flags & XFNM_PERIOD) { if (s[0] == L'.') return MISMATCH; } if (!(flags & XFNM_compiled)) { return wmatch_literal(xfnm, s); } if ((flags & XFNM_HEADTAIL) == XFNM_HEADTAIL) { return wmatch_headtail(&xfnm->value.regex, s); } if (flags & XFNM_SHORTEST) { if (flags & XFNM_HEADONLY) { assert(!(flags & XFNM_TAILONLY)); return wmatch_shortest_head(&xfnm->value.regex, s); } else { assert(flags & XFNM_TAILONLY); return wmatch_shortest_tail(&xfnm->value.regex, s); } } else { return wmatch_longest(&xfnm->value.regex, s); } } /* Performs matching on string `s' using pre-compiled literal pattern `xfnm'. * See the `xfnm_wmatch' function. */ xfnmresult_T wmatch_literal( const xfnmatch_T *restrict xfnm, const wchar_t *restrict s) { if (xfnm->flags & XFNM_HEADONLY) { s = matchwcsprefix(s, xfnm->value.literal.contents); if (s == NULL) return MISMATCH; if ((xfnm->flags & XFNM_TAILONLY) && (*s != L'\0')) return MISMATCH; return (xfnmresult_T) { .start = 0, .end = xfnm->value.literal.length }; } else if (xfnm->flags & XFNM_TAILONLY) { size_t slen = wcslen(s); if (slen < xfnm->value.literal.length) return MISMATCH; size_t index = slen - xfnm->value.literal.length; if (wcscmp(&s[index], xfnm->value.literal.contents) != 0) return MISMATCH; return (xfnmresult_T) { .start = index, .end = slen }; } else { const wchar_t *ss; switch (xfnm->flags & (XFNM_SHORTEST | XFNM_headstar | XFNM_tailstar)) { case XFNM_headstar: case XFNM_SHORTEST | XFNM_tailstar: ss = last_wcsstr(s, xfnm->value.literal.contents); break; default: ss = wcsstr(s, xfnm->value.literal.contents); break; } if (ss == NULL) return MISMATCH; xfnmresult_T result; if (xfnm->flags & XFNM_headstar) result.start = 0; else result.start = ss - s; if (xfnm->flags & XFNM_tailstar) result.end = wcslen(s); else result.end = (size_t) (ss - s) + xfnm->value.literal.length; return result; } } /* Returns a pointer to the substring of `s' where `sub' last appears in `s'. */ wchar_t *last_wcsstr(const wchar_t *restrict s, const wchar_t *restrict sub) { if (sub[0] == L'\0') return (wchar_t *) s + wcslen(s); wchar_t *lastresult = NULL; for (;;) { wchar_t *result = wcsstr(s, sub); if (result == NULL) break; lastresult = result; s = &result[1]; } return lastresult; } xfnmresult_T wmatch_headtail( const regex_t *restrict regex, const wchar_t *restrict s) { char *mbs = malloc_wcstombs(s); if (mbs == NULL) return MISMATCH; int r = regexec(regex, mbs, 0, NULL, 0); free(mbs); return (r == 0) ? ((xfnmresult_T) { .start = 0 }) : MISMATCH; } xfnmresult_T wmatch_shortest_head( const regex_t *restrict regex, const wchar_t *restrict s) { xstrbuf_T buf; mbstate_t state; size_t i; sb_init(&buf); memset(&state, 0, sizeof state); /* initial shift state */ i = 0; for (;;) { if (regexec(regex, buf.contents, 0, NULL, 0) == 0) { /* successful match */ break; } if (s[i] == L'\0') { /* mismatch */ i = (size_t) -1; break; } if (!sb_wccat(&buf, s[i], &state)) { /* error */ i = (size_t) -1; break; } i++; } sb_destroy(&buf); return (xfnmresult_T) { .start = (i == (size_t) -1) ? -1 : 0, .end = i, }; } xfnmresult_T wmatch_shortest_tail( const regex_t *restrict regex, const wchar_t *restrict s) { size_t i = 0; xfnmresult_T result = MISMATCH; for (;;) { xfnmresult_T newresult = wmatch_longest(regex, &s[i]); if (newresult.start == (size_t) -1) break; newresult.start += i; newresult.end += i; result = newresult; if (s[newresult.start] == L'\0') break; i = newresult.start + 1; } return result; } xfnmresult_T wmatch_longest( const regex_t *restrict regex, const wchar_t *restrict s) { char *mbs = malloc_wcstombs(s); if (mbs == NULL) return MISMATCH; regmatch_t match[1]; int r = regexec(regex, mbs, 1, match, 0); if (r != 0) { free(mbs); return MISMATCH; } /* Now convert the byte offsets into the character offsets */ const char *mbs2; mbstate_t state; xfnmresult_T result; memset(&state, 0, sizeof state); /* initial shift state */ mbs[match[0].rm_eo] = '\0'; mbs2 = mbs; result.end = mbsrtowcs(NULL, &mbs2, 0, &state); memset(&state, 0, sizeof state); mbs[match[0].rm_so] = '\0'; mbs2 = mbs; result.start = mbsrtowcs(NULL, &mbs2, 0, &state); if (result.start == (size_t) -1 || result.end == (size_t) -1) result = MISMATCH; free(mbs); return result; } /* Substitutes part of string `s' that matches pre-compiled pattern `xfnm' * with string `repl'. If `substall' is true, all matching substrings in `s' are * substituted. Otherwise, only the first match is substituted. The resulting * string is returned as a newly-malloced string. */ wchar_t *xfnm_subst(const xfnmatch_T *restrict xfnm, const wchar_t *restrict s, const wchar_t *restrict repl, bool substall) { xfnmflags_T flags = xfnm->flags; if ((flags & XFNM_HEADTAIL) == XFNM_HEADTAIL) { xfnmresult_T result; if (flags & XFNM_compiled) result = wmatch_headtail(&xfnm->value.regex, s); else result = wmatch_literal(xfnm, s); return xwcsdup((result.start != (size_t) -1) ? repl : s); } if (flags & XFNM_HEADONLY) substall = false; xwcsbuf_T buf; size_t i = 0; wb_init(&buf); do { xfnmresult_T result = xfnm_wmatch(xfnm, &s[i]); if (result.start == (size_t) -1 || result.start >= result.end) break; wb_ncat(&buf, &s[i], result.start); wb_cat(&buf, repl); i += result.end; } while (substall); return wb_towcs(wb_cat(&buf, &s[i])); } /* Frees the specified compiled pattern. */ void xfnm_free(xfnmatch_T *xfnm) { if (xfnm != NULL) { if (xfnm->flags & XFNM_compiled) regfree(&xfnm->value.regex); else wb_destroy(&xfnm->value.literal); free(xfnm); } } #if YASH_ENABLE_TEST /* Tests if extended regular expression `regex' matches string `s'. */ bool match_regex(const wchar_t *s, const wchar_t *regex) { regex_t compiled_regex; char *mbs_regex = malloc_wcstombs(regex); int err = regcomp(&compiled_regex, mbs_regex, REG_EXTENDED | REG_NOSUB); free(mbs_regex); if (err != 0) return false; char *mbs_s = malloc_wcstombs(s); err = regexec(&compiled_regex, mbs_s, 0, NULL, 0); free(mbs_s); regfree(&compiled_regex); return err == 0; } #endif /* YASH_ENABLE_TEST */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/option.c0000644000175000017500000007346312154557026014237 0ustar magicantmagicant/* Yash: yet another shell */ /* option.c: option settings */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "option.h" #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include "builtin.h" #include "exec.h" #include "job.h" #include "plist.h" #include "redir.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" /********** Option Definitions **********/ /* The value of special parameter $0. */ const wchar_t *command_name; /* If set, the shell behaves strictly as defined in POSIX. * Corresponds to the --posixly-correct option. */ bool posixly_correct = false; /* If set, this shell is a login shell. * Corresponds to the --login option. */ bool is_login_shell = false; /* If set, this shell is interactive. * In subshells, `is_interactive_now' is set to false while `is_interactive' * remains unchanged. * Correspond to the -i/--interactive option. */ bool is_interactive = false, is_interactive_now = false; /* `shopt_cmdline' is set if the shell is executing a command in the command- * line argument to the shell. `shopt_stdin' is set if the shell is reading * commands to execute from the standard input. * Correspond to the -c and -s options respectively. */ bool shopt_cmdline = false, shopt_stdin = false; /* If set, the shell performs job control. * Corresponds to the -m/--monitor option. */ bool do_job_control = false; /* If set, the shell immediately notifies on change of job status. * Corresponds to the -b/--notify option. */ bool shopt_notify = false; #if YASH_ENABLE_LINEEDIT /* If set, the shell immediately notifies on change of job status during line- * editing. Ignored if `shopt_notify' is set. Corresponds to the --notifyle * option. */ bool shopt_notifyle = false; #endif /* If set, a background job is set to the current job when: * - invoked as an asynchronous command * - resumed in the background by the "bg" command * - stopped * respectively. * Correspond to the --curasync, --curbg, --curstop options. */ bool shopt_curasync = true, shopt_curbg = true, shopt_curstop = true; /* If set, any variable is exported when assigned. * Corresponds to the -a/--allexport option. */ bool shopt_allexport = false; /* If set, when a function is defined, all the commands in the function * are hashed. Corresponds to the -h/--hashondef option. */ bool shopt_hashondef = false; /* If set, when a command returns a non-zero status, the shell exits. * Corresponds to the -e/--errexit option. */ bool shopt_errexit = false; /* If set, undefined variables are expanded to an empty string. * Corresponds to the +u/--unset option. */ bool shopt_unset = true; /* If set, commands are actually executed. * Corresponds to the +n/--exec option. */ bool shopt_exec = true; /* If set, the shell doesn't exit when EOF is entered (from a terminal). * Corresponds to the --ignoreeof option. */ bool shopt_ignoreeof = false; /* If set, the shell echos the input to the shell. * Corresponds to the -v/--verbose option. */ bool shopt_verbose = false; /* If set, the shell prints the trace of command execution and assignment. * Corresponds to the -x/--xtrace option. */ bool shopt_xtrace = false; /* If set, the "xtrace" option is not ignored while executing auxiliary * commands. */ bool shopt_traceall = true; /* If set, lines that start with a space are not saved in the history. * Corresponds to the --histspace option. */ bool shopt_histspace = false; /* Function definition commands are saved in the history only when this option * is set. * Corresponds to the --log option. * THIS OPTION IS NOT SUPPORTED. */ static bool shopt_log = true; /* If set, the shell performs filename expansion. * Corresponds to the +f/--glob option. */ bool shopt_glob = true; /* If set, filename expansion is case-sensitive. * Corresponds to the --caseglob option. */ bool shopt_caseglob = true; /* If set, in filename expansion, a wildcard character matches a dot at the * beginning of a filename. * Corresponds to the --dotglob option. */ bool shopt_dotglob = false; /* If set, in filename expansion, a directory name is expanded with a slash * appended. * Corresponds to the --markdirs option. */ bool shopt_markdirs = false; /* If set, extended features in filename expansion are enabled. * Corresponds to the --extendedglob option. */ bool shopt_extendedglob = false; /* If set, a glob pattern is removed from the command line rather than left * intact when there are no matches for it. * Corresponds to the --nullglob option. */ bool shopt_nullglob = false; /* If set, brace expansion is enabled. * Corresponds to the --braceexpand option. */ bool shopt_braceexpand = false; /* If set, it is allowed to overwrite existing files by redirections. * Corresponds to the +C/--clobber option. */ bool shopt_clobber = true; #if YASH_ENABLE_LINEEDIT /* When line-editing is disabled, `shopt_lineedit' is SHOPT_NOLINEEDIT. * When line-editing is enabled, `shopt_lineedit' is set to another value that * specifies the type of key bindings. * `shopt_vi' and `shopt_emacs' correspond to the --vi and --emacs options, * respectively. `shopt_lineedit' is set according to the values of them. */ enum shopt_lineedit_T shopt_lineedit = SHOPT_NOLINEEDIT; static bool shopt_vi = false, shopt_emacs = false; /* `shopt_le_convmeta' defines treatment of the 8th bit of input characters in * line-editing. The value of `shopt_le_convmeta' is set according to those of * `shopt_le_yesconvmeta' and `shopt_le_noconvmeta', which correspond to the * --le-convmeta and --le-noconvmeta options, respectively. */ enum shopt_yesnoauto_T shopt_le_convmeta = SHOPT_AUTO; static bool shopt_le_yesconvmeta = false, shopt_le_noconvmeta = false; /* If set, line-editing uses a flash (instead of a bell) to alert the user. */ bool shopt_le_visiblebell = false; /* If set, a special character sequence is printed when starting line-editing * to make sure the prompt starts at the beginning of line. */ bool shopt_le_promptsp = true; /* If set, the right prompt is always visible on the screen. */ bool shopt_le_alwaysrp = false; /* If set, debugging information is printed during command completion. */ bool shopt_le_compdebug = false; #endif struct option_T { wchar_t shortopt_enable, shortopt_disable; const wchar_t *longopt; bool *optp; bool resettable; }; /* List of the shell options. */ static const struct option_T shell_options[] = { { L'a', 0, L"allexport", &shopt_allexport, true, }, { 0, 0, L"braceexpand", &shopt_braceexpand, true, }, { 0, 0, L"caseglob", &shopt_caseglob, true, }, { 0, L'C', L"clobber", &shopt_clobber, true, }, { L'c', 0, L"cmdline", &shopt_cmdline, false, }, { 0, 0, L"curasync", &shopt_curasync, true, }, { 0, 0, L"curbg", &shopt_curbg, true, }, { 0, 0, L"curstop", &shopt_curstop, true, }, { 0, 0, L"dotglob", &shopt_dotglob, true, }, #if YASH_ENABLE_LINEEDIT { 0, 0, L"emacs", &shopt_emacs, true, }, #endif { L'e', 0, L"errexit", &shopt_errexit, true, }, { 0, L'n', L"exec", &shopt_exec, true, }, { 0, 0, L"extendedglob", &shopt_extendedglob, true, }, { 0, L'f', L"glob", &shopt_glob, true, }, { L'h', 0, L"hashondef", &shopt_hashondef, true, }, { 0, 0, L"histspace", &shopt_histspace, true, }, { 0, 0, L"ignoreeof", &shopt_ignoreeof, true, }, { L'i', 0, L"interactive", &is_interactive, false, }, #if YASH_ENABLE_LINEEDIT { 0, 0, L"lealwaysrp", &shopt_le_alwaysrp, true, }, { 0, 0, L"lecompdebug", &shopt_le_compdebug, true, }, { 0, 0, L"leconvmeta", &shopt_le_yesconvmeta, true, }, { 0, 0, L"lenoconvmeta", &shopt_le_noconvmeta, true, }, { 0, 0, L"lepromptsp", &shopt_le_promptsp, true, }, { 0, 0, L"levisiblebell", &shopt_le_visiblebell, true, }, #endif { 0, 0, L"log", &shopt_log, true, }, { L'l', 0, L"login", &is_login_shell, false, }, { 0, 0, L"markdirs", &shopt_markdirs, true, }, { L'm', 0, L"monitor", &do_job_control, true, }, { L'b', 0, L"notify", &shopt_notify, true, }, #if YASH_ENABLE_LINEEDIT { 0, 0, L"notifyle", &shopt_notifyle, true, }, #endif { 0, 0, L"nullglob", &shopt_nullglob, true, }, { 0, 0, L"posixlycorrect", &posixly_correct, true, }, { L's', 0, L"stdin", &shopt_stdin, false, }, { 0, 0, L"traceall", &shopt_traceall, true, }, { 0, L'u', L"unset", &shopt_unset, true, }, { L'v', 0, L"verbose", &shopt_verbose, true, }, #if YASH_ENABLE_LINEEDIT { 0, 0, L"vi", &shopt_vi, true, }, #endif { L'x', 0, L"xtrace", &shopt_xtrace, true, }, { 0, 0, NULL, NULL, false, }, }; enum normal_option_index_T { #if YASH_ENABLE_HELP NOI_HELP, #endif NOI_VERSION, NOI_NOPROFILE, NOI_NORCFILE, NOI_PROFILE, NOI_RCFILE, NOI_N, }; /* List of the normal options. * The normal options are the options that can be used on the shell invocation * but that are not shell options. */ /* A non-NULL `ptr' member indicates that the option can be used for the "set" * built-in. */ static const struct xgetopt_T normal_options[] = { #if YASH_ENABLE_HELP [NOI_HELP] = { L'-', L"help", OPTARG_NONE, false, &normal_options, }, #endif [NOI_VERSION] = { L'V', L"version", OPTARG_NONE, false, NULL, }, [NOI_NOPROFILE] = { L'-', L"noprofile", OPTARG_NONE, false, NULL, }, [NOI_NORCFILE] = { L'-', L"norcfile", OPTARG_NONE, false, NULL, }, [NOI_PROFILE] = { L'-', L"profile", OPTARG_REQUIRED, false, NULL, }, [NOI_RCFILE] = { L'-', L"rcfile", OPTARG_REQUIRED, false, NULL, }, [NOI_N] = { L'\0', NULL, 0, false, NULL, }, }; /********** Functions **********/ static wchar_t *normalize_option_name(const wchar_t *optname) __attribute__((nonnull,malloc,warn_unused_result)); static int parse_short_option(void *const *argv, bool enable, struct shell_invocation_T *shell_invocation) __attribute__((nonnull(1))); static int parse_option_character( wchar_t opt, bool enable, struct shell_invocation_T *shell_invocation); static int parse_long_option(void *const *argv, bool enable, struct shell_invocation_T *shell_invocation) __attribute__((nonnull(1))); static size_t collect_matching_shell_options( const wchar_t *optstr, plist_T *options) __attribute__((nonnull)); static void search_shell_options(const wchar_t *optname, plist_T *resultlist) __attribute__((nonnull)); static void search_normal_options(const wchar_t *optname, plist_T *resultlist, const struct shell_invocation_T *shell_invocation) __attribute__((nonnull(1,2))); static int handle_search_result(plist_T *options, void *const *argv, bool enable, size_t shelloptindex, size_t noshelloptindex, struct shell_invocation_T *shell_invocation) __attribute__((nonnull)); static int set_shell_option(const struct option_T *option, bool enable, struct shell_invocation_T *shell_invocation) __attribute__((nonnull(1))); #if YASH_ENABLE_LINEEDIT static void update_lineedit_option(void); static void update_le_convmeta_option(void); #endif static int set_normal_option(const struct xgetopt_T *opt, const wchar_t *arg, struct shell_invocation_T *shell_invocation) __attribute__((nonnull(1))); #if YASH_ENABLE_TEST static struct option_T *find_option_unique(const wchar_t *s) __attribute__((nonnull,pure)); #endif /* Parses the specified command line arguments and accordingly sets the shell * options and positional parameters. * When this function is called from the `main' function of the shell, * `shell_invocation' must be a pointer to a structure to which parse result is * stored. Otherwise, that is, when called from the set built-in, * `shell_invocation' must be NULL. * Positional parameters are set only when `shell_invocation' is NULL. * `xoptind' is set to the index of the first operand. * Returns Exit_SUCCESS if successful. Otherwise, returns Exit_FAILURE or * Exit_ERROR after printing an error message. */ int parse_shell_options(int argc, void *const *argv, struct shell_invocation_T *shell_invocation) { /* We don't use the xgetopt function because of the non-standard syntax. */ for (xoptind = 1; xoptind < argc; xoptind++) { const wchar_t *arg = ARGV(xoptind); bool enable; switch (arg[0]) { case L'-': enable = true; break; case L'+': enable = false; break; default: goto main; } if (arg[1] == L'\0') { if (enable && shell_invocation != NULL) /* ignore first "-" */ xoptind++; goto main; } int result; if (arg[0] == arg[1]) { if (arg[2] == L'\0') { if (enable) /* `arg' is L"--" */ xoptind++; goto set_positional_parameters; } result = parse_long_option(argv, enable, shell_invocation); } else { result = parse_short_option(argv, enable, shell_invocation); } if (result != Exit_SUCCESS) return result; } main: if (xoptind < argc) { set_positional_parameters: assert(xoptind <= argc); if (shell_invocation == NULL) set_positional_parameters(&argv[xoptind]); } return Exit_SUCCESS; } /* Returns a newly malloced string containing the same string as the argument * string except that the returned string does not contain non-alphanumeric * characters. */ wchar_t *normalize_option_name(const wchar_t *optname) { xwcsbuf_T result; wb_init(&result); for (const wchar_t *s = optname; *s != L'\0'; s++) if (iswalnum(*s)) wb_wccat(&result, towlower(*s)); return wb_towcs(&result); } /* Parses the single-character option at `xoptind' in the specified arguments * and enables/disables the option. * Returns Exit_SUCCESS iff successful. Prints an error message on error. */ int parse_short_option(void *const *argv, bool enable, struct shell_invocation_T *shell_invocation) { const wchar_t *optstr = ARGV(xoptind); assert(optstr[0] != L'\0'); for (size_t i = 1; optstr[i] != L'\0'; i++) { if (optstr[i] == L'o') { const wchar_t *optname = &optstr[i + 1]; if (*optname == L'\0') { optname = ARGV(++xoptind);; if (optname == NULL) { xerror(0, Ngt("the -%lc option requires an argument"), (wint_t) L'o'); return special_builtin_syntax_error(Exit_ERROR); } } plist_T options; pl_init(&options); size_t shelloptindex = collect_matching_shell_options(optname, &options); return handle_search_result(&options, argv, enable, shelloptindex, options.length, shell_invocation); } else { int result = parse_option_character( optstr[i], enable, shell_invocation); if (result != Exit_SUCCESS) return result; } } return Exit_SUCCESS; } /* Parses the specified single-character option and enables/disables the option. * Returns Exit_SUCCESS iff successful. Prints an error message on error. */ int parse_option_character( wchar_t opt, bool enable, struct shell_invocation_T *shell_invocation) { assert(opt != L'\0'); for (const struct option_T *o = shell_options; o->longopt != NULL; o++) { if (opt == o->shortopt_enable) return set_shell_option(o, enable, shell_invocation); else if (opt == o->shortopt_disable) return set_shell_option(o, !enable, shell_invocation); } if (opt != L'-') { const struct xgetopt_T *o; for (o = normal_options; o->shortopt != L'\0'; o++) { if (!o->posix && posixly_correct) continue; if (opt == o->shortopt && (shell_invocation != NULL || o->ptr != NULL)) return set_normal_option(o, NULL, shell_invocation); } } xerror(0, Ngt("`%ls' is not a valid option"), (wchar_t[]) { opt, L'\0' }); return special_builtin_syntax_error(Exit_ERROR); } /* Parses the long option at `xoptind' in the specified arguments and * enables/disables the option. * Returns Exit_SUCCESS iff successful. Prints an error message on error. */ int parse_long_option(void *const *argv, bool enable, struct shell_invocation_T *shell_invocation) { const wchar_t *optstr = ARGV(xoptind); plist_T options; size_t shelloptindex, noshelloptindex; pl_init(&options); if (posixly_correct) { /* No long options are available in the POSIXly correct mode. */ shelloptindex = noshelloptindex = 0; } else { shelloptindex = collect_matching_shell_options(optstr, &options); noshelloptindex = options.length; if (enable) { assert(matchwcsprefix(optstr, L"--")); search_normal_options(&optstr[2], &options, shell_invocation); } } return handle_search_result(&options, argv, enable, shelloptindex, noshelloptindex, shell_invocation); } /* Collects shell options that match the specified name. * This function adds to `options' pointers to shell options (struct option_T) * whose names start with `optname'. * If `optname' starts with "no", options whose names start with `optname' * without "no" are also added. The index of the first such option is returned. */ size_t collect_matching_shell_options(const wchar_t *optname, plist_T *options) { wchar_t *normoptname = normalize_option_name(optname); search_shell_options(normoptname, options); size_t nooptindex = options->length; if (matchwcsprefix(normoptname, L"no")) search_shell_options(&normoptname[2], options); free(normoptname); return nooptindex; } /* Adds pointers to shell options (struct option_T) whose names match `optname' * to the specified list. * If `optname' exactly matches one of the shell option names, `resultlist' is * cleared and only a pointer to that option is added. */ void search_shell_options(const wchar_t *optname, plist_T *resultlist) { for (const struct option_T *o = shell_options; o->longopt != NULL; o++) { const wchar_t *s = matchwcsprefix(o->longopt, optname); if (s != NULL) { if (*s == L'\0') { /* exact match! */ pl_clear(resultlist, 0); pl_add(resultlist, o); break; } else { /* partial match */ pl_add(resultlist, o); } } } } /* Adds to `resultlist' pointers to shell options (struct option_T) whose names * match `optname'. * If `optname' exactly matches one of shell option names, `resultlist' is * cleared and only a pointer to that option is added. */ void search_normal_options(const wchar_t *optname, plist_T *resultlist, const struct shell_invocation_T *shell_invocation) { size_t namelen = wcscspn(optname, L"="); for (const struct xgetopt_T *o = normal_options; o->longopt != NULL; o++) { if (!o->posix && posixly_correct) continue; if (wcsncmp(o->longopt, optname, namelen) == 0 && (shell_invocation != NULL || o->ptr != NULL)) { if (o->longopt[namelen] == L'\0') { /* exact match! */ pl_clear(resultlist, 0); pl_add(resultlist, o); break; } else { /* partial match */ pl_add(resultlist, o); } } } } /* Handles the result of option search. * List `options' must contain pointers to options (struct option_T/xgetopt_T) * that match the currently parsed option name. List members with indices less * than `noshelloptindex' are pointers to shell options (struct option_T) and * the others to normal options (struct xgetopt_T). Inverting shell options, * which have the "no" prefix in their names, must have indices no less than * `shelloptindex'. The list is destroyed in this function. */ int handle_search_result(plist_T *options, void *const *argv, bool enable, size_t shelloptindex, size_t noshelloptindex, struct shell_invocation_T *shell_invocation) { assert(shelloptindex <= noshelloptindex); assert(noshelloptindex <= options->length); const wchar_t *optstr = ARGV(xoptind); switch (options->length) { case 0: pl_destroy(options); xerror(0, Ngt("`%ls' is not a valid option"), optstr); return special_builtin_syntax_error(Exit_ERROR); case 1: if (noshelloptindex > 0) { const struct option_T *opt = options->contents[0]; pl_destroy(options); if (shelloptindex == 0) enable = !enable; return set_shell_option(opt, enable, shell_invocation); } else { const struct xgetopt_T *opt = options->contents[0]; const wchar_t *eq = wcschr(optstr, L'='); const wchar_t *optarg; pl_destroy(options); if (opt->optarg != OPTARG_NONE) { if (eq == NULL) { switch (opt->optarg) { case OPTARG_OPTIONAL: optarg = NULL; break; case OPTARG_REQUIRED: optarg = ARGV(++xoptind); if (optarg == NULL) { xerror(0, Ngt("the --%ls option requires " "an argument"), opt->longopt); return special_builtin_syntax_error( Exit_ERROR); } break; default: assert(false); } } else { optarg = &eq[1]; } } else { if (eq != NULL) { xerror(0, Ngt("%ls: the --%ls option does not take " "an argument"), optstr, opt->longopt); return special_builtin_syntax_error(Exit_ERROR); } optarg = NULL; } return set_normal_option(opt, optarg, shell_invocation); } default: xerror(0, Ngt("option `%ls' is ambiguous"), optstr); #if LIST_AMBIGUOUS_OPTIONS size_t i = 0; for (; i < shelloptindex; i++) fprintf(stderr, "\t--%ls\n", ((const struct option_T *) options->contents[i])->longopt); for (; i < noshelloptindex; i++) fprintf(stderr, "\t--no%ls\n", ((const struct option_T *) options->contents[i])->longopt); for (; i < options->length; i++) fprintf(stderr, "\t--%ls\n", ((const struct xgetopt_T *) options->contents[i])->longopt); #endif pl_destroy(options); return special_builtin_syntax_error(Exit_ERROR); } } /* Sets the specified shell option. * Returns Exit_SUCCESS iff successful. Print an error message on error. */ int set_shell_option(const struct option_T *option, bool enable, struct shell_invocation_T *shell_invocation) { if (shell_invocation == NULL && !option->resettable) { xerror(0, Ngt("the %ls option cannot be changed " "once the shell has been initialized"), option->longopt); return special_builtin_syntax_error(Exit_ERROR); } *option->optp = enable; if (shell_invocation != NULL) { if (option->optp == &is_interactive) shell_invocation->is_interactive_set = true; else if (option->optp == &do_job_control) shell_invocation->do_job_control_set = true; } if (shell_invocation == NULL && option->optp == &do_job_control) { if (do_job_control && ttyfd < 0) open_ttyfd(); if (do_job_control) ensure_foreground(); reset_job_signals(); } #if YASH_ENABLE_LINEEDIT if (option->optp == &shopt_vi) { if (enable) shopt_emacs = false; update_lineedit_option(); if (shell_invocation != NULL) shell_invocation->lineedit_set = true; } else if (option->optp == &shopt_emacs) { if (enable) shopt_vi = false; update_lineedit_option(); if (shell_invocation != NULL) shell_invocation->lineedit_set = true; } else if (option->optp == &shopt_le_yesconvmeta) { if (enable) shopt_le_noconvmeta = false; update_le_convmeta_option(); } else if (option->optp == &shopt_le_noconvmeta) { if (enable) shopt_le_yesconvmeta = false; update_le_convmeta_option(); } #endif return (*option->optp == enable) ? Exit_SUCCESS : Exit_FAILURE; } #if YASH_ENABLE_LINEEDIT /* Updates the value of `shopt_lineedit' according to the values of `shopt_vi' * and `shopt_emacs'. */ void update_lineedit_option(void) { if (shopt_vi) shopt_lineedit = SHOPT_VI; else if (shopt_emacs) shopt_lineedit = SHOPT_EMACS; else shopt_lineedit = SHOPT_NOLINEEDIT; } /* Updates the value of `shopt_le_convmeta' according to the values of * `shopt_le_yesconvmeta' and `shopt_le_noconvmeta'. */ void update_le_convmeta_option(void) { if (shopt_le_yesconvmeta) shopt_le_convmeta = SHOPT_YES; else if (shopt_le_noconvmeta) shopt_le_convmeta = SHOPT_NO; else shopt_le_convmeta = SHOPT_AUTO; } #endif /* Sets the specified normal option. * Returns Exit_SUCCESS iff successful. Print an error message on error. */ int set_normal_option(const struct xgetopt_T *opt, const wchar_t *arg, struct shell_invocation_T *shell_invocation) { enum normal_option_index_T index = opt - normal_options; if (shell_invocation == NULL) { switch (index) { #if YASH_ENABLE_HELP case NOI_HELP: return print_builtin_help(L"set"); #endif default: assert(false); } } else { switch (index) { #if YASH_ENABLE_HELP case NOI_HELP: shell_invocation->help = true; break; #endif case NOI_VERSION: shell_invocation->version = true; break; case NOI_NOPROFILE: shell_invocation->noprofile = true; break; case NOI_NORCFILE: shell_invocation->norcfile = true; break; case NOI_PROFILE: assert(arg != NULL); shell_invocation->profile = arg; break; case NOI_RCFILE: assert(arg != NULL); shell_invocation->rcfile = arg; break; case NOI_N: assert(false); } } return Exit_SUCCESS; } #if YASH_ENABLE_LINEEDIT /* Sets the line-editing option to the specified value. */ void set_lineedit_option(enum shopt_lineedit_T v) { shopt_vi = shopt_emacs = false; shopt_lineedit = v; switch (v) { case SHOPT_VI: shopt_vi = true; break; case SHOPT_EMACS: shopt_emacs = true; break; case SHOPT_NOLINEEDIT: break; } } #endif #if YASH_ENABLE_TEST /* Returns true iff the specified string is a valid option name that can be used * as the argument to the "-o" option. */ bool is_valid_option_name(const wchar_t *s) { return find_option_unique(s) != NULL; } /* Returns true iff the specified string is a valid option name that can be used * as the argument to the "-o" option and the option is enabled. */ bool option_is_enabled(const wchar_t *s) { struct option_T *opt = find_option_unique(s); return opt != NULL && *opt->optp; } /* If the specified string is a valid option name that can be used as the * argument to the "-o" option, then returns the option. Otherwise, NULL is * returned. */ struct option_T *find_option_unique(const wchar_t *s) { plist_T options; pl_init(&options); collect_matching_shell_options(s, &options); struct option_T *opt = (options.length == 1) ? options.contents[0] : NULL; pl_destroy(&options); return opt; } #endif /* YASH_ENABLE_TEST */ /* Returns the current value of special parameter $- as a newly malloced string. */ wchar_t *get_hyphen_parameter(void) { xwcsbuf_T buf; wb_init(&buf); for (const struct option_T *o = shell_options; o->longopt != NULL; o++) { if (o->shortopt_enable != L'\0' && *o->optp) wb_wccat(&buf, o->shortopt_enable); if (o->shortopt_disable != L'\0' && !*o->optp) wb_wccat(&buf, o->shortopt_disable); } return wb_towcs(&buf); } #if YASH_ENABLE_HELP /* Prints a list of all shell options to the standard output. * Returns true iff successful. */ bool print_shopts_body(bool include_normal_options) { if (include_normal_options) if (!print_option_list(normal_options)) return false; for (const struct option_T *o = shell_options; o->longopt != NULL; o++) { if (!xprintf("\t")) return false; if (o->shortopt_enable != L'\0') { if (!xprintf("-%lc", o->shortopt_enable)) return false; } else if (o->shortopt_disable != L'\0') { if (!xprintf("+%lc", o->shortopt_disable)) return false; } else { if (!xprintf(" ")) return false; } if (!xprintf(" -o %ls\n", o->longopt)) return false; } return true; } #endif /* YASH_ENABLE_HELP */ /********** Built-in **********/ const struct xgetopt_T all_help_options[] = { { L'a', L"all", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* Note: `help_option' is defined as (&all_help_options[1]). */ static int set_builtin_print_current_settings(void); static int set_builtin_print_restoring_commands(void); /* The "set" built-in. */ int set_builtin(int argc, void **argv) { if (argc <= 1) { return typeset_builtin(argc, argv); } else if (argc == 2) { if (wcscmp(ARGV(1), L"-o") == 0) return set_builtin_print_current_settings(); else if (wcscmp(ARGV(1), L"+o") == 0) return set_builtin_print_restoring_commands(); } return parse_shell_options(argc, argv, NULL); } int set_builtin_print_current_settings(void) { const char *vals[] = { [true] = gt("on"), [false] = gt("off"), }; for (const struct option_T *o = shell_options; o->longopt != NULL; o++) { if (!xprintf("%-15ls %s\n", o->longopt, vals[(bool) *o->optp])) return Exit_FAILURE; } return Exit_SUCCESS; } int set_builtin_print_restoring_commands(void) { for (const struct option_T *o = shell_options; o->longopt != NULL; o++) { if (o->resettable) if (!xprintf("set %co %ls\n", *o->optp ? '-' : '+', o->longopt)) return Exit_FAILURE; } return Exit_SUCCESS; } #if YASH_ENABLE_HELP const char set_help[] = Ngt( "set shell options and positional parameters" ); const char set_syntax[] = Ngt( "\tset [option...] [--] [new_positional_parameter...]\n" "\tset -o|+o # print current settings\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/option.h0000644000175000017500000000613612154557026014235 0ustar magicantmagicant/* Yash: yet another shell */ /* option.h: option settings */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_OPTION_H #define YASH_OPTION_H #include #include "xgetopt.h" enum shopt_lineedit_T { SHOPT_NOLINEEDIT, SHOPT_VI, SHOPT_EMACS, }; enum shopt_yesnoauto_T { SHOPT_YES, SHOPT_NO, SHOPT_AUTO, }; extern const wchar_t *command_name; extern _Bool posixly_correct; extern _Bool is_login_shell; extern _Bool is_interactive, is_interactive_now; extern _Bool shopt_cmdline, shopt_stdin; extern _Bool do_job_control, shopt_notify, shopt_notifyle, shopt_curasync, shopt_curbg, shopt_curstop; extern _Bool shopt_allexport, shopt_hashondef; extern _Bool shopt_errexit, shopt_unset, shopt_exec, shopt_ignoreeof, shopt_verbose, shopt_xtrace; extern _Bool shopt_traceall; extern _Bool shopt_histspace; extern _Bool shopt_glob, shopt_caseglob, shopt_dotglob, shopt_markdirs, shopt_extendedglob, shopt_nullglob; extern _Bool shopt_braceexpand; extern _Bool shopt_clobber; #if YASH_ENABLE_LINEEDIT extern enum shopt_lineedit_T shopt_lineedit; extern enum shopt_yesnoauto_T shopt_le_convmeta; extern _Bool shopt_le_visiblebell, shopt_le_promptsp, shopt_le_alwaysrp, shopt_le_compdebug; #endif /* Whether or not this shell process is doing job control right now. */ #define doing_job_control_now (do_job_control && ttyfd >= 0) struct shell_invocation_T { _Bool help, version; _Bool noprofile, norcfile; const wchar_t *profile, *rcfile; _Bool is_interactive_set, do_job_control_set, lineedit_set; }; extern int parse_shell_options(int argc, void *const *argv, struct shell_invocation_T *shell_invocation) __attribute__((nonnull(2),warn_unused_result)); #if YASH_ENABLE_LINEEDIT extern void set_lineedit_option(enum shopt_lineedit_T v); #endif extern wchar_t *get_hyphen_parameter(void) __attribute__((malloc,warn_unused_result)); #if YASH_ENABLE_TEST extern _Bool is_valid_option_name(const wchar_t *s) __attribute__((nonnull,pure)); extern _Bool option_is_enabled(const wchar_t *s) __attribute__((nonnull,pure)); #endif #if YASH_ENABLE_HELP extern _Bool print_shopts_body(_Bool include_normal_options); #endif extern const struct xgetopt_T all_help_options[]; #define help_option (&all_help_options[1]) extern int set_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char set_help[], set_syntax[]; #endif #endif /* YASH_OPTION_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/exec.h0000644000175000017500000001012712154557026013644 0ustar magicantmagicant/* Yash: yet another shell */ /* exec.h: command execution */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_EXEC_H #define YASH_EXEC_H #include #include #include "xgetopt.h" /* options for `fork_and_reset' */ typedef enum sigtype_T { t_quitint = 1 << 0, t_tstp = 1 << 1, t_leave = 1 << 2, } sigtype_T; #define Exit_SUCCESS 0 #define Exit_FAILURE 1 #define Exit_ERROR 2 #define Exit_NOEXEC 126 #define Exit_NOTFOUND 127 #define Exit_SYNERROR (256 + Exit_ERROR) #define Exit_EXPERROR Exit_ERROR #define Exit_ASSGNERR Exit_ERROR #define Exit_REDIRERR Exit_ERROR extern int laststatus, savelaststatus; extern pid_t lastasyncpid; extern _Bool special_builtin_executed; extern _Bool is_executing_auxiliary; struct execstate_T; extern void reset_execstate(void); extern struct execstate_T *save_execstate(void) __attribute__((malloc,warn_unused_result)); extern void restore_execstate(struct execstate_T *save) __attribute__((nonnull)); extern void disable_return(void); extern void cancel_return(void); extern _Bool need_break(void) __attribute__((pure)); struct and_or_T; struct embedcmd_T; extern void exec_and_or_lists(const struct and_or_T *a, _Bool finally_exit); extern pid_t fork_and_reset(pid_t pgid, _Bool fg, sigtype_T sigtype); extern struct xwcsbuf_T *get_xtrace_buffer(void); extern wchar_t *exec_command_substitution(const struct embedcmd_T *cmdsub) __attribute__((nonnull,malloc,warn_unused_result)); extern int exec_variable_as_commands( const wchar_t *varname, const char *codename) __attribute__((nonnull)); extern int exec_variable_as_auxiliary( const wchar_t *varname, const char *codename) __attribute__((nonnull)); #define exec_variable_as_auxiliary_(varname) \ exec_variable_as_auxiliary(L varname, "$" varname) #if YASH_ENABLE_LINEEDIT extern _Bool autoload_completion_function_file( const wchar_t *filename, const wchar_t *cmdname) __attribute__((nonnull(1))); extern _Bool call_completion_function(const wchar_t *funcname) __attribute__((nonnull)); #endif extern const struct xgetopt_T iter_options[]; extern int return_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char return_help[], return_syntax[]; #endif extern const struct xgetopt_T return_options[]; extern int break_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char break_help[], break_syntax[], continue_help[], continue_syntax[]; #endif extern int eval_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char eval_help[], eval_syntax[]; #endif extern int dot_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char dot_help[], dot_syntax[]; #endif extern const struct xgetopt_T dot_options[]; extern int exec_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char exec_help[], exec_syntax[]; #endif extern const struct xgetopt_T exec_options[]; extern int command_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char command_help[], command_syntax[], type_help[], type_syntax[]; #endif extern const struct xgetopt_T command_options[]; extern int times_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char times_help[], times_syntax[]; #endif #endif /* YASH_EXEC_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/parser.h0000644000175000017500000003173212154557026014221 0ustar magicantmagicant/* Yash: yet another shell */ /* parser.h: syntax parser */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* Limitation: Don't include "parser.h" and at a time * because identifiers prefixed "c_" conflict. */ #ifndef YASH_PARSER_H #define YASH_PARSER_H #include #include "input.h" /********** Parse Tree Structures **********/ /* Basically, parse tree structure elements constitute linked lists. * For each element, the `next' member points to the next element. */ /* and/or list */ typedef struct and_or_T { struct and_or_T *next; struct pipeline_T *ao_pipelines; /* pipelines in this and/or list */ _Bool ao_async; } and_or_T; /* ao_async: indicates this and/or list is postfixed by "&", which means the * list is executed asynchronously. */ /* pipeline */ typedef struct pipeline_T { struct pipeline_T *next; struct command_T *pl_commands; /* commands in this pipeline */ _Bool pl_neg, pl_cond; } pipeline_T; /* pl_neg: indicates this pipeline is prefix by "!", in which case the exit * status of the pipeline is inverted. * pl_cond: true if prefixed by "&&", false by "||". Ignored for the first * pipeline in an and/or list. */ /* type of command_T */ typedef enum { CT_SIMPLE, /* simple command */ CT_GROUP, /* command group enclosed by { } */ CT_SUBSHELL, /* subshell command group enclosed by ( ) */ CT_IF, /* if command */ CT_FOR, /* for command */ CT_WHILE, /* while/until command */ CT_CASE, /* case command */ CT_FUNCDEF, /* function definition */ } commandtype_T; /* command in a pipeline */ typedef struct command_T { struct command_T *next; unsigned refcount; /* reference count */ commandtype_T c_type; unsigned long c_lineno; /* line number */ struct redir_T *c_redirs; /* redirections */ union { struct { struct assign_T *assigns; /* assignments */ void **words; /* command name and arguments */ } simplecommand; struct and_or_T *subcmds; /* contents of command group */ struct ifcommand_T *ifcmds; /* contents of if command */ struct { wchar_t *forname; /* loop variable of for loop */ void **forwords; /* words assigned to loop variable */ struct and_or_T *forcmds; /* commands executed in for loop */ } forloop; struct { _Bool whltype; /* 1 for while loop, 0 for until */ struct and_or_T *whlcond; /* loop condition of while/until loop */ struct and_or_T *whlcmds; /* commands executed in loop */ } whileloop; struct { struct wordunit_T *casword; /* word compared to case patterns */ struct caseitem_T *casitems; /* pairs of patterns and commands */ } casecommand; struct { struct wordunit_T *funcname; /* name of function */ struct command_T *funcbody; /* body of function */ } funcdef; } c_content; } command_T; #define c_assigns c_content.simplecommand.assigns #define c_words c_content.simplecommand.words #define c_subcmds c_content.subcmds #define c_ifcmds c_content.ifcmds #define c_forname c_content.forloop.forname #define c_forwords c_content.forloop.forwords #define c_forcmds c_content.forloop.forcmds #define c_whltype c_content.whileloop.whltype #define c_whlcond c_content.whileloop.whlcond #define c_whlcmds c_content.whileloop.whlcmds #define c_casword c_content.casecommand.casword #define c_casitems c_content.casecommand.casitems #define c_funcname c_content.funcdef.funcname #define c_funcbody c_content.funcdef.funcbody /* `c_words' and `c_forwords' are NULL-terminated arrays of pointers to * `wordunit_T' that are cast to `void *'. * If `c_forwords' is NULL, the for loop doesn't have the "in" clause. * If `c_forwords[0]' is NULL, the "in" clause exists and is empty. */ /* condition and commands of an if command */ typedef struct ifcommand_T { struct ifcommand_T *next; struct and_or_T *ic_condition; /* condition */ struct and_or_T *ic_commands; /* commands */ } ifcommand_T; /* For an "else" clause, `next' and `ic_condition' are NULL. */ /* patterns and commands of a case command */ typedef struct caseitem_T { struct caseitem_T *next; void **ci_patterns; /* patterns to do matching */ struct and_or_T *ci_commands; /* commands executed if match succeeds */ } caseitem_T; /* `ci_patterns' is a NULL-terminated array of pointers to `wordunit_T' that are * cast to `void *'. */ /* embedded command */ typedef struct embedcmd_T { _Bool is_preparsed; union { wchar_t *unparsed; struct and_or_T *preparsed; } value; } embedcmd_T; /* type of wordunit_T */ typedef enum { WT_STRING, /* string (including quotes) */ WT_PARAM, /* parameter expansion */ WT_CMDSUB, /* command substitution */ WT_ARITH, /* arithmetic expansion */ } wordunittype_T; /* element of a word subject to expansion */ typedef struct wordunit_T { struct wordunit_T *next; wordunittype_T wu_type; union { wchar_t *string; /* string (including quotes) */ struct paramexp_T *param; /* parameter expansion */ struct embedcmd_T cmdsub; /* command substitution */ struct wordunit_T *arith; /* expression for arithmetic expansion */ } wu_value; } wordunit_T; #define wu_string wu_value.string #define wu_param wu_value.param #define wu_cmdsub wu_value.cmdsub #define wu_arith wu_value.arith /* In arithmetic expansion, the expression is subject to parameter expansion * before it is parsed. So `wu_arith' is of type `wordunit_T *'. */ /* type of paramexp_T */ typedef enum { PT_NONE, /* normal */ PT_MINUS, /* ${name-subst} */ PT_PLUS, /* ${name+subst} */ PT_ASSIGN, /* ${name=subst} */ PT_ERROR, /* ${name?subst} */ PT_MATCH, /* ${name#match}, ${name%match} */ PT_SUBST, /* ${name/match/subst} */ PT_MASK = (1 << 3) - 1, PT_NUMBER = 1 << 3, /* ${#name} (only valid for PT_NONE) */ PT_COLON = 1 << 4, /* ${name:-subst}, ${name:+subst}, etc. */ PT_MATCHHEAD = 1 << 5, /* only matches at the beginning of a string */ PT_MATCHTAIL = 1 << 6, /* only matches at the end of a string */ PT_MATCHLONGEST = 1 << 7, /* match as long as possible */ PT_SUBSTALL = 1 << 8, /* substitute all the match */ PT_NEST = 1 << 9, /* have nested expn. like ${${VAR#foo}%bar} */ } paramexptype_T; /* type COLON MATCHH MATCHT MATCHL SUBSTA * ${n-s} MINUS no * ${n+s} PLUS no * ${n=s} ASSIGN no * ${n?s} ERROR no * ${n:-s} MINUS yes * ${n:+s} PLUS yes * ${n:=s} ASSIGN yes * ${n:?s} ERROR yes * ${n#m} MATCH no yes no no no * ${n##m} MATCH no yes no yes no * ${n%m} MATCH no no yes no no * ${n%%m} MATCH no no yes yes no * ${n/m/s} SUBST no no no yes no * ${n/#m/s} SUBST no yes no yes no * ${n/%m/s} SUBST no no yes yes no * ${n//m/s} SUBST no no no yes yes * ${n:/m/s} SUBST yes yes yes * * PT_SUBST and PT_NEST is beyond POSIX. */ /* parameter expansion */ typedef struct paramexp_T { paramexptype_T pe_type; union { wchar_t *name; struct wordunit_T *nest; } pe_value; struct wordunit_T *pe_start, *pe_end; struct wordunit_T *pe_match, *pe_subst; } paramexp_T; #define pe_name pe_value.name #define pe_nest pe_value.nest /* pe_name: name of parameter * pe_nest: nested parameter expansion * pe_start: index of the first element in the range * pe_end: index of the last element in the range * pe_match: word to be matched with the value of the parameter * pe_subst: word to to substitute the matched string with * `pe_start' and `pe_end' is NULL if the indices are not specified. * `pe_match' and `pe_subst' may be NULL to denote an empty string. */ /* type of assignment */ typedef enum { A_SCALAR, A_ARRAY, } assigntype_T; /* assignment */ typedef struct assign_T { struct assign_T *next; assigntype_T a_type; wchar_t *a_name; union { struct wordunit_T *scalar; void **array; } a_value; /* value to assign */ } assign_T; #define a_scalar a_value.scalar #define a_array a_value.array /* `a_scalar' may be NULL to denote an empty string. * `a_array' is an array of pointers to `wordunit_T'. */ /* type of redirection */ typedef enum { RT_INPUT, /* file */ RT_CLOBBER, /* >|file */ RT_APPEND, /* >>file */ RT_INOUT, /* <>file */ RT_DUPIN, /* <&fd */ RT_DUPOUT, /* >&fd */ RT_PIPE, /* >>|fd */ RT_HERE, /* <(command) */ } redirtype_T; /* redirection */ typedef struct redir_T { struct redir_T *next; redirtype_T rd_type; int rd_fd; /* file descriptor to redirect */ union { struct wordunit_T *filename; struct { wchar_t *hereend; /* token indicating end of here-document */ struct wordunit_T *herecontent; /* contents of here-document */ } heredoc; struct embedcmd_T command; } rd_value; } redir_T; #define rd_filename rd_value.filename #define rd_hereend rd_value.heredoc.hereend #define rd_herecontent rd_value.heredoc.herecontent #define rd_command rd_value.command /* For example, for "2>&1", `rd_type' = RT_DUPOUT, `rd_fd' = 2 and * `rd_filename' = "1". * For RT_HERERT, all the lines in `rd_herecontent' have the leading tabs * already removed. If `rd_hereend' is quoted, `rd_herecontent' is a single * word unit of type WT_STRING, since no parameter expansions are performed. * Anyway `rd_herecontent' is expanded by calling `expand_string' with `esc' * argument being true. */ /********** Interface to Parsing Routines **********/ /* Holds parameters that affect the behavior of parsing. */ typedef struct parseparam_T { _Bool print_errmsg; /* print error messages? */ _Bool enable_verbose; /* echo input if `shopt_verbose' is true? */ #if YASH_ENABLE_ALIAS _Bool enable_alias; /* perform alias substitution? */ #endif const char *filename; /* the input filename, which may be NULL */ unsigned long lineno; /* line number, which should be initialized to 1 */ inputfunc_T *input; /* input function */ void *inputinfo; /* pointer passed to the input function */ _Bool interactive; /* input is interactive? */ inputresult_T lastinputresult; /* last return value of input function */ } parseparam_T; /* If `interactive' is true, `input' is `input_interactive' and `inputinfo' is a * pointer to a `struct input_interactive_info_T' object. * Note that input may not be from a terminal even if `interactive' is true. */ typedef enum parseresult_T { PR_OK, PR_EOF, PR_SYNTAX_ERROR, PR_INPUT_ERROR, } parseresult_T; extern parseresult_T read_and_parse( parseparam_T *info, and_or_T **restrict resultp) __attribute__((nonnull,warn_unused_result)); extern _Bool parse_string(parseparam_T *info, wordunit_T **restrict resultp) __attribute__((nonnull,warn_unused_result)); /********** Auxiliary Functions **********/ extern _Bool is_portable_name_char(wchar_t c) __attribute__((const)); extern _Bool is_name_char(wchar_t c) __attribute__((pure)); extern _Bool is_name(const wchar_t *s) __attribute__((pure)); extern _Bool is_keyword(const wchar_t *s) __attribute__((nonnull,pure)); extern _Bool is_token_delimiter_char(wchar_t c) __attribute__((pure)); /********** Functions That Convert Parse Trees into Strings **********/ extern wchar_t *pipelines_to_wcs(const pipeline_T *pipelines) __attribute__((malloc,warn_unused_result)); extern wchar_t *command_to_wcs(const command_T *command, _Bool multiline) __attribute__((malloc,warn_unused_result)); /********** Functions That Free/Duplicate Parse Trees **********/ extern void andorsfree(and_or_T *a); static inline command_T *comsdup(command_T *c); extern void comsfree(command_T *c); extern void wordfree(wordunit_T *w); extern void paramfree(paramexp_T *p); /* Duplicates the specified command (virtually). */ command_T *comsdup(command_T *c) { c->refcount++; return c; } #endif /* YASH_PARSER_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/install-sh0000755000175000017500000003246712154557026014566 0ustar magicantmagicant# install - install a program, script, or datafile scriptversion=2006-12-25.00-rev2 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' HUP INT PIPE TERM # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: yash-2.35/doc/0000755000175000017500000000000012154557026013313 5ustar magicantmagicantyash-2.35/doc/exec.txt0000644000175000017500000002606712154557026015013 0ustar magicantmagicant= Command execution :encoding: UTF-8 :lang: en //:title: Yash manual - Command execution :description: This page describes how commands are executed by yash. This section describes how commands are executed. [[simple]] == Execution of simple commands link:syntax.html#simple[A simple command] is executed as follows: . All tokens in the simple command are link:expand.html[expanded] except for assignment and redirection tokens. If an error occurs during expansion, the execution of the simple command is aborted with a non-zero exit status. + In the following steps, the first word of the expansion results is referred to as dfn:[command name], and the other words as dfn:[command arguments]. If there is only one word of the expansion results, there are no command argument words. If there are none of the expansion results, there is no command name either. . link:redir.html[Redirection] specified in the command, if any, is processed. The word token after each redirection operator is expanded. If an error occurs during processing redirection (including when expanding the word token), the execution of this simple command is aborted with a non-zero exit status. . Assignments specified in the command, if any, are processed. For each assignment token, the value is expanded and assigned to the specified link:params.html#variables[variable]. If an error occurs during assignments (including when expanding the values to be assigned), the execution of this simple command is aborted with a non-zero exit status. + -- - If there is no command name or the name denotes a link:builtin.html#types[special built-in] or <>, the assignments are permanent: the assigned values remain after the command has finished (until the variable is reassigned). - Otherwise, the assignments are temporary: the assigned values only last during the execution of this simple command. -- + The assigned variables are automatically link:params.html#variables[exported] when the command name is specified or the link:_set.html#so-allexport[all-export option] is enabled. . If there is no command name, the command execution ends with the exit status of zero (unless there are any link:expand.html#cmdsub[command substitutions] in the command, in which case the exit status of the simple command is that of the last executed command substitution). . A command to be executed is determined using the <> and the command is executed. + -- - If the command is an external command, the command is executed by creating a new <> and calling the ``exec'' system call in the subshell. The command name and arguments are passed to the executed command. Exported variables are passed to the executed command as environment variables. - If the command is a link:builtin.html[built-in], the built-in is executed with the command arguments passed to the built-in. - If the command is a <>, the contents of the function are executed with the command arguments as function arguments. If the command was executed, the exit status of this simple command is that of the executed command. If the algorithm failed to determine a command, no command is executed and the exit status is 127. If the shell failed to execute the determined command, the exit status is 126. If the executed command was killed by a signal, the exit status is the signal number plus 384. [NOTE] In shells other than yash, the exit status may be different when the command was killed by a signal, because the POSIX standard only requires that the exit status be "greater than 128." If the shell is not in the link:posix.html[POSIXly-correct mode] and the algorithm failed to determine a command, the command ifdef::basebackend-html[] pass:[eval -i -- "${COMMAND_NOT_FOUND_HANDLER-}"] endif::basebackend-html[] ifndef::basebackend-html[`eval -i -- "${COMMAND_NOT_FOUND_HANDLER-}"`] is evaluated. During the command execution, link:params.html#positional[positional parameters] are temporarily set to the command name and arguments that resulted in the first step. Any <> defined during the execution are removed when the execution is finished. The +HANDLED+ local variable is automatically defined with the initial value being the empty string. If the +HANDLED+ variable has a non-empty value when the execution of the command string is finished, the shell pretends that the command was successfully determined and executed. The exit status of the simple command is that of the command string in this case. -- [[search]] === Command search A command that is executed in a simple command is determined by the command name using the following algorithm: . If the command name contains a slash (+/+), the whole name is treated as the pathname of an external command. The external command is determined as the executed command. . If the command name is a link:builtin.html#types[special built-in], the built-in is determined as the executed command. . If the command name is the name of an existing <>, the function is determined as the executed command. . If the command name is a link:builtin.html#types[semi-special built-in], the built-in is determined as the executed command. . If the command name is a link:builtin.html#types[regular built-in], the built-in is determined as the executed command unless the shell is in the link:posix.html[POSIXly-correct mode]. . The shell searches the PATH for a executed command: + -- The value of the link:params.html#sv-path[+PATH+ variable] is separated by colons. Each separated part is considered as a directory pathname (an empty pathname denotes the current working directory). The shell searches the directories (in the order of appearance) and checks if any directory directly contains an executable regular file whose name is equal to the command name. If such a file is found: - If the command name is the name of a built-in, the built-in is determined as the executed command. - Otherwise, the file is determined as the executed command. (The file will be executed as an external command.) If no such file is found, no command is determined as the executed command. -- When the shell finds a file that matches the command name during the search above, the shell remembers the pathname of the file if it is an absolute path. When the algorithm above is used for the same command name again, the shell skips searching and directly determines the command to be executed. If an executable regular file no longer exists at the remembered pathname, however, the shell searches again to update the remembered pathname. You can manage remembered pathnames using the link:_hash.html[hash built-in]. [[exit]] == Termination of the shell The shell exits when it reached the end of input and has parsed and executed all input commands or when the link:_exit.html[exit built-in] is executed. The exit status of the shell is that of the last command the shell executed (or zero if no commands were executed). The exit status of the shell is always between 0 and 255 (inclusive). If the exit status of the last command is 256 or larger, the exit status of the shell will be the remainder of the exit status divided by 256. If an exit handler has been registered by the link:_trap.html[trap built-in], the handler is executed just before the shell exits. The exit status of the commands executed in the handler does not affect the exit status of the shell. If a non-link:interact.html[interactive] shell encountered one of the following errors, the shell immediately exits with a non-zero exit status: - A command cannot be parsed due to an syntax error (except during link:invoke.html#init[shell initialization]). - A link:builtin.html#types[special built-in] is executed in the link:posix.html[POSIXly-correct mode] and the command arguments do not meet the syntax of the built-in's arguments. - An error occurs during redirection or assignment in a link:syntax.html#simple[simple command] whose command name is a special built-in and the shell is in the POSIXly-correct mode. - An error occurs during link:expand.html[expansion] (except during shell initialization). [NOTE] Some shells other than yash exit when they fail to find a command to execute in <>. [[function]] == Functions dfn:[Functions] allow executing a link:syntax.html#compound[compound command] as a link:syntax.html#simple[simple command]. A function can be defined by the link:syntax.html#funcdef[function definition command] and executed by a simple command. You can use the link:_unset.html[unset built-in] to remove function definitions. There are no functions predefined when yash is started. A function is executed by executing its body, which is a compound command. While the function is being executed, link:params.html#positional[positional parameters] are set to the arguments given to the function. The old positional parameters are restored when the function execution finishes. [[localvar]] === Local variables dfn:[Local variables] are temporary variables that are defined in a function and exist during the function execution only. They can be defined by the link:_typeset.html[typeset built-in]. They are removed when the function execution finishes. Local variables may _hide_ variables that have already been defined before the function execution had started. An existing variable becomes inaccessible if a local variable of the same name is defined in a function. The old variable becomes accessible again when the function execution finishes. You cannot create a local variable when not executing a function. A normal variable is created if you try to do so. [[environment]] == Command execution environment The shell holds following properties during execution. - The working directory - Open file descriptors - The file creation mask (link:_umask.html[umask]) - The set of signals whose handler is set to ``ignore'' (link:_trap.html[trap]) - link:params.html#variables[Environment variables] - Resource limits (link:_ulimit.html[ulimit]) Those properties are inherited from the invoker of the shell to the shell, and from the shell to each external command executed by the shell. The properties can be changed during the execution of the shell by built-in commands, variable assignments, etc. [[subshell]] === Subshells A dfn:[subshell] is a copy of the shell process. Subshells are used in execution of link:syntax.html#grouping[groupings], link:syntax.html#pipelines[pipelines], etc. Subshells inherit functions, aliases, etc. defined in the shell as well as the properties above since subshells are copies of the shell process. Notable exceptions are: - Signal handlers registered by the link:_trap.html[trap built-in] are all reset in subshells except for ones whose action is set to ``ignore''. - The link:interact.html[interactive] mode and link:job.html[job control] are disabled in subshells. Jobs are not inherited by subshells. Subshells are executed independently of the original shell, so changes of any properties above do not affect those of the original shell. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/posix.txt0000644000175000017500000001077112154557026015224 0ustar magicantmagicant= POSIXly-correct mode :encoding: UTF-8 :lang: en //:title: Yash manual - POSIXly-correct mode :description: This page describes the behavior of yash's POSIXly-correct mode. Yash behaves as defined in link:http://pubs.opengroup.org/onlinepubs/9699919799/[POSIX.1-2008], Shell & Utilities for the most part, but some functionalities disobey POSIX for usability. When full POSIX-conformance is needed, you can enable the dfn:[POSIXly-correct mode] to make yash obey POSIX as mush as possible. If yash is started with the name ``sh'', the POSIXly-correct mode is automatically enabled. The +-o posixly-correct+ command-line option also enables the POSIXly-correct mode. After yash has been started, the POSIXly-correct mode can be enabled by executing the command string +link:_set.html[set] -o posixly-correct+. When the POSIXly-correct mode is on, yash not only tries to obey the requirements by POSIX, but also treats as errors most conditions where the behavior is _undefined_ or _unspecified_ by POSIX. As a result, most yash-specific functionalities are disabled in the POSIXly-correct mode. Below is the complete list of the behavioral differences between when yash is in the POSIXly-correct mode and when not. When the POSIXly-correct mode is enabled: - Different link:invoke.html#init[initialization scripts] are used. - Global link:syntax.html#aliases[aliases] are not substituted. - Nested commands in a link:syntax.html#compound[compound command] must not be empty. - Words expanded in a link:syntax.html#for[for loop] are assigned as a global variable rather than a local. - The first pattern in a link:syntax.html#case[case command] cannot be +esac+. - The +function+ keyword cannot be used for link:syntax.html#funcdef[function definition]. - link:syntax.html#simple[Simple commands] cannot assign to link:params.html#arrays[arrays]. - Changing the value of the link:params.html#sv-lc_ctype[+LC_CTYPE+ variable] after the shell has been initialized does not affect the shell's locale. - The link:params.html#sv-random[+RANDOM+ variable] cannot be used to generate random numbers. - link:expand.html#tilde[Tilde expansion] only expands +~+ and +~{{username}}+. - link:expand.html#params[Parameter expansion] cannot be nested. No link:expand.html#param-index[indexes] are allowed. - The commands in a link:expand.html#cmdsub[command substitution] of the form +$({{commands}})+ are parsed every time the substitution is executed. - Fractional numbers and the `++` and `--` operators cannot be used in link:expand.html#arith[arithmetic expansion]. - In a link:redir.html#file[redirection to a file], if the link:expand.html#glob[pathname expansion] yielded more than one or no pathname, it is not immediately treated as an error. Instead, the shell tries to treat the word before the expansion as a pathname. - link:redir.html#socket[Socket redirection], link:redir.html#here[here strings], link:redir.html#pipe[pipe redirection], and link:redir.html#process[process redirection] cannot be used. - When link:exec.html#simple[executing a simple command], failure in command search does not trigger execution of the link:params.html#sv-command_not_found_handler[+COMMAND_NOT_FOUND_HANDLER+ variable]. - In link:exec.html#search[command search], a link:builtin.html#types[regular built-in] needs to have a corresponding external command for the built-in to be found. - link:syntax.html#async[asynchronous commands] ignore the SIGINT and SIGQUIT signals even when link:job.html[job control] is active. The standard input of asynchronous commands is redirected to /dev/null if the shell is not link:interact.html[interactive], regardless of whether job control is active or not. - Some link:builtin.html[built-ins] behave differently. Especially, some command-line options cannot be used. - A link:interact.html[non-interactive] shell exits when a link:builtin.html#types[special built-in] is given a syntactically wrong arguments or when an error occurs in assignment or redirection with a special built-in. - An link:interact.html[interactive] shell does not execute the link:params.html#sv-prompt_command[+PROMPT_COMMAND+ variable] before printing a prompt. The values of the link:params.html#sv-ps1[+PS1+], link:params.html#sv-ps2[+PS2+], and link:params.html#sv-ps4[+PS4+] variables are parsed differently. - In link:interact.html#mailcheck[mail checking], a notification message is printed if the file has been modified, regardless of whether the file is empty. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_array.html0000644000175000017500000001112512154557026015456 0ustar magicantmagicant Array built-in

The array built-in prints or modifies arrays.

Syntax

  • array

  • array name [value…]

  • array -d name [index…]

  • array -i name index [value…]

  • array -s name index value

Description

When executed without any option or operands, the built-in prints all array definitions to the standard output in a form that can be parsed as commands.

When executed with name and values (but without an option), the built-in sets the values as the values of the array named name.

With the -d (--delete) option, the built-in removes the indexth values of the array named name. The number of values in the array will be decreased by the number of the indexes specified. If the indexth value does not exist, it is silently ignored.

With the -i (--insert) option, the built-in inserts values into the array named name. The number of values in the array will be increased by the number of the values specified. The values are inserted between the indexth and next values. If index is zero, the values are inserted before the first value. If index is larger than the number of values in the array, the values are appended after the last element.

With the -s (--set) option, the built-in sets value as the indexth value of the array named name. The array must have at least index values.

Options

-d
--delete

Delete array values.

-i
--insert

Insert array values.

-s
--set

Set an array value.

Operands

name

The name of an array to operate on.

index

The index to an array element. The first element has the index of 1.

value

A string to which the array element is set.

Exit status

The exit status of the array built-in is zero unless there is any error.

Notes

The array built-in is not defined in the POSIX standard.

The command array name value is equivalent to the assignment name=(value…).

yash-2.35/doc/intro.txt0000644000175000017500000000236312154557026015213 0ustar magicantmagicant= Introduction :encoding: UTF-8 :lang: en //:title: Yash manual - Introduction :description: This is the introduction page of the yash manual. dfn:[Yet anther shell] (yash) is a command line shell for UNIX-like operating systems. The shell conforms to the POSIX.1-2008 standard (for the most parts), and actually is more conforming than other POSIX-conforming shells. Moreover, it has many features that are used for interactive use, such as command history and command line editing. This program can be freely modified and redistributed under the terms of http://www.gnu.org/licenses/gpl.html[GNU General Public License] (Version 2). *Use of this program is all at your own risk. There is no warranty and the author is not responsible for any consequences caused by use of this program.* This manual can be freely modified and redistributed under the terms of http://creativecommons.org/licenses/by-sa/2.1/jp/[Creative Commons Attribution-ShareAlike 2.1 Japan]. Yash is developed and maintained by 渡邊裕貴 (WATANABE Yuki) aka Magicant. http://sourceforge.jp/projects/yash/[Yash development project] and http://yash.sourceforge.jp/[Yash's homepage] are hosted by http://sourceforge.jp/[SourceForge.jp]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_return.html0000644000175000017500000000765212154557026015671 0ustar magicantmagicant Return built-in

The return built-in returns from a function or script.

Syntax

  • return [-n] [exit_status]

Description

When executed without the -n (--no-return) option, one of the following happens:

  • If the shell is executing a function, the execution of the function is terminated.

  • If the dot built-in is executing a script, the execution of the script is terminated.

  • If the eval built-in is executing a command string, the execution of the command is terminated.

  • Otherwise, the shell exits unless it is interactive.

When executed with the -n (--no-return) option, the built-in does nothing but return the specified exit_status.

Options

-n
--no-return

Do not terminate a function, script, evaluated command, or the shell.

Operands

exit_status

The exit status of the built-in.

The value must be a non-negative integer.

If omitted, the exit status of the last executed command is used. (But when the shell is executing a trap, the exit status of the last command before the trap is used.)

Exit status

The exit status of the return built-in is defined by the exit_status operand. The exit status is used also as the exit status of the terminated function, script, evaluated script, or the shell.

Notes

The return built-in is a special built-in.

The POSIX standard provides that the exit_status operand should be between 0 and 255 (inclusive). Yash accepts integers larger than 255 as an extension.

In the POSIX standard, the behavior of the return built-in is defined only when the shell is executing a function or script.

The POSIX standard defines no options for the return built-in; the built-in accepts no options in the POSIXly-correct mode.

yash-2.35/doc/_bg.html0000644000175000017500000000522012154557026014727 0ustar magicantmagicant Bg built-in

The bg built-in resumes a job in the background.

Syntax

  • bg [job…]

Description

The bg built-in sends the SIGCONT signal to the specified job. As a result, the job is resumed in the background (if it has been suspended).

The name of the job is printed when the job is resumed.

The built-in can be used only when job control is enabled.

Operands

job

The job ID of the job to be resumed.

More than one job can be specified at a time. The current job is resumed if none is specified.

The percent sign (%) at the beginning of a job ID can be omitted if the shell is not in the POSIXly-correct mode.

Exit status

The exit status of the bg built-in is zero unless there is any error.

Notes

The bg built-in is a semi-special built-in.

The POSIX standard provides that the built-in shall have no effect when the job is already running. The bg built-in of yash, however, always sends the SIGCONT signal to the job.

yash-2.35/doc/makeindex.sh0000644000175000017500000000331312154557026015614 0ustar magicantmagicant# This script prints a section list for index.txt. # (C) 2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # skip up to the "//*//" marker while read -r line; do case $line in //*//) break;; *) printf '%s\n' "$line";; esac done # insert chapter/section titles for file do htmlfile=${file%.txt}.html # print the chapter title sed -n '1s/^=[[:space:]]*\(.*\)$/. link:'"${htmlfile}"'[\1]/p' <${file} # print section titles # The first sed prints something like this: # == # section-1[Section 1] # === # subsection-1-1[Subsection 1.1] # === # subsection-1-2[Subsection 1.2] # ... <${file} \ sed -n ' /^\[\[.*\]\]$/{ N /\n==/{ s/^\[\[\(.*\)\]\]\n\(===*\)[[:space:]]*\(.*\)$/\2\n\1[\3]/p } } ' | # The second sed replaces '=' with '.', inserts the "link:${htmlfile}#" # strings, and joins lines: # .. link:${htmlfile}#section-1[Section 1] # ... link:${htmlfile}#subsection-1-1[Subsection 1.1] # ... link:${htmlfile}#subsection-1-2[Subsection 1.2] # ... sed " s/=/./g N s|\n| link:${htmlfile}#| " done # print the rest of the input as is exec cat # vim: set ft=sh ts=8 sts=4 sw=4 noet tw=80: yash-2.35/doc/_echo.txt0000644000175000017500000000556712154557026015146 0ustar magicantmagicant= Echo built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Echo built-in The dfn:[echo built-in] prints its arguments. [[syntax]] == Syntax - +echo [{{string}}...]+ The built-in treats all command line arguments as operands except for the options described below. Any word that cannot be parsed as an acceptable option is treated as an operand. Options must precede all operands. Syntax errors never happen in the echo built-in. [[description]] == Description The echo built-in prints the operand {{string}}s followed by a newline to the standard output. The {{string}}s are each separated by a space. [[escapes]] === Escape sequences The +ECHO_STYLE+ variable and the +-e+ option enable escape sequences that are replaced with corresponding characters: +\a+:: Bell character (ASCII code: 7) +\b+:: Backspace (ASCII code: 8) +\c+:: Nothing. After this escape sequence, no characters are printed at all. +\e+:: Escape character (ASCII code: 27) +\f+:: Form feed character (ASCII code: 12) +\n+:: Newline character (ASCII code: 10) +\r+:: Carriage return character (ASCII code: 13) +\t+:: Horizontal tab character (ASCII code: 9) +\v+:: Vertical tab character (ASCII code: 11) +\\+:: Backslash +\0{{xxx}}+:: Character whose code is {{xxx}}, where {{xxx}} is an octal number of at most three digits. When escape sequences are not enabled, they are just printed intact. [[echo_style]] === +ECHO_STYLE+ variable The link:params.html#sv-echo_style[+ECHO_STYLE+ variable] defines which options are accepted and whether escape sequences are enabled by default. The variable value should be set to one of the following: +SYSV+:: +XSI+:: No options are accepted. Escape sequences are always enabled. +BSD+:: The +-n+ option is accepted. Escape sequences are never enabled. +GNU+:: The +-n+, +-e+, and +-E+ options are accepted. Escape sequences are not enabled by default, but can be enabled by the +-e+ option. +ZSH+:: The +-n+, +-e+, and +-E+ options are accepted. Escape sequences are enabled by default, but can be disabled by the +-E+ option. +DASH+:: The +-n+ option is accepted. Escape sequences are always enabled. +RAW+:: No options are accepted. Escape sequences are never enabled. When the +ECHO_STYLE+ variable is not set, it defaults to +SYSV+. [[options]] == Options +-n+:: Do not print a newline at the end. +-e+:: Enable escape sequences. +-E+:: Disable escape sequences. [[exitstatus]] == Exit status The exit status of the echo built-in is zero unless there is any error. [[notes]] == Notes The POSIX standard does not define the +ECHO_STYLE+ variable nor any options for the built-in. According to POSIX, the behavior of the built-in is implementation-defined when the first argument is +-n+ or when any argument contains a backslash. For maximum portability, the link:_printf.html[printf built-in] should be preferred over the echo built-in. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_hash.txt0000644000175000017500000000373012154557026015141 0ustar magicantmagicant= Hash built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Hash built-in The dfn:[hash built-in] remembers, forgets, or reports command locations. [[syntax]] == Syntax - +hash {{command}}...+ - +hash -r [{{command}}...]+ - +hash [-a]+ - +hash -d {{user}}...+ - +hash -dr [{{user}}...]+ - +hash -d+ [[description]] == Description When executed with {{command}}s but without options, the built-in immediately performs link:exec.html#search[command path search] and caches {{command}}s' full paths. When executed with the +-r+ (+--remove+) option, it removes the paths of {{command}}s (or all cached paths if none specified) from the cache. When executed without options or {{command}}s, it prints the currently cached paths to the standard output. With the +-d+ (+--directory+) option, the built-in does the same things to the home directory cache, rather than the command path cache. Cached home directory paths are used in link:expand.html#tilde[tilde expansion]. [[options]] == Options +-a+:: +--all+:: Print all cached paths. + Without this option, paths for built-ins are not printed. +-d+:: +--directory+:: Affect the home directory cache instead of the command path cache. +-r+:: +--remove+:: Remove cached paths. [[operands]] == Operands {{command}}:: The name of an external command (that does not contain any slash). {{user}}:: A user name. [[exitstatus]] == Exit status The exit status of the hash built-in is zero unless there is any error. [[notes]] == Notes The shell automatically caches command and directory paths when executing a command or performing tilde expansion, so normally there is no need to use this built-in explicitly to cache paths. Assigning a value to the link:params.html#sv-path[+PATH+ variable] removes all command paths from the cache as if +hash -r+ was executed. The POSIX standard defines the +-r+ option only: other options cannot be used in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_dot.txt0000644000175000017500000000506312154557026015005 0ustar magicantmagicant= Dot built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Dot built-in The dfn:[dot built-in] reads a file and executes commands in it. [[syntax]] == Syntax - +. [-AL] {{file}} [{{argument}}...]+ [[description]] == Description The dot built-in reads the specified {{file}}, parses its contents as commands, and executes them in the current link:exec.html#environment[command execution environment]. If {{argument}}s are specified, link:params.html#positional[positional parameters] are temporarily set to them. The positional parameters will be restored when the dot built-in finishes. If no {{argument}}s are specified, the positional parameters are not changed. If {{file}} does not contain any slashes, the shell searches link:params.html#sv-path[+$PATH+] for a readable (but not necessarily executable) shell script file whose name is {{file}} in the same manner as link:exec.html#search[command search]. If no such file was found, the shell searches the current working directory for a file unless in the link:posix.html[POSIXly-correct mode]. To ensure that the file in the current working directory is used, start {{file}} with `./'. [[options]] == Options +-A+:: +--no-alias+:: Disable alias substitution while parsing. +-L+:: +--autoload+:: Search link:params.html#sv-yash_loadpath[+$YASH_LOADPATH+] instead of link:params.html#sv-path[+$PATH+], regardless of whether {{file}} contains slashes. The {{file}} value is not considered relative to the current working directory. The dot built-in treats as operands any command line arguments after the first operand. [[operands]] == Operands {{file}}:: The pathname of a file to be read. {{arguments}}...:: Strings to which positional parameters are set while execution. [[exitstatus]] == Exit status The exit status of the dot built-in is that of the last command executed. The exit status is zero if the file contains no commands to execute and non-zero if a file was not found or could not be opened. [[notes]] == Notes The dot built-in is a link:builtin.html#types[special built-in]. A link:interact.html[non-interactive] shell that is not in the link:posix.html[POSIXly-correct mode] will immediately exit with a non-zero exit status if the dot built-in fails to find or open a file to execute. The POSIX standard defines no options for the dot built-in; the built-in accepts no options in the POSIXly-correct mode. The POSIX standard does not define the {{arguments}}... operands. It is an error to specify the {{arguments}}... operands in the POSIXly-correct mode. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/fgrammar.txt0000644000175000017500000001654312154557026015661 0ustar magicantmagicant= Formal definition of command syntax :encoding: UTF-8 :lang: en //:title: Yash manual - Formal definition of command syntax :description: This page gives the formal definition of yash command syntax. This chapter defines the syntax of shell commands as a parsing expression grammar. The set of terminals of the grammar is the set of characters that can be handled on the environment in which the shell is run (a.k.a. execution character set), with the exception that the set does not contain the null character (`'\0'`). Below is a list of nonterminals of the grammar with corresponding parsing expressions. The list does not include rules for parsing contents and ends of link:redir.html#here[here documents]. In the link:posix.html[POSIXly-correct mode], the grammar varies from the list below to disable non-POSIX functionalities. [[d-complete-command]]CompleteCommand:: <> <> [[d-sequence]]Sequence:: <>* <>* [[d-list]]List:: <> ((+&&+ / +||+) <>* Pipeline)* <> [[d-pipeline]]Pipeline:: <>? <> (+|+ <>* Command)* [[d-command]]Command:: <> <>* / + !<> <> / + !R <> [[d-compound-command]]CompoundCommand:: <> / + <> / + <> / + <> / + <> / + <> / + <> [[d-subshell]]Subshell:: +(+ <> +)+ <>* [[d-grouping]]Grouping:: <> <> <> [[d-if-command]]IfCommand:: <> <> <> Sequence (<> Sequence <> Sequence)* (<> Sequence)? <> [[d-for-command]]ForCommand:: <> <> <>* <>? (<> <>* <>)? <> <> <> [[d-while-command]]WhileCommand:: (<> / <>) <> <> Sequence <> [[d-case-command]]CaseCommand:: <> <> <>* <> N* <>* <> [[d-case-item]]CaseItem:: !<> (+(+ <>*)? <> (+|+ S* Word)* +)+ <> (+;;+ / &Esac) [[d-function-command]]FunctionCommand:: <> <> (+(+ <>* +)+)? <>* <> <>* [[d-function-definition]]FunctionDefinition:: <> <>* +(+ S* +)+ <>* <> <>* [[d-simple-command]]SimpleCommand:: &(<> / <>) (<> / Redirection)* (Word / Redirection)* [[d-assignment]]Assignment:: <> +=+ <> / + Name +=(+ <>* (Word N*)* +)+ [[d-name]]Name:: !\[[:digit:]] [[:alnum:] +_+]+ [[d-portable-name]]PortableName:: ![++0++-++9++] [++0++-++9++ ++ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_++]+ [[d-word]]Word:: (<> / !<> .)+ <>* [[d-word-element]]WordElement:: +\+ . / + `'` (!`'` .)* `'` / + +"+ <>* +"+ / + <> / + <> / + <> [[d-quote-element]]QuoteElement:: +\+ ([+$`"\+] / <>) / + <> / + <> / + <> / + ![+`"\+] . [[d-parameter]]Parameter:: +$+ [+@*#?-$!+ [:digit:]] / + +$+ <> / + +$+ <> [[d-parameter-body]]ParameterBody:: +{+ <>? (<> / ParameterBody / <>) <>? <>? +}+ [[d-parameter-number]]ParameterNumber:: `#` ![`+=:/%`] !([`-?#`] `}`) [[d-parameter-name]]ParameterName:: [+@*#?-$!+] / + [[:alnum:] +_+]+ [[d-parameter-index]]ParameterIndex:: +[+ <> (+,+ ParameterIndexWord)? +]+ [[d-parameter-index-word]]ParameterIndexWord:: (<> / ![+"'],+] .)+ [[d-parameter-match]]ParameterMatch:: `:`? [`-+=?`] <> / + (`#` / `##` / `%` / `%%`) ParameterMatchWord / + (`:/` / `/` [`#%/`]?) <> (+/+ ParameterMatchWord)? [[d-parameter-match-word]]ParameterMatchWord:: (<> / ![+"'}+] .)* [[d-parameter-match-word-no-slash]]ParameterMatchWordNoSlash:: (<> / ![+"'/}+] .)* [[d-arithmetic]]Arithmetic:: `$((` <>* `))` [[d-arithmetic-body]]ArithmeticBody:: +\+ . / + <> / + <> / + <> / + +(+ ArithmeticBody +)+ / + ![+`()+] . [[d-command-substitution]]CommandSubstitution:: +$(+ <> +)+ / + +`+ <>* +`+ [[d-command-substitution-body]]CommandSubstitutionBody:: +\+ [+$`\+] / + !++`++ . [[d-redirection]]Redirection:: <> <> <>* <> / + RedirectionFD +<(+ <> +)+ / + RedirectionFD +>(+ Sequence +)+ [[d-redirection-fd]]RedirectionFD:: \[[:digit:]]* [[d-redirection-operator]]RedirectionOperator:: `<` / `<>` / `>` / `>|` / `>>` / `>>|` / `<&` / `>&` / `<<` / `<<-` / `<<<` [[d-list-separator]]ListSeparator:: <> / + +&+ <>* / + &++)++ / + &++;;++ [[d-separator]]Separator:: +;+ <>* / + <>+ / + <> [[d-n]]N:: <>* <> [[d-s]]S:: \[[:blank:]] / + <> [[d-comment]]Comment:: +#+ (!<> .)* [[d-r]]R:: <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> [[d-bang]]Bang:: +!+ <> [[d-left-brace]]LeftBrace:: +{+ <> [[d-right-brace]]RightBrace:: +}+ <> [[d-case]]Case:: +case+ <> [[d-do]]Do:: +do+ <> [[d-done]]Done:: +done+ <> [[d-elif]]Elif:: +elif+ <> [[d-else]]Else:: +else+ <> [[d-esac]]Esac:: +esac+ <> [[d-fi]]Fi:: +fi+ <> [[d-for]]For:: +for+ <> [[d-function]]Function:: +function+ <> [[d-if]]If:: +if+ <> [[d-in]]In:: +in+ <> [[d-then]]Then:: +then+ <> [[d-until]]Until:: +until+ <> [[d-while]]While:: +while+ <> [[d-d]]D:: !<> <>* [[d-special-char]]SpecialChar:: [+|&;<>()`\"'+ [:blank:]] / <> [[d-nl]]NL:: [[d-eof]]EOF:: !. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_dirs.html0000644000175000017500000000724712154557026015313 0ustar magicantmagicant Dirs built-in

The dirs built-in prints the contents of the directory stack.

Syntax

  • dirs [-cv] [index..]

Description

The directory stack is a feature that records history of working directories. You can use the pushd built-in to save a working directory in the directory stack, the popd built-in to recall the saved working directory, and the dirs built-in to see the stack contents. Those built-ins use the DIRSTACK array and the PWD variable to save the stack contents. Modifying the array means modifying the stack contents.

Directory stack entries are indexed by signed integers. The entry of index +0 is the current working directory, +1 is the last saved directory, +2 is the second last, and so on. Negative indices are in the reverse order: the entry of index -0 is the first saved directory, -1 is the second, and -n is the current working directory if the stack has n entries,

When executed without the -c (--clear) option, the dirs built-in prints the current contents of the directory stack to the standard output. With the -c (--clear) option, the built-in clears the directory stack.

Options

-c
--clear

Clear the directory stack contents except for the current working directory, which has index +0.

-v
--verbose

Print indices when printing stack contents.

Operands

index

The index of a stack entry to be printed.

You can specify more than one index. If you do not specify any index, all the entries are printed.

Exit status

The exit status of the dirs built-in is zero unless there is any error.

Notes

The dirs built-in is not defined in the POSIX standard.

yash-2.35/doc/_pwd.txt0000644000175000017500000000224212154557026015005 0ustar magicantmagicant= Pwd built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Pwd built-in The dfn:[pwd built-in] prints the current working directory. [[syntax]] == Syntax - +pwd [-L|-P]+ [[description]] == Description The pwd built-in prints an absolute path to the shell's current working directory to the standard output. [[options]] == Options +-L+:: +--logical+:: If the value of the link:params.html#sv-pwd[+PWD+ variable] is an absolute path to the shell's working directory and the path does not contain any +.+ or +..+ components, then the path is printed. Otherwise, the printed path is the same as when the +-P+ option is specified. +-P+:: +--physical+:: The printed path does not contain any +.+ or +..+ components, symbolic link components, or redundant slashes. The +-L+ (+--logical+) and +-P+ (+--physical+) options are mutually exclusive: only the last specified one is effective. If neither is specified, +-L+ is assumed. [[exitstatus]] == Exit status The exit status of the pwd built-in is zero unless there is any error. [[notes]] == Notes The pwd built-in is a link:builtin.html#types[semi-special built-in]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/makeyash.sh0000644000175000017500000000175012154557026015454 0ustar magicantmagicant# This script prints a section list for index.txt. # (C) 2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # skip up to the "//*//" marker while read -r line; do case $line in //*//) break;; *) printf '%s\n' "$line";; esac done # insert include macros printf 'include::%s[]\n\n' "$@" # print the rest of the input as is exec cat # vim: set ft=sh ts=8 sts=4 sw=4 noet tw=80: yash-2.35/doc/yash.10000644000175000017500000110622112154557026014344 0ustar magicantmagicant'\" t .\" Title: yash .\" Author: Yuki Watanabe .\" Generator: DocBook XSL Stylesheets v1.78.1 .\" Date: 2013-06-08 .\" Manual: \ \& .\" Source: \ \& 2.35 .\" Language: English .\" .TH "YASH" "1" "2013\-06\-08" "\ \& 2\&.35" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" yash \- a POSIX\-compliant command line shell .SH "SYNOPSIS" .sp \fByash [options\&...] [\-\-] [operands\&...]\fR .SH "INTRODUCTION" .sp \fIYet anther shell\fR (yash) is a command line shell for UNIX\-like operating systems\&. The shell conforms to the POSIX\&.1\-2008 standard (for the most parts), and actually is more conforming than other POSIX\-conforming shells\&. Moreover, it has many features that are used for interactive use, such as command history and command line editing\&. .sp This program can be freely modified and redistributed under the terms of GNU General Public License (Version 2)\&. \fBUse of this program is all at your own risk\&. There is no warranty and the author is not responsible for any consequences caused by use of this program\&.\fR .sp This manual can be freely modified and redistributed under the terms of Creative Commons Attribution\-ShareAlike 2\&.1 Japan\&. .sp Yash is developed and maintained by 渡邊裕貴 (WATANABE Yuki) aka Magicant\&. Yash development project and Yash\(cqs homepage are hosted by SourceForge\&.jp\&. .SH "INVOCATION" .sp When invoked as a program, yash performs the predefined initialization steps and repeatedly reads and executed commands\&. Command line arguments given in the invocation determines how the shell initializes itself and executes commands\&. .SS "Command line arguments" .sp The syntax of command line arguments for yash conforms to POSIX\&. As defined in POSIX, arguments are separated into \fIoptions\fR and \fIoperands\fR\&. For more detailed explanation about options and operands, see Command argument syntax\&. All options must come before operands\&. The interpretation of operands depends on options specified\&. .sp When you specify the \fB\-c\fR (\fB\-\-cmdline\fR) option, you must give at least one operand\&. The shell interprets and executes the first operand as a command string\&. The second operand, if any, is used to initialize the \fB0\fR special parameter\&. The other operands, if any, are used to initialize the positional parameters\&. When the \fB\-c\fR (\fB\-\-cmdline\fR) option is specified, the shell does not read any file or the standard input (unless the dot built\-in is used)\&. .sp If you specify the \fB\-s\fR (\fB\-\-stdin\fR) option, the shell reads the standard input, interprets the input as commands, and executes them\&. All the operands given are used to initialize the positional parameters\&. The \fB0\fR special parameter is initialized to the name the shell is invoked as\&. .sp If you specify neither the \fB\-c\fR (\fB\-\-cmdline\fR) nor \fB\-s\fR (\fB\-\-stdin\fR) option, the shell reads a file, interprets the file contents as commands, and executes them\&. The first operand specifies the pathname of the file\&. The remaining operands are used to initialize the positional parameters\&. If you do not give any operands, the shell reads the standard input as if the \fB\-s\fR (\fB\-\-stdin\fR) option is specified\&. .sp You cannot use both the \fB\-c\fR (\fB\-\-cmdline\fR) and \fB\-s\fR (\fB\-\-stdin\fR) options at a time\&. .sp If you specify either the \fB\-\-help\fR or \fB\-\-version\fR option, the shell never performs the usual initialization or command execution\&. Instead, it just prints brief usage (for \fB\-\-help\fR) or version information (for \fB\-\-version\fR)\&. If the \fB\-\-version\fR option is accompanied by the \fB\-v\fR (\fB\-\-verbose\fR) option, the shell prints a list of the available optional features as well\&. .sp If you specify the \fB\-i\fR (\fB\-\-interactive\fR) option, the shell goes into the interactive mode\&. If you specify the \fB+i\fR (\fB++interactive\fR) option, conversely, the shell never goes into the interactive mode\&. .sp If you specify the \fB\-l\fR (\fB\-\-login\fR) option, the shell behaves as a login shell\&. .sp The \fB\-\-noprofile\fR, \fB\-\-norcfile\fR, \fB\-\-profile\fR, and \fB\-\-rcfile\fR options determine how the shell is initialized (see below for details)\&. .sp In addition to the options described above, you can specify options that can be specified to the set built\-in\&. .sp If the first operand is \fB\-\fR and the options and the operands are not separated by \fB\-\-\fR, the first operand is ignored\&. .SS "Initialization of yash" .sp Yash initializes itself as follows: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} Yash first parses the name it was invoked as\&. If the name starts with \fB\-\fR, the shell behaves as a login shell\&. If the name is \fBsh\fR (including names such as \fB/bin/sh\fR), the shell goes into the POSIXly\-correct mode\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} If no operands are given and the standard input and standard error are both connected to a terminal, the shell goes into the interactive mode unless the \fB+i\fR (\fB++interactive\fR) option is specified\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} Job control is automatically enabled in an interactive shell unless the \fB+m\fR (\fB++monitor\fR) option is specified\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} Yash reads and executes commands from the following files (unless the real and effective user IDs of the shell process are different or the real and effective group IDs of the shell process are different): .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} If it is behaving as a login shell, the shell reads the file specified by the \fB\-\-profile=\fR\fB\fIfilename\fR\fR option unless the \fB\-\-noprofile\fR option is specified or the shell is in the POSIXly\-correct mode\&. If the \fB\-\-profile=\fR\fB\fIfilename\fR\fR option is not specified, the shell reads ~/\&.yash_profile as a default\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} If in the interactive mode, the shell reads the file specified by the \fB\-\-rcfile=\fR\fB\fIfilename\fR\fR option unless the \fB\-\-norcfile\fR option is specified\&. If the \fB\-\-rcfile=\fR\fB\fIfilename\fR\fR option is not specified, the shell .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} reads ~/\&.yashrc as a default if not in the POSIXly\-correct mode; or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} performs parameter expansion on the value of the \fBENV\fR environment variable and treats the expansion result as the name of the file to read if in the POSIXly\-correct mode\&. .RE .RE .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp Yash never automatically reads /etc/profile, /etc/yashrc, nor ~/\&.profile\&. .sp .5v .RE .SH "SYNTAX" .sp The shell reads, parses, and executes command line by line\&. If there is more than one command on a line, all the commands are parsed before executed\&. If a command is continued to next lines, the shell reads more enough lines to complete the command\&. On a syntax error, the shell neither reads nor executes any more commands\&. .SS "Tokens and keywords" .sp A command is composed of one or more tokens\&. In the shell syntax, a \fItoken\fR is a word that is part of a command\&. Normally, tokens are separated by whitespaces, that is, the space or tab character\&. Whitespaces inside a command substitution or a parameter expansion, however, do not separate tokens\&. .sp The following symbols have special meanings in the shell syntax and in most cases separate tokens: .sp .if n \{\ .RS 4 .\} .nf ; & | < > ( ) [newline] .fi .if n \{\ .RE .\} .sp The following symbols do not separate tokens, but have syntactic meanings: .sp .if n \{\ .RS 4 .\} .nf $ ` \e " \*(Aq * ? [ # ~ = % .fi .if n \{\ .RE .\} .sp The following tokens are treated as \fIkeywords\fR depending on the context in which they appear: .sp .if n \{\ .RS 4 .\} .nf ! { } case do done elif else esac fi for function if in then until while .fi .if n \{\ .RE .\} .sp A token is treated as a keyword when: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} it is the first token of a command, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} it follows another keyword (except \fBcase\fR, \fBfor\fR, and \fBin\fR), or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} it is a non\-first token of a command and is supposed to be a keyword to compose a composite command\&. .RE .sp If a token begins with \fB#\fR, then the \fB#\fR and any following characters up to the end of the line are treated as a \fIcomment\fR, which is completely ignored in syntax parsing\&. .SS "Quotations" .sp If you want whitespaces, separator characters, or keywords described above to be treated as a normal characters, you must quote the characters using appropriate quotation marks\&. Quotation marks are not treated as normal characters unless they are themselves quoted\&. You can use the following three quotation marks: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A backslash (\fB\e\fR) quotes a character that immediately follows\&. The only exception about a backslash is the case where a backslash is followed by a newline\&. In this case, the two characters are treated as a \fIline continuation\fR rather than a newline being quoted\&. The two characters are removed from the input and the two lines surrounding the line continuation are concatenated into a single line\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A pair of single\-quotation marks (\fB\*(Aq\fR) quote any characters between them except another single\-quotation\&. Note that newlines can be quoted using single\-quotations\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Double\-quotation marks (\fB"\fR) are like single\-quotations, but they have a few exceptions: Parameter expansion, command substitution, and arithmetic expansion are interpreted as usual even between double\-quotations\&. A backslash between double\-quotations is treated as a quotation mark only when it is followed by \fB$\fR, \fB`\fR, \fB"\fR, \fB\e\fR, or a newline; other backslashes are treated as normal characters\&. .RE .SS "Aliases" .sp Tokens that compose a command are subject to \fIalias substitution\fR\&. A token that matches the name of an alias that has already been defined is substituted with the value of the alias before the command is parsed\&. .sp Tokens that contain quotations are not alias\-substituted since an alias name cannot contain quotation marks\&. Keywords and command separator characters are not alias\-substituted either\&. .sp There are two kinds of aliases: normal aliases and global aliases\&. A \fInormal alias\fR can only substitute the first token of a command while a \fIglobal alias\fR can substitute any part of a command\&. Global aliases are yash extension that is not defined in POSIX\&. .sp If a token is alias\-substituted with the value of a normal alias that ends with a whitespace, the next token is exceptionally subject to alias substitution for normal aliases\&. .sp The results of alias substitution are again subject to alias substitution for other aliases (but not for the aliases that have been already applied)\&. .sp You can define aliases using the alias built\-in and remove using the unalias built\-in\&. .SS "Simple commands" .sp A command that does not start with a keyword token is a \fIsimple command\fR\&. Simple commands are executed as defined in Execution of simple commands\&. .sp If the first and any number of following tokens of a simple command have the form \fB\fIname\fR\fR\fB=\fR\fB\fIvalue\fR\fR, they are interpreted as variable assignments\&. A variable name must consist of one or more alphabets, digits and/or underlines (\fB_\fR) and must not start with a digit\&. The first token that is not a variable assignment is considered as a command name and all the following tokens (whether or not they have the form \fB\fIname\fR\fR\fB=\fR\fB\fIvalue\fR\fR) as command arguments\&. .sp A variable assignment of the form \fB\fIvar\fR\fR\fB=(\fR\fB\fItokens\fR\fR\fB)\fR is interpreted as assignment to an array\&. You can write any number of tokens between a pair of parentheses\&. Tokens can be separated by not only spaces and tabs but also newlines\&. .SS "Pipelines" .sp A \fIpipeline\fR is a sequence of one or more simple commands, compound commands, and/or function definitions that are separated by \fB|\fR\&. .sp A pipeline that has more than one subcommand is executed by executing each subcommand of the pipeline in a subshell simultaneously\&. The standard output of each subcommand except the last one is redirected to the standard input of the next subcommand\&. The standard input of the first subcommand and the standard output of the last subcommand are not redirected\&. The exit status of the pipeline is that of the last subcommand\&. .sp A pipeline can be prefixed by \fB!\fR, in which case the exit status of the pipeline is \fIreversed\fR: the exit status of the pipeline is 1 if that of the last subcommand is 0, and 0 otherwise\&. .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp When the execution of a pipeline finishes, at least the execution of the last subcommand has finished since the exit status of the last subcommand defines that of the whole pipeline\&. The execution of other subcommands, however, may not have finished then\&. On the other hand, the execution of the pipeline may not finish soon after that of the last subcommand finished because the shell may choose to wait for the execution of other subcommands to finish\&. .sp .5v .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp The POSIX standard allows executing any of subcommands in the current shell rather than subshells, though yash does not do so\&. .sp .5v .RE .SS "And/or lists" .sp An \fIand/or list\fR is a sequence of one or more pipelines separated by \fB&&\fR or \fB||\fR\&. .sp An and/or list is executed by executing some of the pipelines conditionally\&. The first pipeline is always executed\&. The other pipelines are either executed or not executed according to the exit status of the previous pipelines\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If two pipelines are separated by \fB&&\fR and the exit status of the first pipeline is zero, the second pipeline is executed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If two pipelines are separated by \fB||\fR and the exit status of the first pipeline is not zero, the second pipeline is executed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} In other cases, the execution of the and/or list ends: the second and any remaining pipelines are not executed\&. .RE .sp The exit status of an and/or list is that of the last pipeline that was executed\&. .sp Normally, an and/or list must be terminated by a semicolon, ampersand, or newline\&. See Command separators and asynchronous commands\&. .SS "Command separators and asynchronous commands" .sp The whole input to the shell must be composed of any number of and/or lists separated by a semicolon or ampersand\&. A terminating semicolon can be omitted if it is followed by \fB;;\fR, \fB)\fR, or a newline\&. Otherwise, an and/or list must be terminated by a semicolon or ampersand\&. .sp If an and/or list is terminated by a semicolon, it is executed synchronously: the shell waits for the and/or list to finish before executing the next and/or list\&. If an and/or list is terminated by an ampersand, it is executed asynchronously: after the execution of the and/or list is started, the next and/or list is executed immediately\&. An asynchronous and/or list is always executed in a subshell and its exit status is zero\&. .sp If the shell is not doing job control, the standard input of an asynchronous and/or list is automatically redirected to /dev/null\&. Signal handlers of the and/or list for the SIGINT and SIGQUIT signals are set to \(lqignore\(rq the signal so that the execution of the and/or list cannot be stopped by those signals\&. (In the POSIXly\-correct mode, the standard input is redirected if and only if the shell is interactive, regardless of whether job control is on\&. Moreover, the SIGINT and SIGQUIT signals are ignored even if job control is on\&.) .sp When the execution of an asynchronous and/or list is started, the shell remembers its process ID\&. You can obtain the ID by referencing the \fB!\fR special parameter\&. You can obtain the current and exit status of the asynchronous list as well by using the jobs and wait built\-ins\&. .SS "Compound commands" .sp Compound commands provide you with programmatic control of shell command execution\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBGrouping\fR .RS 4 .sp A grouping is a list of commands that is treated as a simple command\&. .PP Normal grouping syntax .RS 4 \fB{ \fR\fB\fIcommand\fR\fR\fB\&...; }\fR .RE .PP Subshell grouping syntax .RS 4 \fB(\fR\fB\fIcommand\fR\fR\fB\&...)\fR .RE .sp The \fB{\fR and \fB}\fR tokens are keywords, which must be separated from other tokens\&. The \fB(\fR and \fB)\fR tokens, however, are special separators that need not to be separated\&. .sp In the normal grouping syntax, the commands in a grouping are executed in the current shell\&. In the subshell grouping syntax, the commands are executed in a new subshell\&. .sp In the POSIXly\-correct mode, a grouping must contain at least one command\&. If the shell is not in the POSIXly\-correct mode, a grouping may contain no commands\&. .sp The exit status of a grouping is that of the last command in the grouping\&. If the grouping contains no commands, its exit status is that of the last executed command before the grouping\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBIf command\fR .RS 4 .sp The if command performs a conditional branch\&. .PP Basic if command syntax .RS 4 \fBif \fR\fB\fIcondition\fR\fR\fB\&...; then \fR\fB\fIbody\fR\fR\fB\&...; fi\fR .RE .PP Syntax with the else clause .RS 4 \fBif \fR\fB\fIcondition\fR\fR\fB\&...; then \fR\fB\fIbody\fR\fR\fB\&...; else \fR\fB\fIbody\fR\fR\fB\&...; fi\fR .RE .PP Syntax with the elif clause .RS 4 \fBif \fR\fB\fIcondition\fR\fR\fB\&...; then \fR\fB\fIbody\fR\fR\fB\&...; elif \fR\fB\fIcondition\fR\fR\fB\&...; then \fR\fB\fIbody\fR\fR\fB\&...; fi\fR .RE .PP Syntax with the elif clause .RS 4 \fBif \fR\fB\fIcondition\fR\fR\fB\&...; then \fR\fB\fIbody\fR\fR\fB\&...; elif \fR\fB\fIcondition\fR\fR\fB\&...; then \fR\fB\fIbody\fR\fR\fB\&...; else \fR\fB\fIbody\fR\fR\fB\&...; fi\fR .RE .sp For all the syntaxes, the execution of an if command starts with the execution of the \fIcondition\fR commands that follows the \fBif\fR token\&. If the exit status of the condition commands is zero, the condition is considered as \(lqtrue\(rq\&. In this case, the \fIbody\fR commands that follows the \fBthen\fR token are executed and the execution of the if command finishes\&. If the exit status of the condition commands is non\-zero, the condition is considered as \(lqfalse\(rq\&. In this case, the \fIcondition\fR commands for the next elif clause are executed and the exit status is tested in the same manner as above\&. If there is no elif clause, the \fIbody\fR commands that follow the \fBelse\fR token are executed and the execution of the if command finishes\&. If there is no else clause either, the execution of the if command just ends\&. .sp An if command may have more than one elif\-then clause\&. .sp The exit status of an if command is that of the \fIbody\fR commands that were executed\&. The exit status is zero if no \fIbody\fR commands were executed, that is, all the conditions were false and there was no else clause\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBWhile and until loops\fR .RS 4 .sp The while loop and until loop are simple loops with condition\&. .PP While loop syntax .RS 4 \fBwhile \fR\fB\fIcondition\fR\fR\fB\&...; do \fR\fB\fIbody\fR\fR\fB\&...; done\fR .RE .PP Until loop syntax .RS 4 \fBuntil \fR\fB\fIcondition\fR\fR\fB\&...; do \fR\fB\fIbody\fR\fR\fB\&...; done\fR .RE .sp If the shell is not in the POSIXly\-correct mode, you can omit the \fIcondition\fR and/or \fIbody\fR commands of a while/until loop\&. .sp The execution of a while loop is started by executing the \fIcondition\fR commands\&. If the exit status of the \fIcondition\fR commands is zero, the shell executes the \fIbody\fR commands and returns to the execution of the \fIcondition\fR commands\&. The \fIcondition\fR and \fIbody\fR commands are repeatedly executed until the exit status of the \fIcondition\fR commands is non\-zero\&. .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp The \fIbody\fR commands are not executed at all if the first execution of the \fIcondition\fR commands yields a non\-zero exit status\&. .sp .5v .RE .sp An until loop is executed in the same manner as a while loop except that the condition to repeat the loop is reversed: the \fIbody\fR commands are executed when the exit status of the \fIcondition\fR commands is non\-zero\&. .sp The exit status of a while/until loop is that of the last executed \fIbody\fR command\&. The exit status is zero if the \fIbody\fR commands are empty or were not executed at all\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBFor loop\fR .RS 4 .sp The for loop repeats commands with a variable assigned one of given values in each round\&. .PP For loop syntax .RS 4 \fBfor \fR\fB\fIvarname\fR\fR\fB in \fR\fB\fIword\fR\fR\fB\&...; do \fR\fB\fIcommand\fR\fR\fB\&...; done\fR\fBfor \fR\fB\fIvarname\fR\fR\fB do \fR\fB\fIcommand\fR\fR\fB\&...; done\fR .RE .sp The \fIword\fR list after the \fBin\fR token may be empty, but the semicolon (or newline) before the \fBdo\fR token is required even in that case\&. The \fIword\fRs are not treated as keywords, but you need to quote separator characters (such as \fB&\fR and \fB|\fR) to include them as part of a \fIword\fR\&. If you omit the \fBin\fR token and the following \fIword\fRs, you must also omit the semicolon before the \fBdo\fR token\&. However, the shell does not complain about the existence of the semicolon if not in the POSIXly\-correct mode\&. The \fIcommand\fR list may be empty if not in the POSIXly\-correct mode\&. .sp The execution of a for loop is started by expanding the \fIword\fRs in the same manner as in the execution of a simple command\&. If the \fBin\fR and \fIword\fR tokens are omitted, the shell assumes the \fIword\fR tokens to be \fB"$@"\fR\&. Next, the following steps are taken for each word expanded (in the order the words were expanded): .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} Assign the word to the variable whose name is \fIvarname\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} Execute the \fIcommand\fRs\&. .RE .sp Each word is assigned as a local variable except in the POSIXly\-correct mode\&. If the expansion of the \fIword\fRs yielded no words as a result, the \fIcommand\fRs are not executed at all\&. .sp The exit status of a for loop is that of the last executed \fIcommand\fR\&. The exit status is zero if the \fIcommand\fRs are not empty and not executed at all\&. If the \fIcommand\fRs are empty, the exit status is that of the last executed command before the for loop\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBCase command\fR .RS 4 .sp The case command performs a pattern matching to select commands to execute\&. .PP Case command syntax .RS 4 \fBcase \fR\fB\fIword\fR\fR\fB in \fR\fB\fIcaseitem\fR\fR\fB\&... esac\fR .RE .PP Case item syntax .RS 4 \fB(\fR\fB\fIpatterns\fR\fR\fB) \fR\fB\fIcommand\fR\fR\fB\&...;;\fR .RE .sp The \fIword\fR between the \fBcase\fR and \fBin\fR tokens must be exactly one word\&. The \fIword\fR is not treated as a keyword, but you need to quote separator characters (such as \fB&\fR and \fB|\fR) to include them as part of the \fIword\fR\&. Between the \fBin\fR and \fBesac\fR tokens you can put any number of case items (may be none)\&. You can omit the first \fB(\fR token of a case item and the last \fB;;\fR token before the \fBesac\fR token\&. If the last \fIcommand\fR of a case item is terminated by a semicolon, you can omit the semicolon as well\&. The \fIcommand\fRs in a case item may be empty\&. .sp The \fIpatterns\fR in a case item are one or more tokens each separated by a \fB|\fR token\&. .sp The execution of a case command starts with subjecting the \fIword\fR to the four expansions\&. Next, the following steps are taken for each case item (in the order of appearance): .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} For each word in the \fIpatterns\fR, expand the word in the same manner as the \fIword\fR and test if the expanded pattern matches the expanded word\&. (If a pattern is found that matches the word, the remaining patterns are not expanded nor tested, so some of the \fIpatterns\fR may not be expanded\&. Yash expands and tests the patterns in the order of appearance, but it may not be the case for other shells\&.) .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} If one of the \fIpatterns\fR was found to match the \fIword\fR in the previous step, the \fIcommand\fRs in this case item are executed and the execution of the whole case item ends\&. Otherwise, proceed to the next case item\&. .RE .sp The exit status of a case command is that of the \fIcommand\fRs executed\&. The exit status is zero if no \fIcommand\fRs were executed, that is, there were no case items, no matching pattern was found, or no commands were associated with the matching pattern\&. .sp In the POSIXly\-correct mode, the first pattern in a case item cannot be \fBesac\fR (even if you do not omit the \fB(\fR token)\&. .RE .SS "Function definition" .sp The function definition command defines a function\&. .PP Function definition syntax .RS 4 \fB\fIfuncname\fR\fR\fB ( ) \fR\fB\fIcompound_command\fR\fR\fBfunction \fR\fB\fIfuncname\fR\fR\fB \fR\fB\fIcompound_command\fR\fR\fBfunction \fR\fB\fIfuncname\fR\fR\fB ( ) \fR\fB\fIcompound_command\fR\fR .RE .sp In the first syntax without the \fBfunction\fR keyword, \fIfuncname\fR cannot contain any special characters such as semicolons and quotation marks\&. In the second and third syntax, which cannot be used in the POSIXly\-correct mode, \fIfuncname\fR is subjected to the four expansions when executed\&. .sp When a function definition command is executed, a function whose name is \fIfuncname\fR is defined with its body being \fIcompound_command\fR\&. .sp A function definition command cannot be directly redirected\&. Any redirections that follow a function definition are associated with \fIcompound_command\fR rather than the whole function definition command\&. In \fBfunc() { cat; } >/dev/null\fR, for example, it is not \fBfunc() { cat; }\fR but \fB{ cat; }\fR that is redirected\&. .sp The exit status of a function definition is zero if the function was defined without errors, and non\-zero otherwise\&. .SH "PARAMETERS AND VARIABLES" .sp \fIParameters\fR are string values that are expanded in parameter expansion\&. There are three types of parameters: positional parameters, special parameters and variables\&. .SS "Positional parameters" .sp \fIPositional parameters\fR are parameters that are identified by natural numbers\&. If there are three positional parameters, for example, they are identified as \fB1\fR, \fB2\fR, and \fB3\fR\&. You can obtain the number of positional parameters by the \fB#\fR special parameter\&. The \fB*\fR and \fB@\fR special parameters are expanded to all positional parameters\&. .sp Positional parameters are initialized from the shell\(cqs command line arguments when the shell is started (see Command line arguments)\&. In the initialization, the order of the operands are preserved as the order of the positional parameters\&. .sp When the shell executes a function call, positional parameters are changed to the arguments to the function call so that you can access the arguments while the function is being executed\&. Positional parameters are restored to the original values when the execution of the function is finished\&. .sp Positional parameters can be manipulated by built\-in commands like set and shift\&. .sp Note that \fB0\fR is not a positional parameter but a special parameter\&. .SS "Special parameters" .sp \fISpecial parameters\fR are parameters each identified by a single symbol\&. They cannot be directly assigned to by the user\&. .sp Yash provides the following special parameters: .PP \fB0\fR .RS 4 The name of the shell executable file or the script file that was specified in the invocation of the shell\&. .RE .PP \fB#\fR .RS 4 The number of current positional parameters\&. The value is a non\-negative integer\&. .RE .PP \fB$\fR .RS 4 The process ID of the shell\&. The value is a positive integer and is never changed even in subshells\&. .RE .PP \fB\-\fR .RS 4 Currently enabled shell options\&. The value is a concatenation of alphabet characters that are the names of currently enabled single\-character options that can be specified in shell invocation\&. The value reflects changes of enabled options when you enable or disable options using the set built\-in\&. .RE .PP \fB?\fR .RS 4 The exit status of the last executed pipeline\&. The value is a non\-negative integer\&. .RE .PP \fB!\fR .RS 4 The process ID of the last executed asynchronous list\&. .RE .PP \fB*\fR .RS 4 This special parameter represents the whole positional parameters\&. When there is no positional parameters, the value of this special parameter is the empty string\&. When there is more than one positional parameter, the value is a concatenation of all the positional parameters, each of which is separated as follows: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the \fBIFS\fR variable exists and its value is not empty, positional parameters are each separated by the first character of the value of the \fBIFS\fR variable\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the \fBIFS\fR variable exists and has an empty value, positional parameters are just concatenated without any separator\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the \fBIFS\fR variable does not exist, positional parameters are each separated by a space character\&. .RE .RE .PP \fB@\fR .RS 4 This special parameter represents the whole positional parameters like the \fB*\fR special parameter above\&. The difference between the two is the results of expansion that occurs between a pair of double\-quotation marks\&. If the \fB@\fR special parameter is expanded inside double\-quotations, positional parameters are field\-split rather than concatenated (in spite of the quotation)\&. If there are no positional parameters, the expansion yields no word rather than an empty word\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When there are no positional parameters, the command words \fBecho 1 "$@" 2\fR is expanded to the three words \fBecho\fR, \fB1\fR, and \fB2\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When positional parameters are the three words \fB1\fR, \fB2 2\fR, and \fB3\fR, the command words \fBecho "$@"\fR is expanded to the four words \fBecho\fR, \fB1\fR, \fB2 2\fR, and \fB3\fR, and the words \fBecho "a$@b"\fR to the four words \fBecho\fR, \fBa1\fR, \fB2 2\fR, and \fB3b\fR\&. .RE .RE .SS "Variables" .sp \fIVariables\fR are parameters the user can assign values to\&. Each variable has a name that identifies it and a value that defines the results of expansion\&. .sp A variable name is composed of one or more alphanumeric characters and underscores (\fB_\fR)\&. A name cannot start with a digit\&. Other characters may be used in a name depending on internationalization support of your environment\&. .sp Variables that are exported to external commands are called \fIenvironment variables\fR\&. They are passed to all external commands the shell invokes\&. Variables passed to the shell in invocation will be automatically exported\&. .sp You can assign to variables by a simple command as well as the typeset built\-in\&. You can remove variables by using the unset built\-in\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBVariables used by the shell\fR .RS 4 .sp The following variables are used by the shell for special purposes\&. .PP \fBCDPATH\fR .RS 4 This variable is used by the cd built\-in to find a destination directory\&. .RE .PP \fBCOLUMNS\fR .RS 4 This variable specifies the width (the number of character columns) of the terminal screen\&. The value affects the display of line\-editing\&. .RE .PP \fBCOMMAND_NOT_FOUND_HANDLER\fR .RS 4 When the shell cannot find a command to be executed, the value of this variable is interpreted and executed instead\&. You can override the shell\(cqs error handling behavior with this variable\&. See Execution of simple commands for detail\&. .sp This feature is disabled in the POSIXly\-correct mode\&. .RE .PP \fBDIRSTACK\fR .RS 4 This array variable is used by the shell to store the directory stack contents\&. If you modify the value of this variable, the directory stack may be corrupted\&. .RE .PP \fBECHO_STYLE\fR .RS 4 This variable specifies the behavior of the echo built\-in\&. .RE .PP \fBENV\fR .RS 4 When an interactive shell is started in the POSIXly\-correct mode, the value of this variable is used to find the initialization file\&. See Initialization of yash\&. .RE .PP \fBFCEDIT\fR .RS 4 This variable specifies an editor program used to edit command lines during execution of the fc built\-in\&. .RE .PP \fBHANDLED\fR .RS 4 This variable can be set in the command-not-found handler to tell the shell not to produce a further error message\&. See Execution of simple commands for detail\&. .RE .PP \fBHISTFILE\fR .RS 4 This variable specifies the pathname of the file to save the command history in\&. .RE .PP \fBHISTRMDUP\fR .RS 4 This variable specifies the number of command history items to be checked for duplication\&. When the shell is adding a new history item to the command history, if some of the most recent \fIn\fR items have the same contents as the new one, then the duplicate existing items are removed from the history before the new one is added, where \fIn\fR is the value of this variable\&. .sp If the value of this variable is \fB1\fR, for example, the most recent item is removed when a new item that have the same contents is added\&. .sp Items older than the \fIn\fRth recent item are not removed\&. No items are removed if the value of this variable is \fB0\fR\&. All items are subject to removal if the variable value is greater than or equal to the value of the \fBHISTSIZE\fR variable\&. .RE .PP \fBHISTSIZE\fR .RS 4 This variable specifies the maximum number of items in the command history\&. .RE .PP \fBHOME\fR .RS 4 This variable specifies the pathname of the user\(cqs home directory and affects results of tilde expansion and cd built\-in\&. .RE .PP \fBIFS\fR .RS 4 This variable specifies separators used in field splitting\&. The variable value is initialized to the three characters of a space, a tab, and a newline when the shell is started\&. .RE .PP \fBLANG\fR, \fBLC_ALL\fR, \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_MONETARY\fR, \fBLC_NUMERIC\fR, \fBLC_TIME\fR .RS 4 These variables specify a locale in which the shell runs\&. The shell chooses the file input/output encoding, the error message language, etc\&. according to the locale specified\&. .sp Unless the shell is interactive and not in the POSIXly\-correct mode, the value of the \fBLC_CTYPE\fR variable is considered only when the shell is started\&. Once the shell has been initialized, changing the value of \fBLC_CTYPE\fR will have no effect on the shell\(cqs behavior\&. .RE .PP \fBLINENO\fR .RS 4 The value of this variable is automatically set to the line number in which the currently executed command appears in the file\&. .sp In the interactive shell, the line number is reset to 1 each time the shell reads and executes a command\&. .sp If you assign to or remove this variable, it will no longer provide line numbers\&. .RE .PP \fBLINES\fR .RS 4 This variable specifies the height (the number of character lines) of the terminal screen\&. The value affects the display of line\-editing\&. .RE .PP \fBMAIL\fR .RS 4 This variable specifies the pathname of a file that is checked in mail checking\&. .RE .PP \fBMAILCHECK\fR .RS 4 This variable specifies how often the shell should do mail checking\&. The value has to be specified as a positive integer in seconds\&. The value is initialized to the default value of \fB600\fR when the shell is started\&. .RE .PP \fBMAILPATH\fR .RS 4 This variable specifies the pathnames of files that are checked in mail checking\&. .RE .PP \fBNLSPATH\fR .RS 4 The POSIX standard prescribes that the value of this variable specifies pathname templates of locale\-dependent message data files, but yash does not use it\&. .RE .PP \fBOLDPWD\fR .RS 4 This variable is set to the previous working directory path when you change the working directory by using the cd or other built\-ins\&. This variable is exported by default\&. .RE .PP \fBOPTARG\fR .RS 4 When the getopts built\-in parses an option that takes an argument, the argument value is assigned to this variable\&. .RE .PP \fBOPTIND\fR .RS 4 The value of this variable specifies the index of an option that is to be parsed by the next getopts built\-in execution\&. This variable is initialized to \fB1\fR when the shell is started\&. .RE .PP \fBPATH\fR .RS 4 This variable specifies paths that are searched for a command in command search\&. .RE .PP \fBPPID\fR .RS 4 The value of this variable is the process ID of the shell\(cqs parent process, which is a positive integer\&. This variable is initialized when the shell is started\&. The value is not changed when the shell makes a new subshell\&. .RE .PP \fBPROMPT_COMMAND\fR .RS 4 The shell interprets and executes the value of this variable before printing each command prompt if the shell is interactive and not in the POSIXly\-correct mode\&. This behavior is equivalent to executing the command \fBeval \-i \-\- "${PROMPT_COMMAND\-}"\fR before each command prompt, but its exit status does not affect the expansion of the \fB?\fR special parameter in the next command\&. .RE .PP \fBPS1\fR .RS 4 This variable specifies the main command prompt string printed by an interactive shell\&. See Prompts for the format of the variable value\&. The value is initialized to \fB\e$ \fR when the shell is started\&. (In the POSIXly\-correct mode, the initial value is either \fB$ \fR or \fB# \fR depending on whether the effective user ID of the shell process is zero or not\&.) .RE .PP \fBPS1R\fR .RS 4 This variable specifies the auxiliary prompt string printed to the right of the cursor when you input a command line to an interactive shell\&. See Prompts for the format of the variable value\&. .RE .PP \fBPS1S\fR .RS 4 This variable specifies the font style of command strings you enter to an interactive shell\&. See Prompts for the format of the variable value\&. .RE .PP \fBPS2\fR .RS 4 This variable is like the \fBPS1\fR variable, but it is used for the second and following lines of a command that is longer than one line\&. See Prompts for the format of the variable value\&. The value is initialized to \fB> \fR when the shell is started\&. .RE .PP \fBPS2R\fR .RS 4 This variable is like the \fBPS1R\fR variable, but it is used when \fBPS2\fR is used\&. See Prompts for the format of the variable value\&. .RE .PP \fBPS2S\fR .RS 4 This variable is like the \fBPS1S\fR variable, but it is used when \fBPS2\fR is used\&. See Prompts for the format of the variable value\&. .RE .PP \fBPS4\fR .RS 4 The value of this variable is printed before each command trace output when the xtrace option is enabled\&. The value is subject to parameter expansion, command substitution, arithmetic expansion\&. You can also use backslash notations if the shell is not in the POSIXly\-correct mode\&. The value is initialized to \fB+ \fR when the shell is started\&. .RE .PP \fBPS4S\fR .RS 4 This variable is like the \fBPS1S\fR variable, but it is used when \fBPS4\fR is used\&. You can use this variable to modify font style of command trace output\&. .RE .PP \fBPWD\fR .RS 4 The value of this variable is the pathname of the current working directory\&. The value is set when the shell is started and reset each time the working directory is changed by the cd or other built\-ins\&. This variable is exported by default\&. .RE .PP \fBRANDOM\fR .RS 4 You can use this variable to get random numbers\&. The value of this variable is a uniformly distributed random integer between 0 and 32767 (inclusive)\&. You will get a different number each time the variable is expanded\&. .sp You can set the \(lqseed\(rq of random numbers by assigning a non\-negative integer to the variable\&. .sp If you remove this variable, it will no longer work as a random number generator\&. If the shell was invoked in the POSIXly\-correct mode, this variable does not work as a random number generator\&. .RE .PP \fBTERM\fR .RS 4 This variable specifies the type of the terminal in which the shell is running\&. The value affects the behavior of line\-editing\&. .RE .PP \fBYASH_AFTER_CD\fR .RS 4 The shell interprets and executes the value of this variable after each time the shell\(cqs working directory is changed by the cd or other built\-ins\&. This behavior is equivalent to executing the command \fBeval \-i \-\- "${YASH_AFTER_CD\-}"\fR after the directory was changed\&. .RE .PP \fBYASH_LOADPATH\fR .RS 4 This variable specifies directories the dot built\-in searches for a script file\&. More than one directory can be specified by separating them by colons like the \fBPATH\fR variable\&. When the shell is started, this variable is initialized to the pathname of the directory where common script files are installed\&. .RE .PP \fBYASH_LE_TIMEOUT\fR .RS 4 This variable specifies how long the shell should wait for a next possible input from the terminal when it encountered an ambiguous control sequence while line\-editing\&. The value must be specified in milliseconds\&. If you do not define this variable, the default value of 100 milliseconds is assumed\&. .RE .PP \fBYASH_VERSION\fR .RS 4 The value is initialized to the version number of the shell when the shell is started\&. .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBArrays\fR .RS 4 .sp An \fIarray\fR is a variable that contains zero or more strings\&. The string values of an array are identified by natural numbers (like positional parameters)\&. .sp You can assign values to an array by using a simple command as well as the array built\-in\&. You can use the unset built\-in to remove arrays\&. .sp Arrays cannot be exported as arrays\&. When an array is exported, it is treated as a normal variable whose value is a concatenation of all the array values, each separated by a colon\&. .sp Arrays are not supported in the POSIXly\-correct mode\&. .RE .SH "WORD EXPANSIONS" .sp \fIWord expansion\fR is substitution of part of a word with another particular string\&. There are seven types of word expansions: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} Tilde expansion .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} Parameter expansion .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} Command substitution .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} Arithmetic expansion .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} Brace expansion .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} Field splitting .RE .sp .RS 4 .ie n \{\ \h'-04' 7.\h'+01'\c .\} .el \{\ .sp -1 .IP " 7." 4.2 .\} Pathname expansion (globbing) .RE .sp These types of expansions are performed in the order specified above\&. .sp Tilde expansion, parameter expansion, command substitution, and arithmetic expansion are called the \fIfour expansions\fR\&. .SS "Tilde expansion" .sp In \fItilde expansion\fR, parts of words that start with a tilde (\fB~\fR) are substituted with particular pathnames\&. The part of each word that gets substituted is from the beginning of the word, which is a tilde, up to (but not including) the first slash (\fB/\fR) in the word\&. If the word does not contain a slash, the whole word is substituted\&. If any character in the substituted part is quoted, tilde expansion is not performed on the word\&. .sp The results of expansion are determined by the format of the substituted part: .PP \fB~\fR .RS 4 A single tilde is substituted with the value of the \fBHOME\fR variable\&. .RE .PP \fB~\fR\fB\fIusername\fR\fR .RS 4 A tilde followed by a user name is substituted with the pathname of the user\(cqs home directory\&. .RE .PP \fB~+\fR .RS 4 \fB~+\fR is substituted with the value of the \fBPWD\fR variable\&. .RE .PP \fB~\-\fR .RS 4 \fB~\-\fR is substituted with the value of the \fBOLDPWD\fR variable\&. .RE .PP \fB~+\fR\fB\fIn\fR\fR, \fB~\-\fR\fB\fIn\fR\fR .RS 4 where \fIn\fR is a non\-negative integer\&. This type of tilde expansion yields the pathname of a directory of which \fB~+\fR\fB\fIn\fR\fR or \fB~\-\fR\fB\fIn\fR\fR is the index in the directory stack\&. .RE .sp When tilde expansion is performed on the value of a variable assignment that occurs during execution of a simple command, the value is considered as a colon\-separated list of words and those words are each subject to tilde expansion\&. For example, the variable assignment .sp .if n \{\ .RS 4 .\} .nf VAR=~/a:~/b:~/c .fi .if n \{\ .RE .\} .sp is equivalent to .sp .if n \{\ .RS 4 .\} .nf VAR=/home/foo/a:/home/foo/b:/home/foo/c .fi .if n \{\ .RE .\} .sp if the value of \fBHOME\fR variable is \fB/home/foo\fR\&. .sp The POSIX standard does not prescribe how the shell should behave when it encounters an error during tilde expansion (e\&.g\&., when the \fBHOME\fR variable is not defined)\&. Yash silently ignores any errors during tilde expansion; the part of the word that would be substituted is left intact\&. .sp In the POSIXly\-correct mode, tilde expansion supports the formats of \fB~\fR and \fB~\fR\fB\fIusername\fR\fR only\&. .SS "Parameter expansion" .sp \fIParameter expansion\fR expands to the value of a parameter\&. .sp The syntax of typical, simple parameter expansion is \fB${\fR\fB\fIparameter\fR\fR\fB}\fR, which expands to the value of the parameter whose name is \fIparameter\fR\&. You can omit the braces (e\&.g\&., \fB$\fR\fB\fIparameter\fR\fR) if .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIparameter\fR is a special parameter, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIparameter\fR is a positional parameter whose index is a one\-digit integer, or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIparameter\fR is a variable and the parameter expansion is not followed by a character that can be used as part of a variable name\&. For example, \fB${path}\-name\fR is equivalent to \fB$path\-name\fR, but \fB${path}name\fR and \fB$pathname\fR are different\&. .RE .sp If \fIparameter\fR is none of a special parameter, positional parameter, and variable, it is a syntax error\&. (Some shells other than yash may treat such a case as an expansion error\&.) .sp If the unset option is disabled and the \fIparameter\fR is an undefined variable, it is an expansion error\&. If the unset option is enabled, an undefined variable expands to the empty string\&. .sp More complex syntax of parameter expansion allows modifying the value of a parameter\&. .PP Parameter expansion .RS 4 \fB${ \fR\fB\fIprefix\fR\fR\fB \fR\fB\fIparameter\fR\fR\fB \fR\fB\fIindex\fR\fR\fB \fR\fB\fImodifier\fR\fR\fB }\fR .RE .sp The spaces in the syntax definition above are for readability only and must be omitted\&. You can omit \fIprefix\fR, \fIindex\fR, and/or \fImodifier\fR\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBPrefix\fR .RS 4 .sp The \fIprefix\fR, if any, must be a hash sign (\fB#\fR)\&. If a parameter expansion has the prefix, the result of expansion is the number of characters in the value this expansion would be expanded to without the prefix\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBParameter name\fR .RS 4 .sp The parameter name (\fIparameter\fR) must be either .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} a name of a special parameter, positional parameter, or variable; or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} another parameter expansion, command substitution, or arithmetic expansion\&. .RE .sp The parameter expansion is expanded to the value of the \fIparameter\fR\&. If \fIparameter\fR is an array variable, the values of the array are field-split like the \fB@\fR special parameter unless the index \fB[*]\fR is specified\&. .sp If \fIparameter\fR is another expansion, it is called a \fInested expansion\fR\&. Nested expansion cannot be used in the POSIXly\-correct mode\&. The braces (\fB{ }\fR) of a nested parameter expansion cannot be omitted\&. .RE Index.sp An \fIindex\fR allows extracting part of the parameter value (or some of array values)\&. .PP Index .RS 4 \fB[\fR\fB\fIword1\fR\fR\fB]\fR .sp \fB[\fR\fB\fIword1\fR\fR\fB,\fR\fB\fIword2\fR\fR\fB]\fR .RE .sp where \fIword1\fR and \fIword2\fR are parsed in the same manner as normal tokens except that they are always delimited by \fB,\fR or \fB]\fR and can contain whitespace characters\&. .sp If there is an \fIindex\fR in a parameter expansion, it is interpreted as follows: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} Words \fIword1\fR and \fIword2\fR are subjected to parameter expansion, command substitution, and arithmetic expansion\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} If there is no \fIword2\fR and if \fIword1\fR expands to one of \fB*\fR, \fB@\fR, and \fB#\fR, then that is the interpretation of \fIindex\fR and the next step is not taken\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} The results of the previous steps (the expanded \fIword1\fR and \fIword2\fR) are interpreted and evaluated as an arithmetic expression in the same manner as in arithmetic expansion\&. The resulting integers are the interpretation of \fIindex\fR\&. If the results are not integers, it is an expansion error\&. If there is no \fIword2\fR, it is assumed that \fIword2\fR is equal to \fIword1\fR\&. .RE .sp If \fIparameter\fR is an array variable, the \fIindex\fR specifies the part of the array\&. If \fIparameter\fR is either the \fB*\fR or \fB@\fR special parameter, the \fIindex\fR specifies the index range of positional parameters\&. In other cases, the \fIindex\fR specifies the index range of a substring of the parameter value that is being expanded\&. In all cases, the specified range of the array values, positional parameters, or parameter value remains in the results of the expansion and other values are dropped\&. .sp If the interpretation of \fIindex\fR is one or two integers, the following rules apply: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the interpreted index value is negative, it \fIwraps around\fR\&. For example, the index value of \-1 corresponds to the last value/character\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} It is not an error when the index value is out of range\&. Existing values/characters within the range are just selected\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the interpretation of either \fIword1\fR or \fIword2\fR is 0, the range is assumed empty and the expansion results in nothing\&. .RE .sp If the interpretation of \fIindex\fR is one of \fB*\fR, \fB@\fR, and \fB#\fR, it is treated as follows: .PP \fB*\fR .RS 4 If \fIparameter\fR is an array, all values of the array are concatenated into a single string\&. If \fIparameter\fR is the \fB*\fR or \fB@\fR special parameter, all positional parameters are concatenated into a string\&. See the description of the \fB*\fR special parameter for how the values/positional parameters are separated in the result string\&. In other cases, the interpretation of \fIindex\fR is treated as if the interpretation is the two integers 1 and \-1\&. .RE .PP \fB@\fR .RS 4 The interpretation of \fIindex\fR is treated as if the interpretation is the two integers 1 and \-1\&. .RE .PP \fB#\fR .RS 4 The interpretation of the \fB#\fR\fIindex\fR is special in that it does not simply specify a range\&. Instead, the expanded values are substituted with the count\&. .sp If \fIparameter\fR is an array, the result of this parameter expansion will be the number of values in the array being expanded\&. If \fIparameter\fR is the \fB*\fR or \fB@\fR special parameter, the result will be the number of current positional parameters\&. Otherwise, the result will be the number of characters in the value that is being expanded\&. .RE .sp If a parameter expansion does not contain an \fIindex\fR, it is assumed to be \fB[@]\fR\&. In the POSIXly\-correct mode, \fIindex\fR cannot be specified\&. .PP \fBExample\ \&1.\ \&Expansion of a normal variable\fR .sp The following commands will print the string \fBABC\fR: .sp .if n \{\ .RS 4 .\} .nf var=\*(Aq123ABC789\*(Aq echo "${var[4,6]}" .fi .if n \{\ .RE .\} .PP \fBExample\ \&2.\ \&Expansion of positional parameters\fR .sp The following commands will print the string \fB2 3 4\fR: .sp .if n \{\ .RS 4 .\} .nf set 1 2 3 4 5 echo "${*[2,\-2]}" .fi .if n \{\ .RE .\} .PP \fBExample\ \&3.\ \&Expansion of an array\fR .sp The following commands will print the string \fB2 3 4\fR: .sp .if n \{\ .RS 4 .\} .nf array=(1 2 3 4 5) echo "${array[2,\-2]}" .fi .if n \{\ .RE .\} .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBModifier\fR .RS 4 .sp You can modify the value to be expanded by using \fImodifiers\fR: .PP \fB\-\fR\fB\fIword\fR\fR .RS 4 If the parameter name (\fIparameter\fR) is an undefined variable, the parameter expansion is expanded to \fIword\fR\&. It is not treated as an error if the unset option is disabled\&. .RE .PP \fB+\fR\fB\fIword\fR\fR .RS 4 If the parameter name (\fIparameter\fR) is an existing variable, the parameter expansion is expanded to \fIword\fR\&. It is not treated as an error if the unset option is disabled\&. .RE .PP \fB=\fR\fB\fIword\fR\fR .RS 4 If the parameter name (\fIparameter\fR) is an undefined variable, \fIword\fR is assigned to the variable and the parameter expansion is expanded to \fIword\fR\&. It is not treated as an error if the unset option is disabled\&. .RE .PP \fB?\fR\fB\fIword\fR\fR .RS 4 If the parameter name (\fIparameter\fR) is an undefined variable, \fIword\fR is printed as an error message to the standard error\&. If \fIword\fR is empty, the default error message is printed instead\&. .RE .PP \fB:\-\fR\fB\fIword\fR\fR, \fB:+\fR\fB\fIword\fR\fR, \fB:=\fR\fB\fIword\fR\fR, \fB:?\fR\fB\fIword\fR\fR .RS 4 These are similar to the four types of modifiers above\&. The only difference is that, if \fIparameter\fR exists and has an empty value, it is also treated as an undefined variable\&. .RE .PP \fB#\fR\fB\fIword\fR\fR .RS 4 The shell performs pattern matching against the value that is being expanded, using \fIword\fR as a pattern\&. If \fIword\fR matches the beginning of the value, the matching part is removed from the value and the other part remains as expansion results\&. The shortest matching is used if more than one matching is possible\&. .RE .PP \fB##\fR\fB\fIword\fR\fR .RS 4 This is similar to \fB#\fR\fB\fIword\fR\fR above\&. The only difference is that the longest matching is used if more than one matching is possible\&. .RE .PP \fB%\fR\fB\fIword\fR\fR .RS 4 This is similar to \fB#\fR\fB\fIword\fR\fR above\&. The only difference is that matching is tried at the end of the value rather than at the beginning: if \fIword\fR matches the end of the value, the matching part is removed from the value and the other part remains as expansion results\&. .RE .PP \fB%%\fR\fB\fIword\fR\fR .RS 4 This is similar to \fB%\fR\fB\fIword\fR\fR above\&. The only difference is that the longest matching is used if more than one matching is possible\&. .RE .PP \fB/\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR .RS 4 The shell performs pattern matching against the value that is being expanded, using \fIword1\fR as a pattern\&. If \fIword1\fR matches any part of the value, the matching part is replaced with \fIword2\fR and the whole value after the replacement remains as expansion results\&. If \fIword1\fR matches more than one part of the value, only the first part is replaced\&. The shortest matching is replaced if more than one matching is possible for the same starting point in the value\&. .sp This modifier cannot be used in the POSIXly\-correct mode\&. .RE .PP \fB/#\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR .RS 4 This is similar to \fB/\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR above\&. The only difference is that \fIword1\fR matches only at the beginning of the value being expanded\&. .RE .PP \fB/%\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR .RS 4 This is similar to \fB/\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR above\&. The only difference is that \fIword1\fR matches only at the end of the value being expanded\&. .RE .PP \fB//\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR .RS 4 This is similar to \fB/\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR above\&. The only difference is that all matched parts are replaced if \fIword1\fR matches more than one part of the value\&. .RE .PP \fB:/\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR .RS 4 This is similar to \fB/\fR\fB\fIword1\fR\fR\fB/\fR\fB\fIword2\fR\fR above\&. The only difference is that the value is replaced only when \fIword1\fR matches the whole value\&. .RE .sp In all types of modifiers above, words are subjected to the four expansions when (and only when) they are used\&. .sp If \fIparameter\fR is an array variable or the \fB@\fR or \fB*\fR special parameter, modifiers affect each value of the array or all positional parameters\&. .RE .SS "Command substitution" .sp \fICommand substitution\fR expands to output of commands specified\&. .PP Command substitution .RS 4 \fB$(\fR\fB\fIcommands\fR\fR\fB)\fR .sp \fB`\fR\fB\fIcommands\fR\fR\fB`\fR .RE .sp When command substitution is evaluated, \fIcommands\fR are executed by a subshell with output pipelined to the shell\&. When the \fIcommands\fR finished, command substitution is substituted with the output of the \fIcommands\fR\&. Any trailing newline characters in the output are ignored\&. .sp When command substitution of the form \fB$(\fR\fB\fIcommands\fR\fR\fB)\fR is parsed, the \fIcommands\fR are parsed carefully so that complex commands such as nested command substitution are parsed correctly\&. If \fIcommands\fR start with \fB(\fR, you should put a space before \fIcommands\fR so that the whole command substitution is not confused with arithmetic expansion\&. If the shell is in the POSIXly\-correctly mode, the \fIcommands\fR are parsed each time the command substitution is expanded; otherwise, \fIcommands\fR are parsed only when the command substitution is parsed\&. .sp If command substitution is of the form \fB`\fR\fB\fIcommands\fR\fR\fB`\fR, the \fIcommands\fR are not parsed when the command substitution is parsed\&. The end of \fIcommands\fR is detected by the first backquote character (\fB`\fR) after the beginning of \fIcommands\fR that is not quoted by a backslash\&. Backquotes that are part of \fIcommands\fR (typically used for nested command substitution) must be quoted by backslashes\&. The \fIcommands\fR are parsed each time the command substitution is expanded\&. .SS "Arithmetic expansion" .sp \fIArithmetic expansion\fR evaluates an arithmetic expression and expands to the value of the expression\&. .PP Arithmetic expansion .RS 4 \fB$((\fR\fB\fIexpression\fR\fR\fB))\fR .RE .sp When arithmetic expansion is expanded, the \fIexpression\fR is subject to parameter expansion, command substitution, and (nested) arithmetic expansion\&. The \fIexpression\fR is parsed in (almost) same manner as an expression of the C programming language\&. .sp Yash allows an expression to be either an integer (of the long type in C) or a floating\-point number (of the double type in C)\&. An operation on integers yields an integer and an operation involving a floating\-point number yields a floating\-point number\&. In the POSIXly\-correct mode, you can use integers only\&. .sp The following operators are available (in the order of precedence): .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} \fB( )\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} \fB++\fR\fB\-\-\fR (postfix operators) .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} \fB++\fR\fB\-\-\fR\fB+\fR\fB\-\fR\fB~\fR\fB!\fR (prefix operators) .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} \fB*\fR\fB/\fR\fB%\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} \fB+\fR\fB\-\fR (binary operators) .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} \fB<<\fR\fB>>\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 7.\h'+01'\c .\} .el \{\ .sp -1 .IP " 7." 4.2 .\} \fB<\fR\fB<=\fR\fB>\fR\fB>=\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 8.\h'+01'\c .\} .el \{\ .sp -1 .IP " 8." 4.2 .\} \fB==\fR\fB!=\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 9.\h'+01'\c .\} .el \{\ .sp -1 .IP " 9." 4.2 .\} \fB&\fR .RE .sp .RS 4 .ie n \{\ \h'-04'10.\h'+01'\c .\} .el \{\ .sp -1 .IP "10." 4.2 .\} \fB^\fR .RE .sp .RS 4 .ie n \{\ \h'-04'11.\h'+01'\c .\} .el \{\ .sp -1 .IP "11." 4.2 .\} \fB|\fR .RE .sp .RS 4 .ie n \{\ \h'-04'12.\h'+01'\c .\} .el \{\ .sp -1 .IP "12." 4.2 .\} \fB&&\fR .RE .sp .RS 4 .ie n \{\ \h'-04'13.\h'+01'\c .\} .el \{\ .sp -1 .IP "13." 4.2 .\} \fB||\fR .RE .sp .RS 4 .ie n \{\ \h'-04'14.\h'+01'\c .\} .el \{\ .sp -1 .IP "14." 4.2 .\} \fB? :\fR .RE .sp .RS 4 .ie n \{\ \h'-04'15.\h'+01'\c .\} .el \{\ .sp -1 .IP "15." 4.2 .\} \fB=\fR\fB*=\fR\fB/=\fR\fB%=\fR\fB+=\fR\fB\-=\fR\fB<<=\fR\fB>>=\fR\fB&=\fR\fB^=\fR\fB|=\fR .RE .sp The \fB++\fR and \fB\-\-\fR operators cannot be used in the POSIXly\-correct mode\&. .sp An atomic expression can be one of an integer literal, a floating\-point number literal, and a variable\&. Literals are parsed in the same manner as in C\&. An octal integer literal starts with \fB0\fR, and hexadecimal with \fB0x\fR\&. A floating\-point number literal may have an exponent (i\&.e\&. \fB1\&.23e+6\fR)\&. A variable with a non\-numeric value will result in an error\&. .SS "Brace expansion" .sp \fIBrace expansion\fR expands to several split words with preceding and succeeding portions duplicated to each split words\&. Brace expansion is expanded only when the brace\-expand option is enabled\&. .PP Comma\-separated brace expansion .RS 4 \fB{\fR\fB\fIword1\fR\fR\fB,\fR\fB\fIword2\fR\fR\fB,\&...,\fR\fB\fIwordn\fR\fR\fB}\fR .RE .PP Range brace expansion .RS 4 \fB{\fR\fB\fIstart\fR\fR\fB\&.\&.\fR\fB\fIend\fR\fR\fB}\fR .sp \fB{\fR\fB\fIstart\fR\fR\fB\&.\&.\fR\fB\fIend\fR\fR\fB\&.\&.\fR\fB\fIdelta\fR\fR\fB}\fR .RE .sp Comma\-separated brace expansion is expanded to each comma\-separated word\&. For example, \fBa{1,2,3}b\fR is expanded to the three words \fBa1b\fR, \fBa2b\fR, and \fBa3b\fR\&. .sp Range brace expansion is expanded to integers in the range defined by \fIstart\fR and \fIend\fR\&. The difference between each integer can be defined by \fIdelta\fR\&. If \fIstart\fR is larger than \fIend\fR, the results will be in descending order\&. When \fB\&.\&.\fR\fB\fIdelta\fR\fR is omitted, it defaults to 1 or \-1\&. For example, \fBa{1\&.\&.3}b\fR is expanded to the three words \fBa1b\fR, \fBa2b\fR, and \fBa3b\fR; and \fBa{1\&.\&.7\&.\&.2}b\fR to the four words \fBa1b\fR, \fBa3b\fR, \fBa5b\fR, and \fBa7b\fR\&. .sp Multiple brace expansions can be used in one word\&. Brace expansions can also be nested\&. You can quote braces and/or commas to prevent them from being treated as brace expansion\&. .sp Any errors in brace expansion are silently ignored\&. .SS "Field splitting" .sp In \fIfield splitting\fR, words are split at predefined separators\&. .sp Field splitting can occur only within parts of words that resulted from parameter expansion, command substitution, and arithmetic expansion that are not between double\-quotation marks\&. Expansion results of the \fB@\fR special parameter are exceptionally split even between double\-quotation marks\&. .sp Separators used in field splitting are defined by the value of the \fBIFS\fR variable\&. If the variable does not exist, the value is assumed to be the three characters of space, tab, and newline\&. .sp Characters included in the value of the \fBIFS\fR variable are called \fIIFS characters\fR\&. IFS characters that are any of space, tab, and newline are called \fIIFS whitespace\fR and other IFS characters are called \fIIFS non\-whitespace\fR\&. .sp Field splitting is performed as follows: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} The shell searches words for split points\&. A split point is one or more adjacent IFS characters within the word portions that are subject to field splitting\&. The following steps are taken for each split point found\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} If the split point includes one or more IFS non\-whitespaces, any IFS whitespaces in the split point are ignored and the word is split at each IFS non\-whitespace in the split point\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} If the split point includes no IFS non\-whitespaces, the word is split at the split point unless it is at the beginning or end of the word\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} The split points are removed from the results\&. .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp Words are not split at all when the value of the \fBIFS\fR variable is empty\&. .sp .5v .RE .SS "Pathname expansion" .sp \fIPathname expansion\fR performs pattern matching and expands to pathnames matched by the pattern\&. .sp A word subjected to pathname expansion is treated as a pattern\&. If one or more pathnames are found that are matched by the pattern, the pathnames become the results of the pathname expansion\&. .sp Pathname expansion is not performed when the glob option is disabled\&. .sp The shell searches readable directories for matching pathnames\&. Unreadable directories are silently ignored\&. .sp The following options affect the behavior of pathname expansion: .PP null\-glob .RS 4 This option affects the result of pathname expansion when no matching pathnames are found\&. If enabled, the result is no word\&. If disabled, the result is the original pattern word\&. .RE .PP case\-glob .RS 4 This option specifies case\-sensitivity in matching\&. If enabled, pattern matching is done case\-sensitively\&. .RE .PP dot\-glob .RS 4 This option affects matching of filenames that start with a period (\fB\&.\fR)\&. If disabled, a period at the beginning of a filename does not match wildcard patterns (\fB?\fR and \fB*\fR) or bracket expressions\&. If enabled, there is no such special treatment of periods\&. .RE .PP mark\-dirs .RS 4 If enabled, each resulting pathname that is a directory name is suffixed by a slash (\fB/\fR)\&. .RE .PP extended\-glob .RS 4 This option enables the extension\&. (See below) .RE .sp Any errors in pathname expansion are silently ignored\&. If the word is an invalid pattern, it just becomes the result\&. The results depend on the null\-glob option when no matching pathnames are found\&. .sp Pattern matching is done for each filename (or pathname component) of pathnames\&. The shell skips matching for literal patterns that contain no wildcards or bracket expressions\&. As a result, the patterns \fB/*/foo\fR and \fB/*/fo[o]\fR may yield different expansion results when the case-glob option is disabled; for example, the pattern \fB/*/fo[o]\fR matches the pathname \fB/bar/FOO\fR but the pattern \fB/*/foo\fR does not because matching is skipped for \fBfoo\fR\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBExtension in pathname expansion\fR .RS 4 .sp The following patterns can be used when the extended-glob option is enabled\&. .PP \fB**\fR .RS 4 The directory is searched recursively and the pattern matches any number of directory filenames (each separated by a slash)\&. Any directory whose name begins with a period is excluded from search\&. For example, the pattern \fBdir/**/file\fR can match the pathnames \fBdir/file\fR, \fBdir/foo/file\fR, \fBdir/a/b/c/file\fR, etc\&. .sp This pattern is not effective when appearing at the end of the whole pattern (i\&.e\&. \fBfoo/bar/**\fR)\&. .RE .PP \fB\&.**\fR .RS 4 This pattern is like \fB**\fR, but all directories are searched including ones with a name starting with a period\&. .RE .PP \fB***\fR .RS 4 This pattern is like \fB**\fR, but if a symbolic link to a directory is found during recursive search, the directory is searched recursively as well\&. .RE .PP \fB\&.***\fR .RS 4 This pattern is like \fB***\fR, but all directories are searched including ones with a name starting with a period\&. .RE .RE .SH "PATTERN MATCHING NOTATION" .sp \fIPattern matching notation\fR is a syntax of \fIpatterns\fR that represent particular sets of strings\&. When a string is included in the set of strings a pattern represents, the pattern is said to \fImatch\fR the string\&. Whether a pattern matches a string or not is defined as follows\&. .SS "Normal characters" .sp A character that is not quoted or any of special characters defined below is a normal character, which matches the character itself\&. .sp For example, the pattern \fBabc\fR matches the string \fBabc\fR, and not any other strings\&. .SS "Single\-character wildcard" .sp The character \fB?\fR matches any single character\&. .sp For example, the pattern \fBa?c\fR matches any three\-character strings that starts with \fBa\fR and ends with \fBc\fR, such as \fBaac\fR, \fBabc\fR, and \fBa;c\fR\&. .SS "Multi\-character wildcard" .sp The character \fB*\fR matches any strings (of any length, including the empty string)\&. .sp For example, the pattern \fBa*c\fR matches any string that starts with \fBa\fR and ends with \fBc\fR, such as \fBac\fR, \fBabc\fR, and \fBa;xyz;c\fR\&. .SS "Bracket expression" .sp A pattern that is enclosed by brackets (\fB[\fR and \fB]\fR) is a \fIbracket expression\fR\&. A bracket expression must have at least one character between the brackets\&. The characters between the brackets are interpreted as a \fIbracket expression pattern\fR, which is a below\-defined special notation for bracket expression\&. A bracket expression pattern represents a set of characters\&. The bracket expression matches any one of the characters in the set the bracket expression pattern represents\&. .sp If the opening bracket (\fB[\fR) is followed by an exclamation mark (\fB!\fR), the exclamation is not treated as part of the bracket expression pattern and the whole bracket expression instead matches a character that is \fInot\fR included in the set the bracket expression pattern represents\&. If the opening bracket is followed by a caret (\fB^\fR), it is treated like an exclamation mark as above (but shells other than yash may treat the caret differently)\&. .sp If the opening bracket (or the following exclamation or caret, if any) is followed by a closing bracket (\fB]\fR), it is treated as part of the bracket expression pattern rather than the end of the bracket expression\&. You cannot quote characters in the bracket expression pattern because quotation is treated before bracket expression\&. .sp An opening bracket in a pattern is treated as a normal character if it is not the beginning of a valid bracket expression\&. .SS "Normal characters (in bracket expression pattern)" .sp A character that is not any of special characters defined below is a normal character, which represents the character itself\&. .sp For example, the bracket expression pattern \fBabc\fR represents the set of the three characters \fBa\fR, \fBb\fR, and \fBc\fR\&. The bracket expression \fB[abc]\fR therefore matches any of the three characters\&. .SS "Range expressions" .sp A hyphen preceded and followed by a character (or collating symbol) is a \fIrange expression\fR, which represents the set of the two characters and all characters between the two in the collation order\&. A \fIcollation order\fR is an order of characters that is defined in the locale data\&. .sp If a hyphen is followed by a closing bracket (\fB]\fR), the bracket is treated as the end of the bracket expression and the hyphen as a normal character\&. .sp For example, the range expression \fB3\-5\fR represents the set of the three characters \fB3\fR, \fB4\fR, and \fB5\fR\&. The bracket expression \fB[3\-5\-]\fR therefore matches one of the four characters \fB3\fR, \fB4\fR, \fB5\fR, and \fB\-\fR\&. .SS "Collating symbols" .sp A \fIcollating symbol\fR allows more than one character to be treated as a single character in matching\&. A collating symbol is made up of one or more characters enclosed by the special brackets \fB[\&.\fR and \fB\&.]\fR\&. .sp One or more characters that are treated as a single character in matching are called a \fIcollating element\fR\&. Precisely, a bracket expression pattern represents a set of collating elements and a bracket expression matches a collating element rather than a character, but we do not differentiate them for brevity here\&. .sp For example, the character combination \(lqch\(rq was treated as a single character in the traditional Spanish language\&. If this character combination is registered as a collating element in the locale data, the bracket expression \fB[[\&.ch\&.]df]\fR matches one of \fBch\fR, \fBd\fR, and \fBf\fR\&. .SS "Equivalence classes" .sp An \fIequivalence class\fR represents a set of characters that are considered \fIequivalent\fR\&. A equivalence class is made up of a character (or more precisely, a collating element) enclosed by the special brackets \fB[=\fR and \fB=]\fR\&. .sp An equivalence class represents the set of characters that consists of the character enclosed by the brackets and the characters that are in the same primary equivalence class as the enclosed character\&. The shell consults the locale data for the definition of equivalence classes in the current locale\&. .sp For example, if the six characters \fBa\fR, \fBà\fR, \fBá\fR, \fBâ\fR, \fBã\fR, \fBä\fR are defined to be in the same primary equivalence class, the bracket expressions \fB[[=a=]]\fR, \fB[[=à=]]\fR, and \fB[[=á=]]\fR match one of the six\&. .SS "Character classes" .sp A \fIcharacter class\fR represents a predefined set of characters\&. A character class is made up of a class name enclosed by the special brackets \fB[:\fR and \fB:]\fR\&. The shell consults the locale data for which class a character belongs to\&. .sp The following character classes can be used in all locales: .PP \fB[:lower:]\fR .RS 4 set of lowercase letters .RE .PP \fB[:upper:]\fR .RS 4 set of uppercase letters .RE .PP \fB[:alpha:]\fR .RS 4 set of letters, including the \fB[:lower:]\fR and \fB[:upper:]\fR classes\&. .RE .PP \fB[:digit:]\fR .RS 4 set of decimal digits .RE .PP \fB[:xdigit:]\fR .RS 4 set of hexadecimal digits .RE .PP \fB[:alnum:]\fR .RS 4 set of letters and digits, including the \fB[:alpha:]\fR and \fB[:digit:]\fR classes\&. .RE .PP \fB[:blank:]\fR .RS 4 set of blank characters, not including the newline character .RE .PP \fB[:space:]\fR .RS 4 set of space characters, including the newline character .RE .PP \fB[:punct:]\fR .RS 4 set of punctuations .RE .PP \fB[:print:]\fR .RS 4 set of printable characters .RE .PP \fB[:cntrl:]\fR .RS 4 set of control characters .RE .sp For example, the bracket expression \fB[[:lower:][:upper:]]\fR matches a lower or upper case character\&. In addition to the classes listed above, other classes may be used depending on the definition of the current locale\&. .SH "REDIRECTION" .sp \fIRedirection\fR is a feature you can use to modify file descriptors of commands\&. By using redirection, you can execute commands with their standard input/output connected with files or devices other than the terminal\&. .sp You can do redirection by adding redirection operators to a command (simple command or compound command) In a simple command, redirection operators may appear anywhere in the command as long as operator tokens are separated from other tokens\&. In a compound command, redirection operators must appear at the end of the command\&. .sp Redirection operators are processed before the command body is executed\&. More than one redirection operator in a command are processed in the order of appearance\&. Redirection operators affect only the command in which they appear, except when they appear in an exec built\-in without command operands\&. That is, file descriptors modified by redirection are restored after the command has finished\&. .sp A redirection operator starts with \fB<\fR or \fB>\fR\&. Redirection operators starting with \fB<\fR affects the standard input (file descriptor 0) by default\&. Redirection operators starting with \fB>\fR affects the standard output (file descriptor 1) by default\&. To affect another file descriptor, you can prefix a redirection operator with a non\-negative integer; the operator will affect the file descriptor specified by the integer\&. The integer must immediately precede the \fB<\fR or \fB>\fR without any whitespaces in between\&. The integer must not be quoted, either\&. .SS "Redirection to files" .sp The most common type of redirection is redirection to files\&. .PP Redirection of input .RS 4 \fB< \fR\fB\fItoken\fR\fR .RE .PP Redirection of output .RS 4 \fB> \fR\fB\fItoken\fR\fR .sp \fB>| \fR\fB\fItoken\fR\fR .sp \fB>> \fR\fB\fItoken\fR\fR .RE .PP Redirection of input and output .RS 4 \fB<> \fR\fB\fItoken\fR\fR .RE .sp The \fItoken\fR is subject to the four expansions\&. It is also subject to pathname expansion if the shell is interactive\&. The expansion result is treated as the pathname of the file to which redirection is performed\&. If the pathname expansion does not result in a single pathname, it is an error\&. .sp In redirection of input, the standard input is replaced with a file descriptor which is open for read\-only access to the target file\&. If the target file cannot be opened for read\-only access, it is an error\&. .sp In redirection of output, the standard output is replaced with a file descriptor which is open for write\-only access to the target file\&. If the target file cannot be opened for write\-only access, it is an error\&. If the target file does not exist, a new empty file is created and opened\&. If the target file already exists, the file is opened as follows: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For the \fB>|\fR operator, the file is emptied when opened if it is a regular file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For the \fB>\fR operator, the behavior is the same as the \fB>|\fR operator if the clobber option is enabled\&. If the option is disabled and the file is a regular file, it is treated as an error\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For the \fB>>\fR operator, the file is opened for appending; any output to the file descriptor is appended to the end of the file\&. .RE .sp In redirection of input and output, the standard input is replaced with a file descriptor which is open for read\-and\-write access to the target file\&. If the file does not exist, a new empty file is created and opened\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBSocket redirection\fR .RS 4 .sp If the pathname of the target file is of the form \fB/dev/tcp/\fR\fB\fIhost\fR\fR\fB/\fR\fB\fIport\fR\fR or \fB/dev/udp/\fR\fB\fIhost\fR\fR\fB/\fR\fB\fIport\fR\fR and the file cannot be opened in the usual manner, a new socket is opened for communication with the \fIport\fR of the \fIhost\fR\&. The redirection replaces the standard input or output with the file descriptor to the socket\&. .sp A stream socket is opened for the form \fB/dev/tcp/\fR\fB\fIhost\fR\fR\fB/\fR\fB\fIport\fR\fR and a datagram socket for the form \fB/dev/udp/\fR\fB\fIhost\fR\fR\fB/\fR\fB\fIport\fR\fR\&. The protocol actually used for communication is determined by the socket library the shell uses\&. Typically, stream sockets use TCP and datagram sockets UDP\&. .sp In socket redirection, the file descriptor is both readable and writable regardless of the type of the redirection operator used\&. .sp Socket redirection is yash\(cqs extension that is not defined in POSIX\&. Bash as well has socket redirection as extension\&. .RE .SS "Duplication of file descriptors" .sp Redirection allows duplicating or closing existing file descriptors\&. .PP Duplication of file descriptor .RS 4 \fB<& \fR\fB\fItoken\fR\fR .sp \fB>& \fR\fB\fItoken\fR\fR .RE .sp The \fItoken\fR is subject to expansion as in redirection to files, but it is treated as a file descriptor rather than a pathname\&. Thus the expanded \fItoken\fR must be a non\-negative integer\&. .sp The \fB<&\fR and \fB>&\fR operators duplicate the file descriptor specified by \fItoken\fR to the standard input and output, respectively\&. (The operators can be prefixed with a non\-negative integer so that the file descriptor is duplicated to a file descriptor other than the standard input or output\&.) .sp If the expanded \fItoken\fR is a single hyphen rather than a non\-negative integer, the file descriptor is closed rather than duplicated\&. By default, the \fB<&\fR and \fB>&\fR operators close the standard input and output, respectively, but the operators can be prefixed with a non\-negative integer so that another file descriptor is closed\&. .sp In the POSIXly\-correct mode, a file descriptor must be readable when duplicated by the \fB<&\fR operator and writable when duplicated by the \fB>&\fR operator\&. .SS "Here documents and here strings" .sp \fIHere document\fR and \fIhere string\fR allow redirection to file descriptors that reads strings directly specified in shell commands\&. .PP Here document .RS 4 \fB<< \fR\fB\fItoken\fR\fR .sp \fB<<\- \fR\fB\fItoken\fR\fR .RE .PP Here string .RS 4 \fB<<< \fR\fB\fItoken\fR\fR .RE .sp In a here document or here string, the standard input is replaced with a readable file descriptor\&. When the command reads from the file descriptor, it will read the contents of the here document/string, which is defined below\&. .sp When a here document operator (\fB<<\fR or \fB<<\-\fR) appears in a command, the shell reads the contents of the here document starting from the next line\&. The contents of here documents are not parsed nor executed as commands\&. The \fItoken\fR after the operand specifies a delimiter that indicates the end of the contents\&. (The \fItoken\fR is not subject to any expansion, but quotation is processed\&.) The contents of the here document is terminated just before the first line containing the \fItoken\fR only\&. When using the \fB<<\-\fR operator, all tab characters at the beginning of each line in the here document contents are removed and the delimiter \fItoken\fR may be preceded by tab characters\&. .sp If there are more than one here document operator on one line, the contents of the here documents are parsed in order: The contents of the first here document starts from the next line and ends before the first line containing the \fItoken\fR that followed the first operator\&. Just after that line, the contents of the second here document starts, and so on\&. .sp The contents of here documents are treated literally: whitespaces, tabs, etc\&. remain as is\&. The exception is that, when the \fItoken\fR is not quoted at all: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the contents are subject to parameter expansion, command substitution, arithmetic expansion\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} a backslash in the contents is treated as quotation if and only if it precedes \fB$\fR, \fB`\fR, \fB"\fR, or another backslash\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} a backslash followed by a newline is treated as line continuation\&. .RE .sp In here string, the \fItoken\fR after the operator is subject to expansion as in redirection to files\&. The expansion result becomes the contents of the here string\&. A newline character is automatically appended to the end of here string contents\&. .sp Here string is yash\(cqs extension that is not defined in POSIX\&. Other shells like bash, ksh, and zsh have the same feature\&. .SS "Pipeline redirection" .sp \fIPipeline redirection\fR allows opening pipelines that can be used for arbitrary purposes\&. .PP Pipeline redirection .RS 4 \fB>>| \fR\fB\fItoken\fR\fR .RE .sp The \fItoken\fR is subject to expansion as in redirection to files, but it is treated as a file descriptor rather than a pathname\&. Thus the expanded \fItoken\fR must be a non\-negative integer\&. .sp Pipeline redirection opens a new pipeline\&. The standard output (or the file descriptor specified before the operator, if any) is replaced with the file descriptor open for writing to the pipeline\&. The file descriptor specified by \fItoken\fR is replaced with the file descriptor open for reading from the pipeline\&. .sp Pipeline redirection is yash\(cqs extension that is not defined in POSIX\&. .SS "Process redirection" .sp \fIProcess redirection\fR creates a pipeline connected to another command\&. .PP Process redirection .RS 4 \fB<(\fR\fB\fIcommand\fR\fR\fB\&...)\fR .sp \fB>(\fR\fB\fIcommand\fR\fR\fB\&...)\fR .RE .sp In process redirection, the \fIcommand\fR specified is executed in a subshell\&. If the process redirection is of the form \fB<(\fR\fB\fIcommand\fR\fR\fB\&...)\fR, the standard output of \fIcommand\fR is connected with a pipeline to the standard input of the command the redirection is associated with\&. If the process redirection is of the form \fB>(\fR\fB\fIcommand\fR\fR\fB\&...)\fR, the standard input of \fIcommand\fR is connected with a pipeline to the standard output of the command the redirection is associated with\&. .sp Process redirection is yash\(cqs extension that is not defined in POSIX\&. Bash and zsh have a feature called process substitution, which uses the same syntax as yash\(cqs process redirection, but incompatibly differs in behavior\&. .SH "COMMAND EXECUTION" .sp This section describes how commands are executed\&. .SS "Execution of simple commands" .sp A simple command is executed as follows: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} All tokens in the simple command are expanded except for assignment and redirection tokens\&. If an error occurs during expansion, the execution of the simple command is aborted with a non\-zero exit status\&. In the following steps, the first word of the expansion results is referred to as \fIcommand name\fR, and the other words as \fIcommand arguments\fR\&. If there is only one word of the expansion results, there are no command argument words\&. If there are none of the expansion results, there is no command name either\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} Redirection specified in the command, if any, is processed\&. The word token after each redirection operator is expanded\&. If an error occurs during processing redirection (including when expanding the word token), the execution of this simple command is aborted with a non\-zero exit status\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} Assignments specified in the command, if any, are processed\&. For each assignment token, the value is expanded and assigned to the specified variable\&. If an error occurs during assignments (including when expanding the values to be assigned), the execution of this simple command is aborted with a non\-zero exit status\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If there is no command name or the name denotes a special built\-in or function, the assignments are permanent: the assigned values remain after the command has finished (until the variable is reassigned)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Otherwise, the assignments are temporary: the assigned values only last during the execution of this simple command\&. .RE .sp The assigned variables are automatically exported when the command name is specified or the all\-export option is enabled\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} If there is no command name, the command execution ends with the exit status of zero (unless there are any command substitutions in the command, in which case the exit status of the simple command is that of the last executed command substitution)\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} A command to be executed is determined using the command search algorithm and the command is executed\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the command is an external command, the command is executed by creating a new subshell and calling the \(lqexec\(rq system call in the subshell\&. The command name and arguments are passed to the executed command\&. Exported variables are passed to the executed command as environment variables\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the command is a built\-in, the built\-in is executed with the command arguments passed to the built\-in\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the command is a function, the contents of the function are executed with the command arguments as function arguments\&. .RE .sp If the command was executed, the exit status of this simple command is that of the executed command\&. If the algorithm failed to determine a command, no command is executed and the exit status is 127\&. If the shell failed to execute the determined command, the exit status is 126\&. If the executed command was killed by a signal, the exit status is the signal number plus 384\&. .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br In shells other than yash, the exit status may be different when the command was killed by a signal, because the POSIX standard only requires that the exit status be "greater than 128\&." .sp .5v .RE If the shell is not in the POSIXly\-correct mode and the algorithm failed to determine a command, the command \fBeval \-i \-\- "${COMMAND_NOT_FOUND_HANDLER\-}"\fR is evaluated\&. During the command execution, positional parameters are temporarily set to the command name and arguments that resulted in the first step\&. Any local variables defined during the execution are removed when the execution is finished\&. The \fBHANDLED\fR local variable is automatically defined with the initial value being the empty string\&. If the \fBHANDLED\fR variable has a non\-empty value when the execution of the command string is finished, the shell pretends that the command was successfully determined and executed\&. The exit status of the simple command is that of the command string in this case\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBCommand search\fR .RS 4 .sp A command that is executed in a simple command is determined by the command name using the following algorithm: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} If the command name contains a slash (\fB/\fR), the whole name is treated as the pathname of an external command\&. The external command is determined as the executed command\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} If the command name is a special built\-in, the built\-in is determined as the executed command\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} If the command name is the name of an existing function, the function is determined as the executed command\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} If the command name is a semi\-special built\-in, the built\-in is determined as the executed command\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} If the command name is a regular built\-in, the built\-in is determined as the executed command unless the shell is in the POSIXly\-correct mode\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} The shell searches the PATH for a executed command: .sp The value of the \fBPATH\fR variable is separated by colons\&. Each separated part is considered as a directory pathname (an empty pathname denotes the current working directory)\&. The shell searches the directories (in the order of appearance) and checks if any directory directly contains an executable regular file whose name is equal to the command name\&. If such a file is found: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the command name is the name of a built\-in, the built\-in is determined as the executed command\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Otherwise, the file is determined as the executed command\&. (The file will be executed as an external command\&.) .RE .sp If no such file is found, no command is determined as the executed command\&. .RE .sp When the shell finds a file that matches the command name during the search above, the shell remembers the pathname of the file if it is an absolute path\&. When the algorithm above is used for the same command name again, the shell skips searching and directly determines the command to be executed\&. If an executable regular file no longer exists at the remembered pathname, however, the shell searches again to update the remembered pathname\&. You can manage remembered pathnames using the hash built\-in\&. .RE .SS "Termination of the shell" .sp The shell exits when it reached the end of input and has parsed and executed all input commands or when the exit built\-in is executed\&. The exit status of the shell is that of the last command the shell executed (or zero if no commands were executed)\&. The exit status of the shell is always between 0 and 255 (inclusive)\&. If the exit status of the last command is 256 or larger, the exit status of the shell will be the remainder of the exit status divided by 256\&. .sp If an exit handler has been registered by the trap built\-in, the handler is executed just before the shell exits\&. The exit status of the commands executed in the handler does not affect the exit status of the shell\&. .sp If a non\-interactive shell encountered one of the following errors, the shell immediately exits with a non\-zero exit status: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A command cannot be parsed due to an syntax error (except during shell initialization)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A special built\-in is executed in the POSIXly\-correct mode and the command arguments do not meet the syntax of the built\-in\(cqs arguments\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} An error occurs during redirection or assignment in a simple command whose command name is a special built\-in and the shell is in the POSIXly\-correct mode\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} An error occurs during expansion (except during shell initialization)\&. .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp Some shells other than yash exit when they fail to find a command to execute in command search\&. .sp .5v .RE .SS "Functions" .sp \fIFunctions\fR allow executing a compound command as a simple command\&. A function can be defined by the function definition command and executed by a simple command\&. You can use the unset built\-in to remove function definitions\&. .sp There are no functions predefined when yash is started\&. .sp A function is executed by executing its body, which is a compound command\&. While the function is being executed, positional parameters are set to the arguments given to the function\&. The old positional parameters are restored when the function execution finishes\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBLocal variables\fR .RS 4 .sp \fILocal variables\fR are temporary variables that are defined in a function and exist during the function execution only\&. They can be defined by the typeset built\-in\&. They are removed when the function execution finishes\&. .sp Local variables may \fIhide\fR variables that have already been defined before the function execution had started\&. An existing variable becomes inaccessible if a local variable of the same name is defined in a function\&. The old variable becomes accessible again when the function execution finishes\&. .sp You cannot create a local variable when not executing a function\&. A normal variable is created if you try to do so\&. .RE .SS "Command execution environment" .sp The shell holds following properties during execution\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The working directory .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Open file descriptors .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The file creation mask (umask) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The set of signals whose handler is set to \(lqignore\(rq (trap) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Environment variables .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Resource limits (ulimit) .RE .sp Those properties are inherited from the invoker of the shell to the shell, and from the shell to each external command executed by the shell\&. .sp The properties can be changed during the execution of the shell by built\-in commands, variable assignments, etc\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBSubshells\fR .RS 4 .sp A \fIsubshell\fR is a copy of the shell process\&. Subshells are used in execution of groupings, pipelines, etc\&. .sp Subshells inherit functions, aliases, etc\&. defined in the shell as well as the properties above since subshells are copies of the shell process\&. Notable exceptions are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Signal handlers registered by the trap built\-in are all reset in subshells except for ones whose action is set to \(lqignore\(rq\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The interactive mode and job control are disabled in subshells\&. Jobs are not inherited by subshells\&. .RE .sp Subshells are executed independently of the original shell, so changes of any properties above do not affect those of the original shell\&. .RE .SH "INTERACTIVE MODE" .sp The \fIinteractive mode\fR is a mode of the shell intended for direct interaction with a user\&. If yash is in the interactive mode, it is called an \fIinteractive shell\fR\&. .sp Whether a shell runs in the interactive mode or not is determined in the invocation of the shell\&. After the shell has started up, the interactive mode cannot be switched on or off\&. .sp When the shell is interactive: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Initialization scripts are executed during invocation\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The shell checks for mail and prints a command prompt when it reads a command\&. Job status changes are also reported if job control is active\&. Line\-editing may be used depending on the capability of the terminal\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Commands executed are automatically registered in command history\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If a command executed by the shell is killed by a signal other than SIGINT and SIGPIPE, the shell reports the fact to the standard error\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The filename token is subject to pathname expansion in file redirection\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The standard input of an asynchronous command is not automatically redirected to /dev/null (in the POSIXly\-correct mode only)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The shell does not exit when it encounters a syntax or expansion error during command execution\&. (cf\&. Termination of the shell) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The shell does not exit when it receives the SIGINT, SIGTERM, or SIGQUIT signal\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A signal handler can be changed by the trap built\-in even if the handler had been set to \(lqignore\(rq when the shell was invoked\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The value of the \fB\-\fR special parameter contains \fBi\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The shell\(cqs locale reflects the value of the \fBLC_CTYPE\fR variable whenever the value is changed (if the shell is not in the POSIXly\-correct mode)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Commands are executed even when the exec option is off\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The ignore\-eof option takes effect when enabled\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When the shell reaches the end of input or the exit built\-in is executed, the shell checks if there is any stopped job\&. If so, the shell prints a warning and does not actually exit\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The suspend built\-in by default cannot stop the shell if it is a session leader\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The shell does not exit when the dot built\-in fails to find a script file to read\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The shell does not exit when the exec built\-in fails to execute a command (if not in the POSIXly\-correct mode)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When a job finished for which the wait built\-in has been waiting, the fact is reported (only if job control is active and not in the POSIXly\-correct mode)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A prompt is printed when the read built\-in reads a second or following line\&. .RE .SS "Prompts" .sp The interactive shell prints a \fIprompt\fR just before it reads a command\&. The contents of the prompt is specified by the value of the \fBPS1\fR and \fBPS2\fR variables\&. The former is used for reading the first line of the command and the latter for other lines\&. .sp When the prompt is printed, the variable value is subjected to parameter expansion, command substitution, and arithmetic expansion (but note that the POSIX standard requires parameter expansion only)\&. The result of the expansion is parsed by the rules below to make the actual prompt string, which is printed to the standard error\&. .sp In the POSIXly\-correct mode, each exclamation mark (\fB!\fR) in the string is substituted with the command history number of the command that is being input\&. Two adjacent exclamation marks (\fB!!\fR) are printed as a single exclamation\&. Other characters are printed intact\&. .sp If the shell is not in the POSIXly\-command mode, the following notations can be used to format the prompt string\&. Notations are replaced with the strings designated in the list below\&. Characters that are not interpreted as notations are printed intact\&. .PP \fB\ea\fR .RS 4 Bell character (ASCII code: 7) .RE .PP \fB\ee\fR .RS 4 Escape character (ASCII code: 27) .RE .PP \fB\ej\fR .RS 4 The number of jobs in the shell\&. .RE .PP \fB\en\fR .RS 4 Newline character (ASCII code: 10) .RE .PP \fB\er\fR .RS 4 Carriage return character (ASCII code: 13) .RE .PP \fB\e!\fR .RS 4 The command history number of the command that is being input .RE .PP \fB\e$\fR .RS 4 \fB#\fR if the shell\(cqs effective user ID is 0; \fB$\fR otherwise\&. .RE .PP \fB\e\e\fR .RS 4 Backslash .RE .PP \fB\e[\fR, \fB\e]\fR .RS 4 These two notations can surround part of the prompt string that is not visible on the terminal\&. The surrounded part is ignored when the shell counts the number of characters that is displayed on the terminal, thus making characters correctly aligned on the terminal when the prompt string contains special invisible characters\&. .RE .PP \fB\ef\fR\fB\fIfontspecs\fR\fR\fB\&.\fR .RS 4 When line\-editing is active, this notation is replaced with special characters to change font styles on the terminal if the terminal is capable of it\&. If line\-editing is inactive or the terminal is incapable of changing font styles, this notation is silently ignored\&. One or more of the following can be used for \fIfontspecs\fR: .PP \fBk\fR .RS 4 Change font color to black .RE .PP \fBr\fR .RS 4 Change font color to red .RE .PP \fBg\fR .RS 4 Change font color to green .RE .PP \fBy\fR .RS 4 Change font color to yellow .RE .PP \fBb\fR .RS 4 Change font color to blue .RE .PP \fBm\fR .RS 4 Change font color to magenta .RE .PP \fBc\fR .RS 4 Change font color to cyan .RE .PP \fBw\fR .RS 4 Change font color to white .RE .PP \fBK\fR .RS 4 Change background color to black .RE .PP \fBR\fR .RS 4 Change background color to red .RE .PP \fBG\fR .RS 4 Change background color to green .RE .PP \fBY\fR .RS 4 Change background color to yellow .RE .PP \fBB\fR .RS 4 Change background color to blue .RE .PP \fBM\fR .RS 4 Change background color to magenta .RE .PP \fBC\fR .RS 4 Change background color to cyan .RE .PP \fBW\fR .RS 4 Change background color to white .RE .PP \fBt\fR .RS 4 Make font color or background brighter (can only be used just after one of the characters above) .RE .PP \fBd\fR .RS 4 Change font and background colors to normal .RE .PP \fBs\fR .RS 4 Make font standout .RE .PP \fBu\fR .RS 4 Make font underlined .RE .PP \fBv\fR .RS 4 Make font and background colors reversed .RE .PP \fBb\fR .RS 4 Make font blink .RE .PP \fBi\fR .RS 4 Make font dim .RE .PP \fBo\fR .RS 4 Make font bold .RE .PP \fBx\fR .RS 4 Make font invisible .RE .PP \fBD\fR .RS 4 Make color and style normal .RE .sp The actual colors of font and background are defined by the terminal\&. Different terminals may use different colors\&. .RE .sp In addition to the normal prompt, a prompt string can be displayed to the right of the cursor if line\-editing is active\&. Those prompts are called \fIright prompts\fR\&. The contents of right prompts are defined by the value of the \fBPS1R\fR and \fBPS2R\fR variables, each corresponding to the \fBPS1\fR and \fBPS2\fR variables\&. .sp Using the above\-said notations, the font style of command strings the user inputs can be changed as well as that of prompts\&. The font style of command strings is defined by the value of the \fBPS1S\fR and \fBPS2S\fR variables, each corresponding to the \fBPS1\fR and \fBPS2\fR variables\&. The value can contain the \fB\ef\fR\fB\fIfontspecs\fR\fR\fB\&.\fR notation only\&. .sp When the shell is not in the POSIXly\-correct mode, the value of the \fBPROMPT_COMMAND\fR variable is executed before each prompt\&. .SS "Command history" .sp \fICommand history\fR is a feature of the shell that remembers executed commands to allow re\-executing them later\&. Commands executed in the interactive mode are automatically saved in the command history\&. Saved commands can be edited and re\-executed using line\-editing and the fc and history built\-ins\&. .sp Commands are saved line by line\&. Lines that do not contain any non\-whitespace characters are not saved in the history\&. Lines that start with whitespaces are not saved when the hist\-space option is on\&. .sp Command history is saved in a file\&. When history is first used after an interactive shell was started, the shell opens a file to save history in\&. The filename is specified by the value of the \fBHISTFILE\fR variable\&. If the file contains history data when opened, the data is restored to the shell\(cqs history\&. The file contents are updated in real time as the user inputs commands into the shell\&. If the \fBHISTFILE\fR variable is not set or the file cannot be opened successfully, history is not saved in the file, but the history feature will be functional in all other respects\&. .sp The number of commands saved in history is specified by the value of the \fBHISTSIZE\fR variable\&. The shell automatically removes old history data so that the number of saved commands does not exceed the value\&. If the \fBHISTSIZE\fR variable is not set or its value is not a natural number, 500 items will be saved in history\&. .sp The shell looks at the value of the \fBHISTFILE\fR and \fBHISTSIZE\fR variables only when the history feature is first used after the shell was started\&. \(lqThe history feature is used\(rq when: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the fc or history built\-in is executed, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} line\-editing is used (regardless of whether or not history data is recalled in line\-editing), or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} a command is input to the shell .RE .sp Therefore, the variables should be set in initialization scripts\&. .sp When more than one instance of yash shares a single history file, all the shells use the same history data\&. As a result, commands that have been executed by a shell instance can be recalled on another shell instance\&. Shells sharing the same history should have the same \fBHISTSIZE\fR value so that they manipulate history data properly\&. .sp Yash\(cqs history data file has its own format that is incompatible with other kinds of shells\&. .sp The \fBHISTRMDUP\fR variable can be set to remove duplicate history items\&. .SS "Mail checking" .sp An interactive shell can notify receipt of email\&. The shell periodically checks the modification date/time of a file specified by the user\&. If the file has been modified since the previous check, the shell prints a notification message (except when the shell is not in the POSIXly\-correct mode and the file is empty)\&. By specifying a mailbox file to be checked, the shell will print a message when the file has been modified, that is, some mail has been received\&. .sp Check is done just before the shell prints a command line prompt\&. The interval of checks can be specified by the \fBMAILCHECK\fR variable in seconds\&. If the variable value is 0, check is done before every prompt\&. If the variable value is not a non\-negative integer, no checks are done\&. .sp The file whose modification time is checked is specified by the \fBMAIL\fR variable\&. The variable value should be set to the pathname of the file\&. .sp If you want to check more than one file or customize the notification message, you can set the \fBMAILPATH\fR variable instead of the \fBMAIL\fR variable\&. When the \fBMAILPATH\fR variable is set, the \fBMAIL\fR variable is ignored\&. The value of the \fBMAILPATH\fR variable should be set to one or more colon\-separated pathnames of files to be checked\&. Each pathname can be followed by a percent sign (\fB%\fR) and a custom notification message, which is printed when the corresponding file has been modified\&. If the pathname contains a percent sign, it should be quoted by a backslash\&. The specified message is subject to parameter expansion\&. For example, if the value of the \fBMAILPATH\fR variable is \fB/foo/mail%New mail!:/bar/mailbox%You\*(Aqve got mail:/baz/mail\e%data\fR, the shell will print .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBNew mail!\fR when the file /foo/mail has been modified .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBYou\*(Aqve got mail\fR when the file /bar/mailbox has been modified .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the default message when the file /baz/mail%data has been modified\&. .RE .SH "JOB CONTROL" .sp \fIJob control\fR is a function of the shell that executes multiple commands simultaneously and suspends/resumes the commands\&. .sp When control is active: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Every pipeline executed by the shell becomes a \fIjob\fR\&. A job has its unique process group ID that is shared among all processes in the job\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the processes of a job are suspended while the shell is waiting for the processes to finish, the shell continues to the next command as if the process have finished\&. The shell remembers the job as suspended so that it can be resumed later\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If a job is executed synchronously, the shell sets the foreground process group of the terminal to the process group of the job\&. When the job is finished (or suspended), the shell gets back to the foreground\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The subshell executing a command substitution has its own unique process group ID like a job\&. However, the shell does not remember the subshell as a job, so it cannot be suspended or resumed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the shell is interactive, job status is reported before every command line prompt as if the command \fBjobs\fR\fB \-n\fR is executed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The standard input of an asynchronous command is not automatically redirected to /dev/null (unless in the POSIXly\-correct mode)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The shell does not exit when it receives the SIGTSTP signal\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The value of the \fB\-\fR special parameter contains \fBm\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When a job finished for which the wait built\-in has been waiting, the fact is reported (only if the shell is interactive and not in the POSIXly\-correct mode)\&. .RE .sp When job control is inactive, processes executed by the shell have the same process group ID as the shell\&. The shell treats asynchronous commands as an uncontrolled job\&. .sp You can use the following built\-ins to manipulate jobs: .PP jobs .RS 4 prints existing jobs .RE .PP fg and bg .RS 4 run jobs in the foreground or background .RE .PP wait .RS 4 waits for jobs to be finished (or suspended) .RE .PP disown .RS 4 forgets jobs .RE .PP kill .RS 4 sends a signal to jobs .RE .sp An interactive job\-controlling shell reports jobs status before every prompt by default\&. You can set the following options to make the shell report status at other timings: .PP notify .RS 4 the shell reports immediately whenever job status changes\&. .RE .PP notify\-le .RS 4 the shell reports immediately when job status changes while line\-editing\&. .RE .sp A job is removed from the shell\(cqs job list when: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} it has finished and the \(lqfinished\(rq status is reported, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the wait built\-in successfully waited for the job to finish, or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the disown built\-in removed the job\&. .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br .sp The word \(lqstop\(rq is synonymous to \(lqsuspend\(rq in the context of job control\&. .sp .5v .RE .SS "Job ID" .sp Some built\-ins use the following notation, which is called \fIjob ID\fR, to specify a job to operate on: .PP \fB%\fR, \fB%%\fR, \fB%+\fR .RS 4 the current job .RE .PP \fB%\-\fR .RS 4 the previous job .RE .PP \fB%\fR\fB\fIn\fR\fR .RS 4 the job that has job number \fIn\fR, where \fIn\fR is a positive integer .RE .PP \fB%\fR\fB\fIstring\fR\fR .RS 4 the job whose name begins with \fIstring\fR .RE .PP \fB%?\fR\fB\fIstring\fR\fR .RS 4 the job whose name contains \fIstring\fR .RE .sp The \fIcurrent job\fR and \fIprevious job\fR are jobs selected by the shell according to the following rules: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When there is one or more suspended jobs, the current job is selected from them\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When there is one or more suspended jobs other than the current job, the previous job is selected from them\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The current and previous jobs are always different\&. When the shell has only one job, it is the current job and there is no previous job\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When the current job finished, the previous job becomes the current job\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When the current job is changed, the old current job becomes the previous job except when the old job finished\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When the foreground job is suspended, the job becomes the current job\&. .RE .sp Yash has some options to modify the rules of the current/previous job selection\&. (The rules above have priority over the options below\&.) .PP cur\-async .RS 4 When a new asynchronous command is started, it becomes the current job\&. .RE .PP cur\-bg .RS 4 When a job is resumed by the bg built\-in, the job becomes the current job\&. .RE .PP cur\-stop .RS 4 When a job is suspended, it becomes the current job\&. .RE .sp The current and previous jobs are not changed as long as the rules above are met\&. .sp The rules of the current/previous job selection defined in the POSIX standard are looser than yash\(cqs rules above\&. Other POSIX\-compliant shells may select the current and previous jobs differently\&. .SH "BUILT-IN COMMANDS" .sp \fIBuilt\-in commands\fR are commands that are implemented in the shell and are executed by the shell without external programs\&. .SS "Types of built\-in commands" .sp There are three types of built\-in commands in yash: special built\-in commands, semi\-special built\-in commands and regular built\-in commands\&. .sp \fISpecial built\-in commands\fR are much more important commands than others\&. They are executed regardless of whether the corresponding external commands exist or not\&. Results of variable assignments that occur in a simple command that invokes a special built\-in last after the command has finished\&. Moreover, in the POSIXly\-correct mode, a non\-interactive shell immediately exits with a non\-zero exit status when a redirect error, assignment error, or misuse of option or operand occurs in a special built\-in command\&. .sp \fISemi special built\-in commands\fR are the second important built\-in commands\&. They are executed regardless of whether the corresponding external commands exist or not\&. In other parts they are the same as regular built\-in commands\&. .sp \fIRegular built\-in commands\fR are less important built\-in commands including commands that can be implemented as external commands or are not listed in POSIX\&. In the POSIXly\-correct mode, a regular built\-in is executed only when a corresponding external command is found in PATH\&. .SS "Syntax of command arguments" .sp In this section we explain common rules about command arguments\&. The built\-in commands of yash follow the rules unless otherwise stated\&. .sp There are two types of command arguments\&. One is options and the other is operands\&. An option is an argument that starts with a hyphen (\fB\-\fR) and changes the way the command behaves\&. Some options take arguments\&. An operand is an argument that is not an option and specifies objects the command operates on\&. .sp If you specify more than one option to a command, the order of the options are normally not significant\&. The order of operands, however, affects the command behavior\&. .sp An option is either a single\-character option or a long option\&. A single\-character option is identified by one alphabetic character\&. A long option is identified by multiple alphabetic characters\&. The POSIX standard only prescribes single\-character options, so in the POSIXly\-correct mode you cannot use long options\&. .sp A single\-character option is composed of a hyphen followed by a letter\&. For example, \fB\-a\fR is a single\-character option\&. A single\-character option that takes an argument requires the argument to be just after the option name\&. .PP \fBExample\ \&4.\ \&The set built-in and single-character options\fR .sp For the set built\-in, \fB\-m\fR is a single\-character option that does not take an argument and \fB\-o\fR is one that takes an argument\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-o errexit \-m\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-oerrexit \-m\fR .RE .sp In these two command lines, \fBerrexit\fR is the argument to the \fB\-o\fR option\&. .sp In the second example above, the \fB\-o\fR option and its argument are combined into a single command line argument\&. The POSIX standard deprecates that style and any POSIX\-conforming applications must specify options and their arguments as separate command line arguments, although yash accepts both styles\&. .sp You can combine single\-character options that do not take arguments into a single command line argument\&. For example, the three options \fB\-a\fR, \fB\-b\fR and \fB\-c\fR can be combined into \fB\-abc\fR\&. .sp A long option is composed of two hyphens followed by an option name\&. For example, \fB\-\-long\-option\fR is a long option\&. You can omit some last characters of a long option name as long as it is not ambiguous\&. For example, you can use \fB\-\-long\fR instead of \fB\-\-long\-option\fR if there is no other options beginning with \fB\-\-long\fR\&. Like a single\-character option, a long option that takes an argument requires the argument to be a command line argument just after the option name or to be specified in the same command line argument as the option name, separated by an equal sign (\fB=\fR)\&. .PP \fBExample\ \&5.\ \&The fc built-in and long options\fR .sp For the fc built\-in, \fB\-\-quiet\fR is a long option that does not take an argument and \fB\-\-editor\fR is one that takes an argument\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-\-editor vi \-\-quiet\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-\-editor=vi \-\-quiet\fR .RE .sp In these command lines, \fBvi\fR is the argument to the \fB\-\-editor\fR option\&. .sp Arguments that are not options (nor arguments to them) are interpreted as operands\&. The POSIX standard requires all options should be specified before any operands\&. Therefore, in the POSIXly\-correct mode, any arguments that come after the first operand are interpreted as operands (even if they look like options)\&. If not in the POSIXly\-correct mode, you can specify options after operand\&. .sp Regardless of whether the shell is in the POSIXly\-correct mode or not, an argument that is just composed of two hyphens (\fB\-\-\fR) can be used as a separator between options and operands\&. All command line arguments after the \fB\-\-\fR separator are interpreted as operands, so you can specify operands that start with a hyphen correctly using the separator\&. .PP \fBExample\ \&6.\ \&Options and operands to the set built-in\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-a \-b \-\- \-c \-d\fR .RE .sp In this example, \fB\-a\fR and \fB\-b\fR are options and \fB\-c\fR and \fB\-d\fR are operands\&. The \fB\-\-\fR separator itself is neither an option nor an operand\&. .sp Regardless of whether the shell is in the POSIXly\-correct mode or not, an argument that is just composed of a single hyphen (\fB\-\fR) is interpreted as an operand\&. .SH "LINE-EDITING" .sp With the \fIline\-editing\fR feature, you can edit the command text when you input a command to an interactive shell\&. It not only works as a simple visual\-interface editor, but also is integrated with the command history\&. You can recall, edit, and execute commands in the history with line\-editing instead of using the fc built\-in\&. .sp Line\-editing has two editing modes, the vi and emacs modes, which each have their own key binding settings\&. By switching editing modes, you can change key bindings used in line\-editing\&. Each mode has a corresponding shell option, which determines whether the mode is currently active or not\&. No more than one mode can be active at a time, so the options for the other modes are automatically turned off when you turn on the option for one mode\&. The whole line\-editing feature is deactivated when those options are off\&. .sp When an interactive shell is started, the vi mode is automatically activated if the standard input and error are both connected to a terminal\&. .sp Line\-editing can be used only when the standard input and error are both connected to a terminal\&. If not, the shell silently falls back to the normal input mechanism\&. While line\-editing is being used, the shell uses the termios interface to change I/O settings of the terminal and the terminfo interface to parse input key sequences\&. .SS "Shell options on line\-editing" .sp The following options can be set by the set built\-in to enable line\-editing and choose an editing mode to activate: .PP vi .RS 4 activates the vi mode\&. .RE .PP emacs .RS 4 activates the emacs mode\&. .RE .sp The other line\-editing\-related options are: .PP le\-always\-rp .RS 4 When this options is enabled, the right prompt is always visible: when the cursor reaches the right prompt, it moves to the next line from the original position, which would otherwise be overwritten by input text\&. .RE .PP le\-comp\-debug .RS 4 When enabled, internal information is printed during completion, which will help debugging completion scripts\&. .RE .PP le\-conv\-meta .RS 4 When enabled, the 8th bit of each input byte is always treated as a meta\-key flag, regardless of terminfo data\&. .RE .PP le\-no\-conv\-meta .RS 4 When enabled, the 8th bit of each input byte is never treated as a meta\-key flag, regardless of terminfo data\&. .sp The le\-conv\-meta and le\-no\-conv\-meta options cannot be both enabled at a time\&. When either is enabled, the other is automatically disabled\&. When neither is enabled, the 8th bit may be treated as a meta\-key flag depending on terminfo data\&. .RE .PP le\-prompt\-sp .RS 4 When enabled, the shell prints a special character sequence before printing each prompt so that every prompt is printed at the beginning of a line\&. .sp This option is enabled by default\&. .RE .PP le\-visible\-bell .RS 4 When enabled, the shell flashes the terminal instead of sounding an alarm when an alert is required\&. .RE .SS "Editing modes" .sp The \fIvi mode\fR is an editing mode that offers key bindings similar to that of the vi editor\&. The vi mode has two sub\-modes that are switched during editing: the insert and command modes\&. The sub\-mode is always reset to the insert mode when line\-editing is started for a new command line\&. In the insert mode, most characters are inserted to the buffer as typed\&. In the command mode, input characters are treated as commands that move the cursor, insert/delete text, etc\&. .sp The \fIemacs mode\fR offers key bindings similar to the emacs editor\&. Most characters are inserted to the buffer as typed, but more characters are treated as commands than the vi insert mode\&. .sp Another sub\-mode is used while you enter search keywords\&. The sub\-mode is called the \fIsearch mode\fR, which offers slightly different key bindings depending on the active editing mode\&. .SS "Line\-editing commands" .sp All characters the user enters while line\-editing is active are treated as line\-editing commands listed below\&. The bindkey built\-in allows customizing the key bindings of each mode (except for the search mode)\&. .sp The list below shows not only the functions of commands but also the default key bindings\&. The keywords \(lqvi\-insert\(rq, \(lqvi\-command\(rq, \(lqvi\-search\(rq, \(lqemacs\(rq, \(lqemacs\-search\(rq means the vi insert mode, the vi command mode, the search mode for the vi mode (the vi search mode), the emacs mode, and the search mode for the emacs mode (the emacs search mode), respectively\&. .sp Some commands take an argument that affects the function of the commands\&. For example, the forward\-char command moves the cursor by as many characters as specified by the argument\&. To specify an argument, use the digit\-argument command just before another command that takes an argument\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBBasic editing commands\fR .RS 4 .PP noop .RS 4 Do nothing\&. .PP vi\-command .RS 4 \fB\e^[\fR .RE .RE .PP alert .RS 4 Alert\&. .RE .PP self\-insert .RS 4 Insert the input character at the current cursor position\&. Characters escaped by escape sequences cannot be inserted\&. .PP vi\-insert, emacs .RS 4 \fB\e\e\fR .RE .RE .PP insert\-tab .RS 4 Insert a tab character at the current cursor position\&. .PP emacs .RS 4 \fB\e^[\e^I\fR .RE .RE .PP expect\-verbatim .RS 4 Insert a character that is entered just after this command at the current cursor position\&. This command can input a character that cannot be input by the self\-insert command, except a null character (\fB\*(Aq\e0\*(Aq\fR)\&. .PP vi\-insert, vi\-search, emacs\-search .RS 4 \fB\e^V\fR .RE .PP emacs .RS 4 \fB\e^Q\fR, \fB\e^V\fR .RE .RE .PP digit\-argument .RS 4 Pass the input digit to the next command as an argument\&. .sp This command can be bound to a digit or hyphen\&. To pass \(lq12\(rq as an argument to the forward\-char command in the vi mode, for example, enter \fB12l\fR\&. .PP vi\-command .RS 4 \fB1\fR, \fB2\fR, \fB3\fR, \fB4\fR, \fB5\fR, \fB6\fR, \fB7\fR, \fB8\fR, \fB9\fR .RE .PP emacs .RS 4 \fB\e^[0\fR, \fB\e^[1\fR, \fB\e^[2\fR, \fB\e^[3\fR, \fB\e^[4\fR, \fB\e^[5\fR, \fB\e^[6\fR, \fB\e^[7\fR, \fB\e^[8\fR, \fB\e^[9\fR, \fB\e^[\-\fR, .RE .RE .PP bol\-or\-digit .RS 4 Like the beginning\-of\-line command if there is no argument; like the digit\-argument command otherwise\&. .PP vi\-command .RS 4 \fB0\fR .RE .RE .PP accept\-line .RS 4 Finish editing the current line\&. A newline is automatically appended to the line\&. The line will be executed by the shell\&. .PP vi\-insert, vi\-command, emacs, emacs\-search .RS 4 \fB\e^J\fR, \fB\e^M\fR .RE .RE .PP abort\-line .RS 4 Abandon the current buffer and finish editing as if an empty line was input\&. .PP vi\-insert, vi\-command, vi\-search, emacs, emacs\-search .RS 4 \fB\e!\fR, \fB\e^C\fR .RE .RE .PP eof .RS 4 Abandon the current buffer and finish editing as if the shell reached the end of input\&. This normally makes the shell exit\&. .RE .PP eof\-if\-empty .RS 4 Like the eof command if the buffer is empty; like the alert command otherwise\&. .PP vi\-insert, vi\-command .RS 4 \fB\e#\fR, \fB\e^D\fR .RE .RE .PP eof\-or\-delete .RS 4 Like the eof command if the buffer is empty; like the delete\-char command otherwise\&. .PP emacs .RS 4 \fB\e#\fR, \fB\e^D\fR .RE .RE .PP accept\-with\-hash .RS 4 Like the accept\-line command, but: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A hash sign (\fB#\fR) is inserted at the beginning of the line if there is none\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Otherwise, the hash sign is removed from the beginning of the line\&. .RE .PP vi\-command .RS 4 \fB#\fR .RE .PP emacs .RS 4 \fB\e^[#\fR .RE .RE .PP setmode\-viinsert .RS 4 Switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBi\fR, \fB\eI\fR .RE .RE .PP setmode\-vicommand .RS 4 Switch to the vi command mode\&. .PP vi\-insert .RS 4 \fB\e^[\fR .RE .RE .PP setmode\-emacs .RS 4 Switch to the emacs mode\&. .RE .PP expect\-char, abort\-expect\-char .RS 4 These commands are not meant for use by the user\&. They are used by the shell to implement some other commands\&. .RE .PP redraw\-all .RS 4 Reprint the prompt and the current line to the terminal\&. .PP vi\-insert, vi\-command, vi\-search, emacs, emacs\-search .RS 4 \fB\e^L\fR .RE .RE .PP clear\-and\-redraw\-all .RS 4 Clear the terminal and reprint the prompt and the current line\&. .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBMotion commands\fR .RS 4 .sp \fIMotion commands\fR move the cursor on the line\&. Most motion commands accept an argument\&. When passed an argument, they repeat the cursor motion as many times as specified by the argument\&. Passing \(lq4\(rq as an argument to the forward\-char command, for example, advances the cursor by four characters\&. .sp The shell has several definitions of words as units of distance: A \fIbigword\fR is one or more adjacent non\-whitespace characters\&. A \fIsemiword\fR is one or more adjacent characters that contain no whitespaces or punctuations\&. An \fIemacsword\fR is one or more adjacent alphanumeric characters\&. A \fIviword\fR is either: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} one or more adjacent alphanumeric characters and/or underscores (\fB_\fR), or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} one or more adjacent characters that contain none of alphanumeric characters, underscores, and whitespaces\&. .RE .PP forward\-char .RS 4 Move the cursor to the next character\&. .PP vi\-insert .RS 4 \fB\eR\fR .RE .PP vi\-command .RS 4 \fBl\fR, (space), \fB\eR\fR .RE .PP emacs .RS 4 \fB\eR\fR, \fB\e^F\fR .RE .RE .PP backward\-char .RS 4 Move the cursor to the previous character\&. .PP vi\-insert .RS 4 \fB\eL\fR .RE .PP vi\-command .RS 4 \fBh\fR, \fB\eB\fR, \fB\eL\fR, \fB\e?\fR, \fB\e^H\fR .RE .PP emacs .RS 4 \fB\eL\fR, \fB\e^B\fR .RE .RE .PP forward\-bigword .RS 4 Move the cursor to the next bigword\&. .PP vi\-command .RS 4 \fBW\fR .RE .RE .PP end\-of\-bigword .RS 4 Move the cursor to the next end of a bigword\&. .PP vi\-command .RS 4 \fBE\fR .RE .RE .PP backward\-bigword .RS 4 Move the cursor to the previous bigword\&. .PP vi\-command .RS 4 \fBB\fR .RE .RE .PP forward\-semiword .RS 4 Move the cursor to the next semiword\&. .RE .PP end\-of\-semiword .RS 4 Move the cursor to the next end of a semiword\&. .RE .PP backward\-semiword .RS 4 Move the cursor to the previous semiword\&. .RE .PP forward\-viword .RS 4 Move the cursor to the next viword\&. .PP vi\-command .RS 4 \fBw\fR .RE .RE .PP end\-of\-viword .RS 4 Move the cursor to the next end of a viword\&. .PP vi\-command .RS 4 \fBe\fR .RE .RE .PP backward\-viword .RS 4 Move the cursor to the previous viword\&. .PP vi\-command .RS 4 \fBb\fR .RE .RE .PP forward\-emacsword .RS 4 Move the cursor to the next emacsword\&. .PP emacs .RS 4 \fB\e^[f\fR, \fB\e^[F\fR .RE .RE .PP backward\-emacsword .RS 4 Move the cursor to the previous emacsword\&. .PP emacs .RS 4 \fB\e^[b\fR, \fB\e^[B\fR .RE .RE .PP beginning\-of\-line .RS 4 Move the cursor to the beginning of the line\&. .PP vi\-insert, vi\-command .RS 4 \fB\eH\fR .RE .PP emacs .RS 4 \fB\eH\fR, \fB\e^A\fR .RE .RE .PP end\-of\-line .RS 4 Move the cursor to the end of the line\&. .PP vi\-insert .RS 4 \fB\eE\fR .RE .PP vi\-command .RS 4 \fB$\fR, \fB\eE\fR .RE .PP emacs .RS 4 \fB\eE\fR, \fB\e^E\fR .RE .RE .PP go\-to\-column .RS 4 Move the cursor to the \fIn\fRth character on the line, where \fIn\fR is the argument\&. Assume \fIn\fR = 1 when no argument\&. .PP vi\-command .RS 4 \fB|\fR .RE .RE .PP first\-nonblank .RS 4 Move the cursor to the first non\-blank character on the line\&. .PP vi\-command .RS 4 \fB^\fR .RE .RE .PP find\-char .RS 4 Move the cursor to the first position where a character that is entered just after this command appears after the current cursor position\&. .PP vi\-command .RS 4 \fBf\fR .RE .PP emacs .RS 4 \fB\e^]\fR .RE .RE .PP find\-char\-rev .RS 4 Move the cursor to the last position where a character that is entered just after this command appears before the current cursor position\&. .PP vi\-command .RS 4 \fBF\fR .RE .PP emacs .RS 4 \fB\e^[\e^]\fR .RE .RE .PP till\-char .RS 4 Move the cursor to the first position just before a character that is entered just after this command appears after the current cursor position\&. .PP vi\-command .RS 4 \fBt\fR .RE .RE .PP till\-char\-rev .RS 4 Move the cursor to the last position just after a character that is entered just after this command appears before the current cursor position\&. .PP vi\-command .RS 4 \fBT\fR .RE .RE .PP refind\-char .RS 4 Redo the last find\-char, find\-char\-rev, till\-char, till\-char\-rev command\&. .PP vi\-command .RS 4 \fB;\fR .RE .RE .PP refind\-char\-rev .RS 4 Redo the last find\-char, find\-char\-rev, till\-char, till\-char\-rev command in the reverse direction\&. .PP vi\-command .RS 4 \fB,\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBEditing commands\fR .RS 4 .sp Editing commands modify contents of the buffer\&. Most editing commands accept an argument\&. When passed an argument, they repeat the modification as many times as specified by the argument\&. .sp Texts deleted by commands whose name starts with \(lqkill\(rq are saved in \fIkill ring\fR, from which deleted contents can be restored to the buffer\&. The most recent 32 texts are kept in the kill ring\&. .PP delete\-char .RS 4 Delete a character at the current cursor position if no argument is passed; like the kill\-char command otherwise\&. .PP vi\-insert, emacs .RS 4 \fB\eX\fR .RE .RE .PP delete\-bigword .RS 4 Delete a bigword at the current cursor position if no argument is passed; like the kill\-bigword command otherwise\&. .RE .PP delete\-semiword .RS 4 Delete a semiword at the current cursor position if no argument is passed; like the kill\-semiword command otherwise\&. .RE .PP delete\-viword .RS 4 Delete a viword at the current cursor position if no argument is passed; like the kill\-viword command otherwise\&. .RE .PP delete\-emacsword .RS 4 Delete a emacsword at the current cursor position if no argument is passed; like the kill\-emacsword command otherwise\&. .RE .PP backward\-delete\-char .RS 4 Delete a character just before the current cursor position if no argument is passed; like the backward\-kill\-char command otherwise\&. .PP vi\-insert, emacs .RS 4 \fB\eB\fR, \fB\e?\fR, \fB\e^H\fR .RE .RE .PP backward\-delete\-bigword .RS 4 Delete a bigword just before the current cursor position if no argument is passed; like the backward\-kill\-bigword command otherwise\&. .RE .PP backward\-delete\-semiword .RS 4 Delete a semiword just before the current cursor position if no argument is passed; like the backward\-kill\-semiword command otherwise\&. .PP vi\-insert .RS 4 \fB\e^W\fR .RE .RE .PP backward\-delete\-viword .RS 4 Delete a viword just before the current cursor position if no argument is passed; like the backward\-kill\-viword command otherwise\&. .RE .PP backward\-delete\-emacsword .RS 4 Delete a emacsword just before the current cursor position if no argument is passed; like the backward\-kill\-emacsword command otherwise\&. .RE .PP delete\-line .RS 4 Delete the whole buffer contents\&. .RE .PP forward\-delete\-line .RS 4 Delete all characters from the current cursor position to the end of the buffer\&. .RE .PP backward\-delete\-line .RS 4 Delete all characters before the current cursor position\&. .PP vi\-insert .RS 4 \fB\e$\fR, \fB\e^U\fR .RE .RE .PP kill\-char .RS 4 Delete a character at the current cursor position and add it to the kill ring\&. .PP vi\-command .RS 4 \fBx\fR, \fB\eX\fR .RE .RE .PP kill\-bigword .RS 4 Delete a bigword at the current cursor position and add it to the kill ring\&. .RE .PP kill\-semiword .RS 4 Delete a semiword at the current cursor position and add it to the kill ring\&. .RE .PP kill\-viword .RS 4 Delete a viword at the current cursor position and add it to the kill ring\&. .RE .PP kill\-emacsword .RS 4 Delete a emacsword at the current cursor position and add it to the kill ring\&. .PP emacs .RS 4 \fB\e^[d\fR, \fB\e^[D\fR .RE .RE .PP backward\-kill\-char .RS 4 Delete a character just before the current cursor position and add it to the kill ring\&. .PP vi\-command .RS 4 \fBX\fR .RE .RE .PP backward\-kill\-bigword .RS 4 Delete a bigword just before the current cursor position and add it to the kill ring\&. .PP emacs .RS 4 \fB\e^W\fR .RE .RE .PP backward\-kill\-semiword .RS 4 Delete a semiword just before the current cursor position and add it to the kill ring\&. .RE .PP backward\-kill\-viword .RS 4 Delete a viword just before the current cursor position and add it to the kill ring\&. .RE .PP backward\-kill\-emacsword .RS 4 Delete a emacsword just before the current cursor position and add it to the kill ring\&. .PP emacs .RS 4 \fB\e^[\eB\fR, \fB\e^[\e?\fR, \fB\e^[\e^H\fR .RE .RE .PP kill\-line .RS 4 Delete the whole buffer contents and add it to the kill ring\&. .RE .PP forward\-kill\-line .RS 4 Delete all characters from the current cursor position to the end of the buffer and add it to the kill ring\&. .PP emacs .RS 4 \fB\e^K\fR .RE .RE .PP backward\-kill\-line .RS 4 Delete all characters before the current cursor position and add it to the kill ring\&. .PP emacs .RS 4 \fB\e$\fR, \fB\e^U\fR, \fB\e^X\eB\fR, \fB\e^X\e?\fR .RE .RE .PP put\-before .RS 4 Insert the last\-killed text before the current cursor position and move the cursor to the last character that was inserted\&. .PP vi\-command .RS 4 \fBP\fR .RE .RE .PP put .RS 4 Insert the last\-killed text after the current cursor position and move the cursor to the last character that was inserted\&. .PP vi\-command .RS 4 \fBp\fR .RE .RE .PP put\-left .RS 4 Insert the last\-killed text before the current cursor position and move the cursor to the last character that was inserted\&. .PP emacs .RS 4 \fB\e^Y\fR .RE .RE .PP put\-pop .RS 4 Replace the just put text with the next older killed text\&. .sp This command can be used only just after the put\-before, put, put\-left, or put\-pop command\&. .PP emacs .RS 4 \fB\e^[y\fR, \fB\e^[Y\fR .RE .RE .PP undo .RS 4 Cancel modification by the last editing command\&. .PP vi .RS 4 \fBu\fR .RE .PP emacs .RS 4 \fB\e^_\fR, \fB\e^X\e$\fR, \fB\e^X\e^U\fR .RE .RE .PP undo\-all .RS 4 Cancel all modification in the current buffer, restoring the initial contents\&. .PP vi .RS 4 \fBU\fR .RE .PP emacs .RS 4 \fB\e^[\e^R\fR, \fB\e^[r\fR, \fB\e^[R\fR .RE .RE .PP cancel\-undo .RS 4 Cancel cancellation by the last undo or undo\-all command\&. .PP vi .RS 4 \fB\e^R\fR .RE .RE .PP cancel\-undo\-all .RS 4 Cancel all cancellation by all most recent undo and undo\-all commands\&. .RE .PP redo .RS 4 Repeat modification by the last editing command\&. .PP vi\-command .RS 4 \fB\&.\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBCompletion commands\fR .RS 4 .PP complete .RS 4 Complete a word just before the cursor position and, if there is more than one candidate, show a list of the candidates\&. .RE .PP complete\-next\-candidate .RS 4 Like the complete command when candidates are not being listed; otherwise, select the next candidate in the list\&. .PP vi\-insert, emacs .RS 4 \fB\e^I\fR .RE .RE .PP complete\-prev\-candidate .RS 4 Like the complete command when candidates are not being listed; otherwise, select the previous candidate in the list\&. .PP vi\-insert, emacs .RS 4 \fB\ebt\fR .RE .RE .PP complete\-next\-column .RS 4 Like the complete command when candidates are not being listed; otherwise, select the first candidate in the next column in the list\&. .RE .PP complete\-prev\-column .RS 4 Like the complete command when candidates are not being listed; otherwise, select the first candidate in the previous column in the list\&. .RE .PP complete\-next\-page .RS 4 Like the complete command when candidates are not being listed; otherwise, select the first candidate in the next page in the list\&. .RE .PP complete\-prev\-page .RS 4 Like the complete command when candidates are not being listed; otherwise, select the first candidate in the previous page in the list\&. .RE .PP complete\-list .RS 4 Complete a word just before the cursor position\&. .sp If you pass no argument, a list of completion candidates is shown\&. Otherwise, the word is completed with the \fIn\fRth candidate where \fIn\fR is the argument\&. .PP emacs .RS 4 \fB\e^[?\fR, \fB\e^[=\fR .RE .RE .PP complete\-all .RS 4 Replace a word just before the cursor position with all possible completion candidates, each separated by a space\&. .PP emacs .RS 4 \fB\e^[*\fR .RE .RE .PP complete\-max .RS 4 Complete a word just before the cursor position with the longest prefix of all possible completion candidates\&. .RE .PP clear\-candidates .RS 4 Clear the list of completion candidates\&. .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBVi-specific commands\fR .RS 4 .PP vi\-replace\-char .RS 4 Replace the character at the cursor position with a character that is entered just after this command\&. .PP vi\-command .RS 4 \fBr\fR .RE .RE .PP vi\-insert\-beginning .RS 4 Move the cursor to the beginning of the line and switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBI\fR .RE .RE .PP vi\-append .RS 4 Move the cursor to the next character and switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBI\fR .RE .RE .PP vi\-append\-to\-eol .RS 4 Move the cursor to the end of the line and switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBA\fR .RE .RE .PP vi\-replace .RS 4 Switch to the vi insert mode and start overwriting\&. While overwriting, the self\-insert command replaces the character at cursor position rather than inserting a character\&. Overwriting ends when the editing mode is changed\&. .PP vi\-command .RS 4 \fBR\fR .RE .RE .PP vi\-switch\-case .RS 4 Switch case of characters between the current and next cursor positions\&. This command must be followed by a motion command, which determines the next cursor position\&. .RE .PP vi\-switch\-case\-char .RS 4 Switch case of the character at the current cursor position and move the cursor to the next character\&. .PP vi\-command .RS 4 \fB~\fR .RE .RE .PP vi\-yank .RS 4 Add to the kill ring the characters between the current and next cursor positions\&. This command must be followed by a motion command, which determines the next cursor position\&. .PP vi\-command .RS 4 \fBy\fR .RE .RE .PP vi\-yank\-to\-eol .RS 4 Add to the kill ring the characters from the current cursor position to the end of the line\&. .PP vi\-command .RS 4 \fBY\fR .RE .RE .PP vi\-delete .RS 4 Delete characters between the current and next cursor positions and add it to the kill ring\&. This command must be followed by a motion command, which determines the next cursor position\&. .PP vi\-command .RS 4 \fBd\fR .RE .RE .PP vi\-delete\-to\-eol .RS 4 Delete the characters from the current cursor position to the end of the line and add it to the kill ring\&. .PP vi\-command .RS 4 \fBD\fR .RE .RE .PP vi\-change .RS 4 Delete characters between the current and next cursor positions and switch to the vi insert mode\&. This command must be followed by a motion command, which determines the next cursor position\&. .PP vi\-command .RS 4 \fBc\fR .RE .RE .PP vi\-change\-to\-eol .RS 4 Delete the characters from the current cursor position to the end of the line and switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBC\fR .RE .RE .PP vi\-change\-line .RS 4 Delete the whole buffer contents and switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBS\fR .RE .RE .PP vi\-yank\-and\-change .RS 4 Like the vi\-change command, but the deleted text is added to the kill ring\&. .RE .PP vi\-yank\-and\-change\-to\-eol .RS 4 Like the vi\-change\-to\-eol command, but the deleted text is added to the kill ring\&. .RE .PP vi\-yank\-and\-change\-line .RS 4 Like the vi\-change\-line command, but the deleted text is added to the kill ring\&. .RE .PP vi\-substitute .RS 4 Delete a character at the current cursor position, add it to the kill ring, and switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBs\fR .RE .RE .PP vi\-append\-last\-bigword .RS 4 Insert a space and the last bigword in the most recent command history entry just after the current cursor position and switch to the vi insert mode\&. If argument \fIn\fR is passed, the \fIn\fRth bigword in the entry is inserted instead of the last\&. .PP vi\-command .RS 4 \fB_\fR .RE .RE .PP vi\-exec\-alias .RS 4 Execute the value of an alias named \fB_\fR\fB\fIc\fR\fR as editing commands where \fIc\fR is a character input just after this command\&. .PP vi\-command .RS 4 \fB@\fR .RE .RE .PP vi\-edit\-and\-accept .RS 4 Start the vi editor to edit the current buffer contents\&. When the editor finished, the edited buffer contents is accepted like the accept\-line command unless the exit status of the editor is non\-zero\&. .PP vi\-command .RS 4 \fBv\fR .RE .RE .PP vi\-complete\-list .RS 4 Like the complete\-list command, but also switch to the vi insert mode\&. .PP vi\-command .RS 4 \fB=\fR .RE .RE .PP vi\-complete\-all .RS 4 Like the complete\-all command, but also switch to the vi insert mode\&. .PP vi\-command .RS 4 \fB*\fR .RE .RE .PP vi\-complete\-max .RS 4 Like the complete\-max command, but also switch to the vi insert mode\&. .PP vi\-command .RS 4 \fB\e\e\fR .RE .RE .PP vi\-search\-forward .RS 4 Switch to the vi search mode and start forward history search\&. .PP vi\-command .RS 4 \fB?\fR .RE .RE .PP vi\-search\-backward .RS 4 Switch to the vi search mode and start backward history search\&. .PP vi\-command .RS 4 \fB/\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBEmacs-specific commands\fR .RS 4 .PP emacs\-transpose\-chars .RS 4 Move a character just before the cursor to the right\&. .PP emacs .RS 4 \fB\e^T\fR .RE .RE .PP emacs\-transpose\-words .RS 4 Move an emacsword just before the cursor to the right\&. .PP emacs .RS 4 \fB\e^[t\fR, \fB\e^[T\fR .RE .RE .PP emacs\-downcase\-word .RS 4 Make an emacsword just after the cursor lowercase\&. .PP emacs .RS 4 \fB\e^[l\fR, \fB\e^[L\fR .RE .RE .PP emacs\-upcase\-word .RS 4 Make an emacsword just after the cursor uppercase\&. .PP emacs .RS 4 \fB\e^[u\fR, \fB\e^[U\fR .RE .RE .PP emacs\-capitalize\-word .RS 4 Capitalize the first letter of an emacsword just after the cursor\&. .PP emacs .RS 4 \fB\e^[c\fR, \fB\e^[u\fR .RE .RE .PP emacs\-delete\-horizontal\-space .RS 4 Delete spaces around the cursor\&. If any argument was passed, delete spaces just before the cursor only\&. .PP emacs .RS 4 \fB\e^[\e\e\fR .RE .RE .PP emacs\-just\-one\-space .RS 4 Delete spaces around the cursor and leave one space\&. If an argument is specified, leave as many spaces as the argument\&. .PP emacs .RS 4 \fB\e^[\fR (Escape followed by a space) .RE .RE .PP emacs\-search\-forward .RS 4 Switch to the emacs search mode and start forward history search\&. .PP emacs .RS 4 \fB\e^S\fR .RE .RE .PP emacs\-search\-backward .RS 4 Switch to the emacs search mode and start backward history search\&. .PP emacs .RS 4 \fB\e^R\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBHistory-related commands\fR .RS 4 .PP oldest\-history .RS 4 Recall the oldest entry in the history\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. The cursor position remains unchanged\&. .RE .PP newest\-history .RS 4 Recall the newest entry in the history\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. The cursor position remains unchanged\&. .RE .PP return\-history .RS 4 Return to the initial buffer corresponding to none of existing history entries\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. The cursor position remains unchanged\&. .RE .PP oldest\-history\-bol .RS 4 Recall the oldest entry in the history and move the cursor to the beginning of the line\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. .PP vi\-command .RS 4 \fBG\fR .RE .RE .PP newest\-history\-bol .RS 4 Recall the newest entry in the history and move the cursor to the beginning of the line\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. .RE .PP return\-history\-bol .RS 4 Return to the initial buffer corresponding to none of existing history entries and move the cursor to the beginning of the line\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. .PP vi\-command .RS 4 \fBg\fR .RE .RE .PP oldest\-history\-eol .RS 4 Recall the oldest entry in the history and move the cursor to the end of the line\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. .PP emacs .RS 4 \fB\e^[<\fR .RE .RE .PP newest\-history\-eol .RS 4 Recall the newest entry in the history and move the cursor to the end of the line\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. .RE .PP return\-history\-eol .RS 4 Return to the initial buffer corresponding to none of existing history entries and move the cursor to the end of the line\&. If argument \fIn\fR is passed, the entry whose number is \fIn\fR is recalled instead\&. .PP emacs .RS 4 \fB\e^[>\fR .RE .RE .PP next\-history .RS 4 Recall the next history entry\&. The cursor position remains unchanged\&. .RE .PP prev\-history .RS 4 Recall the previous history entry\&. The cursor position remains unchanged\&. .RE .PP next\-history\-bol .RS 4 Recall the next history entry and move the cursor to the beginning of the line\&. .PP vi\-command .RS 4 \fBj\fR, \fB+\fR, \fB\eD\fR, \fB\e^N\fR .RE .RE .PP prev\-history\-bol .RS 4 Recall the previous history entry and move the cursor to the beginning of the line\&. .PP vi\-command .RS 4 \fBk\fR, \fB\-\fR, \fB\eU\fR, \fB\e^P\fR .RE .RE .PP next\-history\-eol .RS 4 Recall the next history entry and move the cursor to the end of the line\&. .PP vi\-insert, emacs .RS 4 \fB\eD\fR, \fB\e^N\fR .RE .RE .PP prev\-history\-eol .RS 4 Recall the previous history entry and move the cursor to the end of the line\&. .PP vi\-insert, emacs .RS 4 \fB\eU\fR, \fB\e^P\fR .RE .RE .PP search\-again .RS 4 Repeat the last command history search\&. .PP vi\-command .RS 4 \fBn\fR .RE .RE .PP search\-again\-rev .RS 4 Repeat the last command history search in the reverse direction\&. .PP vi\-command .RS 4 \fBN\fR .RE .RE .PP search\-again\-forward .RS 4 Repeat the last command history search in the forward direction\&. .RE .PP search\-again\-backward .RS 4 Repeat the last command history search in the backward direction\&. .RE .PP beginning\-search\-forward .RS 4 Recall the next history entry that starts with the same text as the text from the beginning of the line up to the current cursor position\&. The cursor position remains unchanged\&. .RE .PP beginning\-search\-backward .RS 4 Recall the previous history entry that starts with the same text as the text from the beginning of the line up to the current cursor position\&. The cursor position remains unchanged\&. .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBSearch mode commands\fR .RS 4 .PP srch\-self\-insert .RS 4 Insert the input character at the current cursor position\&. Characters escaped by escape sequences cannot be inserted\&. .PP vi\-search, emacs\-search .RS 4 \fB\e\e\fR .RE .RE .PP srch\-backward\-delete\-char .RS 4 Delete the last character in the search text\&. If the text is empty: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} like the srch\-abort\-search command when in the vi search mode, or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} like the alert command when in the emacs search mode\&. .RE .PP vi\-search, emacs\-search .RS 4 \fB\eB\fR, \fB\e?\fR, \fB\e^H\fR .RE .RE .PP srch\-backward\-delete\-line .RS 4 Delete the whole search text\&. .PP vi\-search, emacs\-search .RS 4 \fB\e$\fR, \fB\e^U\fR .RE .RE .PP srch\-continue\-forward .RS 4 Find the next matching history entry\&. .PP emacs\-search .RS 4 \fB\e^S\fR .RE .RE .PP srch\-continue\-backward .RS 4 Find the previous matching history entry\&. .PP emacs\-search .RS 4 \fB\e^R\fR .RE .RE .PP srch\-accept\-search .RS 4 Finish the search mode, accepting the result being shown\&. .PP vi\-search .RS 4 \fB\e^J\fR, \fB\e^M\fR .RE .PP emacs\-search .RS 4 \fB\e^J\fR, \fB\e^[\fR .RE .RE .PP srch\-abort\-search .RS 4 Abort search and restore the previous buffer contents\&. .PP vi\-search .RS 4 \fB\e^[\fR .RE .PP emacs\-search .RS 4 \fB\e^G\fR .RE .RE .RE .SS "Escape sequences" .sp In the bindkey built\-in, escape sequences are used to represent special keys such as function keys and arrow keys\&. Every escape sequence starts with a backslash (\fB\e\fR) and thus there is also an escape sequence for a backslash itself\&. .sp Below are available escape sequences: .PP \fB\e\e\fR .RS 4 Backslash (\fB\e\fR) .RE .PP \fB\eB\fR .RS 4 Backspace .RE .PP \fB\eD\fR .RS 4 Down arrow .RE .PP \fB\eE\fR .RS 4 End .RE .PP \fB\eH\fR .RS 4 Home .RE .PP \fB\eI\fR .RS 4 Insert (Insert\-char, Enter\-insert\-mode) .RE .PP \fB\eL\fR .RS 4 Left arrow .RE .PP \fB\eN\fR .RS 4 Page\-down (Next\-page) .RE .PP \fB\eP\fR .RS 4 Page\-up (Previous\-page) .RE .PP \fB\eR\fR .RS 4 Right arrow .RE .PP \fB\eU\fR .RS 4 Up arrow .RE .PP \fB\eX\fR .RS 4 Delete .RE .PP \fB\e!\fR .RS 4 INTR .RE .PP \fB\e#\fR .RS 4 EOF .RE .PP \fB\e$\fR .RS 4 KILL .RE .PP \fB\e?\fR .RS 4 ERASE .RE .PP \fB\e^@\fR .RS 4 Ctrl + @ .RE .PP \fB\e^A\fR, \fB\e^B\fR, \&..., \fB\e^Z\fR .RS 4 Ctrl + A, Ctrl + B, \&..., Ctrl + Z .sp Note that Ctrl + I, Ctrl + J, and Ctrl + M are tab, newline, and carriage return, respectively\&. .RE .PP \fB\e^[\fR .RS 4 Ctrl + [ (Escape) .RE .PP \fB\e^\e\fR .RS 4 Ctrl + \e .RE .PP \fB\e^]\fR .RS 4 Ctrl + ] .RE .PP \fB\e^^\fR .RS 4 Ctrl + ^ .RE .PP \fB\e^_\fR .RS 4 Ctrl + _ .RE .PP \fB\e^?\fR .RS 4 Ctrl + ? (Delete) .RE .PP \fB\eF00\fR, \fB\eF01\fR, \&..., \fB\eF63\fR .RS 4 F0, F1, \&..., F63 .RE .PP \fB\ea1\fR .RS 4 Top\-left on keypad .RE .PP \fB\ea3\fR .RS 4 Top\-right on keypad .RE .PP \fB\eb2\fR .RS 4 Center on keypad .RE .PP \fB\ebg\fR .RS 4 Beginning .RE .PP \fB\ebt\fR .RS 4 Back\-tab .RE .PP \fB\ec1\fR .RS 4 Bottom\-left on keypad .RE .PP \fB\ec3\fR .RS 4 Bottom\-right on keypad .RE .PP \fB\eca\fR .RS 4 Clear\-all\-tabs .RE .PP \fB\ecl\fR .RS 4 Close .RE .PP \fB\ecn\fR .RS 4 Cancel .RE .PP \fB\eco\fR .RS 4 Command .RE .PP \fB\ecp\fR .RS 4 Copy .RE .PP \fB\ecr\fR .RS 4 Create .RE .PP \fB\ecs\fR .RS 4 Clear\-screen or erase .RE .PP \fB\ect\fR .RS 4 Clear\-tab .RE .PP \fB\edl\fR .RS 4 Delete\-line .RE .PP \fB\eei\fR .RS 4 Exit\-insert\-mode .RE .PP \fB\eel\fR .RS 4 Clear\-to\-end\-of\-line .RE .PP \fB\ees\fR .RS 4 Clear\-to\-end\-of\-screen .RE .PP \fB\eet\fR .RS 4 Enter (Send) .RE .PP \fB\eex\fR .RS 4 Exit .RE .PP \fB\efd\fR .RS 4 Find .RE .PP \fB\ehp\fR .RS 4 Help .RE .PP \fB\eil\fR .RS 4 Insert\-line .RE .PP \fB\ell\fR .RS 4 Home\-down .RE .PP \fB\eme\fR .RS 4 Message .RE .PP \fB\emk\fR .RS 4 Mark .RE .PP \fB\ems\fR .RS 4 Mouse event .RE .PP \fB\emv\fR .RS 4 Move .RE .PP \fB\enx\fR .RS 4 Next\-object .RE .PP \fB\eon\fR .RS 4 Open .RE .PP \fB\eop\fR .RS 4 Options .RE .PP \fB\epr\fR .RS 4 Print (Copy) .RE .PP \fB\epv\fR .RS 4 Previous\-object .RE .PP \fB\erd\fR .RS 4 Redo .RE .PP \fB\ere\fR .RS 4 Resume .RE .PP \fB\erf\fR .RS 4 Ref (Reference) .RE .PP \fB\erh\fR .RS 4 Refresh .RE .PP \fB\erp\fR .RS 4 Replace .RE .PP \fB\ers\fR .RS 4 Restart .RE .PP \fB\esf\fR .RS 4 Scroll\-forward (Scroll\-down) .RE .PP \fB\esl\fR .RS 4 Select .RE .PP \fB\esr\fR .RS 4 Scroll\-backward (Scroll\-up) .RE .PP \fB\est\fR .RS 4 Set\-tab .RE .PP \fB\esu\fR .RS 4 Suspend .RE .PP \fB\esv\fR .RS 4 Save .RE .PP \fB\eud\fR .RS 4 Undo .RE .PP \fB\eSE\fR .RS 4 Shift + End .RE .PP \fB\eSH\fR .RS 4 Shift + Home .RE .PP \fB\eSI\fR .RS 4 Shift + Insert .RE .PP \fB\eSL\fR .RS 4 Shift + Left arrow .RE .PP \fB\eSR\fR .RS 4 Shift + Right arrow .RE .PP \fB\eSX\fR .RS 4 Shift + Delete .RE .PP \fB\eSbg\fR .RS 4 Shift + Beginning .RE .PP \fB\eScn\fR .RS 4 Shift + Cancel .RE .PP \fB\eSco\fR .RS 4 Shift + Command .RE .PP \fB\eScp\fR .RS 4 Shift + Copy .RE .PP \fB\eScr\fR .RS 4 Shift + Create .RE .PP \fB\eSdl\fR .RS 4 Shift + Delete\-line .RE .PP \fB\eSel\fR .RS 4 Shift + End\-of\-line .RE .PP \fB\eSex\fR .RS 4 Shift + Exit .RE .PP \fB\eSfd\fR .RS 4 Shift + Find .RE .PP \fB\eShp\fR .RS 4 Shift + Help .RE .PP \fB\eSmg\fR .RS 4 Shift + Message .RE .PP \fB\eSmv\fR .RS 4 Shift + Move .RE .PP \fB\eSnx\fR .RS 4 Shift + Next .RE .PP \fB\eSop\fR .RS 4 Shift + Options .RE .PP \fB\eSpr\fR .RS 4 Shift + Print .RE .PP \fB\eSpv\fR .RS 4 Shift + Previous .RE .PP \fB\eSrd\fR .RS 4 Shift + Redo .RE .PP \fB\eSre\fR .RS 4 Shift + Resume .RE .PP \fB\eSrp\fR .RS 4 Shift + Replace .RE .PP \fB\eSsu\fR .RS 4 Shift + Suspend .RE .PP \fB\eSsv\fR .RS 4 Shift + Save .RE .PP \fB\eSud\fR .RS 4 Shift + Undo .RE .sp INTR, EOF, KILL, and ERASE are special characters configured by the stty command\&. In a typical configuration, they are sent by typing Ctrl+C, Ctrl+D, Ctrl+U, and Ctrl+H, respectively, but some configuration uses Ctrl+? instead of Ctrl+H for ERASE\&. .SS "Command line completion" .sp By using the complete and complete\-next\-candidate commands, etc\&., you can complete command names, options, and operands\&. By default, the complete\-next\-candidate command is bound with the Tab key in the vi insert and emacs modes\&. .sp Type a few first letters of a command name or pathname and hit the Tab key, and a list of matching names will be shown\&. You can choose a candidate from the list to complete the name by hitting the Tab key again\&. If there is only one matching name, no list will be shown and the name will directly be completed\&. .sp If the name to be completed contains characters like \fB*\fR and \fB?\fR, it is treated as a pattern\&. The name on the command line will be directly substituted with all possible names matching the pattern (you cannot choose from a list)\&. .sp Normally, command names are completed with command names and command arguments with pathnames\&. However, \fIcompletion functions\fR can be defined to refine completion results\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBCompletion details\fR .RS 4 .sp When doing completion for the first time after the shell has been started, the INIT file is loaded as if the command string \fB\&.\fR\fB \-AL completion/INIT\fR is executed\&. If the file is not found, it is silently ignored\&. This automatic loading is mainly intended for loading completion functions bundled with the shell, but you can let the shell load your own functions by putting a file in the load path\&. .sp When completing a command name, the shell executes the \fBcompletion//command\fR function and when completing a command argument, the \fBcompletion//argument\fR function\&. If those completion functions are not defined, the shell just completes with command names or pathnames\&. When completing other names, such as the user name in tilde expansion and the parameter name in parameter expansion, completion functions are never used: the shell just completes with user names, parameter names, or whatever applicable\&. .sp Completion functions are executed without any arguments\&. The following local variables are automatically defined while executing completion functions: .PP \fBIFS\fR .RS 4 The value is the three characters of a space, a tab, and a newline, which are the default value of the variable\&. .RE .PP \fBWORDS\fR .RS 4 This variable is an array whose elements are a command name and arguments that have already been entered before the argument being completed\&. When completing a command name, the array has no elements\&. .RE .PP \fBTARGETWORD\fR .RS 4 The value is the partially entered command name or argument that is being completed\&. .RE .sp Completion candidates are generated by executing the complete built\-in during a completion function\&. .sp Completion functions must not perform I/O to the terminal, or displayed text will be corrupted\&. Completion functions should run as quickly as possible for better user experience\&. .sp While a completion function is being executed: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the POSIXly\-correct mode is temporarily disabled, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the err\-exit option is temporarily disabled, and .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} traps are not executed\&. .RE .RE .SH "POSIXLY-CORRECT MODE" .sp Yash behaves as defined in POSIX\&.1\-2008, Shell & Utilities for the most part, but some functionalities disobey POSIX for usability\&. When full POSIX\-conformance is needed, you can enable the \fIPOSIXly\-correct mode\fR to make yash obey POSIX as mush as possible\&. .sp If yash is started with the name \(lqsh\(rq, the POSIXly\-correct mode is automatically enabled\&. The \fB\-o posixly\-correct\fR command\-line option also enables the POSIXly\-correct mode\&. After yash has been started, the POSIXly\-correct mode can be enabled by executing the command string \fBset\fR\fB \-o posixly\-correct\fR\&. .sp When the POSIXly\-correct mode is on, yash not only tries to obey the requirements by POSIX, but also treats as errors most conditions where the behavior is \fIundefined\fR or \fIunspecified\fR by POSIX\&. As a result, most yash\-specific functionalities are disabled in the POSIXly\-correct mode\&. .sp Below is the complete list of the behavioral differences between when yash is in the POSIXly\-correct mode and when not\&. When the POSIXly\-correct mode is enabled: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Different initialization scripts are used\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Global aliases are not substituted\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Nested commands in a compound command must not be empty\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Words expanded in a for loop are assigned as a global variable rather than a local\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The first pattern in a case command cannot be \fBesac\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The \fBfunction\fR keyword cannot be used for function definition\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Simple commands cannot assign to arrays\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Changing the value of the \fBLC_CTYPE\fR variable after the shell has been initialized does not affect the shell\(cqs locale\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The \fBRANDOM\fR variable cannot be used to generate random numbers\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Tilde expansion only expands \fB~\fR and \fB~\fR\fB\fIusername\fR\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Parameter expansion cannot be nested\&. No indexes are allowed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The commands in a command substitution of the form \fB$(\fR\fB\fIcommands\fR\fR\fB)\fR are parsed every time the substitution is executed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Fractional numbers and the \fB++\fR and \fB\-\-\fR operators cannot be used in arithmetic expansion\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} In a redirection to a file, if the pathname expansion yielded more than one or no pathname, it is not immediately treated as an error\&. Instead, the shell tries to treat the word before the expansion as a pathname\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Socket redirection, here strings, pipe redirection, and process redirection cannot be used\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When executing a simple command, failure in command search does not trigger execution of the \fBCOMMAND_NOT_FOUND_HANDLER\fR variable\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} In command search, a regular built\-in needs to have a corresponding external command for the built\-in to be found\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} asynchronous commands ignore the SIGINT and SIGQUIT signals even when job control is active\&. The standard input of asynchronous commands is redirected to /dev/null if the shell is not interactive, regardless of whether job control is active or not\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Some built\-ins behave differently\&. Especially, some command\-line options cannot be used\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A non\-interactive shell exits when a special built\-in is given a syntactically wrong arguments or when an error occurs in assignment or redirection with a special built\-in\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} An interactive shell does not execute the \fBPROMPT_COMMAND\fR variable before printing a prompt\&. The values of the \fBPS1\fR, \fBPS2\fR, and \fBPS4\fR variables are parsed differently\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} In mail checking, a notification message is printed if the file has been modified, regardless of whether the file is empty\&. .RE .SH "FORMAL DEFINITION OF COMMAND SYNTAX" .sp This chapter defines the syntax of shell commands as a parsing expression grammar\&. .sp The set of terminals of the grammar is the set of characters that can be handled on the environment in which the shell is run (a\&.k\&.a\&. execution character set), with the exception that the set does not contain the null character (\fB\*(Aq\e0\*(Aq\fR)\&. .sp Below is a list of nonterminals of the grammar with corresponding parsing expressions\&. The list does not include rules for parsing contents and ends of here documents\&. In the POSIXly\-correct mode, the grammar varies from the list below to disable non\-POSIX functionalities\&. .PP CompleteCommand .RS 4 SequenceEOF .RE .PP Sequence .RS 4 N* List* .RE .PP List .RS 4 Pipeline ((\fB&&\fR / \fB||\fR) N* Pipeline)* ListSeparator .RE .PP Pipeline .RS 4 Bang? Command (\fB|\fRN* Command)* .RE .PP Command .RS 4 CompoundCommandRedirection* / !RFunctionDefinition / !R SimpleCommand .RE .PP CompoundCommand .RS 4 Subshell / Grouping / IfCommand / ForCommand / WhileCommand / CaseCommand / FunctionCommand .RE .PP Subshell .RS 4 \fB(\fRSequence\fB)\fRS* .RE .PP Grouping .RS 4 LeftBraceSequenceRightBrace .RE .PP IfCommand .RS 4 IfSequenceThen Sequence (Elif Sequence Then Sequence)* (Else Sequence)? Fi .RE .PP ForCommand .RS 4 ForNameS* Separator? (InWord* Separator)? DoSequenceDone .RE .PP WhileCommand .RS 4 (While / Until) SequenceDo Sequence Done .RE .PP CaseCommand .RS 4 CaseWordN* In N* CaseItem* Esac .RE .PP CaseItem .RS 4 !Esac (\fB(\fRS*)? Word (\fB|\fR S* Word)* \fB)\fRSequence (\fB;;\fR / &Esac) .RE .PP FunctionCommand .RS 4 FunctionWord (\fB(\fRS* \fB)\fR)? N* CompoundCommandRedirection* .RE .PP FunctionDefinition .RS 4 NameS* \fB(\fR S* \fB)\fRN* CompoundCommandRedirection* .RE .PP SimpleCommand .RS 4 &(Word / Redirection) (Assignment / Redirection)* (Word / Redirection)* .RE .PP Assignment .RS 4 Name\fB=\fRWord / Name \fB=(\fRN* (Word N*)* \fB)\fR .RE .PP Name .RS 4 ![[:digit:]] [[:alnum:] \fB_\fR]+ .RE .PP PortableName .RS 4 ![\fB0\fR\-\fB9\fR] [\fB0\fR\-\fB9\fR\fBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_\fR]+ .RE .PP Word .RS 4 (WordElement / !SpecialChar \&.)+ S* .RE .PP WordElement .RS 4 \fB\e\fR \&. / \fB\*(Aq\fR (!\fB\*(Aq\fR \&.)* \fB\*(Aq\fR / \fB"\fRQuoteElement* \fB"\fR / Parameter / Arithmetic / CommandSubstitution .RE .PP QuoteElement .RS 4 \fB\e\fR ([\fB$`"\e\fR] / NL) / Parameter / Arithmetic / CommandSubstitution / ![\fB`"\e\fR] \&. .RE .PP Parameter .RS 4 \fB$\fR [\fB@*#?\-$!\fR [:digit:]] / \fB$\fRPortableName / \fB$\fRParameterBody .RE .PP ParameterBody .RS 4 \fB{\fRParameterNumber? (ParameterName / ParameterBody / Parameter) ParameterIndex? ParameterMatch? \fB}\fR .RE .PP ParameterNumber .RS 4 \fB#\fR ![\fB+=:/%\fR] !([\fB\-?#\fR] \fB}\fR) .RE .PP ParameterName .RS 4 [\fB@*#?\-$!\fR] / [[:alnum:] \fB_\fR]+ .RE .PP ParameterIndex .RS 4 \fB[\fRParameterIndexWord (\fB,\fR ParameterIndexWord)? \fB]\fR .RE .PP ParameterIndexWord .RS 4 (WordElement / ![\fB"\*(Aq],\fR] \&.)+ .RE .PP ParameterMatch .RS 4 \fB:\fR? [\fB\-+=?\fR] ParameterMatchWord / (\fB#\fR / \fB##\fR / \fB%\fR / \fB%%\fR) ParameterMatchWord / (\fB:/\fR / \fB/\fR [\fB#%/\fR]?) ParameterMatchWordNoSlash (\fB/\fR ParameterMatchWord)? .RE .PP ParameterMatchWord .RS 4 (WordElement / ![\fB"\*(Aq}\fR] \&.)* .RE .PP ParameterMatchWordNoSlash .RS 4 (WordElement / ![\fB"\*(Aq/}\fR] \&.)* .RE .PP Arithmetic .RS 4 \fB$((\fRArithmeticBody* \fB))\fR .RE .PP ArithmeticBody .RS 4 \fB\e\fR \&. / Parameter / Arithmetic / CommandSubstitution / \fB(\fR ArithmeticBody \fB)\fR / ![\fB`()\fR] \&. .RE .PP CommandSubstitution .RS 4 \fB$(\fRSequence\fB)\fR / \fB`\fRCommandSubstitutionBody* \fB`\fR .RE .PP CommandSubstitutionBody .RS 4 \fB\e\fR [\fB$`\e\fR] / !\fB`\fR \&. .RE .PP Redirection .RS 4 RedirectionFDRedirectionOperatorS* Word / RedirectionFD \fB<(\fRSequence\fB)\fR / RedirectionFD \fB>(\fR Sequence \fB)\fR .RE .PP RedirectionFD .RS 4 [[:digit:]]* .RE .PP RedirectionOperator .RS 4 \fB<\fR / \fB<>\fR / \fB>\fR / \fB>|\fR / \fB>>\fR / \fB>>|\fR / \fB<&\fR / \fB>&\fR / \fB<<\fR / \fB<<\-\fR / \fB<<<\fR .RE .PP ListSeparator .RS 4 Separator / \fB&\fRN* / &\fB)\fR / &\fB;;\fR .RE .PP Separator .RS 4 \fB;\fRN* / N+ / EOF .RE .PP N .RS 4 S* NL .RE .PP S .RS 4 [[:blank:]] / Comment .RE .PP Comment .RS 4 \fB#\fR (!NL \&.)* .RE .PP R .RS 4 Bang / LeftBrace / RightBrace / Case / Do / Done / Elif / Else / Esac / Fi / For / If / In / Then / Until / While .RE .PP Bang .RS 4 \fB!\fRD .RE .PP LeftBrace .RS 4 \fB{\fRD .RE .PP RightBrace .RS 4 \fB}\fRD .RE .PP Case .RS 4 \fBcase\fRD .RE .PP Do .RS 4 \fBdo\fRD .RE .PP Done .RS 4 \fBdone\fRD .RE .PP Elif .RS 4 \fBelif\fRD .RE .PP Else .RS 4 \fBelse\fRD .RE .PP Esac .RS 4 \fBesac\fRD .RE .PP Fi .RS 4 \fBfi\fRD .RE .PP For .RS 4 \fBfor\fRD .RE .PP Function .RS 4 \fBfunction\fRD .RE .PP If .RS 4 \fBif\fRD .RE .PP In .RS 4 \fBin\fRD .RE .PP Then .RS 4 \fBthen\fRD .RE .PP Until .RS 4 \fBuntil\fRD .RE .PP While .RS 4 \fBwhile\fRD .RE .PP D .RS 4 !WordS* .RE .PP SpecialChar .RS 4 [\fB|&;<>()`\e"\*(Aq\fR [:blank:]] / NL .RE .PP NL .RS 4 .RE .PP EOF .RS 4 !\&. .RE .SH "ALIAS BUILT-IN" .sp The \fIalias built\-in\fR defines and/or prints aliases\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBalias [\-gp] [\fR\fB\fIname\fR\fR\fB[=\fR\fB\fIvalue\fR\fR\fB]\&...]\fR .RE .SS "Description" .sp The alias built\-in defines and/or prints aliases as specified by operands\&. The printed aliases can be used as (part of) shell commands\&. The built\-in prints all currently defined aliases when given no operands\&. .SS "Options" .PP \fB\-g\fR, \fB\-\-global\fR .RS 4 With this option, aliases are defined as global aliases; without this option, as normal aliases\&. .RE .PP \fB\-p\fR, \fB\-\-prefix\fR .RS 4 With this option, aliases are printed in a full command form like \fBalias \-g foo=\*(Aqbar\*(Aq\fR\&. Without this option, only command operands are printed like \fBfoo=\*(Aqbar\*(Aq\fR\&. .RE .SS "Operands" .PP \fIname\fR .RS 4 The name of an alias that should be printed\&. .RE .PP \fIname\fR=\fIvalue\fR .RS 4 The name and value of an alias that is being defined\&. .RE .SS "Exit status" .sp The exit status of the alias built\-in is zero unless there is any error\&. .SS "Notes" .sp The characters that cannot be used in an alias name are the space, tab, newline, and any of \fB=$<>\e\*(Aq"`;&|()#\fR\&. You can use any characters in an alias value\&. .sp The alias built\-in is a semi\-special built\-in\&. .sp The POSIX standard defines no options for the alias built\-in, thus no options are available in the POSIXly correct mode\&. .SH "ARRAY BUILT-IN" .sp The \fIarray built\-in\fR prints or modifies arrays\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \fR\fB\fIname\fR\fR\fB [\fR\fB\fIvalue\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \-d \fR\fB\fIname\fR\fR\fB [\fR\fB\fIindex\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \-i \fR\fB\fIname\fR\fR\fB \fR\fB\fIindex\fR\fR\fB [\fR\fB\fIvalue\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \-s \fR\fB\fIname\fR\fR\fB \fR\fB\fIindex\fR\fR\fB \fR\fB\fIvalue\fR\fR .RE .SS "Description" .sp When executed without any option or operands, the built\-in prints all array definitions to the standard output in a form that can be parsed as commands\&. .sp When executed with \fIname\fR and \fIvalue\fRs (but without an option), the built\-in sets the \fIvalue\fRs as the values of the array named \fIname\fR\&. .sp With the \fB\-d\fR (\fB\-\-delete\fR) option, the built\-in removes the \fIindex\fRth values of the array named \fIname\fR\&. The number of values in the array will be decreased by the number of the \fIindex\fRes specified\&. If the \fIindex\fRth value does not exist, it is silently ignored\&. .sp With the \fB\-i\fR (\fB\-\-insert\fR) option, the built\-in inserts \fIvalue\fRs into the array named \fIname\fR\&. The number of values in the array will be increased by the number of the \fIvalue\fRs specified\&. The values are inserted between the \fIindex\fRth and next values\&. If \fIindex\fR is zero, the values are inserted before the first value\&. If \fIindex\fR is larger than the number of values in the array, the values are appended after the last element\&. .sp With the \fB\-s\fR (\fB\-\-set\fR) option, the built\-in sets \fIvalue\fR as the \fIindex\fRth value of the array named \fIname\fR\&. The array must have at least \fIindex\fR values\&. .SS "Options" .PP \fB\-d\fR, \fB\-\-delete\fR .RS 4 Delete array values\&. .RE .PP \fB\-i\fR, \fB\-\-insert\fR .RS 4 Insert array values\&. .RE .PP \fB\-s\fR, \fB\-\-set\fR .RS 4 Set an array value\&. .RE .SS "Operands" .PP \fIname\fR .RS 4 The name of an array to operate on\&. .RE .PP \fIindex\fR .RS 4 The index to an array element\&. The first element has the index of 1\&. .RE .PP \fIvalue\fR .RS 4 A string to which the array element is set\&. .RE .SS "Exit status" .sp The exit status of the array built\-in is zero unless there is any error\&. .SS "Notes" .sp The array built\-in is not defined in the POSIX standard\&. .sp The command \fBarray \fR\fB\fIname\fR\fR\fB \fR\fB\fIvalue\fR\fR\fB\&...\fR is equivalent to the assignment \fB\fIname\fR\fR\fB=(\fR\fB\fIvalue\fR\fR\fB\&...)\fR\&. .SH "BG BUILT-IN" .sp The \fIbg built\-in\fR resumes a job in the background\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbg [\fR\fB\fIjob\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The bg built\-in sends the SIGCONT signal to the specified job\&. As a result, the job is resumed in the background (if it has been suspended)\&. .sp The name of the job is printed when the job is resumed\&. .sp The built\-in can be used only when job control is enabled\&. .SS "Operands" .PP \fIjob\fR .RS 4 The job ID of the job to be resumed\&. .sp More than one job can be specified at a time\&. The current job is resumed if none is specified\&. .sp The percent sign (\fB%\fR) at the beginning of a job ID can be omitted if the shell is not in the POSIXly\-correct mode\&. .RE .SS "Exit status" .sp The exit status of the bg built\-in is zero unless there is any error\&. .SS "Notes" .sp The bg built\-in is a semi\-special built\-in\&. .sp The POSIX standard provides that the built\-in shall have no effect when the job is already running\&. The bg built\-in of yash, however, always sends the SIGCONT signal to the job\&. .SH "BINDKEY BUILT-IN" .sp The \fIbindkey built\-in\fR prints or modifies key bindings used in line\-editing\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbindkey \-aev [\fR\fB\fIkey\fR\fR\fB [\fR\fB\fIcommand\fR\fR\fB]]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbindkey \-l\fR .RE .SS "Description" .sp When executed with the \fB\-l\fR (\fB\-\-list\fR) option, the built\-in lists all available line\-editing commands to the standard output\&. .sp When executed with one of the other options, the built\-in prints or modifies key bindings for the editing mode specified by the option: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Without \fIkey\fR or \fIcommand\fR, all currently defined bindings are printed to the standard output in a form that can be parsed as commands that restore the current bindings when executed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} With \fIkey\fR but without \fIcommand\fR, only the binding for the given \fIkey\fR is printed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} With \fIkey\fR and \fIcommand\fR, \fIkey\fR is bound to \fIcommand\fR\&. .RE .SS "Options" .PP \fB\-a\fR, \fB\-\-vi\-command\fR .RS 4 Print or modify bindings for the vi command mode\&. .RE .PP \fB\-e\fR, \fB\-\-emacs\fR .RS 4 Print or modify bindings for the emacs mode\&. .RE .PP \fB\-v\fR, \fB\-\-vi\-insert\fR .RS 4 Print or modify bindings for the vi insert mode\&. .RE .SS "Operands" .PP \fIkey\fR .RS 4 A character sequence of one or more keys that is bound to an editing command\&. The sequence may include escape sequences\&. .RE .PP \fIcommand\fR .RS 4 A line\-editing command to which \fIkey\fR is bound\&. If \fIcommand\fR is a single hyphen (\fB\-\fR), \fIkey\fR is unbound\&. .RE .SS "Exit status" .sp The exit status of the bindkey built\-in is zero unless there is any error\&. .SS "Notes" .sp The bindkey built\-in is not defined in the POSIX standard\&. .SH "BREAK BUILT-IN" .sp The \fIbreak built\-in\fR aborts a loop being executed\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbreak [\fR\fB\fInest\fR\fR\fB]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbreak \-i\fR .RE .SS "Description" .sp When executed without the \fB\-i\fR (\fB\-\-iteration\fR) option, the built\-in aborts a currently executed for, while, or until loop\&. When executed in nested loops, it aborts the \fInest\fRth innermost loop\&. The default \fInest\fR is one\&. If the number of currently executed nested loops is less than \fInest\fR, the built\-in aborts the outermost loop\&. .sp When executed with the \fB\-i\fR (\fB\-\-iteration\fR) option, the built\-in aborts the currently executed (innermost) iterative execution\&. .SS "Options" .PP \fB\-i\fR, \fB\-\-iteration\fR .RS 4 Abort an iterative execution instead of a loop\&. .RE .SS "Operands" .PP \fInest\fR .RS 4 The number of loops to abort, which must be a positive integer\&. .RE .SS "Exit status" .sp The exit status of the break built\-in is: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} zero if a loop was successfully aborted\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} that of the command that was executed just before the break built\-in if an iterative execution was successfully aborted\&. .RE .SS "Notes" .sp The break built\-in is a special built\-in\&. .sp The POSIX standard defines no options for the break built\-in; the built\-in accepts no options in the POSIXly\-correct mode\&. .SH "CD BUILT-IN" .sp The \fIcd built\-in\fR changes the working directory\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcd [\-L|\-P] [\fR\fB\fIdirectory\fR\fR\fB]\fR .RE .SS "Description" .sp The cd built\-in changes the working directory to the directory specified by the operand\&. The pathname of the new working directory is assigned to the \fBPWD\fR variable, whose previous value is again assigned to the \fBOLDPWD\fR variable\&. .sp If \fIdirectory\fR is a relative path that does not start with \(oq\&.\(cq or \(oq\&.\&.\(cq, paths in the \fBCDPATH\fR variable are searched to find a new working directory\&. The search is done in a manner similar to the last step of command search, but a directory is sought instead of an executable regular file\&. If a new working directory was found from \fBCDPATH\fR, its pathname is printed to the standard output\&. If no applicable directory was found in the search, \fIdirectory\fR is simply treated as a pathname relative to the current working directory\&. .sp If the working directory was successfully changed, the value of the \fBYASH_AFTER_CD\fR variable is executed as a command unless the shell is in the POSIXly\-correct mode\&. If the variable is an array, its values are executed iteratively (cf\&. eval built\-in)\&. .SS "Options" .PP \fB\-L\fR, \fB\-\-logical\fR .RS 4 Symbolic links in the pathname of the new working directory are not resolved\&. The new value of the \fBPWD\fR may include pathname components that are symbolic links\&. .RE .PP \fB\-P\fR, \fB\-\-physical\fR .RS 4 Symbolic links in the pathname of the new working directory are resolved\&. The new value of the \fBPWD\fR variable never includes pathname components that are symbolic links\&. .RE .PP \fB\-\-default\-directory=\fR\fB\fIdirectory\fR\fR .RS 4 If this option is specified and the \fIdirectory\fR operand is omitted, the argument to this option is used for the \fIdirectory\fR operand\&. If the \fIdirectory\fR operand is specified, this option is ignored\&. .RE .sp The \fB\-L\fR (\fB\-\-logical\fR) and \fB\-P\fR (\fB\-\-physical\fR) options are mutually exclusive: only the last specified one is effective\&. If neither is specified, \fB\-L\fR is assumed\&. .SS "Operands" .PP \fIdirectory\fR .RS 4 The pathname of the new working directory\&. .sp If \fIdirectory\fR is a single hyphen (\(oq\-\(cq), the value of the \fBOLDPWD\fR variable is assumed for the new directory pathname, which is printed to the standard output\&. .sp If \fIdirectory\fR is omitted, the working directory is changed to the directory specified by the \fB\-\-default\-directory=\&...\fR option\&. If that option is not specified either, the default is the home directory\&. .RE .SS "Exit status" .sp The exit status of the cd built\-in is zero if the working directory was successfully changed and non\-zero if there was an error\&. .SS "Notes" .sp The cd built\-in is a semi\-special built\-in\&. .sp The POSIX standard does not define the use of the \fBYASH_AFTER_CD\fR variable or the \fB\-\-default\-directory=\&...\fR option\&. The standard does not allow using an option with a single hyphen operand\&. .sp The exit status of the commands in the \fBYASH_AFTER_CD\fR variable does not affect that of the cd built\-in\&. .SH "COLON BUILT-IN" .sp The \fIcolon built\-in\fR does nothing\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB: [\fR\fB\fIargument\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The colon built\-in does nothing\&. Any command line arguments are ignored\&. .SS "Exit status" .sp The exit status of the colon built\-in is zero\&. .SS "Notes" .sp The colon built\-in is a special built\-in\&. .sp Arguments are expanded and redirections are performed as usual\&. The colon and true built\-ins have the same effect, but colon is a special built\-in while true is a semi\-special\&. .SH "COMMAND BUILT-IN" .sp The \fIcommand built\-in\fR executes or identifies a command\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcommand [\-befp] \fR\fB\fIcommand\fR\fR\fB [\fR\fB\fIargument\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcommand \-v|\-V [\-abefkp] \fR\fB\fIcommand\fR\fR\fB\&...\fR .RE .SS "Description" .sp Without the \fB\-v\fR (\fB\-\-identify\fR) or \fB\-V\fR (\fB\-\-verbose\-identify\fR) option, the built\-in executes \fIcommand\fR with \fIargument\fRs in the same manner as the last step of execution of simple commands\&. The command is treated as a built\-in or external command or a function according to the options specified to the command built\-in\&. The shell does not exit on argument syntax error etc\&. even if the command is a special built\-in .sp With the \fB\-v\fR (\fB\-\-identify\fR) option, \fIcommand\fR is identified\&. If the command is found in \fB$PATH\fR, its full pathname is printed\&. If it is a keyword, function, or built\-in that is not found in \fB$PATH\fR, the command name is simply printed\&. If it is an alias, it is printed in the form like \fBalias ll=\*(Aqls \-l\*(Aq\fR\&. If the command is not found, nothing is printed and the exit status is non\-zero\&. .sp The \fB\-V\fR (\fB\-\-verbose\-identify\fR) option is similar to the \fB\-v\fR (\fB\-\-identify\fR) option, but the output format is more human\-friendly\&. .SS "Options" .PP \fB\-a\fR, \fB\-\-alias\fR .RS 4 Search for the command as an alias\&. Must be used with the \fB\-v\fR (\fB\-\-identify\fR) or \fB\-V\fR (\fB\-\-verbose\-identify\fR) option\&. .RE .PP \fB\-b\fR, \fB\-\-builtin\-command\fR .RS 4 Search for the command as a built\-in\&. .RE .PP \fB\-e\fR, \fB\-\-external\-command\fR .RS 4 Search for the command as an external command\&. .RE .PP \fB\-f\fR, \fB\-\-function\fR .RS 4 Search for the command as a function\&. .RE .PP \fB\-k\fR, \fB\-\-keyword\fR .RS 4 Search for the command as a keyword\&. Must be used with the \fB\-v\fR (\fB\-\-identify\fR) or \fB\-V\fR (\fB\-\-verbose\-identify\fR) option\&. .RE .PP \fB\-p\fR, \fB\-\-standard\-path\fR .RS 4 Search the system\(cqs default \fBPATH\fR instead of the current \fB$PATH\fR\&. .RE .PP \fB\-v\fR, \fB\-\-identify\fR .RS 4 Identify \fIcommand\fRs and print in the format defined in the POSIX standard\&. .RE .PP \fB\-V\fR, \fB\-\-verbose\-identify\fR .RS 4 Identify \fIcommand\fRs and print in a human\-friendly format\&. .RE .sp If none of the \fB\-a\fR (\fB\-\-alias\fR), \fB\-b\fR (\fB\-\-builtin\-command\fR), \fB\-e\fR (\fB\-\-external\-command\fR), \fB\-f\fR (\fB\-\-function\fR), and \fB\-k\fR (\fB\-\-keyword\fR) options is specified, the following defaults are assumed: .PP Without the \fB\-v\fR (\fB\-\-identify\fR) or \fB\-V\fR (\fB\-\-verbose\-identify\fR) option .RS 4 \fB\-b \-e\fR .RE .PP With the \fB\-v\fR (\fB\-\-identify\fR) or \fB\-V\fR (\fB\-\-verbose\-identify\fR) option .RS 4 \fB\-a \-b \-e \-f \-k\fR .RE .SS "Operands" .PP \fIcommand\fR .RS 4 A command to be executed or identified\&. .RE .PP \fIargument\fR\&... .RS 4 Arguments passed to the executed command\&. .RE .SS "Exit status" .sp The exit status of the command built\-in is: .PP Without the \fB\-v\fR (\fB\-\-identify\fR) or \fB\-V\fR (\fB\-\-verbose\-identify\fR) option .RS 4 the exit status of the executed command\&. .RE .PP With the \fB\-v\fR (\fB\-\-identify\fR) or \fB\-V\fR (\fB\-\-verbose\-identify\fR) option .RS 4 zero unless there is any error\&. .RE .SS "Notes" .sp The command built\-in is a semi\-special built\-in\&. .sp In the POSIXly\-correct mode, options other than \fB\-p\fR, \fB\-v\fR, and \fB\-V\fR cannot be used and at most one \fIcommand\fR can be specified\&. The POSIX standard does not allow specifying both \fB\-v\fR and \fB\-V\fR together, but yash does (only the last specified one is effective)\&. .SH "COMPLETE BUILT-IN" .sp The \fIcomplete built\-in\fR generates completion candidates\&. This built\-in can only be executed from completion functions during command line completion\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcomplete [\-A \fR\fB\fIpattern\fR\fR\fB] [\-R \fR\fB\fIpattern\fR\fR\fB] [\-T] [\-P \fR\fB\fIprefix\fR\fR\fB] [\-S \fR\fB\fIsuffix\fR\fR\fB] [\-abcdfghjkuv] [[\-O] [\-D \fR\fB\fIdescription\fR\fR\fB] \fR\fB\fIword\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The built\-in generates completion candidates according to the specified arguments\&. No matter how candidates are generated, only candidates that match the word being completed are generated\&. .SS "Options" .PP \fB\-A \fR\fB\fIpattern\fR\fR, \fB\-\-accept=\fR\fB\fIpattern\fR\fR .RS 4 Only accept candidates that match the pattern specified by this option\&. When more than one of this option is specified, only candidates that match all of the patterns are generated\&. .RE .PP \fB\-D \fR\fB\fIdescription\fR\fR, \fB\-\-description=\fR\fB\fIdescription\fR\fR .RS 4 Give a description of the \fIword\fR candidates\&. The description is shown beside the candidates in the candidate list\&. .RE .PP \fB\-O\fR, \fB\-\-option\fR .RS 4 The candidates are treated as command line options\&. A hyphen is prepended to each candidate that is treated as an option\&. .RE .PP \fB\-P \fR\fB\fIprefix\fR\fR, \fB\-\-prefix=\fR\fB\fIprefix\fR\fR .RS 4 Ignore \fIprefix\fR of the word being completed when generating candidates\&. The specified \fIprefix\fR must be initial part of the word\&. .sp If the word being completed is \fBfile:///home/user/docume\fR for example, the command line \fBcomplete \-P file:// \-f\fR will generate pathname candidates that complete \fB/home/user/docume\fR\&. .RE .PP \fB\-R \fR\fB\fIpattern\fR\fR, \fB\-\-reject=\fR\fB\fIpattern\fR\fR .RS 4 Reject candidates that match the pattern specified by this option\&. When more than one of this option is specified, only candidates that match none of the patterns are generated\&. .RE .PP \fB\-S \fR\fB\fIsuffix\fR\fR, \fB\-\-suffix=\fR\fB\fIsuffix\fR\fR .RS 4 Append \fIsuffix\fR to each generated candidate\&. .RE .PP \fB\-T\fR, \fB\-\-no\-termination\fR .RS 4 Do not append a space after the word is completed\&. Without this option, a space is appended to the completed word so that you do not have to enter a space before the next word\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBOptions that select candidate types\fR .RS 4 .PP \fB\-a\fR, \fB\-\-alias\fR .RS 4 Aliases\&. (same as \fB\-\-normal\-alias \-\-global\-alias\fR) .RE .PP \fB\-\-array\-variable\fR .RS 4 Arrays\&. .RE .PP \fB\-\-bindkey\fR .RS 4 Line\-editing commands the \fBbindkey\fR built\-in accepts\&. .RE .PP \fB\-b\fR, \fB\-\-builtin\-command\fR .RS 4 Built\-in commands\&. (same as \fB\-\-special\-builtin \-\-semi\-special\-builtin \-\-regular\-builtin\fR) .RE .PP \fB\-c\fR, \fB\-\-command\fR .RS 4 Commands\&. (same as \fB\-\-builtin\-command \-\-external\-command \-\-function\fR) .RE .PP \fB\-d\fR, \fB\-\-directory\fR .RS 4 Directories\&. .RE .PP \fB\-\-dirstack\-index\fR .RS 4 Valid indices of the directory stack\&. .RE .PP \fB\-\-executable\-file\fR .RS 4 Executable regular files\&. .RE .PP \fB\-\-external\-command\fR .RS 4 External commands\&. .RE .PP \fB\-f\fR, \fB\-\-file\fR .RS 4 Files (including directories)\&. .RE .PP \fB\-\-finished\-job\fR .RS 4 Job IDs of finished jobs\&. .RE .PP \fB\-\-function\fR .RS 4 Functions\&. .RE .PP \fB\-\-global\-alias\fR .RS 4 Global aliases\&. .RE .PP \fB\-g\fR, \fB\-\-group\fR .RS 4 User groups\&. .RE .PP \fB\-h\fR, \fB\-\-hostname\fR .RS 4 Host names\&. .RE .PP \fB\-j\fR, \fB\-\-job\fR .RS 4 Job IDs\&. .RE .PP \fB\-k\fR, \fB\-\-keyword\fR .RS 4 Keywords\&. .RE .PP \fB\-\-normal\-alias\fR .RS 4 Normal aliases\&. .RE .PP \fB\-\-regular\-builtin\fR .RS 4 Regular built\-in commands\&. .RE .PP \fB\-\-running\-job\fR .RS 4 Job IDs of jobs that are being executed\&. .RE .PP \fB\-\-scalar\-variable\fR .RS 4 Variables that are not arrays\&. .RE .PP \fB\-\-semi\-special\-builtin\fR .RS 4 Semi\-special built\-in commands\&. .RE .PP \fB\-\-signal\fR .RS 4 Signals\&. .RE .PP \fB\-\-special\-builtin\fR .RS 4 Special built\-in commands\&. .RE .PP \fB\-\-stopped\-job\fR .RS 4 Job IDs of jobs that are suspended\&. .RE .PP \fB\-u\fR, \fB\-\-username\fR .RS 4 Users\*(Aq log\-in names\&. .RE .PP \fB\-v\fR, \fB\-\-variable\fR .RS 4 Variables\&. .RE .sp If the \fB\-d\fR (\fB\-\-directory\fR) option is specified without the \fB\-f\fR (\fB\-\-file\fR) option, the \fB\-S / \-T\fR options are assumed\&. .sp Generated candidates for job IDs do not have leading percent signs (\fB%\fR)\&. If the word being completed starts with a percent sign, the \fB\-P %\fR option should be specified\&. .RE .SS "Operands" .sp Operands are treated as completion candidates\&. .SS "Exit status" .sp The exit status of the built\-in is zero if one or more candidates were generated, one if no candidates were generated, or larger than one if an error occurred\&. .SS "Notes" .sp The complete built\-in is not defined in the POSIX standard\&. .SH "CONTINUE BUILT-IN" .sp The \fIcontinue built\-in\fR skips an iteration of a loop being executed\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcontinue [\fR\fB\fInest\fR\fR\fB]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcontinue \-i\fR .RE .SS "Description" .sp When executed without the \fB\-i\fR (\fB\-\-iteration\fR) option, the built\-in aborts the current iteration of for, while, or until loop and starts the next iteration of the loop\&. When executed in nested loops, it affects the \fInest\fRth innermost loop\&. The default \fInest\fR is one\&. If the number of currently executed nested loops is less than \fInest\fR, the built\-in affects the outermost loop\&. .sp When executed with the \fB\-i\fR (\fB\-\-iteration\fR) option, the built\-in aborts the current iteration of (innermost) iterative execution\&. .SS "Options" .PP \fB\-i\fR, \fB\-\-iteration\fR .RS 4 Skip an iterative execution instead of a loop\&. .RE .SS "Operands" .PP \fInest\fR .RS 4 The \fInest\fRth innermost loop is affected\&. \fInest\fR must be a positive integer\&. .RE .SS "Exit status" .sp The exit status of the continue built\-in is: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} zero if loop iteration was successfully skipped\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} that of the command that was executed just before the continue built\-in if iterative execution was successfully skipped\&. .RE .SS "Notes" .sp The continue built\-in is a special built\-in\&. .sp The POSIX standard defines no options for the continue built\-in; the built\-in accepts no options in the POSIXly\-correct mode\&. .SH "DIRS BUILT-IN" .sp The \fIdirs built\-in\fR prints the contents of the directory stack\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBdirs [\-cv] [\fR\fB\fIindex\fR\fR\fB\&.\&.]\fR .RE .SS "Description" .sp The \fIdirectory stack\fR is a feature that records history of working directories\&. You can use the pushd built\-in to save a working directory in the directory stack, the popd built\-in to recall the saved working directory, and the dirs built\-in to see the stack contents\&. Those built\-ins use the \fBDIRSTACK\fR array and the \fBPWD\fR variable to save the stack contents\&. Modifying the array means modifying the stack contents\&. .sp Directory stack entries are indexed by signed integers\&. The entry of index +0 is the current working directory, +1 is the last saved directory, +2 is the second last, and so on\&. Negative indices are in the reverse order: the entry of index \-0 is the first saved directory, \-1 is the second, and \-\fIn\fR is the current working directory if the stack has \fIn\fR entries, .sp When executed without the \fB\-c\fR (\fB\-\-clear\fR) option, the dirs built\-in prints the current contents of the directory stack to the standard output\&. With the \fB\-c\fR (\fB\-\-clear\fR) option, the built\-in clears the directory stack\&. .SS "Options" .PP \fB\-c\fR, \fB\-\-clear\fR .RS 4 Clear the directory stack contents except for the current working directory, which has index +0\&. .RE .PP \fB\-v\fR, \fB\-\-verbose\fR .RS 4 Print indices when printing stack contents\&. .RE .SS "Operands" .PP \fIindex\fR .RS 4 The index of a stack entry to be printed\&. .sp You can specify more than one index\&. If you do not specify any index, all the entries are printed\&. .RE .SS "Exit status" .sp The exit status of the dirs built\-in is zero unless there is any error\&. .SS "Notes" .sp The dirs built\-in is not defined in the POSIX standard\&. .SH "DISOWN BUILT-IN" .sp The \fIdisown built\-in\fR removes jobs\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBdisown [\-a] [\fR\fB\fIjob\fR\fR\fB\&...}\fR .RE .SS "Description" .sp The disown built\-in removes the specified jobs from the job list\&. The removed jobs will no longer be job\-controlled, but the job processes continue execution (unless they have been suspended)\&. .SS "Options" .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 Removes all jobs\&. .RE .SS "Operands" .PP \fIjob\fR .RS 4 The job ID of the job to be removed\&. .sp You can specify more than one job ID\&. If you do not specify any job ID, the current job is removed\&. If the shell is not in the POSIXly\-correct mode, the %\-prefix of the job ID can be omitted\&. .RE .SS "Exit status" .sp The exit status of the disown built\-in is zero unless there is any error\&. .SS "Notes" .sp The disown built\-in is not defined in the POSIX standard\&. .SH "DOT BUILT-IN" .sp The \fIdot built\-in\fR reads a file and executes commands in it\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\&. [\-AL] \fR\fB\fIfile\fR\fR\fB [\fR\fB\fIargument\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The dot built\-in reads the specified \fIfile\fR, parses its contents as commands, and executes them in the current command execution environment\&. .sp If \fIargument\fRs are specified, positional parameters are temporarily set to them\&. The positional parameters will be restored when the dot built\-in finishes\&. If no \fIargument\fRs are specified, the positional parameters are not changed\&. .sp If \fIfile\fR does not contain any slashes, the shell searches \fB$PATH\fR for a readable (but not necessarily executable) shell script file whose name is \fIfile\fR in the same manner as command search\&. If no such file was found, the shell searches the current working directory for a file unless in the POSIXly\-correct mode\&. To ensure that the file in the current working directory is used, start \fIfile\fR with \(oq\&./\(cq\&. .SS "Options" .PP \fB\-A\fR, \fB\-\-no\-alias\fR .RS 4 Disable alias substitution while parsing\&. .RE .PP \fB\-L\fR, \fB\-\-autoload\fR .RS 4 Search \fB$YASH_LOADPATH\fR instead of \fB$PATH\fR, regardless of whether \fIfile\fR contains slashes\&. The \fIfile\fR value is not considered relative to the current working directory\&. .RE .sp The dot built\-in treats as operands any command line arguments after the first operand\&. .SS "Operands" .PP \fIfile\fR .RS 4 The pathname of a file to be read\&. .RE .PP \fIarguments\fR\&... .RS 4 Strings to which positional parameters are set while execution\&. .RE .SS "Exit status" .sp The exit status of the dot built\-in is that of the last command executed\&. The exit status is zero if the file contains no commands to execute and non\-zero if a file was not found or could not be opened\&. .SS "Notes" .sp The dot built\-in is a special built\-in\&. .sp A non\-interactive shell that is not in the POSIXly\-correct mode will immediately exit with a non\-zero exit status if the dot built\-in fails to find or open a file to execute\&. .sp The POSIX standard defines no options for the dot built\-in; the built\-in accepts no options in the POSIXly\-correct mode\&. .sp The POSIX standard does not define the \fIarguments\fR\&... operands\&. It is an error to specify the \fIarguments\fR\&... operands in the POSIXly\-correct mode\&. .SH "ECHO BUILT-IN" .sp The \fIecho built\-in\fR prints its arguments\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBecho [\fR\fB\fIstring\fR\fR\fB\&...]\fR .RE .sp The built\-in treats all command line arguments as operands except for the options described below\&. Any word that cannot be parsed as an acceptable option is treated as an operand\&. Options must precede all operands\&. Syntax errors never happen in the echo built\-in\&. .SS "Description" .sp The echo built\-in prints the operand \fIstring\fRs followed by a newline to the standard output\&. The \fIstring\fRs are each separated by a space\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBEscape sequences\fR .RS 4 .sp The \fBECHO_STYLE\fR variable and the \fB\-e\fR option enable escape sequences that are replaced with corresponding characters: .PP \fB\ea\fR .RS 4 Bell character (ASCII code: 7) .RE .PP \fB\eb\fR .RS 4 Backspace (ASCII code: 8) .RE .PP \fB\ec\fR .RS 4 Nothing\&. After this escape sequence, no characters are printed at all\&. .RE .PP \fB\ee\fR .RS 4 Escape character (ASCII code: 27) .RE .PP \fB\ef\fR .RS 4 Form feed character (ASCII code: 12) .RE .PP \fB\en\fR .RS 4 Newline character (ASCII code: 10) .RE .PP \fB\er\fR .RS 4 Carriage return character (ASCII code: 13) .RE .PP \fB\et\fR .RS 4 Horizontal tab character (ASCII code: 9) .RE .PP \fB\ev\fR .RS 4 Vertical tab character (ASCII code: 11) .RE .PP \fB\e\e\fR .RS 4 Backslash .RE .PP \fB\e0\fR\fB\fIxxx\fR\fR .RS 4 Character whose code is \fIxxx\fR, where \fIxxx\fR is an octal number of at most three digits\&. .RE .sp When escape sequences are not enabled, they are just printed intact\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBECHO_STYLE variable\fR .RS 4 .sp The \fBECHO_STYLE\fR variable defines which options are accepted and whether escape sequences are enabled by default\&. The variable value should be set to one of the following: .PP \fBSYSV\fR, \fBXSI\fR .RS 4 No options are accepted\&. Escape sequences are always enabled\&. .RE .PP \fBBSD\fR .RS 4 The \fB\-n\fR option is accepted\&. Escape sequences are never enabled\&. .RE .PP \fBGNU\fR .RS 4 The \fB\-n\fR, \fB\-e\fR, and \fB\-E\fR options are accepted\&. Escape sequences are not enabled by default, but can be enabled by the \fB\-e\fR option\&. .RE .PP \fBZSH\fR .RS 4 The \fB\-n\fR, \fB\-e\fR, and \fB\-E\fR options are accepted\&. Escape sequences are enabled by default, but can be disabled by the \fB\-E\fR option\&. .RE .PP \fBDASH\fR .RS 4 The \fB\-n\fR option is accepted\&. Escape sequences are always enabled\&. .RE .PP \fBRAW\fR .RS 4 No options are accepted\&. Escape sequences are never enabled\&. .RE .sp When the \fBECHO_STYLE\fR variable is not set, it defaults to \fBSYSV\fR\&. .RE .SS "Options" .PP \fB\-n\fR .RS 4 Do not print a newline at the end\&. .RE .PP \fB\-e\fR .RS 4 Enable escape sequences\&. .RE .PP \fB\-E\fR .RS 4 Disable escape sequences\&. .RE .SS "Exit status" .sp The exit status of the echo built\-in is zero unless there is any error\&. .SS "Notes" .sp The POSIX standard does not define the \fBECHO_STYLE\fR variable nor any options for the built\-in\&. According to POSIX, the behavior of the built\-in is implementation\-defined when the first argument is \fB\-n\fR or when any argument contains a backslash\&. For maximum portability, the printf built\-in should be preferred over the echo built\-in\&. .SH "EVAL BUILT-IN" .sp The \fIeval built\-in\fR evaluates operands as commands\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBeval [\-i] [\fR\fB\fIcommand\fR\fR\fB\&...]\fR .RE .sp The eval built\-in requires that all options precede operands\&. Any command line arguments after the first operand are all treated as operands\&. .SS "Description" .sp The eval parses operands as commands and executes them in the current command execution environment\&. .sp When executed without the \fB\-i\fR (\fB\-\-iteration\fR) option, all the operands are concatenated into one string (with a space inserted between each operand) and parsed/executed at once\&. .sp With the \fB\-i\fR (\fB\-\-iteration\fR) option, the built\-in performs \fIiterative execution\fR: operands are parsed/executed one by one\&. If the continue built\-in is executed with the \fB\-i\fR (\fB\-\-iteration\fR) option during the iterative execution, the execution of the current operand is aborted and the next operand is parsed/executed immediately\&. The break built\-in with the \fB\-i\fR (\fB\-\-iteration\fR) option is similar but the remaining operands are not parsed/executed\&. .SS "Options" .PP \fB\-i\fR, \fB\-\-iteration\fR .RS 4 Perform iterative execution\&. .RE .SS "Operands" .PP \fIcommand\fR .RS 4 A string that is parsed and executed as commands\&. .RE .SS "Exit status" .sp The exit status is zero if no \fIcommand\fR was specified or \fIcommand\fR contained no actual command that can be executed\&. Otherwise, that is, if the eval built\-in executed one or more commands, the exit status of the eval built\-in is that of the last executed command\&. .SS "Notes" .sp The eval built\-in is a special built\-in\&. .sp The POSIX standard defines no options for the eval built\-in; the built\-in accepts no options in the POSIXly\-correct mode\&. .SH "EXEC BUILT-IN" .sp The \fIexec built\-in\fR replaces the shell process with another external command\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBexec [\-cf] [\-a \fR\fB\fIname\fR\fR\fB] [\fR\fB\fIcommand\fR\fR\fB [\fR\fB\fIargument\fR\fR\fB\&...]]\fR .RE .sp The exec built\-in requires that all options precede operands\&. It is important so that options to the exec built\-in are not confused with options to \fIcommand\fR\&. Any command line arguments after \fIcommand\fR are treated as \fIargument\fRs\&. .SS "Description" .sp When the exec built\-in is executed with \fIcommand\fR, the shell executes \fIcommand\fR with \fIargument\fRs in a manner similar to the last step of execution of a simple command\&. The differences are that \fIcommand\fR is always treated as an external command ignoring any existing functions and built\-ins and that the exec system call that starts the external command is called in the current command execution environment instead of a subshell, replacing the shell process with the new command process\&. .sp If the shell is in the POSIXly\-correct mode or not interactive, failure in execution of \fIcommand\fR causes the shell to exit immediately\&. .sp If an interactive shell that is not in the POSIXly\-correct mode has a stopped job, the shell prints a warning message and refuses to execute \fIcommand\fR\&. Once the shell process is replaced with an external command, information about the shell\(cqs jobs is lost, so you will have to resume or kill the stopped jobs by sending signals by hand\&. To force the shell to execute \fIcommand\fR regardless, specify the \fB\-f\fR (\fB\-\-force\fR) option\&. .sp When executed without \fIcommand\fR, the built\-in does nothing\&. As a side effect, however, redirection applied to the built\-in remains in the current command execution environment even after the built\-in finished\&. .SS "Options" .PP \fB\-a \fR\fB\fIname\fR\fR, \fB\-\-as=\fR\fB\fIname\fR\fR .RS 4 Pass \fIname\fR, instead of \fIcommand\fR, to the external command as its name\&. .RE .PP \fB\-c\fR, \fB\-\-clear\fR .RS 4 Pass to the external command only variables that are assigned in the simple command in which the built\-in is being executed\&. Other environment variables are not passed to the command\&. .RE .PP \fB\-f\fR, \fB\-\-force\fR .RS 4 Suppress warnings that would prevent command execution\&. .RE .SS "Operands" .PP \fIcommand\fR .RS 4 An external command to be executed\&. .RE .PP \fIargument\fR\&... .RS 4 Arguments to be passed to the command\&. .RE .SS "Exit status" .sp If the shell process was successfully replaced with the external command, there is no exit status since the shell process no longer exists\&. .sp The exit status is: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 127 if the command was not found, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 126 if the command was found but could not be executed, and .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} zero if no \fIcommand\fR was specified\&. .RE .SS "Notes" .sp The exec built\-in is a special built\-in\&. .sp The POSIX standard defines no options for the exec built\-in; the built\-in accepts no options in the POSIXly\-correct mode\&. .SH "EXIT BUILT-IN" .sp The \fIexit built\-in\fR causes the shell process to exit\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBexit [\-f] [\fR\fB\fIexit_status\fR\fR\fB]\fR .RE .SS "Description" .sp The exit built\-in causes the current shell (or subshell) process to exit\&. .sp If an interactive shell has a stopped job, the shell prints a warning message and refuses to exit\&. To force the shell to exit regardless, specify the \fB\-f\fR (\fB\-\-force\fR) option or execute the built\-in twice in a row\&. .sp If an EXIT trap has been set, the shell executes the trap before exiting\&. .SS "Options" .PP \fB\-f\fR, \fB\-\-force\fR .RS 4 Suppress warnings that would prevent the shell from exiting\&. .RE .SS "Operands" .PP \fIexit_status\fR .RS 4 A non\-negative integer that will be the exit status of the exiting shell\&. .sp If this operand is omitted, the exit status of the shell will be that of the last command executed before the exit built\-in (but, if the built\-in is executed during a trap, the exit status will be that of the last command before the trap is entered)\&. .sp If \fIexit_status\fR is 256 or larger, the actual exit status will be the remainder of \fIexit_status\fR divided by 256\&. .RE .SS "Exit status" .sp Because the built\-in causes the shell to exit, there is no exit status of the built\-in\&. .sp As an exception, if the shell refused to exit, the exit status of the built\-in is non\-zero\&. .SS "Notes" .sp The exit built\-in is a special built\-in\&. .sp The POSIX standard defines no options for the exit built\-in; the built\-in accepts no options in the POSIXly\-correct mode\&. .sp The POSIX standard provides that the \fIexit_status\fR operand should be between 0 and 255 (inclusive)\&. Yash accepts integers larger than 255 as an extension\&. .sp If the built\-in is executed during an EXIT trap, the shell just exits without executing the trap again\&. If \fIexit_status\fR was not specified, the exit status of the shell is what the exit status would be if the trap had not been set\&. See also Termination of the shell\&. .SH "EXPORT BUILT-IN" .sp The \fIexport built\-in\fR marks variables for export to child processes\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBexport [\-prX] [\fR\fB\fIname\fR\fR\fB[=\fR\fB\fIvalue\fR\fR\fB]\&...]\fR .RE .SS "Description" .sp The export built\-in is equivalent to the typeset built\-in with the \fB\-gx\fR option\&. .SS "Notes" .sp The export built\-in is a special built\-in\&. .sp The POSIX standard defines the \fB\-p\fR option only; other options cannot be used in the POSIXly\-correct mode\&. The POSIX does not allow using the option together with operands\&. .SH "FALSE BUILT-IN" .sp The \fIfalse built\-in\fR does nothing unsuccessfully\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfalse\fR .RE .SS "Description" .sp The false built\-in does nothing\&. Any command line arguments are ignored\&. .SS "Exit status" .sp The exit status of the false built\-in is non\-zero\&. .SS "Notes" .sp The false built\-in is a semi\-special built\-in\&. .SH "FC BUILT-IN" .sp The \fIfc built\-in\fR re\-executes or prints commands from command history\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc [\-qr] [\-e \fR\fB\fIeditor\fR\fR\fB] [\fR\fB\fIstart\fR\fR\fB [\fR\fB\fIend\fR\fR\fB]]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-s[q] [\fR\fB\fIold\fR\fR\fB=\fR\fB\fInew\fR\fR\fB] [\fR\fB\fIstart\fR\fR\fB]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-l[nrv] [\fR\fB\fIstart\fR\fR\fB [\fR\fB\fIend\fR\fR\fB]]\fR .RE .SS "Description" .sp When executed without the \fB\-l\fR (\fB\-\-list\fR) option, the built\-in executes the commands in the command history range specified by the operands\&. If the \fB\-s\fR (\fB\-\-silent\fR) option is not specified, the shell invokes an editor which allows you to edit the commands before they are executed\&. The commands are executed when you quit the editor\&. If the \fB\-s\fR (\fB\-\-silent\fR) option is specified, the commands are immediately executed\&. In either case, the executed commands are printed to the standard output and added to the history\&. .sp When executed with the \fB\-l\fR (\fB\-\-list\fR) option, the built\-in prints the commands in the command history range specified by the operands\&. By default, commands are printed with their history entry numbers, but output format can be changed using the \fB\-n\fR (\fB\-\-no\-numbers)\fR) and \fB\-v\fR (\fB\-\-verbose\fR) options\&. .SS "Options" .PP \fB\-e \fR\fB\fIeditor\fR\fR, \fB\-\-editor=\fR\fB\fIeditor\fR\fR .RS 4 Specify an editor that is used to edit commands\&. .sp If this option is not specified, the value of the \fBFCEDIT\fR variable is used\&. If the variable is not set either, \fBvi\fR is used\&. .RE .PP \fB\-l\fR, \fB\-\-list\fR .RS 4 Print command history entries\&. .RE .PP \fB\-n\fR, \fB\-\-no\-numbers\fR .RS 4 Don\(cqt print entry numbers when printing history entries\&. .RE .PP \fB\-q\fR, \fB\-\-quiet\fR .RS 4 Don\(cqt print commands before executing\&. .RE .PP \fB\-r\fR, \fB\-\-reverse\fR .RS 4 Reverse the order of command entries in the range\&. .RE .PP \fB\-s\fR, \fB\-\-silent\fR .RS 4 Execute commands without editing them\&. .RE .PP \fB\-v\fR, \fB\-\-verbose\fR .RS 4 Print execution time before each history entry when printing\&. .RE .SS "Operands" .PP \fIstart\fR and \fIend\fR .RS 4 The \fIstart\fR and \fIend\fR operands specify a range of command history entries that are executed or printed\&. If one of the operands is an integer, it is treated as a history entry number\&. A negative integer means the \fIn\fRth most recent entry where \fIn\fR is the absolute value of the integer\&. If one of the operands is not an integer, it is treated as part of a command string: the most recent entry that starts with the string is selected as the start or end of the range\&. .sp If the first entry of the range that is specified by \fIstart\fR is newer than the last entry of the range that is specified by \fIend\fR, the range is reversed as if the \fB\-r\fR (\fB\-\-reverse\fR) option was specified\&. (If the option is already specified, it is cancelled\&.) .sp The default values for \fIstart\fR and \fIend\fR are: .TS allbox tab(:); ltB ltB ltB. T{ T}:T{ with \fB\-l\fR T}:T{ without \fB\-l\fR T} .T& lt lt lt lt lt lt. T{ \fIstart\fR T}:T{ \-16 T}:T{ \-1 T} T{ \fIend\fR T}:T{ \-16 T}:T{ same as \fIstart\fR T} .TE .sp 1 .RE .PP \fIold\fR=\fInew\fR .RS 4 An operand of this format replaces part of the command string\&. If the command string contains \fIold\fR, it is replaced with \fInew\fR and the new string is executed\&. Only the first occurrence of \fIold\fR is replaced\&. .RE .SS "Exit status" .sp If commands was executed, the exit status of the fc built\-in is that of the last executed command\&. Otherwise, the exit status is zero unless there is any error\&. .SS "Notes" .sp The fc built\-in is a semi\-special built\-in\&. .sp The POSIX standard does not define the \fB\-q\fR (\fB\-\-quiet\fR) or \fB\-v\fR (\fB\-\-verbose\fR) options, so they cannot be used in the POSIXly\-correct mode\&. .sp Command history cannot be modified during line\-editing\&. .SH "FG BUILT-IN" .sp The \fIfg built\-in\fR resumes a job in the foreground\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfg [\fR\fB\fIjob\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The fg built\-in brings the specified job to the foreground and sends the SIGCONT signal to the job\&. As a result, the job is resumed in the foreground (if it has been suspended)\&. The built\-in then waits for the job to finish and returns the exit status of it\&. .sp The name of the job is printed when the job is resumed\&. .sp The built\-in can be used only when job control is enabled\&. .SS "Operands" .PP \fIjob\fR .RS 4 The job ID of the job to be resumed\&. .sp If more than one job is specified, they are resumed in order, one at a time\&. The current job is resumed if none is specified\&. .sp The percent sign (\fB%\fR) at the beginning of a job ID can be omitted if the shell is not in the POSIXly\-correct mode\&. .RE .SS "Exit status" .sp The exit status of the fg built\-in is that of the (last) job resumed\&. The exit status is non\-zero when there was some error\&. .SS "Notes" .sp The fg built\-in is a semi\-special built\-in\&. .sp You cannot specify more than one job in the POSIXly\-correct mode\&. .SH "GETOPTS BUILT-IN" .sp The \fIgetopts built\-in\fR parses command options\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBgetopts \fR\fB\fIoptionlist\fR\fR\fB \fR\fB\fIvariable\fR\fR\fB [\fR\fB\fIargument\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The getopts built\-in parses single\-character options that appear in \fIargument\fRs\&. Each time the built\-in is invoked, it parses one option and assigns the option character to \fIvariable\fR\&. .sp The \fIoptionlist\fR operand is a list of option characters that should be accepted by the parser\&. In \fIoptionlist\fR, an option that takes an argument should be specified as the option character followed by a colon\&. For example, if you want the \fB\-a\fR, \fB\-b\fR and \fB\-c\fR options to be parsed and the \fB\-b\fR option to take an argument, then \fIoptionlist\fR should be \fBab:c\fR\&. .sp When an option that takes an argument is parsed, the argument is assigned to the \fBOPTARG\fR variable\&. .sp When an option that is not specified in \fIoptionlist\fR is found or when an option argument is missing, the result depends on the first character of \fIoptionlist\fR: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If \fIoptionlist\fR starts with a colon, the option character is assigned to the \fBOPTARG\fR variable and \fIvariable\fR is set to either \fB?\fR (when the option is not in \fIoptionlist\fR) or \fB:\fR (when the option argument is missing)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Otherwise, \fIvariable\fR is set to \fB?\fR, the \fBOPTARG\fR variable is unset, and an error message is printed\&. .RE .sp The built\-in parses one option for each execution\&. For all options in a set of command line arguments to be parsed, the built\-in has to be executed repeatedly with the same arguments\&. The built\-in uses the \fBOPTIND\fR variable to remember which \fIargument\fR should be parsed next\&. When the built\-in is invoked for the first time, the variable value must be \fB1\fR, which is the default value\&. You must not modify the variable until all the options have been parsed, when the built\-in sets the variable to the index of the first operand in \fIargument\fRs\&. (If there are no operands, it will be set to the number of \fIargument\fRs plus one\&.) .sp When you want to start parsing a new set of \fIargument\fRs, you have to reset the \fBOPTIND\fR variable to \fB1\fR beforehand\&. .SS "Operands" .PP \fIoptionlist\fR .RS 4 A list of options that should be accepted as valid options in parsing\&. .RE .PP \fIvariable\fR .RS 4 The name of a variable the result is to be assigned to\&. .RE .PP \fIargument\fRs .RS 4 Command line arguments that are to be parsed\&. .sp When no \fIargument\fRs are given, the positional parameters are parsed\&. .RE .SS "Exit status" .sp If an option is found, whether or not it is specified in \fIoptionlist\fR, the exit status is zero\&. If there is no more option to be parsed, the exit status is non\-zero\&. .SS "Example" .sp .if n \{\ .RS 4 .\} .nf aopt=false bopt= copt=false while getopts ab:c opt do case $opt in a) aopt=true ;; b) bopt=$OPTARG ;; c) copt=true ;; \e?) return 2 ;; esac done if $aopt; then echo Option \-a specified; fi if [ \-n "$bopt" ]; then echo Option \-b $bopt specified; fi if $copt; then echo Option \-c specified; fi shift $((OPTIND \- 1)) echo Operands are: $* .fi .if n \{\ .RE .\} .SS "Notes" .sp In \fIargument\fRs that are parsed, options must precede operands\&. The built\-in ends parsing when it encounters the first operand\&. .sp The getopts built\-in is a semi\-special built\-in\&. .sp The POSIX standard does not specify what will happen when the \fBOPTIND\fR variable is assigned a value other than \fB1\fR\&. .SH "HASH BUILT-IN" .sp The \fIhash built\-in\fR remembers, forgets, or reports command locations\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \fR\fB\fIcommand\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-r [\fR\fB\fIcommand\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash [\-a]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-d \fR\fB\fIuser\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-dr [\fR\fB\fIuser\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-d\fR .RE .SS "Description" .sp When executed with \fIcommand\fRs but without options, the built\-in immediately performs command path search and caches \fIcommand\fRs\*(Aq full paths\&. .sp When executed with the \fB\-r\fR (\fB\-\-remove\fR) option, it removes the paths of \fIcommand\fRs (or all cached paths if none specified) from the cache\&. .sp When executed without options or \fIcommand\fRs, it prints the currently cached paths to the standard output\&. .sp With the \fB\-d\fR (\fB\-\-directory\fR) option, the built\-in does the same things to the home directory cache, rather than the command path cache\&. Cached home directory paths are used in tilde expansion\&. .SS "Options" .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 Print all cached paths\&. .sp Without this option, paths for built\-ins are not printed\&. .RE .PP \fB\-d\fR, \fB\-\-directory\fR .RS 4 Affect the home directory cache instead of the command path cache\&. .RE .PP \fB\-r\fR, \fB\-\-remove\fR .RS 4 Remove cached paths\&. .RE .SS "Operands" .PP \fIcommand\fR .RS 4 The name of an external command (that does not contain any slash)\&. .RE .PP \fIuser\fR .RS 4 A user name\&. .RE .SS "Exit status" .sp The exit status of the hash built\-in is zero unless there is any error\&. .SS "Notes" .sp The shell automatically caches command and directory paths when executing a command or performing tilde expansion, so normally there is no need to use this built\-in explicitly to cache paths\&. .sp Assigning a value to the \fBPATH\fR variable removes all command paths from the cache as if \fBhash \-r\fR was executed\&. .sp The POSIX standard defines the \fB\-r\fR option only: other options cannot be used in the POSIXly\-correct mode\&. .SH "HELP BUILT-IN" .sp The \fIhelp built\-in\fR prints usage of built\-ins\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhelp [\fR\fB\fIbuilt\-in\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The help built\-in prints a description of \fIbuilt\-in\fRs\&. .sp The built\-in extracts part of the output of \fBman yash\fR and prints it to the standard output\&. Therefore, the manual page of yash must have been installed for the built\-in to work\&. Depending on the formatting style of the man command, the built\-in may not work as expected\&. .SS "Operands" .PP \fIbuilt\-in\fRs .RS 4 Names of built\-ins\&. .RE .SS "Exit status" .sp The exit status of the help built\-in is zero unless there is any error\&. .SS "Notes" .sp The help built\-in is not defined in the POSIX standard\&. .sp Many built\-ins of yash accept the \fB\-\-help\fR option that prints the same description\&. .SH "HISTORY BUILT-IN" .sp The \fIhistory built\-in\fR prints or edits command history\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhistory [\-cF] [\-d \fR\fB\fIentry\fR\fR\fB] [\-s \fR\fB\fIcommand\fR\fR\fB] [\-r \fR\fB\fIfile\fR\fR\fB] [\-w \fR\fB\fIfile\fR\fR\fB] [\fR\fB\fIcount\fR\fR\fB]\fR .RE .SS "Description" .sp The history built\-in prints or edits command history\&. .sp When executed with an option, the built\-in edits history according to the option\&. If more than one option is specified, each option is processed in order\&. .sp When executed with the \fIcount\fR operand, the built\-in prints the most recent \fIcount\fR history entries to the standard output in the same manner as the fc built\-in\&. .sp When executed with neither options nor operands, the built\-in prints the whole history\&. .SS "Options" .PP \fB\-c\fR, \fB\-\-clear\fR .RS 4 Clear all history entries completely\&. .RE .PP \fB\-d \fR\fB\fIentry\fR\fR, \fB\-\-delete=\fR\fB\fIentry\fR\fR .RS 4 Delete the specified \fIentry\fR\&. The \fIentry\fR should be specified in the same manner as the \fIstart\fR and \fIend\fR operands of the fc built\-in\&. .RE .PP \fB\-F\fR, \fB\-\-flush\-file\fR .RS 4 Rebuild the history file\&. This operation removes unused old data from the file\&. .RE .PP \fB\-r \fR\fB\fIfile\fR\fR, \fB\-\-read=\fR\fB\fIfile\fR\fR .RS 4 Read command lines from \fIfile\fR and add them to the history\&. The file contents are treated as lines of simple text\&. .RE .PP \fB\-s \fR\fB\fIcommand\fR\fR, \fB\-\-set=\fR\fB\fIcommand\fR\fR .RS 4 Add \fIcommand\fR as a new history entry after removing the most recent entry\&. .RE .PP \fB\-w \fR\fB\fIfile\fR\fR, \fB\-\-write=\fR\fB\fIfile\fR\fR .RS 4 Write the whole history to \fIfile\fR\&. Any existing data in the file will be lost\&. The output format is lines of simple text, each of which is a command string\&. .RE .SS "Operands" .PP \fIcount\fR .RS 4 The number of entries to be printed\&. .RE .SS "Exit status" .sp The exit status of the history built\-in is zero unless there is any error\&. .SS "Notes" .sp The history built\-in is not defined in the POSIX standard\&. .sp Command history cannot be modified during line\-editing\&. .SH "JOBS BUILT-IN" .sp The \fIjobs built\-in\fR reports job status\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBjobs [\-lnprs] [\fR\fB\fIjob\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The jobs built\-in prints information of jobs the shell is currently controlling\&. .sp By default, the following information is printed for each job, line by line: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the job number, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the \fB+\fR or \fB\-\fR symbol if the job is the current or previous job, respectively, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the status, and .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the command string\&. .RE .SS "Options" .PP \fB\-l\fR, \fB\-\-verbose\fR .RS 4 Print the process ID, status, and command string for each process in the jobs\&. .RE .PP \fB\-n\fR, \fB\-\-new\fR .RS 4 Print new jobs only: jobs whose status has never been reported since the status changed\&. .RE .PP \fB\-p\fR, \fB\-\-pgid\-only\fR .RS 4 Print process group IDs of jobs only\&. .RE .PP \fB\-r\fR, \fB\-\-running\-only\fR .RS 4 Print running jobs only\&. .RE .PP \fB\-s\fR, \fB\-\-stopped\-only\fR .RS 4 Print stopped jobs only\&. .RE .SS "Operands" .PP \fIjob\fRs .RS 4 The job IDs of jobs to be reported\&. When no \fIjob\fR is specified, all jobs under the shell\(cqs control are reported\&. .RE .SS "Exit status" .sp The exit status of the jobs built\-in is zero unless there is any error\&. .SS "Notes" .sp The jobs built\-in is a semi\-special built\-in\&. .sp The POSIX standard defines the \fB\-l\fR and \fB\-p\fR options only: other options cannot be used in the POSIXly\-correct mode\&. In the POSIXly\-correct mode, the effect of the \fB\-l\fR option is different in that status is reported for each job rather than for each process\&. .sp The process group ID of a job executed by yash is equal to the process ID of the first command of the pipeline that forms the job\&. .SH "KILL BUILT-IN" .sp The \fIkill built\-in\fR sends a signal to processes\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBkill [\-\fR\fB\fIsignal\fR\fR\fB|\-s \fR\fB\fIsignal\fR\fR\fB|\-n \fR\fB\fIsignal\fR\fR\fB] \fR\fB\fIprocess\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBkill \-l [\-v] [\fR\fB\fIsignal\fR\fR\fB\&...]\fR .RE .sp The kill built\-in requires that all options precede operands\&. Any command line arguments after the first operand are all treated as operands\&. .SS "Description" .sp When executed without the \fB\-l\fR option, the built\-in sends a signal to processes\&. The signal sent can be specified by option\&. The SIGTERM signal is sent if no signal is specified\&. .sp When executed with the \fB\-l\fR option, the built\-in prints information of \fIsignal\fRs to the standard output\&. If no \fIsignal\fR is specified, information of all signals is printed\&. .SS "Options" .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBSignal-specifying options\fR .RS 4 .PP \fB\-\fR\fB\fIsignal\fR\fR, \fB\-s \fR\fB\fIsignal\fR\fR, \fB\-n \fR\fB\fIsignal\fR\fR .RS 4 A signal\-specifying option specifies a signal to be sent to processes\&. \fIsignal\fR can be specified by name or number\&. If number \fB0\fR is specified, the built\-in checks if a signal could be sent to the processes but no signal is actually sent\&. Signal names are case\-insensitive\&. .RE .sp You can specify at most one signal\-specifying option at a time\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBOther options\fR .RS 4 .PP \fB\-l\fR .RS 4 Print signal information instead of sending a signal\&. .RE .PP \fB\-v\fR .RS 4 Print more signal information\&. .sp Without this option, the built\-in prints the signal name only\&. This option adds the signal number and a short description\&. .sp When the \fB\-v\fR option is specified, the \fB\-l\fR option can be omitted\&. .RE .RE .SS "Operands" .PP \fIprocess\fRes .RS 4 Specify processes to which a signal is sent\&. .sp Processes can be specified by the process ID, the process group ID, or the job ID\&. The process group ID must be prefixed with a hyphen (\fB\-\fR) so that it is not treated as a process ID\&. .sp When \fB0\fR is specified as \fIprocess\fR, the signal is sent to the process group to which the shell process belongs\&. When \fB\-1\fR is specified, the signal is sent to all processes on the system\&. .RE .PP \fIsignal\fR .RS 4 Specify a signal of which information is printed\&. .sp The signal can be specified by the name, the number, or the exit status of a command that was killed by the signal\&. .RE .SS "Exit status" .sp The exit status of the kill built\-in is zero unless there is any error\&. If the signal was sent to at least one process, the exit status is zero even if the signal was not sent to all of the specified processes\&. .SS "Notes" .sp The kill built\-in is a semi\-special built\-in\&. .sp Command arguments that start with a hyphen should be used with care\&. The command \fBkill \-1 \-2\fR, for example, sends signal 1 to process group 2 since \fB\-1\fR is treated as a signal\-specifying option and \fB\-2\fR as an operand that specifies a process group\&. The commands \fBkill \-\- \-1 \-2\fR and \fBkill \-TERM \-1 \-2\fR, on the other hand, treats both \fB\-1\fR and \fB\-2\fR as operands\&. .sp The POSIX standard does not define the \fB\-n\fR or \fB\-v\fR options, so they cannot be used in the POSIXly\-correct mode\&. The standard does not allow specifying a signal number as the argument of the \fB\-s\fR option or a signal name as the \fIsignal\fR operand\&. .sp The standard requires signal names to be specified without the \fBSIG\fR prefix, like \fBINT\fR and \fBQUIT\fR\&. If the shell is not in the POSIXly\-correct mode, the built\-in accepts \fBSIG\fR\-prefixed signal names as well\&. .SH "POPD BUILT-IN" .sp The \fIpopd built\-in\fR pops a directory from the directory stack\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBpopd [\fR\fB\fIindex\fR\fR\fB]\fR .RE .SS "Description" .sp The popd built\-in removes the last entry from the directory stack, returning to the previous working directory\&. If \fIindex\fR is given, the entry specified by \fIindex\fR is removed instead of the last one\&. .SS "Operands" .PP \fIindex\fR .RS 4 The index of a directory stack entry you want to remove\&. .sp If omitted, \fB+0\fR (the last entry) is assumed\&. .RE .SS "Exit status" .sp The exit status of the popd built\-in is zero unless there is any error\&. .SS "Notes" .sp It is an error to use this built\-in when there is only one directory stack entry\&. .sp The popd built\-in is not defined in the POSIX standard\&. .SH "PRINTF BUILT-IN" .sp The \fIprintf built\-in\fR prints formatted values\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBprintf \fR\fB\fIformat\fR\fR\fB [\fR\fB\fIvalue\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The printf built\-in formats \fIvalue\fRs according to \fIformat\fR and prints them to the standard output\&. Unlike the echo built\-in, the printf built\-in does not print a newline automatically\&. .sp The formatting process is very similar to that of the printf function in the C programming language\&. You can use conversion specifications (which start with \fB%\fR) and escape sequences (which start with \fB\e\fR) in \fIformat\fR\&. Any other characters that are not part of a conversion specification or escape sequence are printed literally\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBConversion specifications\fR .RS 4 .sp A conversion specification starts with a percent sign (\fB%\fR)\&. .sp A conversion specification except \fB%%\fR consumes a \fIvalue\fR, which is formatted according to the specification and printed\&. Each conversion specification consumes one \fIvalue\fR in the order of appearance\&. If there are more \fIvalue\fRs than conversion specifications, the entire \fIformat\fR is re\-processed until all the \fIvalue\fRs are consumed\&. If a \fIvalue\fR to be consumed is missing, it is assumed to be an empty string (if the specification requires a string) or zero (if a number)\&. If no \fIvalue\fRs are given, \fIformat\fR is processed just once\&. .sp Available conversion specifications are: .PP \fB%d\fR, \fB%i\fR .RS 4 prints a signed integer in decimal .RE .PP \fB%u\fR .RS 4 prints an unsigned integer in decimal .RE .PP \fB%o\fR .RS 4 prints an unsigned integer in octal .RE .PP \fB%x\fR .RS 4 prints an unsigned integer in lowercase hexadecimal .RE .PP \fB%X\fR .RS 4 prints an unsigned integer in uppercase hexadecimal .RE .PP \fB%f\fR .RS 4 prints a floating\-point number in lowercase .RE .PP \fB%F\fR .RS 4 prints a floating\-point number in uppercase .RE .PP \fB%e\fR .RS 4 prints a floating\-point number with exponent in lowercase .RE .PP \fB%E\fR .RS 4 prints a floating\-point number with exponent in uppercase .RE .PP \fB%g\fR .RS 4 the same as \fB%f\fR or \fB%e\fR, automatically selected .RE .PP \fB%G\fR .RS 4 the same as \fB%F\fR or \fB%E\fR, automatically selected .RE .PP \fB%c\fR .RS 4 prints the first character of string .RE .PP \fB%s\fR .RS 4 prints a string .RE .PP \fB%b\fR .RS 4 prints a string (recognizing escape sequences like the echo built\-in) .RE .PP \fB%%\fR .RS 4 prints a percent sign (\fB%\fR) .RE .sp For \fB%g\fR and \fB%G\fR, the specification that is actually used is \fB%f\fR or \fB%F\fR if the exponent part is between \-5 and the precision (exclusive); \fB%e\fR or \fB%E\fR otherwise\&. .sp In a conversion specification except \fB%%\fR, the leading percent sign may be followed by flags, field width, and/or precision in this order\&. .sp The flags are a sequence of any number of the following characters: .PP Minus sign (\fB\-\fR) .RS 4 With this flag, spaces are appended to the formatted value to fill up to the field width\&. Otherwise, spaces are prepended\&. .RE .PP Plus sign (\fB+\fR) .RS 4 A plus or minus sign is always prepended to a number\&. .RE .PP Space (\fB \fR) .RS 4 A space is prepended to a formatted number if it has no plus or minus sign\&. .RE .PP Hash sign (\fB#\fR) .RS 4 The value is formatted in an alternative form: For \fB%o\fR, the printed octal integer has at least one leading zero\&. For \fB%x\fR and \fB%X\fR, a non\-zero integer is formatted with \fB0x\fR and \fB0X\fR prefixes, respectively\&. For \fB%e\fR, \fB%E\fR, \fB%f\fR, \fB%F\fR, \fB%g\fR, and \fB%G\fR, a decimal mark (a\&.k\&.a\&. radix character) is always printed even if the value is an exact integer\&. For \fB%g\fR and \fB%G\fR, the printed number has at least one digit in the fractional part\&. .RE .PP Zero (\fB0\fR) .RS 4 Zeros are prepended to a formatted number to fill up to the field width\&. This flag is ignored if the minus flag is specified or if the conversion specification is \fB%d\fR, \fB%i\fR, \fB%u\fR, \fB%o\fR, \fB%x\fR, or \fB%X\fR with a precision\&. .RE .sp A field width is specified as a decimal integer that has no leading zeros\&. .sp A field width defines a minimum byte count of a formatted value\&. If the formatted value does not reach the minimum byte count, so many spaces are prepended that the printed value has the specified byte count\&. .sp A precision is specified as a period (\fB\&.\fR) followed by a decimal integer\&. If the integer is omitted after the period, the precision is assumed to be zero\&. .sp For conversion specifications \fB%d\fR, \fB%i\fR, \fB%u\fR, \fB%o\fR, \fB%x\fR, and \fB%X\fR, a precision defines a minimum digit count\&. If the formatted integer does not reach the minimum digit count, so many zeros are prepended that the printed integer has the specified number of digits\&. The default precision is one for these conversion specifications\&. .sp For conversion specifications \fB%e\fR, \fB%E\fR, \fB%f\fR, and \fB%F\fR, a precision defines the number of digits after the decimal mark\&. The default precision is six for these conversion specifications\&. .sp For conversion specifications \fB%g\fR, and \fB%G\fR, a precision defines a maximum number of significant digits in the printed value\&. The default precision is six for these conversion specifications\&. .sp For conversion specifications \fB%s\fR, and \fB%b\fR, a precision defines a maximum byte count of the printed string\&. The default precision is infinity for these conversion specifications\&. .sp In the conversion specification \fB%08\&.3f\fR, the zero flag is specified, the field width is 8, and the precision is 3\&. If this specification is applied to value 12\&.34, the output will be \fB0012\&.340\fR\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBEscape sequences\fR .RS 4 .sp The following escape sequences are recognized in \fIformat\fR: .PP \fB\ea\fR .RS 4 Bell character (ASCII code: 7) .RE .PP \fB\eb\fR .RS 4 Backspace (ASCII code: 8) .RE .PP \fB\ef\fR .RS 4 Form feed character (ASCII code: 12) .RE .PP \fB\en\fR .RS 4 Newline character (ASCII code: 10) .RE .PP \fB\er\fR .RS 4 Carriage return character (ASCII code: 13) .RE .PP \fB\et\fR .RS 4 Horizontal tab character (ASCII code: 9) .RE .PP \fB\ev\fR .RS 4 Vertical tab character (ASCII code: 11) .RE .PP \fB\e\e\fR .RS 4 Backslash .RE .PP \fB\e"\fR .RS 4 Double quotation .RE .PP \fB\e\*(Aq\fR .RS 4 Single quotation (apostrophe) .RE .PP \fB\e\fR\fB\fIxxx\fR\fR .RS 4 Character whose code is \fIxxx\fR, where \fIxxx\fR is an octal number of at most three digits\&. .RE .RE .SS "Operands" .PP \fIformat\fR .RS 4 A string that defines how \fIvalue\fRs should be formatted\&. .RE .PP \fIvalue\fRs .RS 4 Values that are formatted according to \fIformat\fR\&. .sp A value is either a number or a string\&. .sp When a numeric value is required, \fIvalue\fR can be a single or double quotation followed by a character, instead of a normal number\&. For example, the command \fBprintf \*(Aq%d\*(Aq \*(Aq"3\*(Aq\fR will print \fB51\fR on a typical environment where character \fB3\fR has character code 51\&. .RE .SS "Exit status" .sp The exit status of the printf built\-in is zero unless there is any error\&. .SS "Notes" .sp The POSIX standard does not precisely define how multibyte characters should be handled by the built\-in\&. When you use the \fB%s\fR conversion specification with precision or the \fB%c\fR conversion specification, you may obtain unexpected results if the formatted value contains a character that is represented by more than one byte\&. Yash never prints only part of the bytes that represent a single multibyte character because all multibyte characters are converted to wide characters when processed in the shell\&. .SH "PUSHD BUILT-IN" .sp The \fIpushd built\-in\fR pushes a directory into the directory stack\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBpushd [\-L|\-P] [\fR\fB\fIdirectory\fR\fR\fB]\fR .RE .SS "Description" .sp The pushd built\-in changes the working directory to \fIdirectory\fR in the same manner as the cd built\-in and adds it to the directory stack\&. If the working directory could not be changed successfully, the stack is not modified\&. .SS "Options" .sp The pushd built\-in accepts the following option as well as the options that can be used for the cd built\-in: .PP \fB\-\-remove\-duplicates\fR .RS 4 If the new working directory has already been in the directory stack, the existing entry is removed from the stack before the new directory is pushed into the stack\&. .RE .SS "Operands" .PP \fIdirectory\fR .RS 4 The pathname of the new working directory\&. .sp If \fIdirectory\fR is a single hyphen (\(oq\-\(cq), the value of the \fBOLDPWD\fR variable is assumed for the new directory pathname, which is printed to the standard output\&. .sp If \fIdirectory\fR is an integer with a plus or minus sign, it is considered as an entry index of the directory stack\&. The entry is removed from the stack and then pushed to the stack again\&. .sp If \fIdirectory\fR is omitted, the working directory is changed to the directory specified by the \fB\-\-default\-directory=\&...\fR option\&. If that option is not specified either, the default is index \fB+1\fR\&. .RE .SS "Exit status" .sp The exit status of the pushd built\-in is zero unless there is any error\&. .SS "Notes" .sp The pushd built\-in is not defined in the POSIX standard\&. .SH "PWD BUILT-IN" .sp The \fIpwd built\-in\fR prints the current working directory\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBpwd [\-L|\-P]\fR .RE .SS "Description" .sp The pwd built\-in prints an absolute path to the shell\(cqs current working directory to the standard output\&. .SS "Options" .PP \fB\-L\fR, \fB\-\-logical\fR .RS 4 If the value of the \fBPWD\fR variable is an absolute path to the shell\(cqs working directory and the path does not contain any \fB\&.\fR or \fB\&.\&.\fR components, then the path is printed\&. Otherwise, the printed path is the same as when the \fB\-P\fR option is specified\&. .RE .PP \fB\-P\fR, \fB\-\-physical\fR .RS 4 The printed path does not contain any \fB\&.\fR or \fB\&.\&.\fR components, symbolic link components, or redundant slashes\&. .RE .sp The \fB\-L\fR (\fB\-\-logical\fR) and \fB\-P\fR (\fB\-\-physical\fR) options are mutually exclusive: only the last specified one is effective\&. If neither is specified, \fB\-L\fR is assumed\&. .SS "Exit status" .sp The exit status of the pwd built\-in is zero unless there is any error\&. .SS "Notes" .sp The pwd built\-in is a semi\-special built\-in\&. .SH "READ BUILT-IN" .sp The \fIread built\-in\fR reads a line from the standard input\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBread [\-Ar] \fR\fB\fIvariable\fR\fR\fB\&...\fR .RE .SS "Description" .sp The read built\-in reads a line of string from the standard input and assigns it to the specified variables\&. If the shell is interactive and line\-editing is enabled, you can use line\-editing when inputting a line\&. .sp If the \fB\-r\fR (\fB\-\-raw\-mode\fR) option is specified, all characters in the line are treated literally\&. .sp If the \fB\-r\fR (\fB\-\-raw\-mode\fR) option is not specified, backslashes in the line are treated as quotations\&. If a backslash is at the end of the line, it is treated as a line continuation\&. When the built\-in reads the next line, the \fBPS2\fR variable is used as a prompt if the standard input is a terminal\&. .sp The input line is subject to field splitting\&. The resulting words are assigned to \fIvariable\fRs in order\&. If there are more words than \fIvariable\fRs, the last variable is assigned all the remaining words (as if the words were not split)\&. If the words are fewer than \fIvariable\fRs, the remaining variables are assigned empty strings\&. .SS "Options" .PP \fB\-A\fR, \fB\-\-array\fR .RS 4 Make the last \fIvariable\fR an array\&. Instead of assigning a concatenation of the remaining words to a normal variable, the words are assigned to an array\&. .RE .PP \fB\-r\fR, \fB\-\-raw\-mode\fR .RS 4 Don\(cqt treat backslashes as quotations\&. .RE .SS "Operands" .PP \fIvariable\fRs .RS 4 Names of variables to which input words are assigned\&. .RE .SS "Exit status" .sp The exit status of the read built\-in is zero unless there is any error\&. .SS "Notes" .sp The read built\-in is a semi\-special built\-in\&. .sp The POSIX standard defines the \fB\-r\fR option only: other options cannot be used in the POSIXly\-correct mode\&. .SH "READONLY BUILT-IN" .sp The \fIreadonly built\-in\fR makes variables and functions read\-only\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBreadonly [\-pxX] [\fR\fB\fIname\fR\fR\fB[=\fR\fB\fIvalue\fR\fR\fB]\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBreadonly \-f[p] [\fR\fB\fIname\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The readonly built\-in is equivalent to the typeset built\-in with the \fB\-gr\fR option\&. .SS "Notes" .sp The readonly built\-in is a special built\-in\&. .sp The POSIX standard defines the \fB\-p\fR option only; other options cannot be used in the POSIXly\-correct mode\&. The POSIX does not allow using the option together with operands\&. .SH "RETURN BUILT-IN" .sp The \fIreturn built\-in\fR returns from a function or script\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBreturn [\-n] [\fR\fB\fIexit_status\fR\fR\fB]\fR .RE .SS "Description" .sp When executed without the \fB\-n\fR (\fB\-\-no\-return\fR) option, one of the following happens: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the shell is executing a function, the execution of the function is terminated\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the dot built\-in is executing a script, the execution of the script is terminated\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If the eval built\-in is executing a command string, the execution of the command is terminated\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Otherwise, the shell exits unless it is interactive\&. .RE .sp When executed with the \fB\-n\fR (\fB\-\-no\-return\fR) option, the built\-in does nothing but return the specified \fIexit_status\fR\&. .SS "Options" .PP \fB\-n\fR, \fB\-\-no\-return\fR .RS 4 Do not terminate a function, script, evaluated command, or the shell\&. .RE .SS "Operands" .PP \fIexit_status\fR .RS 4 The exit status of the built\-in\&. .sp The value must be a non\-negative integer\&. .sp If omitted, the exit status of the last executed command is used\&. (But when the shell is executing a trap, the exit status of the last command before the trap is used\&.) .RE .SS "Exit status" .sp The exit status of the return built\-in is defined by the \fIexit_status\fR operand\&. The exit status is used also as the exit status of the terminated function, script, evaluated script, or the shell\&. .SS "Notes" .sp The return built\-in is a special built\-in\&. .sp The POSIX standard provides that the \fIexit_status\fR operand should be between 0 and 255 (inclusive)\&. Yash accepts integers larger than 255 as an extension\&. .sp In the POSIX standard, the behavior of the return built\-in is defined only when the shell is executing a function or script\&. .sp The POSIX standard defines no options for the return built\-in; the built\-in accepts no options in the POSIXly\-correct mode\&. .SH "SET BUILT-IN" .sp The \fIset built\-in\fR sets shell options and positional parameters\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset [\fR\fB\fIoption\fR\fR\fBs] [\fR\fB\fIoperand\fR\fR\fBs]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-o\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset +o\fR .RE .sp The set built\-in requires that all options precede operands\&. Any command line arguments after the first operand are all treated as operands\&. .SS "Description" .sp When executed without any command arguments, the built\-in prints a list of all existing variables to the standard input in a form that can be reused as commands that will restore the variable definitions\&. .sp When \fB\-o\fR is the only command argument, the built\-in prints a list of shell options with their current settings\&. When \fB+o\fR is the only command argument, the built\-in prints commands that can be reused to restore the current shell option settings\&. .sp In other cases, the built\-in changes shell option settings and/or positional parameters\&. .SS "Options" .sp When one or more options are specified, the built\-in enables or disables the shell options\&. A normal hyphen\-prefixed option enables a shell option\&. An option that is prefixed with a plus (\fB+\fR) instead of a hyphen disables a shell option\&. For example, options \fB\-m\fR, \fB\-o monitor\fR, and \fB\-\-monitor\fR enable the monitor option and options \fB+m\fR, \fB+o monitor\fR, \fB++monitor\fR disable it\&. .sp The name of a long option is case\-insensitive and may include irrelevant non\-alphanumeric characters, which are ignored\&. For example, options \fB\-\-le\-comp\-debug\fR and \fB\-\-LeCompDebug\fR are equivalent\&. If \fBno\fR is prepended to the name of a long option, the meaning is reversed\&. For example, \fB\-\-noallexport\fR is equivalent to \fB++allexport\fR and \fB++nonotify\fR to \fB\-\-notify\fR\&. .sp An option can be specified in one of the following forms: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} a long option e\&.g\&. \fB\-\-allexport\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} an \fB\-o\fR option with a option name specified as the argument e\&.g\&. \fB\-o allexport\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} a single\-character option e\&.g\&. \fB\-a\fR .RE .sp Not all options can be specified as single\-character options\&. .sp The available options are: .PP all\-export (\fB\-a\fR) .RS 4 When enabled, all variables are automatically exported when assigned\&. .RE .PP brace\-expand .RS 4 This option enables brace expansion\&. .RE .PP case\-glob .RS 4 (Enabled by default) When enabled, pattern matching is case\-sensitive in pathname expansion\&. .RE .PP clobber (\fB+C\fR) .RS 4 (Enabled by default) When enabled, the \fB>\fRredirection behaves the same as the \fB>|\fR redirection\&. .RE .PP cur\-async, cur\-bg, cur\-stop .RS 4 (Enabled by default) These options affect choice of the current job (cf\&. job ID)\&. .RE .PP dot\-glob .RS 4 When enabled, periods at the beginning of filenames are not treated specially in pathname expansion\&. .RE .PP emacs .RS 4 This option enables line\-editing in the emacs mode\&. .RE .PP err\-exit (\fB\-e\fR) .RS 4 When enabled, if a pipeline ends with a non\-zero exit status, the shell immediately exits unless: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the pipeline is a condition of an if command or while or until loop; .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the pipeline is prefixed by \fB!\fR; or .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} the pipeline is a single compound command other than a subshell grouping\&. .RE .RE .PP exec (\fB+n\fR) .RS 4 (Enabled by default) Commands are actually executed only when this option is enabled\&. Otherwise, commands are just parsed and not executed\&. Disabling this option may be useful for syntax checking\&. In an interactive shell, this option is always assumed enabled\&. .RE .PP extended\-glob .RS 4 This option enables extension in pathname expansion\&. .RE .PP glob (\fB+f\fR) .RS 4 (Enabled by default) This option enables pathname expansion\&. .RE .PP hash\-on\-def (\fB\-h\fR) .RS 4 When a function is defined when this option is enabled, the shell immediately performs command path search for each command that appears in the function and caches the command\(cqs full path\&. .RE .PP hist\-space .RS 4 When enabled, command lines that start with a whitespace are not saved in command history\&. .RE .PP ignore\-eof .RS 4 When enabled, an interactive shell does not exit when EOF (end of file) is input\&. This prevents the shell from exiting when you accidentally hit Ctrl\-D\&. .RE .PP le\-always\-rp, le\-comp\-debug, le\-conv\-meta, le\-no\-conv\-meta, le\-prompt\-sp, le\-visible\-bell .RS 4 See shell options on line\-editing\&. .RE .PP mark\-dirs .RS 4 When enabled, resulting directory names are suffixed by a slash in pathname expansion\&. .RE .PP monitor (\fB\-m\fR) .RS 4 This option enables job control\&. This option is enabled by default for an interactive shell\&. .RE .PP notify (\fB\-b\fR) .RS 4 When the status of a job changes when this option is enabled, the shell immediately notifies at any time\&. This option overrides the notify\-le option\&. .RE .PP notify\-le .RS 4 This option is similar to the notify option, but the status change is notified only while the shell is waiting for input with line\-editing\&. .RE .PP null\-glob .RS 4 When enabled, in pathname expansion, patterns that do not match any pathname are removed from the command line rather than left as is\&. .RE .PP posixly\-correct .RS 4 This option enables the POSIXly\-correct mode\&. .RE .PP trace\-all .RS 4 (Enabled by default) When this option is disabled, the x-trace option is temporarily disabled while the shell is executing commands defined in the \fBCOMMAND_NOT_FOUND_HANDLER\fR, \fBPROMPT_COMMAND\fR, or \fBYASH_AFTER_CD\fR variable\&. .RE .PP unset (\fB+u\fR) .RS 4 (Enabled by default) When enabled, undefined parameters are expanded to empty strings in parameter expansion\&. When disabled, expansion of undefined parameter results in an error\&. .RE .PP verbose (\fB\-v\fR) .RS 4 When enabled, the shell prints each command line to the standard error before parsing and executing it\&. .RE .PP vi .RS 4 This option enables line\-editing in the vi mode\&. This option is enabled by default in an interactive shell if the standard input and error are both terminals\&. .RE .PP x\-trace (\fB\-x\fR) .RS 4 When enabled, the results of expansion are printed to the standard error for each simple command being executed\&. When printed, each line is prepended with an expansion result of the \fBPS4\fR variable\&. See also the trace-all option\&. .RE .SS "Operands" .sp If one or more operands are passed to the set built\-in, current positional parameters are all removed and the operands are set as new positional parameters\&. If the \fB\-\-\fR separator (cf\&. syntax of command arguments) is passed, the positional parameters are set even when there are no operands, in which case new positional parameters will be nothing\&. .SS "Exit status" .sp The exit status of the set built\-in is zero unless there is any error\&. .SS "Notes" .sp The set built\-in is a special built\-in\&. .sp In the POSIX standard, available shell options are much limited\&. The standard does not define: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} long options such as \fB\-\-allexport\fR, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} prepending \fBno\fR to negate an option, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} using uppercase letters and/or non\-alphanumeric characters in option names .RE .sp The options defined in the standard are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-a\fR, \fB\-o allexport\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-e\fR, \fB\-o errexit\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-m\fR, \fB\-o monitor\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-C\fR, \fB\-o noclobber\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-n\fR, \fB\-o noexec\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-f\fR, \fB\-o noglob\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-b\fR, \fB\-o notify\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-u\fR, \fB\-o nounset\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-v\fR, \fB\-o verbose\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-x\fR, \fB\-o xtrace\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-h\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-o ignoreeof\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-o nolog\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-o vi\fR .RE .sp Yash does not support the nolog option, which prevents function definitions from being added to command history\&. .SH "SHIFT BUILT-IN" .sp The \fIshift built\-in\fR removes some positional parameters\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBshift [\fR\fB\fIcount\fR\fR\fB]\fR .RE .SS "Description" .sp The shift built\-in removes the first \fIcount\fR positional parameters\&. .SS "Operands" .PP \fIcount\fR .RS 4 The number of positional parameters to be removed\&. .sp It is an error if the actual number of positional parameters is less than \fIcount\fR\&. If omitted, the default value is one\&. .RE .SS "Exit status" .sp The exit status of the shift built\-in is zero unless there is any error\&. .SS "Notes" .sp The shift built\-in is a special built\-in\&. .sp The number of positional parameters can be obtained with the \fB#\fR special parameter\&. .SH "SUSPEND BUILT-IN" .sp The \fIsuspend built\-in\fR suspends the shell\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBsuspend [\-f]\fR .RE .SS "Description" .sp The suspend built\-in sends a SIGSTOP signal to all processes in the process group to which the shell process belongs\&. The signal suspends the processes (including the shell)\&. The suspended processes resume when they receive a SIGCONT signal\&. .sp If the shell is interactive and its process group ID is equal to the process ID of the session leader, the shell prints a warning message and refuses to send a signal unless the \fB\-f\fR (\fB\-\-force\fR) option is specified\&. (In such a case, there is no other job\-controlling shell that can send a SIGCONT signal to resume the suspended shell, so the shell could never be resumed\&.) .SS "Options" .PP \fB\-f\fR, \fB\-\-force\fR .RS 4 Suppress warnings that would prevent the shell from sending a signal\&. .RE .SS "Exit status" .sp The exit status is zero if the signal was successfully sent and non\-zero otherwise\&. .SS "Notes" .sp The suspend built\-in is not defined in the POSIX standard\&. .SH "TEST BUILT-IN" .sp The \fItest built\-in\fR evaluates an expression\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtest \fR\fB\fIexpression\fR\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB[ \fR\fB\fIexpression\fR\fR\fB ]\fR .RE .sp The test built\-in does not distinguish options and operands; all command line arguments are interpreted as \fIexpression\fR\&. If the built\-in is executed with the name \fB[\fR, \fIexpression\fR must be followed by \fB]\fR\&. .SS "Description" .sp The test built\-in evaluates \fIexpression\fR as a conditional expression that is made up of operators and operands described below\&. The exit status is 0 if the condition is true and 1 otherwise\&. .sp The unary operators below test a file\&. If the operand \fIfile\fR is a symbolic link, the file referred to by the link is tested (except for the \fB\-h\fR and \fB\-L\fR operators)\&. .PP \fB\-b \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is a block special file .RE .PP \fB\-c \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is a character special file .RE .PP \fB\-d \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is a directory .RE .PP \fB\-e \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR exists .RE .PP \fB\-f \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is a regular file .RE .PP \fB\-G \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR\*(Aqs group ID is same as the shell\(cqs effective group ID .RE .PP \fB\-g \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR\*(Aqs set\-group\-ID flag is set .RE .PP \fB\-h \fR\fB\fIfile\fR\fR .RS 4 same as \-L .RE .PP \fB\-k \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR\*(Aqs sticky bit is set .RE .PP \fB\-L \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is a symbolic link .RE .PP \fB\-N \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR has not been accessed since last modified .RE .PP \fB\-O \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR\*(Aqs user ID is same as the shell\(cqs effective user ID .RE .PP \fB\-p \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is a FIFO (named pipe) .RE .PP \fB\-r \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is readable .RE .PP \fB\-S \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is a socket .RE .PP \fB\-s \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is not empty .RE .PP \fB\-u \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR\*(Aqs set\-user\-ID flag is set .RE .PP \fB\-w \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is writable .RE .PP \fB\-x \fR\fB\fIfile\fR\fR .RS 4 \fIfile\fR is executable .RE .sp The unary operator below tests a file descriptor: .PP \fB\-t \fR\fB\fIfd\fR\fR .RS 4 \fIfd\fR is associated with a terminal .RE .sp The unary operators below test a string: .PP \fB\-n \fR\fB\fIstring\fR\fR .RS 4 \fIstring\fR is not empty .RE .PP \fB\-z \fR\fB\fIstring\fR\fR .RS 4 \fIstring\fR is empty .RE .sp The unary operator below tests a shell option: .PP \fB\-o ?\fR\fB\fIoption\fR\fR .RS 4 \fIoption\fR is a valid shell option name .RE .PP \fB\-o \fR\fB\fIoption\fR\fR .RS 4 \fIoption\fR is a valid shell option name that is enabled .RE .sp The binary operators below compare files\&. Non\-existing files are considered older than any existing files\&. .PP \fB\fIfile1\fR\fR\fB \-nt \fR\fB\fIfile2\fR\fR .RS 4 \fIfile1\fR is newer than \fIfile2\fR .RE .PP \fB\fIfile1\fR\fR\fB \-ot \fR\fB\fIfile2\fR\fR .RS 4 \fIfile1\fR is older than \fIfile2\fR .RE .PP \fB\fIfile1\fR\fR\fB \-ef \fR\fB\fIfile2\fR\fR .RS 4 \fIfile1\fR is a hard link to \fIfile2\fR .RE .sp The binary operators below compare strings: .PP \fB\fIstring1\fR\fR\fB = \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is the same string as \fIstring2\fR .RE .PP \fB\fIstring1\fR\fR\fB != \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is not the same string as \fIstring2\fR .RE .sp The binary operators below compare strings according to the alphabetic order in the current locale: .PP \fB\fIstring1\fR\fR\fB === \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is equal to \fIstring2\fR .RE .PP \fB\fIstring1\fR\fR\fB !== \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is not equal to \fIstring2\fR .RE .PP \fB\fIstring1\fR\fR\fB < \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is less than \fIstring2\fR .RE .PP \fB\fIstring1\fR\fR\fB <= \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is less than or equal to \fIstring2\fR .RE .PP \fB\fIstring1\fR\fR\fB > \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is greater than \fIstring2\fR .RE .PP \fB\fIstring1\fR\fR\fB >= \fR\fB\fIstring2\fR\fR .RS 4 \fIstring1\fR is greater than or equal to \fIstring2\fR .RE .sp The binary operator below performs pattern matching: .PP \fB\fIstring\fR\fR\fB =~ \fR\fB\fIpattern\fR\fR .RS 4 extended regular expression \fIpattern\fR matches \fIstring\fR .RE .sp The binary operators below compare integers: .PP \fB\fIv1\fR\fR\fB \-eq \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is equal to \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-ne \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is not equal to \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-gt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is greater than \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-ge \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is greater than or equal to \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-lt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is less than \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-le \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is less than or equal to \fIv2\fR .RE .sp The binary operators below compare version numbers: .PP \fB\fIv1\fR\fR\fB \-veq \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is equal to \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-vne \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is not equal to \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-vgt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is greater than \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-vge \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is greater than or equal to \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-vlt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is less than \fIv2\fR .RE .PP \fB\fIv1\fR\fR\fB \-vle \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR is less than or equal to \fIv2\fR .RE .sp The operators below can be used to make complex expressions: .PP \fB! \fR\fB\fIexpression\fR\fR .RS 4 negate (reverse) the result .RE .PP \fB( \fR\fB\fIexpression\fR\fR\fB )\fR .RS 4 change operator precedence .RE .PP \fB\fIexpression1\fR\fR\fB \-a \fR\fB\fIexpression2\fR\fR .RS 4 logical conjunction (and) .RE .PP \fB\fIexpression1\fR\fR\fB \-o \fR\fB\fIexpression2\fR\fR .RS 4 logical disjunction (or) .RE .sp If the expression is a single word without operators, the \fB\-n\fR operator is assumed\&. An empty expression evaluates to false\&. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBComparison of version numbers\fR .RS 4 .sp Comparison of version numbers is similar to comparison of strings in alphabetic order\&. The differences are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Adjacent digits are treated as an integer\&. Integers are compared in mathematical order rather than alphabetic order\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Digits are considered larger than any non\-digit characters\&. .RE .sp For example, version numbers \fB0\&.1\&.2\-3\fR and \fB00\&.001\&.02\-3\fR are equal and \fB0\&.2\&.1\fR is smaller than \fB0\&.10\&.0\fR\&. .RE .SS "Exit status" .sp The exit status of the test built\-in is 0 if \fIexpression\fR is true and 1 otherwise\&. The exit status is 2 if \fIexpression\fR cannot be evaluated because of a syntax error or any other reasons\&. .SS "Notes" .sp Complex expressions may cause confusion and should be avoided\&. Use the shell\(cqs compound commands\&. For example, \fB[ 1 \-eq 1 ] && [ \-t = 1 ] && ! [ foo ]\fR is preferred over \fB[ 1 \-eq 1 \-a \-t = 1 \-a ! foo ]\fR\&. .sp The POSIX standard provides that the exit status should be larger than 1 on error\&. The POSIX standard does not define the following operators: \fB\-nt\fR, \fB\-ot\fR, \fB\-ef\fR, \fB==\fR, \fB===\fR, \fB!==\fR, \fB<\fR, \fB<=\fR, \fB>\fR, \fB>=\fR, \fB=~\fR, \fB\-veq\fR, \fB\-vne\fR, \fB\-vgt\fR, \fB\-vge\fR, \fB\-vlt\fR, and \fB\-vle\fR\&. POSIX neither specifies \fB\-o\fR as a unary operator\&. .SH "TIMES BUILT-IN" .sp The \fItimes built\-in\fR prints CPU time usage\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtimes\fR .RE .SS "Description" .sp The times built\-in prints the CPU times consumed by the shell process and its child processes to the standard output\&. .sp The built\-in prints two lines: the first line shows the CPU time of the shell process and the second one that of its child processes (not including those which have not terminated)\&. Each line shows the CPU times consumed in the user and system mode\&. .SS "Exit status" .sp The exit status of the times built\-in is zero unless there is any error\&. .SS "Notes" .sp The times built\-in is a special built\-in\&. .SH "TRAP BUILT-IN" .sp The \fItrap built\-in\fR sets or prints signal handlers\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap \fR\fB\fIaction\fR\fR\fB \fR\fB\fIsignal\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap \fR\fB\fIsignal_number\fR\fR\fB [\fR\fB\fIsignal\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap \-p [\fR\fB\fIsignal\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The trap built\-in sets or prints actions that are taken when the shell receives signals\&. (Those actions are called \fItraps\fR\&.) .sp When executed with \fIaction\fR and one or more \fIsignal\fRs, the built\-in sets the traps for \fIsignal\fRs to \fIaction\fR\&. If the shell receives one of the signals, the action will be taken\&. .sp If the first operand is \fIsignal_number\fR instead of \fIaction\fR, the built\-in resets the traps for \fIsignal_number\fR and \fIsignal\fRs as if \fIaction\fR was \fB\-\fR\&. .sp When executed with the \fB\-p\fR (\fB\-\-print\fR) option or with no operands, the built\-in prints currently set traps to the standard output in a format that can be executed as commands that restore the current traps\&. If one or more \fIsignal\fRs are specified, only those signals are printed\&. Otherwise, all signals with non\-default actions are printed\&. .SS "Options" .PP \fB\-p\fR, \fB\-\-print\fR .RS 4 Print current trap settings\&. .RE .SS "Operands" .PP \fIaction\fR .RS 4 An action that will be taken when \fIsignal\fR is received\&. .sp If \fIaction\fR is a single hyphen (\fB\-\fR), the action is reset to the default action that is defined by the operating system\&. If \fIaction\fR is an empty string, the signal is ignored on receipt\&. Otherwise, \fIaction\fR is treated as a command string: the string is parsed and executed as commands when the signal is received\&. (If a signal is received while a command is being executed, the action is taken just after the command finishes\&.) .RE .PP \fIsignal\fR .RS 4 The number or name of a signal\&. .sp If \fIsignal\fR is number \fB0\fR or name \fBEXIT\fR, it is treated as a special imaginary signal that is always received when the shell exits\&. The action set for this signal is taken when the shell exits normally\&. .RE .PP \fIsignal_number\fR .RS 4 This is like \fIsignal\fR, but must be a number\&. .RE .SS "Exit status" .sp The exit status of the trap built\-in is zero unless there is any error\&. .SS "Notes" .sp The trap built\-in is a special built\-in\&. .sp The POSIX standard requires that signal names must be specified without the \fBSIG\fR\-prefix, like \fBINT\fR and \fBQUIT\fR\&. As an extension, yash accepts \fBSIG\fR\-prefixed names like \fBSIGINT\fR and \fBSIGQUIT\fR and treats signal names case\-insensitively\&. .SH "TRUE BUILT-IN" .sp The \fItrue built\-in\fR does nothing successfully\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrue\fR .RE .SS "Description" .sp The true built\-in does nothing\&. Any command line arguments are ignored\&. .SS "Exit status" .sp The exit status of the true built\-in is zero\&. .SS "Notes" .sp The true built\-in is a semi\-special built\-in\&. .sp The true and colon built\-ins have the same effect, but true is a semi\-special built\-in while colon is a special\&. .SH "TYPE BUILT-IN" .sp The \fItype built\-in\fR identifies a command\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtype [\-abefkp] [\fR\fB\fIcommand\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The type built\-in is equivalent to the command built\-in with the \fB\-V\fR option\&. .SS "Notes" .sp The POSIX standard does not define the relation between the type and command built\-ins\&. The standard does not define options for the type built\-in\&. .sp At least one \fIcommand\fR operand must be specified in the POSIXly\-correct mode\&. .SH "TYPESET BUILT-IN" .sp The \fItypeset built\-in\fR prints or sets variables or functions\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtypeset [\-gprxX] [\fR\fB\fIvariable\fR\fR\fB[=\fR\fB\fIvalue\fR\fR\fB]\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtypeset \-f[pr] [\fR\fB\fIfunction\fR\fR\fB\&...]\fR .RE .SS "Description" .sp If executed without the \fB\-f\fR (\fB\-\-functions\fR) option, the typeset built\-in prints or sets variables to the standard output\&. Otherwise, it prints or sets functions\&. .sp If executed with the \fB\-p\fR (\fB\-\-print\fR) option, the built\-in prints the variables or functions specified by operands\&. Without the option, it sets variables or functions\&. If no operands are specified, it prints all existing variables or functions, regardless of whether the \fB\-p\fR (\fB\-\-print\fR) option is specified\&. .SS "Options" .PP \fB\-f\fR, \fB\-\-functions\fR .RS 4 Print or set functions rather than variables\&. .RE .PP \fB\-g\fR, \fB\-\-global\fR .RS 4 When setting a new variable, the variable will be a global variable if this option is specified\&. Without this option, the variable would be a local variable\&. .sp When printing variables, all existing variables including global variables are printed if this option is specified\&. Without this option, only local variables are printed\&. .RE .PP \fB\-p\fR, \fB\-\-print\fR .RS 4 Print variables or functions in a form that can be parsed and executed as commands that will restore the currently set variables or functions\&. .RE .PP \fB\-r\fR, \fB\-\-readonly\fR .RS 4 When setting variables or functions, make them read\-only\&. .sp When printing variables or functions, print read\-only variables or functions only\&. .RE .PP \fB\-x\fR, \fB\-\-export\fR .RS 4 When setting variables, mark them for export, so that they will be exported to external commands\&. .sp When printing variables, print exported variables only\&. .RE .PP \fB\-X\fR, \fB\-\-unexport\fR .RS 4 When setting variables, cancel exportation of the variables\&. .RE .SS "Operands" .PP \fIvariable\fR (without \fIvalue\fR) .RS 4 The name of a variable that is to be set or printed\&. .sp Without the \fB\-p\fR (\fB\-\-print\fR) option, the variable is defined (if not yet defined) but its value is not set nor changed\&. Variables that are defined without values are treated as unset in parameter expansion\&. .RE .PP \fIvariable\fR=\fIvalue\fR .RS 4 The name of a variable and its new value\&. .sp The value is assigned to the variable (regardless of the \fB\-p\fR (\fB\-\-print\fR) option)\&. .RE .PP \fIfunction\fR .RS 4 The name of an existing function that is to be set or printed\&. .RE .SS "Exit status" .sp The exit status of the typeset built\-in is zero unless there is any error\&. .SS "Notes" .sp A global variable cannot be newly defined if a local variable has already been defined with the same name\&. The local variable will be set regardless of the \fB\-g\fR (\fB\-\-global\fR) option\&. .sp The POSIX standard does not define the typeset built\-in\&. .sp The export and readonly built\-ins are equivalent to the typeset built\-in with the \fB\-gx\fR and \fB\-gr\fR options, respectively\&. .SH "ULIMIT BUILT-IN" .sp The \fIulimit built\-in\fR sets or prints a resource limit\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBulimit \-a [\-H|\-S]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBulimit [\-H|\-S] [\-efilnqrstuvx] [\fR\fB\fIlimit\fR\fR\fB]\fR .RE .SS "Description" .sp The ulimit built\-in sets or prints a resource limit\&. .sp If executed with the \fB\-a\fR (\fB\-\-all\fR) option, the built\-in prints the current limits for all resource types\&. Otherwise, it sets or prints the limit of a single resource type\&. The resource type can be specified by the options listed below\&. The resource limits will affect the current shell process and all commands invoked from the shell\&. .sp Each resource type has two limit values: the hard and soft limit\&. You can change a soft limit freely as long as it does not exceed the hard limit\&. You can decrease a hard limit but cannot increase it without a proper permission\&. .sp When the \fB\-H\fR (\fB\-\-hard\fR) or \fB\-S\fR (\fB\-\-soft\fR) option is specified, the built\-in sets or prints the hard or soft limit, respectively\&. If neither of the options is specified, the built\-in sets both the hard and soft limit or prints the soft limit\&. .SS "Options" .PP \fB\-H\fR, \fB\-\-hard\fR .RS 4 Set or print a hard limit\&. .RE .PP \fB\-S\fR, \fB\-\-soft\fR .RS 4 Set or print a soft limit\&. .RE .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 Print all current limit settings\&. .RE .sp The following options specify the type of resources\&. If none of them is specified, \fB\-f\fR is the default\&. The types of resources that can be set depend on the operating system\&. .PP \fB\-c\fR, \fB\-\-core\fR .RS 4 Maximum size of core files created (in 512\-byte blocks) .RE .PP \fB\-d\fR, \fB\-\-data\fR .RS 4 Maximum size of a process\(cqs data segment (in kilobytes) .RE .PP \fB\-e\fR, \fB\-\-nice\fR .RS 4 Maximum scheduling priority (\(oqnice\(cq) .RE .PP \fB\-f\fR, \fB\-\-fsize\fR .RS 4 Maximum size of files created by a process (in 512\-byte blocks) .RE .PP \fB\-i\fR, \fB\-\-sigpending\fR .RS 4 Maximum number of pending signals .RE .PP \fB\-l\fR, \fB\-\-memlock\fR .RS 4 Maximum memory size that can be locked into RAM (in kilobytes) .RE .PP \fB\-m\fR, \fB\-\-rss\fR .RS 4 Maximum size of a process\(cqs resident set (in kilobytes) .RE .PP \fB\-n\fR, \fB\-\-nofile\fR .RS 4 Maximum file descriptor + 1 .RE .PP \fB\-q\fR, \fB\-\-msgqueue\fR .RS 4 Maximum size of POSIX message queues .RE .PP \fB\-r\fR, \fB\-\-rtprio\fR .RS 4 Maximum real\-time scheduling priority .RE .PP \fB\-s\fR, \fB\-\-stack\fR .RS 4 Maximum size of a process\(cqs stack (in kilobytes) .RE .PP \fB\-t\fR, \fB\-\-cpu\fR .RS 4 Maximum CPU time that can be used by a process (in seconds) .RE .PP \fB\-u\fR, \fB\-\-nproc\fR .RS 4 Maximum number of processes for a user .RE .PP \fB\-v\fR, \fB\-\-as\fR .RS 4 Maximum size of memory used by a process (in kilobytes) .RE .PP \fB\-x\fR, \fB\-\-locks\fR .RS 4 Maximum number of file locks .RE .SS "Operands" .PP \fIlimit\fR .RS 4 A limit to be set\&. .sp The value must be a non\-negative integer or one of \fBhard\fR, \fBsoft\fR, and \fBunlimited\fR\&. If \fIvalue\fR is \fBhard\fR or \fBsoft\fR, the new limit is set to the current hard or soft limit\&. If \fIlimit\fR is not specified, the current limit is printed\&. .RE .SS "Exit status" .sp The exit status of the ulimit built\-in is zero unless there is any error\&. .SS "Notes" .sp The POSIX standard defines no options other than \fB\-f\fR\&. It neither defines \fBhard\fR, \fBsoft\fR, or \fBunlimited\fR for \fIlimit\fR values\&. .SH "UMASK BUILT-IN" .sp The \fIumask built\-in\fR sets or prints the file mode creation mask\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBumask \fR\fB\fImask\fR\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBumask [\-S]\fR .RE .SS "Description" .sp If executed without the \fImask\fR operand, the built\-in prints the current file mode creation mask of the shell to the standard output in a form that can later be used as \fImask\fR to restore the current mask\&. .sp Otherwise, the built\-in sets the file mode creation mask to \fImask\fR\&. .SS "Options" .PP \fB\-S\fR, \fB\-\-symbolic\fR .RS 4 Print in the symbolic form instead of the octal integer form\&. .RE .SS "Operands" .PP \fImask\fR .RS 4 The new file mode creation mask either in the symbolic or octal integer form\&. .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBOctal integer form\fR .RS 4 .sp In the octal integer form, the mask is specified as a non\-negative octal integer that is the sum of the following permissions: .PP 0400 .RS 4 read by owner .RE .PP 0200 .RS 4 write by owner .RE .PP 0100 .RS 4 execute/search by owner .RE .PP 0040 .RS 4 read by group .RE .PP 0020 .RS 4 write by group .RE .PP 0010 .RS 4 execute/search by group .RE .PP 0004 .RS 4 read by others .RE .PP 0002 .RS 4 write by others .RE .PP 0001 .RS 4 execute/search by others .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBSymbolic form\fR .RS 4 .sp In the symbolic form, the mask is specified as a symbolic expression that denotes permissions that are \fBnot\fR included in the mask\&. .sp The entire expression is one or more \fIclause\fRs separated by comma\&. A \fIclause\fR is a sequence of \fIwho\fRs followed by one or more \fIaction\fRs\&. .sp A \fIwho\fR is one of: .PP \fBu\fR .RS 4 owner .RE .PP \fBg\fR .RS 4 group .RE .PP \fBo\fR .RS 4 others .RE .PP \fBa\fR .RS 4 all of owner, group, and others .RE .sp An empty sequence of \fIwho\fRs is equivalent to who \fBa\fR\&. .sp An \fIaction\fR is an \fIoperator\fR followed by \fIpermission\fR\&. An \fIoperator\fR is one of: .PP \fB=\fR .RS 4 set \fIwho\fR\*(Aqs permission to \fIpermission\fR .RE .PP \fB+\fR .RS 4 add \fIpermission\fR to \fIwho\fR\*(Aqs permission .RE .PP \fB\-\fR .RS 4 remove \fIpermission\fR from \fIwho\fR\*(Aqs permission .RE .sp and \fIpermission\fR is one of: .PP \fBr\fR .RS 4 read .RE .PP \fBw\fR .RS 4 write .RE .PP \fBx\fR .RS 4 execute/search .RE .PP \fBX\fR .RS 4 execute/search (only if some user already has execute/search permission) .RE .PP \fBs\fR .RS 4 set\-user\-ID and set\-group\-ID .RE .PP \fBu\fR .RS 4 user\(cqs current permissions .RE .PP \fBg\fR .RS 4 group\(cqs current permissions .RE .PP \fBo\fR .RS 4 others\*(Aq current permissions .RE .sp but more than one of \fBr\fR, \fBw\fR, \fBx\fR, \fBX\fR, and \fBs\fR can be specified after a single \fIoperand\fR\&. .sp For example, the command \fBumask u=rwx,go+r\-w\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} unmasks the user\(cqs read, write, and execute/search permissions; .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} unmasks the group\(cqs and others\*(Aq read permission; and .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} masks the group\(cqs and others\*(Aq write permission\&. .RE .RE .SS "Exit status" .sp The exit status of the umask built\-in is zero unless there is any error\&. .SS "Notes" .sp The umask built\-in is a semi\-special built\-in\&. .sp The POSIX standard does not require the default output format (used when the \fB\-S\fR option is not specified) to be the octal integer form\&. .SH "UNALIAS BUILT-IN" .sp The \fIunalias built\-in\fR undefines aliases\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBunalias \fR\fB\fIname\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBunalias \-a\fR .RE .SS "Description" .sp The unalias built\-in removes the definition of the aliases specified by operands\&. .SS "Options" .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 Undefine all aliases\&. .RE .SS "Operands" .PP \fIname\fR .RS 4 The name of an alias to be undefined\&. .RE .SS "Exit status" .sp The exit status of the unalias built\-in is zero unless there is any error\&. It is an error to specify the name of a non\-existing alias as \fIname\fR\&. .SS "Notes" .sp The unalias built\-in is a semi\-special built\-in\&. .SH "UNSET BUILT-IN" .sp The \fIunset built\-in\fR undefines variables or functions\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBunset [\-fv] [\fR\fB\fIname\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The unset built\-in removes the definition of the variables or functions specified by operands\&. .sp It is not an error if any of the specified variables or functions do not exist; they are silently ignored\&. .SS "Options" .PP \fB\-f\fR, \fB\-\-functions\fR .RS 4 Undefine functions\&. .RE .PP \fB\-v\fR, \fB\-\-variables\fR .RS 4 Undefine variables\&. .RE .sp These options are mutually exclusive: only the last specified one is effective\&. If neither is specified, \fB\-v\fR is assumed\&. .SS "Operands" .PP \fIname\fR .RS 4 The name of a variable or function to be undefined\&. .RE .SS "Exit status" .sp The exit status of the unset built\-in is zero unless there is any error\&. .SS "Notes" .sp The unset built\-in is a special built\-in\&. .sp Although yash does not do so, the POSIX standard allows removing a function if neither of the \fB\-f\fR and \fB\-v\fR options is specified and the specified variable does not exist\&. .sp At least one \fIname\fR operand must be specified in the POSIXly\-correct mode\&. .SH "WAIT BUILT-IN" .sp The \fIwait built\-in\fR waits for jobs to terminate\&. .SS "Syntax" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBwait [\fR\fB\fIjob\fR\fR\fB\&...]\fR .RE .SS "Description" .sp The wait built\-in waits for background jobs to terminate\&. If job control is enabled, stopped jobs are considered as terminated\&. .sp The built\-in can be used to wait for asynchronous commands if job control is disabled\&. .sp If the shell receives a signal while the built\-in is waiting and if a trap has been set for the signal, then the trap is executed and the built\-in immediately finishes (without waiting for the jobs)\&. If the shell receives a SIGINT signal when job control is enabled, the built\-in aborts waiting\&. .SS "Operands" .PP \fIjob\fR .RS 4 The job ID of the job or the process ID of a process in the job\&. .RE .sp If no \fIjob\fRs are specified, the built\-in waits for all existing jobs\&. .sp If the specified job does not exist, the job is considered to have terminated with the exit status of 127\&. .SS "Exit status" .sp If no \fIjob\fRs were specified and the built\-in successfully waited for all the jobs, the exit status is zero\&. If one or more \fIjob\fRs were specified, the exit status is that of the last \fIjob\fR\&. .sp If the built\-in was aborted by a signal, the exit status is an integer (> 128) that denotes the signal\&. If there was any other error, the exit status is between 1 and 126 (inclusive)\&. .SS "Notes" .sp The wait built\-in is a semi\-special built\-in\&. .sp The process ID of the last process of a job can be obtained by the \fB!\fR special parameter\&. You can use the jobs built\-in as well to obtain process IDs of job processes\&. .SH "AUTHOR" .PP \fBYuki Watanabe\fR <\&magicant@users\&.sourceforge\&.jp\&> .RS 4 Author. .RE yash-2.35/doc/_jobs.txt0000644000175000017500000000340112154557026015146 0ustar magicantmagicant= Jobs built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Jobs built-in The dfn:[jobs built-in] reports job status. [[syntax]] == Syntax - +jobs [-lnprs] [{{job}}...]+ [[description]] == Description The jobs built-in prints information of link:job.html[jobs] the shell is currently controlling. By default, the following information is printed for each job, line by line: - the job number, - the +++ or +-+ symbol if the job is the current or previous job, respectively, - the status, and - the command string. [[options]] == Options +-l+:: +--verbose+:: Print the process ID, status, and command string for each process in the jobs. +-n+:: +--new+:: Print new jobs only: jobs whose status has never been reported since the status changed. +-p+:: +--pgid-only+:: Print process group IDs of jobs only. +-r+:: +--running-only+:: Print running jobs only. +-s+:: +--stopped-only+:: Print stopped jobs only. [[operands]] == Operands {{job}}s:: The link:job.html#jobid[job IDs] of jobs to be reported. When no {{job}} is specified, all jobs under the shell's control are reported. [[exitstatus]] == Exit status The exit status of the jobs built-in is zero unless there is any error. [[notes]] == Notes The jobs built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard defines the +-l+ and +-p+ options only: other options cannot be used in the link:posix.html[POSIXly-correct mode]. In the POSIXly-correct mode, the effect of the +-l+ option is different in that status is reported for each job rather than for each process. The process group ID of a job executed by yash is equal to the process ID of the first command of the link:syntax.html#pipelines[pipeline] that forms the job. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_getopts.html0000644000175000017500000001341612154557026016032 0ustar magicantmagicant Getopts built-in

The getopts built-in parses command options.

Syntax

  • getopts optionlist variable [argument…]

Description

The getopts built-in parses single-character options that appear in arguments. Each time the built-in is invoked, it parses one option and assigns the option character to variable.

The optionlist operand is a list of option characters that should be accepted by the parser. In optionlist, an option that takes an argument should be specified as the option character followed by a colon. For example, if you want the -a, -b and -c options to be parsed and the -b option to take an argument, then optionlist should be ab:c.

When an option that takes an argument is parsed, the argument is assigned to the OPTARG variable.

When an option that is not specified in optionlist is found or when an option argument is missing, the result depends on the first character of optionlist:

  • If optionlist starts with a colon, the option character is assigned to the OPTARG variable and variable is set to either ? (when the option is not in optionlist) or : (when the option argument is missing).

  • Otherwise, variable is set to ?, the OPTARG variable is unset, and an error message is printed.

The built-in parses one option for each execution. For all options in a set of command line arguments to be parsed, the built-in has to be executed repeatedly with the same arguments. The built-in uses the OPTIND variable to remember which argument should be parsed next. When the built-in is invoked for the first time, the variable value must be 1, which is the default value. You must not modify the variable until all the options have been parsed, when the built-in sets the variable to the index of the first operand in arguments. (If there are no operands, it will be set to the number of arguments plus one.)

When you want to start parsing a new set of arguments, you have to reset the OPTIND variable to 1 beforehand.

Operands

optionlist

A list of options that should be accepted as valid options in parsing.

variable

The name of a variable the result is to be assigned to.

arguments

Command line arguments that are to be parsed.

When no arguments are given, the positional parameters are parsed.

Exit status

If an option is found, whether or not it is specified in optionlist, the exit status is zero. If there is no more option to be parsed, the exit status is non-zero.

Example

aopt=false bopt= copt=false
while getopts ab:c opt
do
  case $opt in
  a) aopt=true ;;
  b) bopt=$OPTARG ;;
  c) copt=true ;;
  \?) return 2 ;;
  esac
done
if $aopt;          then echo Option -a specified;       fi
if [ -n "$bopt" ]; then echo Option -b $bopt specified; fi
if $copt;          then echo Option -c specified;       fi
shift $((OPTIND - 1))
echo Operands are: $*

Notes

In arguments that are parsed, options must precede operands. The built-in ends parsing when it encounters the first operand.

The getopts built-in is a semi-special built-in.

The POSIX standard does not specify what will happen when the OPTIND variable is assigned a value other than 1.

yash-2.35/doc/_kill.txt0000644000175000017500000000656512154557026015162 0ustar magicantmagicant= Kill built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Kill built-in The dfn:[kill built-in] sends a signal to processes. [[syntax]] == Syntax - +kill [-{{signal}}|-s {{signal}}|-n {{signal}}] {{process}}...+ - +kill -l [-v] [{{signal}}...]+ The kill built-in requires that all options precede operands. Any command line arguments after the first operand are all treated as operands. [[description]] == Description When executed without the +-l+ option, the built-in sends a signal to processes. The signal sent can be specified by option. The SIGTERM signal is sent if no signal is specified. When executed with the +-l+ option, the built-in prints information of {{signal}}s to the standard output. If no {{signal}} is specified, information of all signals is printed. [[options]] == Options === Signal-specifying options +-{{signal}}+:: +-s {{signal}}+:: +-n {{signal}}+:: A signal-specifying option specifies a signal to be sent to processes. {{signal}} can be specified by name or number. If number +0+ is specified, the built-in checks if a signal could be sent to the processes but no signal is actually sent. Signal names are case-insensitive. You can specify at most one signal-specifying option at a time. === Other options +-l+:: Print signal information instead of sending a signal. +-v+:: Print more signal information. + Without this option, the built-in prints the signal name only. This option adds the signal number and a short description. + When the +-v+ option is specified, the +-l+ option can be omitted. [[operands]] == Operands {{process}}es:: Specify processes to which a signal is sent. + Processes can be specified by the process ID, the process group ID, or the link:job.html#jobid[job ID]. The process group ID must be prefixed with a hyphen (+-+) so that it is not treated as a process ID. + When +0+ is specified as {{process}}, the signal is sent to the process group to which the shell process belongs. When +-1+ is specified, the signal is sent to all processes on the system. {{signal}}:: Specify a signal of which information is printed. + The signal can be specified by the name, the number, or the exit status of a command that was killed by the signal. [[exitstatus]] == Exit status The exit status of the kill built-in is zero unless there is any error. If the signal was sent to at least one process, the exit status is zero even if the signal was not sent to all of the specified processes. [[notes]] == Notes The kill built-in is a link:builtin.html#types[semi-special built-in]. Command arguments that start with a hyphen should be used with care. The command +kill -1 -2+, for example, sends signal 1 to process group 2 since +-1+ is treated as a signal-specifying option and +-2+ as an operand that specifies a process group. The commands `kill -- -1 -2` and +kill -TERM -1 -2+, on the other hand, treats both +-1+ and +-2+ as operands. The POSIX standard does not define the +-n+ or +-v+ options, so they cannot be used in the link:posix.html[POSIXly-correct mode]. The standard does not allow specifying a signal number as the argument of the +-s+ option or a signal name as the {{signal}} operand. The standard requires signal names to be specified without the +SIG+ prefix, like +INT+ and +QUIT+. If the shell is not in the POSIXly-correct mode, the built-in accepts +SIG+-prefixed signal names as well. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_unalias.txt0000644000175000017500000000150012154557026015643 0ustar magicantmagicant= Unalias built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Unalias built-in The dfn:[unalias built-in] undefines link:syntax.html#aliases[aliases]. [[syntax]] == Syntax - +unalias {{name}}...+ - +unalias -a+ [[description]] == Description The unalias built-in removes the definition of the link:syntax.html#aliases[aliases] specified by operands. [[options]] == Options +-a+:: +--all+:: Undefine all aliases. [[operands]] == Operands {{name}}:: The name of an alias to be undefined. [[exitstatus]] == Exit status The exit status of the unalias built-in is zero unless there is any error. It is an error to specify the name of a non-existing alias as {{name}}. [[notes]] == Notes The unalias built-in is a link:builtin.html#types[semi-special built-in]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/params.txt0000644000175000017500000004177212154557026015352 0ustar magicantmagicant= Parameters and variables :encoding: UTF-8 :lang: en //:title: Yash manual - Parameters and variables :description: This page describes parameters and variables supported by yash. dfn:[Parameters] are string values that are expanded in link:expand.html[parameter expansion]. There are three types of parameters: <>, <> and <>. [[positional]] == Positional parameters dfn:[Positional parameters] are parameters that are identified by natural numbers. If there are three positional parameters, for example, they are identified as +1+, +2+, and +3+. You can obtain the number of positional parameters by <>. The +*+ and +@+ special parameters are expanded to all positional parameters. Positional parameters are initialized from the shell's command line arguments when the shell is started (see link:invoke.html#arguments[Command line arguments]). In the initialization, the order of the operands are preserved as the order of the positional parameters. When the shell executes a link:exec.html#function[function] call, positional parameters are changed to the arguments to the function call so that you can access the arguments while the function is being executed. Positional parameters are restored to the original values when the execution of the function is finished. Positional parameters can be manipulated by built-in commands like link:_set.html[set] and link:_shift.html[shift]. Note that +0+ is not a positional parameter but a special parameter. [[special]] == Special parameters dfn:[Special parameters] are parameters each identified by a single symbol. They cannot be directly assigned to by the user. Yash provides the following special parameters: [[sp-zero]]+0+:: The name of the shell executable file or the script file that was specified in the invocation of the shell. [[sp-hash]]+#+:: The number of current positional parameters. The value is a non-negative integer. [[sp-dollar]]+$+:: The process ID of the shell. The value is a positive integer and is never changed even in subshells. [[sp-hyphen]]+-+:: Currently enabled shell options. The value is a concatenation of alphabet characters that are the names of currently enabled single-character options that can be specified in shell invocation. The value reflects changes of enabled options when you enable or disable options using the link:_set.html[set built-in]. [[sp-question]]+?+:: The exit status of the last executed link:syntax.html#pipelines[pipeline]. The value is a non-negative integer. [[sp-exclamation]]+!+:: The process ID of the last executed link:syntax.html#async[asynchronous list]. [[sp-asterisk]]+*+:: This special parameter represents the whole <>. When there is no positional parameters, the value of this special parameter is the empty string. When there is more than one positional parameter, the value is a concatenation of all the positional parameters, each of which is separated as follows: + - If the <> variable exists and its value is not empty, positional parameters are each separated by the first character of the value of the +IFS+ variable. - If the +IFS+ variable exists and has an empty value, positional parameters are just concatenated without any separator. - If the +IFS+ variable does not exist, positional parameters are each separated by a space character. [[sp-at]]+@+:: This special parameter represents the whole <> like the +*+ special parameter above. The difference between the two is the results of expansion that occurs between a pair of link:syntax.html#quotes[double-quotation marks]. If the +@+ special parameter is expanded inside double-quotations, positional parameters are link:expand.html#split[field-split] rather than concatenated (in spite of the quotation). If there are no positional parameters, the expansion yields no word rather than an empty word. + -- - When there are no positional parameters, the command words +echo 1 "$@" 2+ is expanded to the three words +echo+, +1+, and +2+. - When positional parameters are the three words +1+, +2 2+, and +3+, the command words +echo "$@"+ is expanded to the four words +echo+, +1+, +2 2+, and +3+, and the words +echo "a$@b"+ to the four words +echo+, +a1+, +2 2+, and +3b+. -- [[variables]] == Variables dfn:[Variables] are parameters the user can assign values to. Each variable has a name that identifies it and a value that defines the results of expansion. A variable name is composed of one or more alphanumeric characters and underscores (+_+). A name cannot start with a digit. Other characters may be used in a name depending on internationalization support of your environment. Variables that are exported to external commands are called dfn:[environment variables]. They are passed to all external commands the shell invokes. Variables passed to the shell in invocation will be automatically exported. You can assign to variables by a link:syntax.html#simple[simple command] as well as the link:_typeset.html[typeset built-in]. You can remove variables by using the link:_unset.html[unset built-in]. [[shellvars]] === Variables used by the shell The following variables are used by the shell for special purposes. [[sv-cdpath]]+CDPATH+:: This variable is used by the cd built-in to find a destination directory. [[sv-columns]]+COLUMNS+:: This variable specifies the width (the number of character columns) of the terminal screen. The value affects the display of link:lineedit.html[line-editing]. [[sv-command_not_found_handler]]+COMMAND_NOT_FOUND_HANDLER+:: When the shell cannot find a command to be executed, the value of this variable is interpreted and executed instead. You can override the shell's error handling behavior with this variable. See link:exec.html#simple[Execution of simple commands] for detail. + This feature is disabled in the link:posix.html[POSIXly-correct mode]. [[sv-dirstack]]+DIRSTACK+:: This array variable is used by the shell to store the directory stack contents. If you modify the value of this variable, the directory stack may be corrupted. [[sv-echo_style]]+ECHO_STYLE+:: This variable specifies the behavior of the link:_echo.html[echo built-in]. [[sv-env]]+ENV+:: When an link:interact.html[interactive] shell is started in the link:posix.html[POSIXly-correct mode], the value of this variable is used to find the initialization file. See link:invoke.html#init[Initialization of yash]. [[sv-fcedit]]+FCEDIT+:: This variable specifies an editor program used to edit command lines during execution of the link:_fc.html[fc built-in]. [[sv-handled]]+HANDLED+:: This variable can be set in the <> to tell the shell not to produce a further error message. See link:exec.html#simple[Execution of simple commands] for detail. [[sv-histfile]]+HISTFILE+:: This variable specifies the pathname of the file to save the link:interact.html#history[command history] in. [[sv-histrmdup]]+HISTRMDUP+:: This variable specifies the number of link:interact.html#history[command history] items to be checked for duplication. When the shell is adding a new history item to the command history, if some of the most recent {{n}} items have the same contents as the new one, then the duplicate existing items are removed from the history before the new one is added, where {{n}} is the value of this variable. + If the value of this variable is +1+, for example, the most recent item is removed when a new item that have the same contents is added. + Items older than the {{n}}th recent item are not removed. No items are removed if the value of this variable is +0+. All items are subject to removal if the variable value is greater than or equal to the value of the <>. [[sv-histsize]]+HISTSIZE+:: This variable specifies the maximum number of items in the link:interact.html#history[command history]. [[sv-home]]+HOME+:: This variable specifies the pathname of the user's home directory and affects results of link:expand.html#tilde[tilde expansion] and link:_cd.html[cd built-in]. [[sv-ifs]]+IFS+:: This variable specifies separators used in link:expand.html#split[field splitting]. The variable value is initialized to the three characters of a space, a tab, and a newline when the shell is started. [[sv-lang]]+LANG+:: [[sv-lc_all]]+LC_ALL+:: [[sv-lc_collate]]+LC_COLLATE+:: [[sv-lc_ctype]]+LC_CTYPE+:: [[sv-lc_messages]]+LC_MESSAGES+:: [[sv-lc_monetary]]+LC_MONETARY+:: [[sv-lc_numeric]]+LC_NUMERIC+:: [[sv-lc_time]]+LC_TIME+:: These variables specify a locale in which the shell runs. The shell chooses the file input/output encoding, the error message language, etc. according to the locale specified. + Unless the shell is link:interact.html[interactive] and not in the link:posix.html[POSIXly-correct mode], the value of the +LC_CTYPE+ variable is considered only when the shell is started. Once the shell has been initialized, changing the value of +LC_CTYPE+ will have no effect on the shell's behavior. [[sv-lineno]]+LINENO+:: The value of this variable is automatically set to the line number in which the currently executed command appears in the file. + In the link:interact.html[interactive shell], the line number is reset to 1 each time the shell reads and executes a command. + If you assign to or remove this variable, it will no longer provide line numbers. [[sv-lines]]+LINES+:: This variable specifies the height (the number of character lines) of the terminal screen. The value affects the display of link:lineedit.html[line-editing]. [[sv-mail]]+MAIL+:: This variable specifies the pathname of a file that is checked in link:interact.html#mailcheck[mail checking]. [[sv-mailcheck]]+MAILCHECK+:: This variable specifies how often the shell should do link:interact.html#mailcheck[mail checking]. The value has to be specified as a positive integer in seconds. The value is initialized to the default value of +600+ when the shell is started. [[sv-mailpath]]+MAILPATH+:: This variable specifies the pathnames of files that are checked in link:interact.html#mailcheck[mail checking]. [[sv-nlspath]]+NLSPATH+:: The POSIX standard prescribes that the value of this variable specifies pathname templates of locale-dependent message data files, but yash does not use it. [[sv-oldpwd]]+OLDPWD+:: This variable is set to the previous working directory path when you change the working directory by using the link:_cd.html[cd] or other built-ins. This variable is exported by default. [[sv-optarg]]+OPTARG+:: When the link:_getopts.html[getopts built-in] parses an option that takes an argument, the argument value is assigned to this variable. [[sv-optind]]+OPTIND+:: The value of this variable specifies the index of an option that is to be parsed by the next link:_getopts.html[getopts built-in] execution. This variable is initialized to +1+ when the shell is started. [[sv-path]]+PATH+:: This variable specifies paths that are searched for a command in link:exec.html#search[command search]. [[sv-ppid]]+PPID+:: The value of this variable is the process ID of the shell's parent process, which is a positive integer. This variable is initialized when the shell is started. The value is not changed when the shell makes a new link:exec.html#subshell[subshell]. [[sv-prompt_command]]+PROMPT_COMMAND+:: The shell interprets and executes the value of this variable before printing each command prompt if the shell is link:interact.html[interactive] and not in the link:posix.html[POSIXly-correct mode]. This behavior is equivalent to executing the command ifdef::basebackend-html[] pass:[eval -i -- "${PROMPT_COMMAND-}"] endif::basebackend-html[] ifndef::basebackend-html[`eval -i -- "${PROMPT_COMMAND-}"`] before each command prompt, but its exit status does not affect the expansion of the +?+ special parameter in the next command. [[sv-ps1]]+PS1+:: This variable specifies the main command prompt string printed by an link:interact.html[interactive] shell. See link:interact.html#prompt[Prompts] for the format of the variable value. The value is initialized to +\$ + when the shell is started. (In the link:posix.html[POSIXly-correct mode], the initial value is either +$ + or +# + depending on whether the effective user ID of the shell process is zero or not.) [[sv-ps1r]]+PS1R+:: This variable specifies the auxiliary prompt string printed to the right of the cursor when you input a command line to an link:interact.html[interactive] shell. See link:interact.html#prompt[Prompts] for the format of the variable value. [[sv-ps1s]]+PS1S+:: This variable specifies the font style of command strings you enter to an link:interact.html[interactive] shell. See link:interact.html#prompt[Prompts] for the format of the variable value. [[sv-ps2]]+PS2+:: This variable is like the <> variable, but it is used for the second and following lines of a command that is longer than one line. See link:interact.html#prompt[Prompts] for the format of the variable value. The value is initialized to +> + when the shell is started. [[sv-ps2r]]+PS2R+:: This variable is like the <> variable, but it is used when <> is used. See link:interact.html#prompt[Prompts] for the format of the variable value. [[sv-ps2s]]+PS2S+:: This variable is like the <> variable, but it is used when <> is used. See link:interact.html#prompt[Prompts] for the format of the variable value. [[sv-ps4]]+PS4+:: The value of this variable is printed before each command trace output when the link:_set.html#so-xtrace[xtrace option] is enabled. The value is subject to link:expand.html#params[parameter expansion], link:expand.html#cmdsub[command substitution], link:expand.html#arith[arithmetic expansion]. You can also use backslash notations if the shell is not in the link:posix.html[POSIXly-correct mode]. The value is initialized to ++ + when the shell is started. [[sv-ps4s]]+PS4S+:: This variable is like the <> variable, but it is used when <> is used. You can use this variable to modify font style of command trace output. [[sv-pwd]]+PWD+:: The value of this variable is the pathname of the current working directory. The value is set when the shell is started and reset each time the working directory is changed by the link:_cd.html[cd] or other built-ins. This variable is exported by default. [[sv-random]]+RANDOM+:: You can use this variable to get random numbers. The value of this variable is a uniformly distributed random integer between 0 and 32767 (inclusive). You will get a different number each time the variable is expanded. + You can set the ``seed'' of random numbers by assigning a non-negative integer to the variable. + If you remove this variable, it will no longer work as a random number generator. If the shell was invoked in the link:posix.html[POSIXly-correct mode], this variable does not work as a random number generator. [[sv-term]]+TERM+:: This variable specifies the type of the terminal in which the shell is running. The value affects the behavior of link:lineedit.html[line-editing]. [[sv-yash_after_cd]]+YASH_AFTER_CD+:: The shell interprets and executes the value of this variable after each time the shell's working directory is changed by the link:_cd.html[cd] or other built-ins. This behavior is equivalent to executing the command ifdef::basebackend-html[] pass:[eval -i -- "${YASH_AFTER_CD-}"] endif::basebackend-html[] ifndef::basebackend-html[`eval -i -- "${YASH_AFTER_CD-}"`] after the directory was changed. [[sv-yash_loadpath]]+YASH_LOADPATH+:: This variable specifies directories the dot built-in searches for a script file. More than one directory can be specified by separating them by colons like the <> variable. When the shell is started, this variable is initialized to the pathname of the directory where common script files are installed. [[sv-yash_le_timeout]]+YASH_LE_TIMEOUT+:: This variable specifies how long the shell should wait for a next possible input from the terminal when it encountered an ambiguous control sequence while link:lineedit.html[line-editing]. The value must be specified in milliseconds. If you do not define this variable, the default value of 100 milliseconds is assumed. [[sv-yash_version]]+YASH_VERSION+:: The value is initialized to the version number of the shell when the shell is started. [[arrays]] === Arrays An dfn:[array] is a variable that contains zero or more strings. The string values of an array are identified by natural numbers (like <>). You can assign values to an array by using a link:syntax.html#simple[simple command] as well as the link:_array.html[array built-in]. You can use the link:_unset.html[unset built-in] to remove arrays. Arrays cannot be exported as arrays. When an array is exported, it is treated as a normal variable whose value is a concatenation of all the array values, each separated by a colon. Arrays are not supported in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_false.txt0000644000175000017500000000077412154557026015315 0ustar magicantmagicant= False built-in :encoding: UTF-8 :lang: en //:title: Yash manual - False built-in The dfn:[false built-in] does nothing unsuccessfully. [[syntax]] == Syntax - +false+ [[description]] == Description The false built-in does nothing. Any command line arguments are ignored. [[exitstatus]] == Exit status The exit status of the false built-in is non-zero. [[notes]] == Notes The false built-in is a link:builtin.html#types[semi-special built-in]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_return.txt0000644000175000017500000000404212154557026015532 0ustar magicantmagicant= Return built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Return built-in The dfn:[return built-in] returns from a function or script. [[syntax]] == Syntax - +return [-n] [{{exit_status}}]+ [[description]] == Description When executed without the +-n+ (+--no-return+) option, one of the following happens: - If the shell is executing a link:exec.html#function[function], the execution of the function is terminated. - If the link:_dot.html[dot built-in] is executing a script, the execution of the script is terminated. - If the link:_eval.html[eval built-in] is executing a command string, the execution of the command is terminated. - Otherwise, the shell exits unless it is link:interact.html[interactive]. When executed with the +-n+ (+--no-return+) option, the built-in does nothing but return the specified {{exit_status}}. [[options]] == Options +-n+:: +--no-return+:: Do not terminate a function, script, evaluated command, or the shell. [[operands]] == Operands {{exit_status}}:: The exit status of the built-in. + The value must be a non-negative integer. + If omitted, the exit status of the last executed command is used. (But when the shell is executing a link:_trap.html[trap], the exit status of the last command before the trap is used.) [[exitstatus]] == Exit status The exit status of the return built-in is defined by the {{exit_status}} operand. The exit status is used also as the exit status of the terminated function, script, evaluated script, or the shell. [[notes]] == Notes The return built-in is a link:builtin.html#types[special built-in]. The POSIX standard provides that the {{exit_status}} operand should be between 0 and 255 (inclusive). Yash accepts integers larger than 255 as an extension. In the POSIX standard, the behavior of the return built-in is defined only when the shell is executing a function or script. The POSIX standard defines no options for the return built-in; the built-in accepts no options in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_cd.txt0000644000175000017500000000644112154557026014606 0ustar magicantmagicant= Cd built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Cd built-in The dfn:[cd built-in] changes the working directory. [[syntax]] == Syntax - +cd [-L|-P] [{{directory}}]+ [[description]] == Description The cd built-in changes the working directory to the directory specified by the operand. The pathname of the new working directory is assigned to the link:params.html#sv-pwd[+PWD+ variable], whose previous value is again assigned to the link:params.html#sv-oldpwd[+OLDPWD+ variable]. If {{directory}} is a relative path that does not start with `.' or `..', paths in the link:params.html#sv-cdpath[+CDPATH+ variable] are searched to find a new working directory. The search is done in a manner similar to the last step of link:exec.html#search[command search], but a directory is sought instead of an executable regular file. If a new working directory was found from +CDPATH+, its pathname is printed to the standard output. If no applicable directory was found in the search, {{directory}} is simply treated as a pathname relative to the current working directory. If the working directory was successfully changed, the value of the link:params.html#sv-yash_after_cd[+YASH_AFTER_CD+ variable] is executed as a command unless the shell is in the link:posix.html[POSIXly-correct mode]. If the variable is an link:params.html#arrays[array], its values are executed iteratively (cf. link:_eval.html#iter[eval built-in]). [[options]] == Options +-L+:: +--logical+:: Symbolic links in the pathname of the new working directory are not resolved. The new value of the +PWD+ may include pathname components that are symbolic links. +-P+:: +--physical+:: Symbolic links in the pathname of the new working directory are resolved. The new value of the +PWD+ variable never includes pathname components that are symbolic links. +--default-directory={{directory}}+:: If this option is specified and the {{directory}} operand is omitted, the argument to this option is used for the {{directory}} operand. If the {{directory}} operand is specified, this option is ignored. The +-L+ (+--logical+) and +-P+ (+--physical+) options are mutually exclusive: only the last specified one is effective. If neither is specified, +-L+ is assumed. [[operands]] == Operands {{directory}}:: The pathname of the new working directory. + If {{directory}} is a single hyphen (`-'), the value of the link:params.html#sv-oldpwd[+OLDPWD+ variable] is assumed for the new directory pathname, which is printed to the standard output. + If {{directory}} is omitted, the working directory is changed to the directory specified by the +--default-directory=...+ option. If that option is not specified either, the default is the link:params.html#sv-home[home directory]. [[exitstatus]] == Exit status The exit status of the cd built-in is zero if the working directory was successfully changed and non-zero if there was an error. [[notes]] == Notes The cd built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard does not define the use of the +YASH_AFTER_CD+ variable or the +--default-directory=...+ option. The standard does not allow using an option with a single hyphen operand. The exit status of the commands in the +YASH_AFTER_CD+ variable does not affect that of the cd built-in. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_command.txt0000644000175000017500000000673512154557026015644 0ustar magicantmagicant= Command built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Command built-in The dfn:[command built-in] executes or identifies a command. [[syntax]] == Syntax - +command [-befp] {{command}} [{{argument}}...]+ - +command -v|-V [-abefkp] {{command}}...+ [[description]] == Description Without the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option, the built-in executes {{command}} with {{argument}}s in the same manner as the last step of link:exec.html#simple[execution of simple commands]. The command is treated as a built-in or external command or a function according to the options specified to the command built-in. The shell does not exit on argument syntax error etc. even if the command is a link:builtin.html#types[special built-in] With the +-v+ (+--identify+) option, {{command}} is identified. If the command is found in link:params.html#sv-path[+$PATH+], its full pathname is printed. If it is a link:syntax.html#tokens[keyword], link:exec.html#function[function], or link:builtin.html[built-in] that is not found in +$PATH+, the command name is simply printed. If it is an link:syntax.html#aliases[alias], it is printed in the form like `alias ll='ls -l'`. If the command is not found, nothing is printed and the exit status is non-zero. The +-V+ (+--verbose-identify+) option is similar to the +-v+ (+--identify+) option, but the output format is more human-friendly. [[options]] == Options +-a+:: +--alias+:: Search for the command as an link:syntax.html#aliases[alias]. Must be used with the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option. +-b+:: +--builtin-command+:: Search for the command as a link:builtin.html[built-in]. +-e+:: +--external-command+:: Search for the command as an external command. +-f+:: +--function+:: Search for the command as a link:exec.html#function[function]. +-k+:: +--keyword+:: Search for the command as a link:syntax.html#tokens[keyword]. Must be used with the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option. +-p+:: +--standard-path+:: Search the system's default +PATH+ instead of the current link:params.html#sv-path[+$PATH+]. +-v+:: +--identify+:: Identify {{command}}s and print in the format defined in the POSIX standard. +-V+:: +--verbose-identify+:: Identify {{command}}s and print in a human-friendly format. If none of the +-a+ (+--alias+), +-b+ (+--builtin-command+), +-e+ (+--external-command+), +-f+ (+--function+), and +-k+ (+--keyword+) options is specified, the following defaults are assumed: Without the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option:: +-b -e+ With the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option:: +-a -b -e -f -k+ [[operands]] == Operands {{command}}:: A command to be executed or identified. {{argument}}...:: Arguments passed to the executed command. [[exitstatus]] == Exit status The exit status of the command built-in is: Without the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option:: the exit status of the executed command. With the +-v+ (+--identify+) or +-V+ (+--verbose-identify+) option:: zero unless there is any error. [[notes]] == Notes The command built-in is a link:builtin.html#types[semi-special built-in]. In the link:posix.html[POSIXly-correct mode], options other than +-p+, +-v+, and +-V+ cannot be used and at most one {{command}} can be specified. The POSIX standard does not allow specifying both +-v+ and +-V+ together, but yash does (only the last specified one is effective). // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/builtin.html0000644000175000017500000001771712154557026015664 0ustar magicantmagicant Built-in commands

Built-in commands are commands that are implemented in the shell and are executed by the shell without external programs.

Types of built-in commands

There are three types of built-in commands in yash: special built-in commands, semi-special built-in commands and regular built-in commands.

Special built-in commands are much more important commands than others. They are executed regardless of whether the corresponding external commands exist or not. Results of variable assignments that occur in a simple command that invokes a special built-in last after the command has finished. Moreover, in the POSIXly-correct mode, a non-interactive shell immediately exits with a non-zero exit status when a redirect error, assignment error, or misuse of option or operand occurs in a special built-in command.

Semi special built-in commands are the second important built-in commands. They are executed regardless of whether the corresponding external commands exist or not. In other parts they are the same as regular built-in commands.

Regular built-in commands are less important built-in commands including commands that can be implemented as external commands or are not listed in POSIX. In the POSIXly-correct mode, a regular built-in is executed only when a corresponding external command is found in PATH.

Syntax of command arguments

In this section we explain common rules about command arguments. The built-in commands of yash follow the rules unless otherwise stated.

There are two types of command arguments. One is options and the other is operands. An option is an argument that starts with a hyphen (-) and changes the way the command behaves. Some options take arguments. An operand is an argument that is not an option and specifies objects the command operates on.

If you specify more than one option to a command, the order of the options are normally not significant. The order of operands, however, affects the command behavior.

An option is either a single-character option or a long option. A single-character option is identified by one alphabetic character. A long option is identified by multiple alphabetic characters. The POSIX standard only prescribes single-character options, so in the POSIXly-correct mode you cannot use long options.

A single-character option is composed of a hyphen followed by a letter. For example, -a is a single-character option. A single-character option that takes an argument requires the argument to be just after the option name.

Example 1. The set built-in and single-character options

For the set built-in, -m is a single-character option that does not take an argument and -o is one that takes an argument.

  • set -o errexit -m

  • set -oerrexit -m

In these two command lines, errexit is the argument to the -o option.

In the second example above, the -o option and its argument are combined into a single command line argument. The POSIX standard deprecates that style and any POSIX-conforming applications must specify options and their arguments as separate command line arguments, although yash accepts both styles.

You can combine single-character options that do not take arguments into a single command line argument. For example, the three options -a, -b and -c can be combined into -abc.

A long option is composed of two hyphens followed by an option name. For example, --long-option is a long option. You can omit some last characters of a long option name as long as it is not ambiguous. For example, you can use --long instead of --long-option if there is no other options beginning with --long. Like a single-character option, a long option that takes an argument requires the argument to be a command line argument just after the option name or to be specified in the same command line argument as the option name, separated by an equal sign (=).

Example 2. The fc built-in and long options

For the fc built-in, --quiet is a long option that does not take an argument and --editor is one that takes an argument.

  • fc --editor vi --quiet

  • fc --editor=vi --quiet

In these command lines, vi is the argument to the --editor option.

Arguments that are not options (nor arguments to them) are interpreted as operands. The POSIX standard requires all options should be specified before any operands. Therefore, in the POSIXly-correct mode, any arguments that come after the first operand are interpreted as operands (even if they look like options). If not in the POSIXly-correct mode, you can specify options after operand.

Regardless of whether the shell is in the POSIXly-correct mode or not, an argument that is just composed of two hyphens (--) can be used as a separator between options and operands. All command line arguments after the -- separator are interpreted as operands, so you can specify operands that start with a hyphen correctly using the separator.

Example 3. Options and operands to the set built-in
  • set -a -b -- -c -d

In this example, -a and -b are options and -c and -d are operands. The -- separator itself is neither an option nor an operand.

Regardless of whether the shell is in the POSIXly-correct mode or not, an argument that is just composed of a single hyphen (-) is interpreted as an operand.

yash-2.35/doc/_typeset.txt0000644000175000017500000000576312154557026015723 0ustar magicantmagicant= Typeset built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Typeset built-in The dfn:[typeset built-in] prints or sets variables or functions. [[syntax]] == Syntax - +typeset [-gprxX] [{{variable}}[={{value}}]...]+ - +typeset -f[pr] [{{function}}...]+ [[description]] == Description If executed without the +-f+ (+--functions+) option, the typeset built-in prints or sets link:params.html#variables[variables] to the standard output. Otherwise, it prints or sets link:exec.html#function[functions]. If executed with the +-p+ (+--print+) option, the built-in prints the variables or functions specified by operands. Without the option, it sets variables or functions. If no operands are specified, it prints all existing variables or functions, regardless of whether the +-p+ (+--print+) option is specified. [[options]] == Options +-f+:: +--functions+:: Print or set functions rather than variables. +-g+:: +--global+:: When setting a new variable, the variable will be a global variable if this option is specified. Without this option, the variable would be a link:exec.html#localvar[local variable]. + When printing variables, all existing variables including global variables are printed if this option is specified. Without this option, only local variables are printed. +-p+:: +--print+:: Print variables or functions in a form that can be parsed and executed as commands that will restore the currently set variables or functions. +-r+:: +--readonly+:: When setting variables or functions, make them read-only. + When printing variables or functions, print read-only variables or functions only. +-x+:: +--export+:: When setting variables, link:params.html#variables[mark them for export], so that they will be exported to external commands. + When printing variables, print exported variables only. +-X+:: +--unexport+:: When setting variables, cancel exportation of the variables. [[operands]] == Operands {{variable}} (without {{value}}):: The name of a variable that is to be set or printed. + Without the +-p+ (+--print+) option, the variable is defined (if not yet defined) but its value is not set nor changed. Variables that are defined without values are treated as unset in link:expand.html#params[parameter expansion]. {{variable}}={{value}}:: The name of a variable and its new value. + The value is assigned to the variable (regardless of the +-p+ (+--print+) option). {{function}}:: The name of an existing function that is to be set or printed. [[exitstatus]] == Exit status The exit status of the typeset built-in is zero unless there is any error. [[notes]] == Notes A global variable cannot be newly defined if a local variable has already been defined with the same name. The local variable will be set regardless of the +-g+ (+--global+) option. The POSIX standard does not define the typeset built-in. The export and readonly built-ins are equivalent to the link:_typeset.html[typeset built-in] with the +-gx+ and +-gr+ options, respectively. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/job.html0000644000175000017500000002030612154557026014754 0ustar magicantmagicant Job control

Job control is a function of the shell that executes multiple commands simultaneously and suspends/resumes the commands.

When control is active:

  • Every pipeline executed by the shell becomes a job. A job has its unique process group ID that is shared among all processes in the job.

  • If the processes of a job are suspended while the shell is waiting for the processes to finish, the shell continues to the next command as if the process have finished. The shell remembers the job as suspended so that it can be resumed later.

  • If a job is executed synchronously, the shell sets the foreground process group of the terminal to the process group of the job. When the job is finished (or suspended), the shell gets back to the foreground.

  • The subshell executing a command substitution has its own unique process group ID like a job. However, the shell does not remember the subshell as a job, so it cannot be suspended or resumed.

  • If the shell is interactive, job status is reported before every command line prompt as if the command jobs -n is executed.

  • The standard input of an asynchronous command is not automatically redirected to /dev/null (unless in the POSIXly-correct mode).

  • The shell does not exit when it receives the SIGTSTP signal.

  • The value of the - special parameter contains m.

  • When a job finished for which the wait built-in has been waiting, the fact is reported (only if the shell is interactive and not in the POSIXly-correct mode).

When job control is inactive, processes executed by the shell have the same process group ID as the shell. The shell treats asynchronous commands as an uncontrolled job.

You can use the following built-ins to manipulate jobs:

jobs

prints existing jobs

fg and bg

run jobs in the foreground or background

wait

waits for jobs to be finished (or suspended)

disown

forgets jobs

kill

sends a signal to jobs

An interactive job-controlling shell reports jobs status before every prompt by default. You can set the following options to make the shell report status at other timings:

notify

the shell reports immediately whenever job status changes.

notify-le

the shell reports immediately when job status changes while line-editing.

A job is removed from the shell’s job list when:

  • it has finished and the “finished” status is reported,

  • the wait built-in successfully waited for the job to finish, or

  • the disown built-in removed the job.

Note
The word “stop” is synonymous to “suspend” in the context of job control.

Job ID

Some built-ins use the following notation, which is called job ID, to specify a job to operate on:

%
%%
%+

the current job

%-

the previous job

%n

the job that has job number n, where n is a positive integer

%string

the job whose name begins with string

%?string

the job whose name contains string

The current job and previous job are jobs selected by the shell according to the following rules:

  • When there is one or more suspended jobs, the current job is selected from them.

  • When there is one or more suspended jobs other than the current job, the previous job is selected from them.

  • The current and previous jobs are always different. When the shell has only one job, it is the current job and there is no previous job.

  • When the current job finished, the previous job becomes the current job.

  • When the current job is changed, the old current job becomes the previous job except when the old job finished.

  • When the foreground job is suspended, the job becomes the current job.

Yash has some options to modify the rules of the current/previous job selection. (The rules above have priority over the options below.)

cur-async

When a new asynchronous command is started, it becomes the current job.

cur-bg

When a job is resumed by the bg built-in, the job becomes the current job.

cur-stop

When a job is suspended, it becomes the current job.

The current and previous jobs are not changed as long as the rules above are met.

The rules of the current/previous job selection defined in the POSIX standard are looser than yash’s rules above. Other POSIX-compliant shells may select the current and previous jobs differently.

yash-2.35/doc/redir.txt0000644000175000017500000002351612154557026015170 0ustar magicantmagicant= Redirection :encoding: UTF-8 :lang: en //:title: Yash manual - Redirection :description: This page describes redirections supported by yash. dfn:[Redirection] is a feature you can use to modify file descriptors of commands. By using redirection, you can execute commands with their standard input/output connected with files or devices other than the terminal. You can do redirection by adding redirection operators to a command (link:syntax.html#simple[simple command] or link:syntax.html#compound[compound command]) In a simple command, redirection operators may appear anywhere in the command as long as operator tokens are separated from other tokens. In a compound command, redirection operators must appear at the end of the command. Redirection operators are processed before the command body is executed. More than one redirection operator in a command are processed in the order of appearance. Redirection operators affect only the command in which they appear, except when they appear in an link:_exec.html[exec built-in] without command operands. That is, file descriptors modified by redirection are restored after the command has finished. A redirection operator starts with +<+ or +>+. Redirection operators starting with +<+ affects the standard input (file descriptor 0) by default. Redirection operators starting with +>+ affects the standard output (file descriptor 1) by default. To affect another file descriptor, you can prefix a redirection operator with a non-negative integer; the operator will affect the file descriptor specified by the integer. The integer must immediately precede the +<+ or +>+ without any whitespaces in between. The integer must not be link:syntax.html#quotes[quoted], either. [[file]] == Redirection to files The most common type of redirection is redirection to files. Redirection of input:: +< {{token}}+ Redirection of output:: +> {{token}}+ + +>| {{token}}+ + +>> {{token}}+ Redirection of input and output:: +<> {{token}}+ The {{token}} is subject to the link:expand.html[four expansions]. It is also subject to link:expand.html#glob[pathname expansion] if the shell is link:interact.html[interactive]. The expansion result is treated as the pathname of the file to which redirection is performed. If the pathname expansion does not result in a single pathname, it is an error. In redirection of input, the standard input is replaced with a file descriptor which is open for read-only access to the target file. If the target file cannot be opened for read-only access, it is an error. In redirection of output, the standard output is replaced with a file descriptor which is open for write-only access to the target file. If the target file cannot be opened for write-only access, it is an error. If the target file does not exist, a new empty file is created and opened. If the target file already exists, the file is opened as follows: - For the +>|+ operator, the file is emptied when opened if it is a regular file. - For the +>+ operator, the behavior is the same as the +>|+ operator if the link:_set.html#so-clobber[clobber option] is enabled. If the option is disabled and the file is a regular file, it is treated as an error. - For the +>>+ operator, the file is opened for appending; any output to the file descriptor is appended to the end of the file. In redirection of input and output, the standard input is replaced with a file descriptor which is open for read-and-write access to the target file. If the file does not exist, a new empty file is created and opened. [[socket]] === Socket redirection If the pathname of the target file is of the form +/dev/tcp/{{host}}/{{port}}+ or +/dev/udp/{{host}}/{{port}}+ and the file cannot be opened in the usual manner, a new socket is opened for communication with the {{port}} of the {{host}}. The redirection replaces the standard input or output with the file descriptor to the socket. A stream socket is opened for the form +/dev/tcp/{{host}}/{{port}}+ and a datagram socket for the form +/dev/udp/{{host}}/{{port}}+. The protocol actually used for communication is determined by the socket library the shell uses. Typically, stream sockets use TCP and datagram sockets UDP. In socket redirection, the file descriptor is both readable and writable regardless of the type of the redirection operator used. Socket redirection is yash's extension that is not defined in POSIX. Bash as well has socket redirection as extension. [[dup]] == Duplication of file descriptors Redirection allows duplicating or closing existing file descriptors. Duplication of file descriptor:: +<& {{token}}+ + +>& {{token}}+ The {{token}} is subject to expansion as in <>, but it is treated as a file descriptor rather than a pathname. Thus the expanded {{token}} must be a non-negative integer. The +<&+ and +>&+ operators duplicate the file descriptor specified by {{token}} to the standard input and output, respectively. (The operators can be prefixed with a non-negative integer so that the file descriptor is duplicated to a file descriptor other than the standard input or output.) If the expanded {{token}} is a single hyphen rather than a non-negative integer, the file descriptor is closed rather than duplicated. By default, the +<&+ and +>&+ operators close the standard input and output, respectively, but the operators can be prefixed with a non-negative integer so that another file descriptor is closed. In the link:posix.html[POSIXly-correct mode], a file descriptor must be readable when duplicated by the +<&+ operator and writable when duplicated by the +>&+ operator. [[here]] == Here documents and here strings dfn:[Here document] and dfn:[here string] allow redirection to file descriptors that reads strings directly specified in shell commands. Here document:: +<< {{token}}+ + +<<- {{token}}+ Here string:: +<<< {{token}}+ In a here document or here string, the standard input is replaced with a readable file descriptor. When the command reads from the file descriptor, it will read the contents of the here document/string, which is defined below. When a here document operator (+<<+ or +<<-+) appears in a command, the shell reads the contents of the here document starting from the next line. The contents of here documents are not parsed nor executed as commands. The {{token}} after the operand specifies a delimiter that indicates the end of the contents. (The {{token}} is not subject to any link:expand.html[expansion], but link:syntax.html#quotes[quotation] is processed.) The contents of the here document is terminated just before the first line containing the {{token}} only. When using the +<<-+ operator, all tab characters at the beginning of each line in the here document contents are removed and the delimiter {{token}} may be preceded by tab characters. If there are more than one here document operator on one line, the contents of the here documents are parsed in order: The contents of the first here document starts from the next line and ends before the first line containing the {{token}} that followed the first operator. Just after that line, the contents of the second here document starts, and so on. The contents of here documents are treated literally: whitespaces, tabs, etc. remain as is. The exception is that, when the {{token}} is not link:syntax.html#quotes[quoted] at all: - the contents are subject to link:expand.html#params[parameter expansion], link:expand.html#cmdsub[command substitution], link:expand.html#arith[arithmetic expansion]. - a backslash in the contents is treated as link:syntax.html#quotes[quotation] if and only if it precedes +$+, +`+, +"+, or another backslash. - a backslash followed by a newline is treated as link:syntax.html#quotes[line continuation]. In here string, the {{token}} after the operator is subject to expansion as in <>. The expansion result becomes the contents of the here string. A newline character is automatically appended to the end of here string contents. Here string is yash's extension that is not defined in POSIX. Other shells like bash, ksh, and zsh have the same feature. [[pipe]] == Pipeline redirection dfn:[Pipeline redirection] allows opening pipelines that can be used for arbitrary purposes. Pipeline redirection:: +>>| {{token}}+ The {{token}} is subject to expansion as in <>, but it is treated as a file descriptor rather than a pathname. Thus the expanded {{token}} must be a non-negative integer. Pipeline redirection opens a new pipeline. The standard output (or the file descriptor specified before the operator, if any) is replaced with the file descriptor open for writing to the pipeline. The file descriptor specified by {{token}} is replaced with the file descriptor open for reading from the pipeline. Pipeline redirection is yash's extension that is not defined in POSIX. [[process]] == Process redirection dfn:[Process redirection] creates a pipeline connected to another command. Process redirection:: +<({{command}}...)+ + +>({{command}}...)+ In process redirection, the {{command}} specified is executed in a link:exec.html#subshell[subshell]. If the process redirection is of the form +<({{command}}...)+, the standard output of {{command}} is connected with a pipeline to the standard input of the command the redirection is associated with. If the process redirection is of the form +>({{command}}...)+, the standard input of {{command}} is connected with a pipeline to the standard output of the command the redirection is associated with. Process redirection is yash's extension that is not defined in POSIX. Bash and zsh have a feature called process substitution, which uses the same syntax as yash's process redirection, but incompatibly differs in behavior. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_pushd.html0000644000175000017500000000651512154557026015472 0ustar magicantmagicant Pushd built-in

The pushd built-in pushes a directory into the directory stack.

Syntax

  • pushd [-L|-P] [directory]

Description

The pushd built-in changes the working directory to directory in the same manner as the cd built-in and adds it to the directory stack. If the working directory could not be changed successfully, the stack is not modified.

Options

The pushd built-in accepts the following option as well as the options that can be used for the cd built-in:

--remove-duplicates

If the new working directory has already been in the directory stack, the existing entry is removed from the stack before the new directory is pushed into the stack.

Operands

directory

The pathname of the new working directory.

If directory is a single hyphen (‘-’), the value of the OLDPWD variable is assumed for the new directory pathname, which is printed to the standard output.

If directory is an integer with a plus or minus sign, it is considered as an entry index of the directory stack. The entry is removed from the stack and then pushed to the stack again.

If directory is omitted, the working directory is changed to the directory specified by the --default-directory=… option. If that option is not specified either, the default is index +1.

Exit status

The exit status of the pushd built-in is zero unless there is any error.

Notes

The pushd built-in is not defined in the POSIX standard.

yash-2.35/doc/_printf.txt0000644000175000017500000001563712154557026015531 0ustar magicantmagicant= Printf built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Printf built-in The dfn:[printf built-in] prints formatted values. [[syntax]] == Syntax - +printf {{format}} [{{value}}...]+ [[description]] == Description The printf built-in formats {{value}}s according to {{format}} and prints them to the standard output. Unlike the link:_echo.html[echo built-in], the printf built-in does not print a newline automatically. The formatting process is very similar to that of the printf function in the C programming language. You can use conversion specifications (which start with +%+) and escape sequences (which start with +\+) in {{format}}. Any other characters that are not part of a conversion specification or escape sequence are printed literally. [[convspec]] === Conversion specifications A conversion specification starts with a percent sign (+%+). A conversion specification except +%%+ consumes a {{value}}, which is formatted according to the specification and printed. Each conversion specification consumes one {{value}} in the order of appearance. If there are more {{value}}s than conversion specifications, the entire {{format}} is re-processed until all the {{value}}s are consumed. If a {{value}} to be consumed is missing, it is assumed to be an empty string (if the specification requires a string) or zero (if a number). If no {{value}}s are given, {{format}} is processed just once. Available conversion specifications are: +%d+:: +%i+:: prints a signed integer in decimal +%u+:: prints an unsigned integer in decimal +%o+:: prints an unsigned integer in octal +%x+:: prints an unsigned integer in lowercase hexadecimal +%X+:: prints an unsigned integer in uppercase hexadecimal +%f+:: prints a floating-point number in lowercase +%F+:: prints a floating-point number in uppercase +%e+:: prints a floating-point number with exponent in lowercase +%E+:: prints a floating-point number with exponent in uppercase +%g+:: the same as +%f+ or +%e+, automatically selected +%G+:: the same as +%F+ or +%E+, automatically selected +%c+:: prints the first character of string +%s+:: prints a string +%b+:: prints a string (recognizing escape sequences like the link:_echo.html#escapes[echo built-in]) +%%+:: prints a percent sign (+%+) For +%g+ and +%G+, the specification that is actually used is +%f+ or +%F+ if the exponent part is between -5 and the precision (exclusive); +%e+ or +%E+ otherwise. In a conversion specification except +%%+, the leading percent sign may be followed by flags, field width, and/or precision in this order. [[convspec-flags]] ==== Flags The flags are a sequence of any number of the following characters: Minus sign (+-+):: With this flag, spaces are appended to the formatted value to fill up to the field width. Otherwise, spaces are prepended. Plus sign (+++):: A plus or minus sign is always prepended to a number. Space (+ +):: A space is prepended to a formatted number if it has no plus or minus sign. Hash sign (+#+):: The value is formatted in an alternative form: For +%o+, the printed octal integer has at least one leading zero. For +%x+ and +%X+, a non-zero integer is formatted with +0x+ and +0X+ prefixes, respectively. For +%e+, +%E+, +%f+, +%F+, +%g+, and +%G+, a decimal mark (a.k.a. radix character) is always printed even if the value is an exact integer. For +%g+ and +%G+, the printed number has at least one digit in the fractional part. Zero (+0+):: Zeros are prepended to a formatted number to fill up to the field width. This flag is ignored if the minus flag is specified or if the conversion specification is +%d+, +%i+, +%u+, +%o+, +%x+, or +%X+ with a precision. [[convspec-width]] ==== Field width A field width is specified as a decimal integer that has no leading zeros. A field width defines a minimum byte count of a formatted value. If the formatted value does not reach the minimum byte count, so many spaces are prepended that the printed value has the specified byte count. [[convspec-precision]] ==== Precision A precision is specified as a period (+.+) followed by a decimal integer. If the integer is omitted after the period, the precision is assumed to be zero. For conversion specifications +%d+, +%i+, +%u+, +%o+, +%x+, and +%X+, a precision defines a minimum digit count. If the formatted integer does not reach the minimum digit count, so many zeros are prepended that the printed integer has the specified number of digits. The default precision is one for these conversion specifications. For conversion specifications +%e+, +%E+, +%f+, and +%F+, a precision defines the number of digits after the decimal mark. The default precision is six for these conversion specifications. For conversion specifications +%g+, and +%G+, a precision defines a maximum number of significant digits in the printed value. The default precision is six for these conversion specifications. For conversion specifications +%s+, and +%b+, a precision defines a maximum byte count of the printed string. The default precision is infinity for these conversion specifications. [[convspec-examples]] ==== Examples In the conversion specification +%08.3f+, the zero flag is specified, the field width is 8, and the precision is 3. If this specification is applied to value 12.34, the output will be +0012.340+. [[escapes]] === Escape sequences The following escape sequences are recognized in {{format}}: +\a+:: Bell character (ASCII code: 7) +\b+:: Backspace (ASCII code: 8) +\f+:: Form feed character (ASCII code: 12) +\n+:: Newline character (ASCII code: 10) +\r+:: Carriage return character (ASCII code: 13) +\t+:: Horizontal tab character (ASCII code: 9) +\v+:: Vertical tab character (ASCII code: 11) +\\+:: Backslash +\"+:: Double quotation +\'+:: Single quotation (apostrophe) +\{{xxx}}+:: Character whose code is {{xxx}}, where {{xxx}} is an octal number of at most three digits. [[operands]] == Operands {{format}}:: A string that defines how {{value}}s should be formatted. {{value}}s:: Values that are formatted according to {{format}}. + A value is either a number or a string. + When a numeric value is required, {{value}} can be a single or double quotation followed by a character, instead of a normal number. For example, the command `printf '%d' '"3'` will print +51+ on a typical environment where character +3+ has character code 51. [[exitstatus]] == Exit status The exit status of the printf built-in is zero unless there is any error. [[notes]] == Notes The POSIX standard does not precisely define how multibyte characters should be handled by the built-in. When you use the +%s+ conversion specification with precision or the +%c+ conversion specification, you may obtain unexpected results if the formatted value contains a character that is represented by more than one byte. Yash never prints only part of the bytes that represent a single multibyte character because all multibyte characters are converted to wide characters when processed in the shell. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_bg.txt0000644000175000017500000000232312154557026014603 0ustar magicantmagicant= Bg built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Bg built-in The dfn:[bg built-in] resumes a job in the background. [[syntax]] == Syntax - +bg [{{job}}...]+ [[description]] == Description The bg built-in sends the SIGCONT signal to the specified job. As a result, the job is resumed in the background (if it has been suspended). The name of the job is printed when the job is resumed. The built-in can be used only when link:job.html[job control] is enabled. [[operands]] == Operands {{job}}:: The link:job.html#jobid[job ID] of the job to be resumed. + More than one job can be specified at a time. The current job is resumed if none is specified. + The percent sign (+%+) at the beginning of a job ID can be omitted if the shell is not in the link:posix.html[POSIXly-correct mode]. [[exitstatus]] == Exit status The exit status of the bg built-in is zero unless there is any error. [[notes]] == Notes The bg built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard provides that the built-in shall have no effect when the job is already running. The bg built-in of yash, however, always sends the SIGCONT signal to the job. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_export.html0000644000175000017500000000333312154557026015663 0ustar magicantmagicant Export built-in

The export built-in marks variables for export to child processes.

Syntax

  • export [-prX] [name[=value]…]

Description

The export built-in is equivalent to the typeset built-in with the -gx option.

Notes

The export built-in is a special built-in.

The POSIX standard defines the -p option only; other options cannot be used in the POSIXly-correct mode. The POSIX does not allow using the option together with operands.

yash-2.35/doc/_exit.html0000644000175000017500000000777312154557026015327 0ustar magicantmagicant Exit built-in

The exit built-in causes the shell process to exit.

Syntax

  • exit [-f] [exit_status]

Description

The exit built-in causes the current shell (or subshell) process to exit.

If an interactive shell has a stopped job, the shell prints a warning message and refuses to exit. To force the shell to exit regardless, specify the -f (--force) option or execute the built-in twice in a row.

If an EXIT trap has been set, the shell executes the trap before exiting.

Options

-f
--force

Suppress warnings that would prevent the shell from exiting.

Operands

exit_status

A non-negative integer that will be the exit status of the exiting shell.

If this operand is omitted, the exit status of the shell will be that of the last command executed before the exit built-in (but, if the built-in is executed during a trap, the exit status will be that of the last command before the trap is entered).

If exit_status is 256 or larger, the actual exit status will be the remainder of exit_status divided by 256.

Exit status

Because the built-in causes the shell to exit, there is no exit status of the built-in.

As an exception, if the shell refused to exit, the exit status of the built-in is non-zero.

Notes

The exit built-in is a special built-in.

The POSIX standard defines no options for the exit built-in; the built-in accepts no options in the POSIXly-correct mode.

The POSIX standard provides that the exit_status operand should be between 0 and 255 (inclusive). Yash accepts integers larger than 255 as an extension.

If the built-in is executed during an EXIT trap, the shell just exits without executing the trap again. If exit_status was not specified, the exit status of the shell is what the exit status would be if the trap had not been set. See also Termination of the shell.

yash-2.35/doc/_suspend.txt0000644000175000017500000000227112154557026015676 0ustar magicantmagicant= Suspend built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Suspend built-in The dfn:[suspend built-in] suspends the shell. [[syntax]] == Syntax - +suspend [-f]+ [[description]] == Description The suspend built-in sends a SIGSTOP signal to all processes in the process group to which the shell process belongs. The signal suspends the processes (including the shell). The suspended processes resume when they receive a SIGCONT signal. If the shell is link:interact.html[interactive] and its process group ID is equal to the process ID of the session leader, the shell prints a warning message and refuses to send a signal unless the +-f+ (+--force+) option is specified. (In such a case, there is no other job-controlling shell that can send a SIGCONT signal to resume the suspended shell, so the shell could never be resumed.) [[options]] == Options +-f+:: +--force+:: Suppress warnings that would prevent the shell from sending a signal. [[exitstatus]] == Exit status The exit status is zero if the signal was successfully sent and non-zero otherwise. [[notes]] == Notes The suspend built-in is not defined in the POSIX standard. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/lineedit.txt0000644000175000017500000013450612154557026015662 0ustar magicantmagicant= Line-editing :encoding: UTF-8 :lang: en //:title: Yash manual - Line-editing :description: This page describes yash's line-editing feature. With the dfn:[line-editing] feature, you can edit the command text when you input a command to an link:interact.html[interactive shell]. It not only works as a simple visual-interface editor, but also is integrated with the link:interact.html#history[command history]. You can recall, edit, and execute commands in the history with line-editing instead of using the link:_fc.html[fc built-in]. Line-editing has two editing modes, the vi and emacs modes, which each have their own key binding settings. By switching editing modes, you can change key bindings used in line-editing. Each mode has a corresponding link:_set.html#options[shell option], which determines whether the mode is currently active or not. No more than one mode can be active at a time, so the options for the other modes are automatically turned off when you turn on the option for one mode. The whole line-editing feature is deactivated when those options are off. When an interactive shell is started, the vi mode is automatically activated if the standard input and error are both connected to a terminal. Line-editing can be used only when the standard input and error are both connected to a terminal. If not, the shell silently falls back to the normal input mechanism. While line-editing is being used, the shell uses the termios interface to change I/O settings of the terminal and the terminfo interface to parse input key sequences. [[options]] == Shell options on line-editing The following options can be set by the link:_set.html[set built-in] to enable line-editing and choose an editing mode to activate: link:_set.html#so-vi[vi]:: activates the vi mode. link:_set.html#so-emacs[emacs]:: activates the emacs mode. The other line-editing-related options are: link:_set.html#so-lealwaysrp[le-always-rp]:: When this options is enabled, the right prompt is always visible: when the cursor reaches the right prompt, it moves to the next line from the original position, which would otherwise be overwritten by input text. link:_set.html#so-lecompdebug[le-comp-debug]:: When enabled, internal information is printed during <>, which will help debugging completion scripts. link:_set.html#so-leconvmeta[le-conv-meta]:: When enabled, the 8th bit of each input byte is always treated as a meta-key flag, regardless of terminfo data. link:_set.html#so-lenoconvmeta[le-no-conv-meta]:: When enabled, the 8th bit of each input byte is never treated as a meta-key flag, regardless of terminfo data. + The le-conv-meta and le-no-conv-meta options cannot be both enabled at a time. When either is enabled, the other is automatically disabled. When neither is enabled, the 8th bit may be treated as a meta-key flag depending on terminfo data. link:_set.html#so-lepromptsp[le-prompt-sp]:: When enabled, the shell prints a special character sequence before printing each prompt so that every prompt is printed at the beginning of a line. + This option is enabled by default. link:_set.html#so-levisiblebell[le-visible-bell]:: When enabled, the shell flashes the terminal instead of sounding an alarm when an alert is required. [[modes]] == Editing modes The dfn:[vi mode] is an editing mode that offers key bindings similar to that of the vi editor. The vi mode has two sub-modes that are switched during editing: the insert and command modes. The sub-mode is always reset to the insert mode when line-editing is started for a new command line. In the insert mode, most characters are inserted to the buffer as typed. In the command mode, input characters are treated as commands that move the cursor, insert/delete text, etc. The dfn:[emacs mode] offers key bindings similar to the emacs editor. Most characters are inserted to the buffer as typed, but more characters are treated as commands than the vi insert mode. Another sub-mode is used while you enter search keywords. The sub-mode is called the dfn:[search mode], which offers slightly different key bindings depending on the active editing mode. [[commands]] == Line-editing commands All characters the user enters while line-editing is active are treated as line-editing commands listed below. The link:_bindkey.html[bindkey built-in] allows customizing the key bindings of each mode (except for the search mode). The list below shows not only the functions of commands but also the default key bindings. The keywords ``vi-insert'', ``vi-command'', ``vi-search'', ``emacs'', ``emacs-search'' means the vi insert mode, the vi command mode, the search mode for the vi mode (the vi search mode), the emacs mode, and the search mode for the emacs mode (the emacs search mode), respectively. Some commands take an argument that affects the function of the commands. For example, the forward-char command moves the cursor by as many characters as specified by the argument. To specify an argument, use the digit-argument command just before another command that takes an argument. [[basic-commands]] === Basic editing commands noop:: Do nothing. + -- vi-command:: ifdef::basebackend-html[+++\^[+++] ifndef::basebackend-html[`\^[`] -- alert:: Alert. self-insert:: Insert the input character at the current cursor position. Characters escaped by <> cannot be inserted. + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\\+++] ifndef::basebackend-html[`\\`] -- insert-tab:: Insert a tab character at the current cursor position. + -- emacs:: ifdef::basebackend-html[+++\^[\^I+++] ifndef::basebackend-html[`\^[\^I`] -- expect-verbatim:: Insert a character that is entered just after this command at the current cursor position. This command can input a character that cannot be input by the self-insert command, except a null character (`'\0'`). + -- vi-insert:: vi-search:: emacs-search:: ifdef::basebackend-html[+++\^V+++] ifndef::basebackend-html[`\^V`] emacs:: ifdef::basebackend-html[] +++\^Q, \^V+++ endif::basebackend-html[] ifndef::basebackend-html[`\^Q`, `\^V`] -- digit-argument:: Pass the input digit to the next command as an argument. + This command can be bound to a digit or hyphen. To pass ``12'' as an argument to the forward-char command in the vi mode, for example, enter `12l`. + -- vi-command:: ifdef::basebackend-html[] +++1, 2, 3, 4, 5, 6, 7, 8, 9+++ endif::basebackend-html[] ifndef::basebackend-html[`1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`] emacs:: ifdef::basebackend-html[] +++\^[0, \^[1, \^[2, \^[3, \^[4, \^[5, \^[6, \^[7, \^[8, \^[9, \^[-+++ endif::basebackend-html[] ifndef::basebackend-html[] `\^[0`, `\^[1`, `\^[2`, `\^[3`, `\^[4`, `\^[5`, `\^[6`, `\^[7`, `\^[8`, `\^[9`, `\^[-`, endif::basebackend-html[] -- bol-or-digit:: Like the beginning-of-line command if there is no argument; like the digit-argument command otherwise. + -- vi-command:: ifdef::basebackend-html[+++0+++] ifndef::basebackend-html[`0`] -- accept-line:: Finish editing the current line. A newline is automatically appended to the line. The line will be executed by the shell. + -- vi-insert:: vi-command:: emacs:: emacs-search:: ifdef::basebackend-html[] +++\^J, \^M+++ endif::basebackend-html[] ifndef::basebackend-html[`\^J`, `\^M`] -- abort-line:: Abandon the current buffer and finish editing as if an empty line was input. + -- vi-insert:: vi-command:: vi-search:: emacs:: emacs-search:: ifdef::basebackend-html[] +++\!, \^C+++ endif::basebackend-html[] ifndef::basebackend-html[`\!`, `\^C`] -- eof:: Abandon the current buffer and finish editing as if the shell reached the end of input. This normally makes the shell exit. eof-if-empty:: Like the eof command if the buffer is empty; like the alert command otherwise. + -- vi-insert:: vi-command:: ifdef::basebackend-html[] +++\#, \^D+++ endif::basebackend-html[] ifndef::basebackend-html[`\#`, `\^D`] -- eof-or-delete:: Like the eof command if the buffer is empty; like the delete-char command otherwise. + -- emacs:: ifdef::basebackend-html[] +++\#, \^D+++ endif::basebackend-html[] ifndef::basebackend-html[`\#`, `\^D`] -- accept-with-hash:: Like the accept-line command, but: + -- - A hash sign (+#+) is inserted at the beginning of the line if there is none. - Otherwise, the hash sign is removed from the beginning of the line. vi-command:: ifdef::basebackend-html[+++#+++] ifndef::basebackend-html[`#`] emacs:: ifdef::basebackend-html[+++\^[#+++] ifndef::basebackend-html[`\^[#`] -- setmode-viinsert:: Switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++i, \I+++] ifndef::basebackend-html[`i`, `\I`] -- setmode-vicommand:: Switch to the vi command mode. + -- vi-insert:: ifdef::basebackend-html[+++\^[+++] ifndef::basebackend-html[`\^[`] -- setmode-emacs:: Switch to the emacs mode. expect-char:: abort-expect-char:: These commands are not meant for use by the user. They are used by the shell to implement some other commands. redraw-all:: Reprint the prompt and the current line to the terminal. + -- vi-insert:: vi-command:: vi-search:: emacs:: emacs-search:: ifdef::basebackend-html[+++\^L+++] ifndef::basebackend-html[`\^L`] -- clear-and-redraw-all:: Clear the terminal and reprint the prompt and the current line. [[motion-commands]] === Motion commands dfn:[Motion commands] move the cursor on the line. Most motion commands accept an argument. When passed an argument, they repeat the cursor motion as many times as specified by the argument. Passing ``4'' as an argument to the forward-char command, for example, advances the cursor by four characters. -- The shell has several definitions of words as units of distance: A dfn:[bigword] is one or more adjacent non-whitespace characters. A dfn:[semiword] is one or more adjacent characters that contain no whitespaces or punctuations. An dfn:[emacsword] is one or more adjacent alphanumeric characters. A dfn:[viword] is either: - one or more adjacent alphanumeric characters and/or underscores (+_+), or - one or more adjacent characters that contain none of alphanumeric characters, underscores, and whitespaces. -- forward-char:: Move the cursor to the next character. + -- vi-insert:: ifdef::basebackend-html[+++\R+++] ifndef::basebackend-html[`\R`] vi-command:: ifdef::basebackend-html[] +++l, (a space), \R+++ endif::basebackend-html[] ifndef::basebackend-html[`l`, (space), `\R`] emacs:: ifdef::basebackend-html[] +++\R, \^F+++ endif::basebackend-html[] ifndef::basebackend-html[`\R`, `\^F`] -- backward-char:: Move the cursor to the previous character. + -- vi-insert:: ifdef::basebackend-html[+++\L+++] ifndef::basebackend-html[`\L`] vi-command:: ifdef::basebackend-html[] +++h, \B, \L, \?, \^H, +++ endif::basebackend-html[] ifndef::basebackend-html[`h`, `\B`, `\L`, `\?`, `\^H`] emacs:: ifdef::basebackend-html[] +++\L, \^B+++ endif::basebackend-html[] ifndef::basebackend-html[`\L`, `\^B`] -- forward-bigword:: Move the cursor to the next bigword. + -- vi-command:: ifdef::basebackend-html[+++W+++] ifndef::basebackend-html[`W`] -- end-of-bigword:: Move the cursor to the next end of a bigword. + -- vi-command:: ifdef::basebackend-html[+++E+++] ifndef::basebackend-html[`E`] -- backward-bigword:: Move the cursor to the previous bigword. + -- vi-command:: ifdef::basebackend-html[+++B+++] ifndef::basebackend-html[`B`] -- forward-semiword:: Move the cursor to the next semiword. end-of-semiword:: Move the cursor to the next end of a semiword. backward-semiword:: Move the cursor to the previous semiword. forward-viword:: Move the cursor to the next viword. + -- vi-command:: ifdef::basebackend-html[+++w+++] ifndef::basebackend-html[`w`] -- end-of-viword:: Move the cursor to the next end of a viword. + -- vi-command:: ifdef::basebackend-html[+++e+++] ifndef::basebackend-html[`e`] -- backward-viword:: Move the cursor to the previous viword. + -- vi-command:: ifdef::basebackend-html[+++b+++] ifndef::basebackend-html[`b`] -- forward-emacsword:: Move the cursor to the next emacsword. + -- emacs:: ifdef::basebackend-html[] +++\^[f, \^[F+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[f`, `\^[F`] -- backward-emacsword:: Move the cursor to the previous emacsword. + -- emacs:: ifdef::basebackend-html[] +++\^[b, \^[B+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[b`, `\^[B`] -- beginning-of-line:: Move the cursor to the beginning of the line. + -- vi-insert:: vi-command:: ifdef::basebackend-html[+++\H+++] ifndef::basebackend-html[`\H`] emacs:: ifdef::basebackend-html[] +++\H, \^A+++ endif::basebackend-html[] ifndef::basebackend-html[`\H`, `\^A`] -- end-of-line:: Move the cursor to the end of the line. + -- vi-insert:: ifdef::basebackend-html[+++\E+++] ifndef::basebackend-html[`\E`] vi-command:: ifdef::basebackend-html[+++$, \E+++] ifndef::basebackend-html[`$`, `\E`] emacs:: ifdef::basebackend-html[] +++\E, \^E+++ endif::basebackend-html[] ifndef::basebackend-html[`\E`, `\^E`] -- go-to-column:: Move the cursor to the {{n}}th character on the line, where {{n}} is the argument. Assume {{n}} = 1 when no argument. + -- vi-command:: ifdef::basebackend-html[+++|+++] ifndef::basebackend-html[`|`] -- first-nonblank:: Move the cursor to the first non-blank character on the line. + -- vi-command:: ifdef::basebackend-html[+++^+++] ifndef::basebackend-html[`^`] -- find-char:: Move the cursor to the first position where a character that is entered just after this command appears after the current cursor position. + -- vi-command:: ifdef::basebackend-html[+++f+++] ifndef::basebackend-html[`f`] emacs:: ifdef::basebackend-html[+++\^\]+++] ifndef::basebackend-html[`\^\]`] -- find-char-rev:: Move the cursor to the last position where a character that is entered just after this command appears before the current cursor position. + -- vi-command:: ifdef::basebackend-html[+++F+++] ifndef::basebackend-html[`F`] emacs:: ifdef::basebackend-html[+++\^[\^\]+++] ifndef::basebackend-html[`\^[\^\]`] -- till-char:: Move the cursor to the first position just before a character that is entered just after this command appears after the current cursor position. + -- vi-command:: ifdef::basebackend-html[+++t+++] ifndef::basebackend-html[`t`] -- till-char-rev:: Move the cursor to the last position just after a character that is entered just after this command appears before the current cursor position. + -- vi-command:: ifdef::basebackend-html[+++T+++] ifndef::basebackend-html[`T`] -- refind-char:: Redo the last find-char, find-char-rev, till-char, till-char-rev command. + -- vi-command:: ifdef::basebackend-html[+++;+++] ifndef::basebackend-html[`;`] -- refind-char-rev:: Redo the last find-char, find-char-rev, till-char, till-char-rev command in the reverse direction. + -- vi-command:: ifdef::basebackend-html[+++,+++] ifndef::basebackend-html[`,`] -- [[editing-commands]] === Editing commands Editing commands modify contents of the buffer. Most editing commands accept an argument. When passed an argument, they repeat the modification as many times as specified by the argument. Texts deleted by commands whose name starts with ``kill'' are saved in dfn:[kill ring], from which deleted contents can be restored to the buffer. The most recent 32 texts are kept in the kill ring. delete-char:: Delete a character at the current cursor position if no argument is passed; like the kill-char command otherwise. + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\X+++] ifndef::basebackend-html[`\X`] -- delete-bigword:: Delete a bigword at the current cursor position if no argument is passed; like the kill-bigword command otherwise. delete-semiword:: Delete a semiword at the current cursor position if no argument is passed; like the kill-semiword command otherwise. delete-viword:: Delete a viword at the current cursor position if no argument is passed; like the kill-viword command otherwise. delete-emacsword:: Delete a emacsword at the current cursor position if no argument is passed; like the kill-emacsword command otherwise. backward-delete-char:: Delete a character just before the current cursor position if no argument is passed; like the backward-kill-char command otherwise. + -- vi-insert:: emacs:: ifdef::basebackend-html[] +++\B, \?, \^H+++ endif::basebackend-html[] ifndef::basebackend-html[`\B`, `\?`, `\^H`] -- backward-delete-bigword:: Delete a bigword just before the current cursor position if no argument is passed; like the backward-kill-bigword command otherwise. backward-delete-semiword:: Delete a semiword just before the current cursor position if no argument is passed; like the backward-kill-semiword command otherwise. + -- vi-insert:: ifdef::basebackend-html[+++\^W+++] ifndef::basebackend-html[`\^W`] -- backward-delete-viword:: Delete a viword just before the current cursor position if no argument is passed; like the backward-kill-viword command otherwise. backward-delete-emacsword:: Delete a emacsword just before the current cursor position if no argument is passed; like the backward-kill-emacsword command otherwise. delete-line:: Delete the whole buffer contents. forward-delete-line:: Delete all characters from the current cursor position to the end of the buffer. backward-delete-line:: Delete all characters before the current cursor position. + -- vi-insert:: ifdef::basebackend-html[] +++\$, \^U+++ endif::basebackend-html[] ifndef::basebackend-html[`\$`, `\^U`] -- kill-char:: Delete a character at the current cursor position and add it to the kill ring. + -- vi-command:: ifdef::basebackend-html[] +++x, \X+++ endif::basebackend-html[] ifndef::basebackend-html[`x`, `\X`] -- kill-bigword:: Delete a bigword at the current cursor position and add it to the kill ring. kill-semiword:: Delete a semiword at the current cursor position and add it to the kill ring. kill-viword:: Delete a viword at the current cursor position and add it to the kill ring. kill-emacsword:: Delete a emacsword at the current cursor position and add it to the kill ring. + -- emacs:: ifdef::basebackend-html[] +++\^[d, \^[D+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[d`, `\^[D`] -- backward-kill-char:: Delete a character just before the current cursor position and add it to the kill ring. + -- vi-command:: ifdef::basebackend-html[+++X+++] ifndef::basebackend-html[`X`] -- backward-kill-bigword:: Delete a bigword just before the current cursor position and add it to the kill ring. + -- emacs:: ifdef::basebackend-html[+++\^W+++] ifndef::basebackend-html[`\^W`] -- backward-kill-semiword:: Delete a semiword just before the current cursor position and add it to the kill ring. backward-kill-viword:: Delete a viword just before the current cursor position and add it to the kill ring. backward-kill-emacsword:: Delete a emacsword just before the current cursor position and add it to the kill ring. + -- emacs:: ifdef::basebackend-html[] +++\^[\B, \^[\?, \^[\^H+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[\B`, `\^[\?`, `\^[\^H`] -- kill-line:: Delete the whole buffer contents and add it to the kill ring. forward-kill-line:: Delete all characters from the current cursor position to the end of the buffer and add it to the kill ring. + -- emacs:: ifdef::basebackend-html[+++\^K+++] ifndef::basebackend-html[`\^K`] -- backward-kill-line:: Delete all characters before the current cursor position and add it to the kill ring. + -- emacs:: ifdef::basebackend-html[] +++\$, \^U, \^X\B, \^X\?+++ endif::basebackend-html[] ifndef::basebackend-html[`\$`, `\^U`, `\^X\B`, `\^X\?`] -- put-before:: Insert the last-killed text before the current cursor position and move the cursor to the last character that was inserted. + -- vi-command:: ifdef::basebackend-html[+++P+++] ifndef::basebackend-html[`P`] -- put:: Insert the last-killed text after the current cursor position and move the cursor to the last character that was inserted. + -- vi-command:: ifdef::basebackend-html[+++p+++] ifndef::basebackend-html[`p`] -- put-left:: Insert the last-killed text before the current cursor position and move the cursor to the last character that was inserted. + -- emacs:: ifdef::basebackend-html[+++\^Y+++] ifndef::basebackend-html[`\^Y`] -- put-pop:: Replace the just put text with the next older killed text. + This command can be used only just after the put-before, put, put-left, or put-pop command. + -- emacs:: ifdef::basebackend-html[] +++\^[y, \^[Y+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[y`, `\^[Y`] -- undo:: Cancel modification by the last editing command. + -- vi:: ifdef::basebackend-html[+++u+++] ifndef::basebackend-html[`u`] emacs:: ifdef::basebackend-html[] +++\^_, \^X\$, \^X\^U+++ endif::basebackend-html[] ifndef::basebackend-html[`\^_`, `\^X\$`, `\^X\^U`] -- undo-all:: Cancel all modification in the current buffer, restoring the initial contents. + -- vi:: ifdef::basebackend-html[+++U+++] ifndef::basebackend-html[`U`] emacs:: ifdef::basebackend-html[] +++\^[\^R, \^[r, \^[R+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[\^R`, `\^[r`, `\^[R`] -- cancel-undo:: Cancel cancellation by the last undo or undo-all command. + -- vi:: ifdef::basebackend-html[+++\^R+++] ifndef::basebackend-html[`\^R`] -- cancel-undo-all:: Cancel all cancellation by all most recent undo and undo-all commands. redo:: Repeat modification by the last editing command. + -- vi-command:: ifdef::basebackend-html[+++.+++] ifndef::basebackend-html[`.`] -- [[completion-commands]] === Completion commands complete:: <> a word just before the cursor position and, if there is more than one candidate, show a list of the candidates. complete-next-candidate:: Like the complete command when candidates are not being listed; otherwise, select the next candidate in the list. + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\^I+++] ifndef::basebackend-html[`\^I`] -- complete-prev-candidate:: Like the complete command when candidates are not being listed; otherwise, select the previous candidate in the list. + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\bt+++] ifndef::basebackend-html[`\bt`] -- complete-next-column:: Like the complete command when candidates are not being listed; otherwise, select the first candidate in the next column in the list. complete-prev-column:: Like the complete command when candidates are not being listed; otherwise, select the first candidate in the previous column in the list. complete-next-page:: Like the complete command when candidates are not being listed; otherwise, select the first candidate in the next page in the list. complete-prev-page:: Like the complete command when candidates are not being listed; otherwise, select the first candidate in the previous page in the list. complete-list:: Complete a word just before the cursor position. + If you pass no argument, a list of completion candidates is shown. Otherwise, the word is completed with the {{n}}th candidate where {{n}} is the argument. + -- emacs:: ifdef::basebackend-html[] +++\^[?, \^[=+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[?`, `\^[=`] -- complete-all:: Replace a word just before the cursor position with all possible completion candidates, each separated by a space. + -- emacs:: ifdef::basebackend-html[+++\^[*+++] ifndef::basebackend-html[`\^[*`] -- complete-max:: Complete a word just before the cursor position with the longest prefix of all possible completion candidates. clear-candidates:: Clear the list of completion candidates. [[vi-commands]] === Vi-specific commands vi-replace-char:: Replace the character at the cursor position with a character that is entered just after this command. + -- vi-command:: ifdef::basebackend-html[+++r+++] ifndef::basebackend-html[`r`] -- vi-insert-beginning:: Move the cursor to the beginning of the line and switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++I+++] ifndef::basebackend-html[`I`] -- vi-append:: Move the cursor to the next character and switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++I+++] ifndef::basebackend-html[`I`] -- vi-append-to-eol:: Move the cursor to the end of the line and switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++A+++] ifndef::basebackend-html[`A`] -- vi-replace:: Switch to the vi insert mode and start overwriting. While overwriting, the self-insert command replaces the character at cursor position rather than inserting a character. Overwriting ends when the editing mode is changed. + -- vi-command:: ifdef::basebackend-html[+++R+++] ifndef::basebackend-html[`R`] -- vi-switch-case:: Switch case of characters between the current and next cursor positions. This command must be followed by a motion command, which determines the next cursor position. vi-switch-case-char:: Switch case of the character at the current cursor position and move the cursor to the next character. + -- vi-command:: ifdef::basebackend-html[+++~+++] ifndef::basebackend-html[`~`] -- vi-yank:: Add to the kill ring the characters between the current and next cursor positions. This command must be followed by a motion command, which determines the next cursor position. + -- vi-command:: ifdef::basebackend-html[+++y+++] ifndef::basebackend-html[`y`] -- vi-yank-to-eol:: Add to the kill ring the characters from the current cursor position to the end of the line. + -- vi-command:: ifdef::basebackend-html[+++Y+++] ifndef::basebackend-html[`Y`] -- vi-delete:: Delete characters between the current and next cursor positions and add it to the kill ring. This command must be followed by a motion command, which determines the next cursor position. + -- vi-command:: ifdef::basebackend-html[+++d+++] ifndef::basebackend-html[`d`] -- vi-delete-to-eol:: Delete the characters from the current cursor position to the end of the line and add it to the kill ring. + -- vi-command:: ifdef::basebackend-html[+++D+++] ifndef::basebackend-html[`D`] -- vi-change:: Delete characters between the current and next cursor positions and switch to the vi insert mode. This command must be followed by a motion command, which determines the next cursor position. + -- vi-command:: ifdef::basebackend-html[+++c+++] ifndef::basebackend-html[`c`] -- vi-change-to-eol:: Delete the characters from the current cursor position to the end of the line and switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++C+++] ifndef::basebackend-html[`C`] -- vi-change-line:: Delete the whole buffer contents and switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++S+++] ifndef::basebackend-html[`S`] -- vi-yank-and-change:: Like the vi-change command, but the deleted text is added to the kill ring. vi-yank-and-change-to-eol:: Like the vi-change-to-eol command, but the deleted text is added to the kill ring. vi-yank-and-change-line:: Like the vi-change-line command, but the deleted text is added to the kill ring. vi-substitute:: Delete a character at the current cursor position, add it to the kill ring, and switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++s+++] ifndef::basebackend-html[`s`] -- vi-append-last-bigword:: Insert a space and the last bigword in the most recent command link:interact.html#history[history] entry just after the current cursor position and switch to the vi insert mode. If argument {{n}} is passed, the {{n}}th bigword in the entry is inserted instead of the last. + -- vi-command:: ifdef::basebackend-html[+++_+++] ifndef::basebackend-html[`_`] -- vi-exec-alias:: Execute the value of an link:syntax.html#aliases[alias] named +_{{c}}+ as editing commands where {{c}} is a character input just after this command. + -- vi-command:: ifdef::basebackend-html[+++@+++] ifndef::basebackend-html[`@`] -- vi-edit-and-accept:: Start the vi editor to edit the current buffer contents. When the editor finished, the edited buffer contents is accepted like the accept-line command unless the exit status of the editor is non-zero. + -- vi-command:: ifdef::basebackend-html[+++v+++] ifndef::basebackend-html[`v`] -- vi-complete-list:: Like the complete-list command, but also switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++=+++] ifndef::basebackend-html[`=`] -- vi-complete-all:: Like the complete-all command, but also switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++*+++] ifndef::basebackend-html[`*`] -- vi-complete-max:: Like the complete-max command, but also switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++\\+++] ifndef::basebackend-html[`\\`] -- vi-search-forward:: Switch to the vi search mode and start forward link:interact.html#history[history] search. + -- vi-command:: ifdef::basebackend-html[+++?+++] ifndef::basebackend-html[`?`] -- vi-search-backward:: Switch to the vi search mode and start backward link:interact.html#history[history] search. + -- vi-command:: ifdef::basebackend-html[+++/+++] ifndef::basebackend-html[`/`] -- [[emacs-commands]] === Emacs-specific commands emacs-transpose-chars:: Move a character just before the cursor to the right. + -- emacs:: ifdef::basebackend-html[+++\^T+++] ifndef::basebackend-html[`\^T`] -- emacs-transpose-words:: Move an emacsword just before the cursor to the right. + -- emacs:: ifdef::basebackend-html[] +++\^[t, \^[T+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[t`, `\^[T`] -- emacs-downcase-word:: Make an emacsword just after the cursor lowercase. + -- emacs:: ifdef::basebackend-html[] +++\^[l, \^[L+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[l`, `\^[L`] -- emacs-upcase-word:: Make an emacsword just after the cursor uppercase. + -- emacs:: ifdef::basebackend-html[] +++\^[u, \^[U+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[u`, `\^[U`] -- emacs-capitalize-word:: Capitalize the first letter of an emacsword just after the cursor. + -- emacs:: ifdef::basebackend-html[] +++\^[c, \^[C+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[c`, `\^[u`] -- emacs-delete-horizontal-space:: Delete spaces around the cursor. If any argument was passed, delete spaces just before the cursor only. + -- emacs:: ifdef::basebackend-html[+++\^[\\+++] ifndef::basebackend-html[`\^[\\`] -- emacs-just-one-space:: Delete spaces around the cursor and leave one space. If an argument is specified, leave as many spaces as the argument. + -- emacs:: ifdef::basebackend-html[+++\^[ +++] ifndef::basebackend-html[`\^[`] (Escape followed by a space) -- emacs-search-forward:: Switch to the emacs search mode and start forward link:interact.html#history[history] search. + -- emacs:: ifdef::basebackend-html[+++\^S+++] ifndef::basebackend-html[`\^S`] -- emacs-search-backward:: Switch to the emacs search mode and start backward link:interact.html#history[history] search. + -- emacs:: ifdef::basebackend-html[+++\^R+++] ifndef::basebackend-html[`\^R`] -- [[history-commands]] === History-related commands oldest-history:: Recall the oldest entry in the link:interact.html#history[history]. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. The cursor position remains unchanged. newest-history:: Recall the newest entry in the link:interact.html#history[history]. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. The cursor position remains unchanged. return-history:: Return to the initial buffer corresponding to none of existing link:interact.html#history[history] entries. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. The cursor position remains unchanged. oldest-history-bol:: Recall the oldest entry in the link:interact.html#history[history] and move the cursor to the beginning of the line. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. + -- vi-command:: ifdef::basebackend-html[+++G+++] ifndef::basebackend-html[`G`] -- newest-history-bol:: Recall the newest entry in the link:interact.html#history[history] and move the cursor to the beginning of the line. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. return-history-bol:: Return to the initial buffer corresponding to none of existing link:interact.html#history[history] entries and move the cursor to the beginning of the line. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. + -- vi-command:: ifdef::basebackend-html[+++g+++] ifndef::basebackend-html[`g`] -- oldest-history-eol:: Recall the oldest entry in the link:interact.html#history[history] and move the cursor to the end of the line. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. + -- emacs:: ifdef::basebackend-html[+++\^[<+++] ifndef::basebackend-html[`\^[<`] -- newest-history-eol:: Recall the newest entry in the link:interact.html#history[history] and move the cursor to the end of the line. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. return-history-eol:: Return to the initial buffer corresponding to none of existing link:interact.html#history[history] entries and move the cursor to the end of the line. If argument {{n}} is passed, the entry whose number is {{n}} is recalled instead. + -- emacs:: ifdef::basebackend-html[+++\^[>+++] ifndef::basebackend-html[`\^[>`] -- next-history:: Recall the next link:interact.html#history[history] entry. The cursor position remains unchanged. prev-history:: Recall the previous link:interact.html#history[history] entry. The cursor position remains unchanged. next-history-bol:: Recall the next link:interact.html#history[history] entry and move the cursor to the beginning of the line. + -- vi-command:: ifdef::basebackend-html[] +++j, +, \D, \^N+++ endif::basebackend-html[] ifndef::basebackend-html[`j`, `+`, `\D`, `\^N`] -- prev-history-bol:: Recall the previous link:interact.html#history[history] entry and move the cursor to the beginning of the line. + -- vi-command:: ifdef::basebackend-html[] +++k, -, \U, \^P+++ endif::basebackend-html[] ifndef::basebackend-html[`k`, `-`, `\U`, `\^P`] -- next-history-eol:: Recall the next link:interact.html#history[history] entry and move the cursor to the end of the line. + -- vi-insert:: emacs:: ifdef::basebackend-html[] +++\D, \^N+++ endif::basebackend-html[] ifndef::basebackend-html[`\D`, `\^N`] -- prev-history-eol:: Recall the previous link:interact.html#history[history] entry and move the cursor to the end of the line. + -- vi-insert:: emacs:: ifdef::basebackend-html[] +++\U, \^P+++ endif::basebackend-html[] ifndef::basebackend-html[`\U`, `\^P`] -- search-again:: Repeat the last command history search. + -- vi-command:: ifdef::basebackend-html[+++n+++] ifndef::basebackend-html[`n`] -- search-again-rev:: Repeat the last command history search in the reverse direction. + -- vi-command:: ifdef::basebackend-html[+++N+++] ifndef::basebackend-html[`N`] -- search-again-forward:: Repeat the last command history search in the forward direction. search-again-backward:: Repeat the last command history search in the backward direction. beginning-search-forward:: Recall the next link:interact.html#history[history] entry that starts with the same text as the text from the beginning of the line up to the current cursor position. The cursor position remains unchanged. beginning-search-backward:: Recall the previous link:interact.html#history[history] entry that starts with the same text as the text from the beginning of the line up to the current cursor position. The cursor position remains unchanged. [[search-commands]] === Search mode commands srch-self-insert:: Insert the input character at the current cursor position. Characters escaped by <> cannot be inserted. + -- vi-search:: emacs-search:: ifdef::basebackend-html[+++\\+++] ifndef::basebackend-html[`\\`] -- srch-backward-delete-char:: Delete the last character in the search text. If the text is empty: + -- - like the srch-abort-search command when in the vi search mode, or - like the alert command when in the emacs search mode. -- + -- vi-search:: emacs-search:: ifdef::basebackend-html[] +++\B, \?, \^H+++ endif::basebackend-html[] ifndef::basebackend-html[`\B`, `\?`, `\^H`] -- srch-backward-delete-line:: Delete the whole search text. + -- vi-search:: emacs-search:: ifdef::basebackend-html[] +++\$, \^U+++ endif::basebackend-html[] ifndef::basebackend-html[`\$`, `\^U`] -- srch-continue-forward:: Find the next matching history entry. + -- emacs-search:: ifdef::basebackend-html[+++\^S+++] ifndef::basebackend-html[`\^S`] -- srch-continue-backward:: Find the previous matching history entry. + -- emacs-search:: ifdef::basebackend-html[+++\^R+++] ifndef::basebackend-html[`\^R`] -- srch-accept-search:: Finish the search mode, accepting the result being shown. + -- vi-search:: ifdef::basebackend-html[] +++\^J, \^M+++ endif::basebackend-html[] ifndef::basebackend-html[`\^J`, `\^M`] emacs-search:: ifdef::basebackend-html[] +++\^J, \^[+++ endif::basebackend-html[] ifndef::basebackend-html[`\^J`, `\^[`] -- srch-abort-search:: Abort search and restore the previous buffer contents. + -- vi-search:: ifdef::basebackend-html[+++\^[+++] ifndef::basebackend-html[`\^[`] emacs-search:: ifdef::basebackend-html[+++\^G+++] ifndef::basebackend-html[`\^G`] -- [[escape]] == Escape sequences In the link:_bindkey.html[bindkey built-in], escape sequences are used to represent special keys such as function keys and arrow keys. Every escape sequence starts with a backslash (`\`) and thus there is also an escape sequence for a backslash itself. Below are available escape sequences: `\\`:: Backslash (`\`) `\B`:: Backspace `\D`:: Down arrow `\E`:: End `\H`:: Home `\I`:: Insert (Insert-char, Enter-insert-mode) `\L`:: Left arrow `\N`:: Page-down (Next-page) `\P`:: Page-up (Previous-page) `\R`:: Right arrow `\U`:: Up arrow `\X`:: Delete `\!`:: INTR `\#`:: EOF `\$`:: KILL `\?`:: ERASE `\^@`:: Ctrl + @ `\^A`, `\^B`, ..., `\^Z`:: Ctrl + A, Ctrl + B, ..., Ctrl + Z + Note that Ctrl + I, Ctrl + J, and Ctrl + M are tab, newline, and carriage return, respectively. `\^[`:: Ctrl + [ (Escape) `\^\`:: Ctrl + \ `\^]`:: Ctrl + ] `\^^`:: Ctrl + ^ `\^_`:: Ctrl + _ `\^?`:: Ctrl + ? (Delete) `\F00`, `\F01`, ..., `\F63`:: F0, F1, ..., F63 `\a1`:: Top-left on keypad `\a3`:: Top-right on keypad `\b2`:: Center on keypad `\bg`:: Beginning `\bt`:: Back-tab `\c1`:: Bottom-left on keypad `\c3`:: Bottom-right on keypad `\ca`:: Clear-all-tabs `\cl`:: Close `\cn`:: Cancel `\co`:: Command `\cp`:: Copy `\cr`:: Create `\cs`:: Clear-screen or erase `\ct`:: Clear-tab `\dl`:: Delete-line `\ei`:: Exit-insert-mode `\el`:: Clear-to-end-of-line `\es`:: Clear-to-end-of-screen `\et`:: Enter (Send) `\ex`:: Exit `\fd`:: Find `\hp`:: Help `\il`:: Insert-line `\ll`:: Home-down `\me`:: Message `\mk`:: Mark `\ms`:: Mouse event `\mv`:: Move `\nx`:: Next-object `\on`:: Open `\op`:: Options `\pr`:: Print (Copy) `\pv`:: Previous-object `\rd`:: Redo `\re`:: Resume `\rf`:: Ref (Reference) `\rh`:: Refresh `\rp`:: Replace `\rs`:: Restart `\sf`:: Scroll-forward (Scroll-down) `\sl`:: Select `\sr`:: Scroll-backward (Scroll-up) `\st`:: Set-tab `\su`:: Suspend `\sv`:: Save `\ud`:: Undo `\SE`:: Shift + End `\SH`:: Shift + Home `\SI`:: Shift + Insert `\SL`:: Shift + Left arrow `\SR`:: Shift + Right arrow `\SX`:: Shift + Delete `\Sbg`:: Shift + Beginning `\Scn`:: Shift + Cancel `\Sco`:: Shift + Command `\Scp`:: Shift + Copy `\Scr`:: Shift + Create `\Sdl`:: Shift + Delete-line `\Sel`:: Shift + End-of-line `\Sex`:: Shift + Exit `\Sfd`:: Shift + Find `\Shp`:: Shift + Help `\Smg`:: Shift + Message `\Smv`:: Shift + Move `\Snx`:: Shift + Next `\Sop`:: Shift + Options `\Spr`:: Shift + Print `\Spv`:: Shift + Previous `\Srd`:: Shift + Redo `\Sre`:: Shift + Resume `\Srp`:: Shift + Replace `\Ssu`:: Shift + Suspend `\Ssv`:: Shift + Save `\Sud`:: Shift + Undo INTR, EOF, KILL, and ERASE are special characters configured by the stty command. In a typical configuration, they are sent by typing Ctrl+C, Ctrl+D, Ctrl+U, and Ctrl+H, respectively, but some configuration uses Ctrl+? instead of Ctrl+H for ERASE. [[completion]] == Command line completion By using the complete and complete-next-candidate commands, etc., you can complete command names, options, and operands. By default, the complete-next-candidate command is bound with the Tab key in the vi insert and emacs modes. Type a few first letters of a command name or pathname and hit the Tab key, and a list of matching names will be shown. You can choose a candidate from the list to complete the name by hitting the Tab key again. If there is only one matching name, no list will be shown and the name will directly be completed. If the name to be completed contains characters like `*` and `?`, it is treated as a link:pattern.html[pattern]. The name on the command line will be directly substituted with all possible names matching the pattern (you cannot choose from a list). Normally, command names are completed with command names and command arguments with pathnames. However, dfn:[completion functions] can be defined to refine completion results. [[completion-detail]] === Completion details When doing completion for the first time after the shell has been started, the INIT file is loaded as if the command string +link:_dot.html[.] -AL completion/INIT+ is executed. If the file is not found, it is silently ignored. This automatic loading is mainly intended for loading completion functions bundled with the shell, but you can let the shell load your own functions by putting a file in the link:params.html#sv-yash_loadpath[load path]. When completing a command name, the shell executes the +completion//command+ function and when completing a command argument, the +completion//argument+ function. If those completion functions are not defined, the shell just completes with command names or pathnames. When completing other names, such as the user name in link:expand.html#tilde[tilde expansion] and the parameter name in link:expand.html#params[parameter expansion], completion functions are never used: the shell just completes with user names, parameter names, or whatever applicable. Completion functions are link:exec.html#function[executed] without any arguments. The following link:exec.html#localvar[local variables] are automatically defined while executing completion functions: link:params.html#sv-ifs[+IFS+]:: The value is the three characters of a space, a tab, and a newline, which are the default value of the variable. +WORDS+:: This variable is an link:params.html#arrays[array] whose elements are a command name and arguments that have already been entered before the argument being completed. When completing a command name, the array has no elements. +TARGETWORD+:: The value is the partially entered command name or argument that is being completed. Completion candidates are generated by executing the link:_complete.html[complete built-in] during a completion function. Completion functions must not perform I/O to the terminal, or displayed text will be corrupted. Completion functions should run as quickly as possible for better user experience. While a completion function is being executed: - the link:posix.html[POSIXly-correct mode] is temporarily disabled, - the link:_set.html#so-errexit[err-exit option] is temporarily disabled, and - link:_trap.html[traps] are not executed. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_fg.txt0000644000175000017500000000250012154557026014604 0ustar magicantmagicant= Fg built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Fg built-in The dfn:[fg built-in] resumes a job in the foreground. [[syntax]] == Syntax - +fg [{{job}}...]+ [[description]] == Description The fg built-in brings the specified job to the foreground and sends the SIGCONT signal to the job. As a result, the job is resumed in the foreground (if it has been suspended). The built-in then waits for the job to finish and returns the exit status of it. The name of the job is printed when the job is resumed. The built-in can be used only when link:job.html[job control] is enabled. [[operands]] == Operands {{job}}:: The link:job.html#jobid[job ID] of the job to be resumed. + If more than one job is specified, they are resumed in order, one at a time. The current job is resumed if none is specified. + The percent sign (+%+) at the beginning of a job ID can be omitted if the shell is not in the link:posix.html[POSIXly-correct mode]. [[exitstatus]] == Exit status The exit status of the fg built-in is that of the (last) job resumed. The exit status is non-zero when there was some error. [[notes]] == Notes The fg built-in is a link:builtin.html#types[semi-special built-in]. You cannot specify more than one job in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_continue.txt0000644000175000017500000000314412154557026016041 0ustar magicantmagicant= Continue built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Continue built-in The dfn:[continue built-in] skips an iteration of a loop being executed. [[syntax]] == Syntax - +continue [{{nest}}]+ - +continue -i+ [[description]] == Description When executed without the +-i+ (+--iteration+) option, the built-in aborts the current iteration of link:syntax.html#for[for], link:syntax.html#while-until[while], or link:syntax.html#while-until[until] loop and starts the next iteration of the loop. When executed in nested loops, it affects the {{nest}}th innermost loop. The default {{nest}} is one. If the number of currently executed nested loops is less than {{nest}}, the built-in affects the outermost loop. When executed with the +-i+ (+--iteration+) option, the built-in aborts the current iteration of (innermost) link:_eval.html#iter[iterative execution]. [[options]] == Options +-i+:: +--iteration+:: Skip an iterative execution instead of a loop. [[operands]] == Operands {{nest}}:: The {{nest}}th innermost loop is affected. {{nest}} must be a positive integer. [[exitstatus]] == Exit status The exit status of the continue built-in is: - zero if loop iteration was successfully skipped. - that of the command that was executed just before the continue built-in if iterative execution was successfully skipped. [[notes]] == Notes The continue built-in is a link:builtin.html#types[special built-in]. The POSIX standard defines no options for the continue built-in; the built-in accepts no options in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_eval.txt0000644000175000017500000000360512154557026015146 0ustar magicantmagicant= Eval built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Eval built-in The dfn:[eval built-in] evaluates operands as commands. [[syntax]] == Syntax - +eval [-i] [{{command}}...]+ The eval built-in requires that all options precede operands. Any command line arguments after the first operand are all treated as operands. [[description]] == Description The eval parses operands as commands and executes them in the current link:exec.html#environment[command execution environment]. When executed without the +-i+ (+--iteration+) option, all the operands are concatenated into one string (with a space inserted between each operand) and parsed/executed at once. With the +-i+ (+--iteration+) option, the built-in performs dfn:iter[iterative execution]: operands are parsed/executed one by one. If the link:_continue.html[continue built-in] is executed with the +-i+ (+--iteration+) option during the iterative execution, the execution of the current operand is aborted and the next operand is parsed/executed immediately. The link:_break.html[break built-in] with the +-i+ (+--iteration+) option is similar but the remaining operands are not parsed/executed. [[options]] == Options +-i+:: +--iteration+:: Perform iterative execution. [[operands]] == Operands {{command}}:: A string that is parsed and executed as commands. [[exitstatus]] == Exit status The exit status is zero if no {{command}} was specified or {{command}} contained no actual command that can be executed. Otherwise, that is, if the eval built-in executed one or more commands, the exit status of the eval built-in is that of the last executed command. [[notes]] == Notes The eval built-in is a link:builtin.html#types[special built-in]. The POSIX standard defines no options for the eval built-in; the built-in accepts no options in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_echo.html0000644000175000017500000001362212154557026015262 0ustar magicantmagicant Echo built-in

The echo built-in prints its arguments.

Syntax

  • echo [string…]

The built-in treats all command line arguments as operands except for the options described below. Any word that cannot be parsed as an acceptable option is treated as an operand. Options must precede all operands. Syntax errors never happen in the echo built-in.

Description

The echo built-in prints the operand strings followed by a newline to the standard output. The strings are each separated by a space.

Escape sequences

The ECHO_STYLE variable and the -e option enable escape sequences that are replaced with corresponding characters:

\a

Bell character (ASCII code: 7)

\b

Backspace (ASCII code: 8)

\c

Nothing. After this escape sequence, no characters are printed at all.

\e

Escape character (ASCII code: 27)

\f

Form feed character (ASCII code: 12)

\n

Newline character (ASCII code: 10)

\r

Carriage return character (ASCII code: 13)

\t

Horizontal tab character (ASCII code: 9)

\v

Vertical tab character (ASCII code: 11)

\\

Backslash

\0xxx

Character whose code is xxx, where xxx is an octal number of at most three digits.

When escape sequences are not enabled, they are just printed intact.

ECHO_STYLE variable

The ECHO_STYLE variable defines which options are accepted and whether escape sequences are enabled by default. The variable value should be set to one of the following:

SYSV
XSI

No options are accepted. Escape sequences are always enabled.

BSD

The -n option is accepted. Escape sequences are never enabled.

GNU

The -n, -e, and -E options are accepted. Escape sequences are not enabled by default, but can be enabled by the -e option.

ZSH

The -n, -e, and -E options are accepted. Escape sequences are enabled by default, but can be disabled by the -E option.

DASH

The -n option is accepted. Escape sequences are always enabled.

RAW

No options are accepted. Escape sequences are never enabled.

When the ECHO_STYLE variable is not set, it defaults to SYSV.

Options

-n

Do not print a newline at the end.

-e

Enable escape sequences.

-E

Disable escape sequences.

Exit status

The exit status of the echo built-in is zero unless there is any error.

Notes

The POSIX standard does not define the ECHO_STYLE variable nor any options for the built-in. According to POSIX, the behavior of the built-in is implementation-defined when the first argument is -n or when any argument contains a backslash. For maximum portability, the printf built-in should be preferred over the echo built-in.

yash-2.35/doc/_wait.html0000644000175000017500000000655712154557026015321 0ustar magicantmagicant Wait built-in

The wait built-in waits for jobs to terminate.

Syntax

  • wait [job…]

Description

The wait built-in waits for background jobs to terminate. If job control is enabled, stopped jobs are considered as terminated.

The built-in can be used to wait for asynchronous commands if job control is disabled.

If the shell receives a signal while the built-in is waiting and if a trap has been set for the signal, then the trap is executed and the built-in immediately finishes (without waiting for the jobs). If the shell receives a SIGINT signal when job control is enabled, the built-in aborts waiting.

Operands

job

The job ID of the job or the process ID of a process in the job.

If no jobs are specified, the built-in waits for all existing jobs.

If the specified job does not exist, the job is considered to have terminated with the exit status of 127.

Exit status

If no jobs were specified and the built-in successfully waited for all the jobs, the exit status is zero. If one or more jobs were specified, the exit status is that of the last job.

If the built-in was aborted by a signal, the exit status is an integer (> 128) that denotes the signal. If there was any other error, the exit status is between 1 and 126 (inclusive).

Notes

The wait built-in is a semi-special built-in.

The process ID of the last process of a job can be obtained by the ! special parameter. You can use the jobs built-in as well to obtain process IDs of job processes.

yash-2.35/doc/_fc.html0000644000175000017500000001612412154557026014734 0ustar magicantmagicant Fc built-in

The fc built-in re-executes or prints commands from command history.

Syntax

  • fc [-qr] [-e editor] [start [end]]

  • fc -s[q] [old=new] [start]

  • fc -l[nrv] [start [end]]

Description

When executed without the -l (--list) option, the built-in executes the commands in the command history range specified by the operands. If the -s (--silent) option is not specified, the shell invokes an editor which allows you to edit the commands before they are executed. The commands are executed when you quit the editor. If the -s (--silent) option is specified, the commands are immediately executed. In either case, the executed commands are printed to the standard output and added to the history.

When executed with the -l (--list) option, the built-in prints the commands in the command history range specified by the operands. By default, commands are printed with their history entry numbers, but output format can be changed using the -n (--no-numbers)) and -v (--verbose) options.

Options

-e editor
--editor=editor

Specify an editor that is used to edit commands.

If this option is not specified, the value of the FCEDIT variable is used. If the variable is not set either, vi is used.

-l
--list

Print command history entries.

-n
--no-numbers

Don’t print entry numbers when printing history entries.

-q
--quiet

Don’t print commands before executing.

-r
--reverse

Reverse the order of command entries in the range.

-s
--silent

Execute commands without editing them.

-v
--verbose

Print execution time before each history entry when printing.

Operands

start and end

The start and end operands specify a range of command history entries that are executed or printed. If one of the operands is an integer, it is treated as a history entry number. A negative integer means the nth most recent entry where n is the absolute value of the integer. If one of the operands is not an integer, it is treated as part of a command string: the most recent entry that starts with the string is selected as the start or end of the range.

If the first entry of the range that is specified by start is newer than the last entry of the range that is specified by end, the range is reversed as if the -r (--reverse) option was specified. (If the option is already specified, it is cancelled.)

The default values for start and end are:

with -l without -l

start

-16

-1

end

-16

same as start

old=new

An operand of this format replaces part of the command string. If the command string contains old, it is replaced with new and the new string is executed. Only the first occurrence of old is replaced.

Exit status

If commands was executed, the exit status of the fc built-in is that of the last executed command. Otherwise, the exit status is zero unless there is any error.

Notes

The fc built-in is a semi-special built-in.

The POSIX standard does not define the -q (--quiet) or -v (--verbose) options, so they cannot be used in the POSIXly-correct mode.

Command history cannot be modified during line-editing.

yash-2.35/doc/_false.html0000644000175000017500000000305512154557026015435 0ustar magicantmagicant False built-in

The false built-in does nothing unsuccessfully.

Syntax

  • false

Description

The false built-in does nothing. Any command line arguments are ignored.

Exit status

The exit status of the false built-in is non-zero.

Notes

The false built-in is a semi-special built-in.

yash-2.35/doc/pattern.txt0000644000175000017500000001474112154557026015540 0ustar magicantmagicant= Pattern matching notation :encoding: UTF-8 :lang: en //:title: Yash manual - Pattern matching notation :description: This page describes pattern matching notation supported by yash. dfn:[Pattern matching notation] is a syntax of dfn:[patterns] that represent particular sets of strings. When a string is included in the set of strings a pattern represents, the pattern is said to dfn:[match] the string. Whether a pattern matches a string or not is defined as follows. [[normal]] == Normal characters A character that is not link:syntax.html#quotes[quoted] or any of special characters defined below is a normal character, which matches the character itself. For example, the pattern +abc+ matches the string +abc+, and not any other strings. [[single]] == Single-character wildcard The character +?+ matches any single character. For example, the pattern +a?c+ matches any three-character strings that starts with +a+ and ends with +c+, such as +aac+, +abc+, and +a;c+. [[multiple]] == Multi-character wildcard The character +*+ matches any strings (of any length, including the empty string). For example, the pattern +a*c+ matches any string that starts with +a+ and ends with +c+, such as +ac+, +abc+, and +a;xyz;c+. [[bracket]] == Bracket expression A pattern that is enclosed by brackets (+[+ and +]+) is a dfn:[bracket expression]. A bracket expression must have at least one character between the brackets. The characters between the brackets are interpreted as a dfn:[bracket expression pattern], which is a below-defined special notation for bracket expression. A bracket expression pattern represents a set of characters. The bracket expression matches any one of the characters in the set the bracket expression pattern represents. If the opening bracket (+[+) is followed by an exclamation mark (+!+), the exclamation is not treated as part of the bracket expression pattern and the whole bracket expression instead matches a character that is _not_ included in the set the bracket expression pattern represents. If the opening bracket is followed by a caret (+^+), it is treated like an exclamation mark as above (but shells other than yash may treat the caret differently). If the opening bracket (or the following exclamation or caret, if any) is followed by a closing bracket (+]+), it is treated as part of the bracket expression pattern rather than the end of the bracket expression. You cannot link:syntax.html#quotes[quote] characters in the bracket expression pattern because quotation is treated before bracket expression. An opening bracket in a pattern is treated as a normal character if it is not the beginning of a valid bracket expression. [[bra-normal]] == Normal characters (in bracket expression pattern) A character that is not any of special characters defined below is a normal character, which represents the character itself. For example, the bracket expression pattern +abc+ represents the set of the three characters +a+, +b+, and +c+. The bracket expression +[abc]+ therefore matches any of the three characters. [[bra-range]] == Range expressions A hyphen preceded and followed by a character (or <>) is a dfn:[range expression], which represents the set of the two characters and all characters between the two in the collation order. A dfn:[collation order] is an order of characters that is defined in the locale data. If a hyphen is followed by a closing bracket (+]+), the bracket is treated as the end of the bracket expression and the hyphen as a normal character. For example, the range expression +3-5+ represents the set of the three characters +3+, +4+, and +5+. The bracket expression +[3-5-]+ therefore matches one of the four characters +3+, +4+, +5+, and +-+. [[bra-colsym]] == Collating symbols A dfn:[collating symbol] allows more than one character to be treated as a single character in matching. A collating symbol is made up of one or more characters enclosed by the special brackets +[.+ and +.]+. One or more characters that are treated as a single character in matching are called a dfn:[collating element]. Precisely, a bracket expression pattern represents a set of collating elements and a bracket expression matches a collating element rather than a character, but we do not differentiate them for brevity here. For example, the character combination ``ch'' was treated as a single character in the traditional Spanish language. If this character combination is registered as a collating element in the locale data, the bracket expression +[[.ch.]df]+ matches one of +ch+, +d+, and +f+. [[bra-eqclass]] == Equivalence classes An dfn:[equivalence class] represents a set of characters that are considered _equivalent_. A equivalence class is made up of a character (or more precisely, a collating element) enclosed by the special brackets +[=+ and +=]+. An equivalence class represents the set of characters that consists of the character enclosed by the brackets and the characters that are in the same primary equivalence class as the enclosed character. The shell consults the locale data for the definition of equivalence classes in the current locale. For example, if the six characters +a+, +à+, +á+, +â+, +ã+, +ä+ are defined to be in the same primary equivalence class, the bracket expressions +[[=a=]]+, +[[=à=]]+, and +[[=á=]]+ match one of the six. [[bra-chclass]] == Character classes A dfn:[character class] represents a predefined set of characters. A character class is made up of a class name enclosed by the special brackets +[:+ and +:]+. The shell consults the locale data for which class a character belongs to. The following character classes can be used in all locales: +[:lower:]+:: set of lowercase letters +[:upper:]+:: set of uppercase letters +[:alpha:]+:: set of letters, including the +[:lower:]+ and +[:upper:]+ classes. +[:digit:]+:: set of decimal digits +[:xdigit:]+:: set of hexadecimal digits +[:alnum:]+:: set of letters and digits, including the +[:alpha:]+ and +[:digit:]+ classes. +[:blank:]+:: set of blank characters, not including the newline character +[:space:]+:: set of space characters, including the newline character +[:punct:]+:: set of punctuations +[:print:]+:: set of printable characters +[:cntrl:]+:: set of control characters For example, the bracket expression `[[:lower:][:upper:]]` matches a lower or upper case character. In addition to the classes listed above, other classes may be used depending on the definition of the current locale. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_readonly.html0000644000175000017500000000345712154557026016166 0ustar magicantmagicant Readonly built-in

The readonly built-in makes variables and functions read-only.

Syntax

  • readonly [-pxX] [name[=value]…]

  • readonly -f[p] [name…]

Description

The readonly built-in is equivalent to the typeset built-in with the -gr option.

Notes

The readonly built-in is a special built-in.

The POSIX standard defines the -p option only; other options cannot be used in the POSIXly-correct mode. The POSIX does not allow using the option together with operands.

yash-2.35/doc/exec.html0000644000175000017500000003544612154557026015141 0ustar magicantmagicant Command execution

This section describes how commands are executed.

Execution of simple commands

A simple command is executed as follows:

  1. All tokens in the simple command are expanded except for assignment and redirection tokens. If an error occurs during expansion, the execution of the simple command is aborted with a non-zero exit status.
    In the following steps, the first word of the expansion results is referred to as command name, and the other words as command arguments. If there is only one word of the expansion results, there are no command argument words. If there are none of the expansion results, there is no command name either.

  2. Redirection specified in the command, if any, is processed. The word token after each redirection operator is expanded. If an error occurs during processing redirection (including when expanding the word token), the execution of this simple command is aborted with a non-zero exit status.

  3. Assignments specified in the command, if any, are processed. For each assignment token, the value is expanded and assigned to the specified variable. If an error occurs during assignments (including when expanding the values to be assigned), the execution of this simple command is aborted with a non-zero exit status.

    • If there is no command name or the name denotes a special built-in or function, the assignments are permanent: the assigned values remain after the command has finished (until the variable is reassigned).

    • Otherwise, the assignments are temporary: the assigned values only last during the execution of this simple command.

    The assigned variables are automatically exported when the command name is specified or the all-export option is enabled.

  4. If there is no command name, the command execution ends with the exit status of zero (unless there are any command substitutions in the command, in which case the exit status of the simple command is that of the last executed command substitution).

  5. A command to be executed is determined using the command search algorithm and the command is executed.

    • If the command is an external command, the command is executed by creating a new subshell and calling the “exec” system call in the subshell. The command name and arguments are passed to the executed command. Exported variables are passed to the executed command as environment variables.

    • If the command is a built-in, the built-in is executed with the command arguments passed to the built-in.

    • If the command is a function, the contents of the function are executed with the command arguments as function arguments.

    If the command was executed, the exit status of this simple command is that of the executed command. If the algorithm failed to determine a command, no command is executed and the exit status is 127. If the shell failed to execute the determined command, the exit status is 126. If the executed command was killed by a signal, the exit status is the signal number plus 384.

    Note
    In shells other than yash, the exit status may be different when the command was killed by a signal, because the POSIX standard only requires that the exit status be "greater than 128."

    If the shell is not in the POSIXly-correct mode and the algorithm failed to determine a command, the command eval -i -- "${COMMAND_NOT_FOUND_HANDLER-}" is evaluated. During the command execution, positional parameters are temporarily set to the command name and arguments that resulted in the first step. Any local variables defined during the execution are removed when the execution is finished. The HANDLED local variable is automatically defined with the initial value being the empty string. If the HANDLED variable has a non-empty value when the execution of the command string is finished, the shell pretends that the command was successfully determined and executed. The exit status of the simple command is that of the command string in this case.

A command that is executed in a simple command is determined by the command name using the following algorithm:

  1. If the command name contains a slash (/), the whole name is treated as the pathname of an external command. The external command is determined as the executed command.

  2. If the command name is a special built-in, the built-in is determined as the executed command.

  3. If the command name is the name of an existing function, the function is determined as the executed command.

  4. If the command name is a semi-special built-in, the built-in is determined as the executed command.

  5. If the command name is a regular built-in, the built-in is determined as the executed command unless the shell is in the POSIXly-correct mode.

  6. The shell searches the PATH for a executed command:

    The value of the PATH variable is separated by colons. Each separated part is considered as a directory pathname (an empty pathname denotes the current working directory). The shell searches the directories (in the order of appearance) and checks if any directory directly contains an executable regular file whose name is equal to the command name. If such a file is found:

    • If the command name is the name of a built-in, the built-in is determined as the executed command.

    • Otherwise, the file is determined as the executed command. (The file will be executed as an external command.)

    If no such file is found, no command is determined as the executed command.

When the shell finds a file that matches the command name during the search above, the shell remembers the pathname of the file if it is an absolute path. When the algorithm above is used for the same command name again, the shell skips searching and directly determines the command to be executed. If an executable regular file no longer exists at the remembered pathname, however, the shell searches again to update the remembered pathname. You can manage remembered pathnames using the hash built-in.

Termination of the shell

The shell exits when it reached the end of input and has parsed and executed all input commands or when the exit built-in is executed. The exit status of the shell is that of the last command the shell executed (or zero if no commands were executed). The exit status of the shell is always between 0 and 255 (inclusive). If the exit status of the last command is 256 or larger, the exit status of the shell will be the remainder of the exit status divided by 256.

If an exit handler has been registered by the trap built-in, the handler is executed just before the shell exits. The exit status of the commands executed in the handler does not affect the exit status of the shell.

If a non-interactive shell encountered one of the following errors, the shell immediately exits with a non-zero exit status:

  • A command cannot be parsed due to an syntax error (except during shell initialization).

  • A special built-in is executed in the POSIXly-correct mode and the command arguments do not meet the syntax of the built-in’s arguments.

  • An error occurs during redirection or assignment in a simple command whose command name is a special built-in and the shell is in the POSIXly-correct mode.

  • An error occurs during expansion (except during shell initialization).

Note
Some shells other than yash exit when they fail to find a command to execute in command search.

Functions

Functions allow executing a compound command as a simple command. A function can be defined by the function definition command and executed by a simple command. You can use the unset built-in to remove function definitions.

There are no functions predefined when yash is started.

A function is executed by executing its body, which is a compound command. While the function is being executed, positional parameters are set to the arguments given to the function. The old positional parameters are restored when the function execution finishes.

Local variables

Local variables are temporary variables that are defined in a function and exist during the function execution only. They can be defined by the typeset built-in. They are removed when the function execution finishes.

Local variables may hide variables that have already been defined before the function execution had started. An existing variable becomes inaccessible if a local variable of the same name is defined in a function. The old variable becomes accessible again when the function execution finishes.

You cannot create a local variable when not executing a function. A normal variable is created if you try to do so.

Command execution environment

The shell holds following properties during execution.

  • The working directory

  • Open file descriptors

  • The file creation mask (umask)

  • The set of signals whose handler is set to “ignore” (trap)

  • Environment variables

  • Resource limits (ulimit)

Those properties are inherited from the invoker of the shell to the shell, and from the shell to each external command executed by the shell.

The properties can be changed during the execution of the shell by built-in commands, variable assignments, etc.

Subshells

A subshell is a copy of the shell process. Subshells are used in execution of groupings, pipelines, etc.

Subshells inherit functions, aliases, etc. defined in the shell as well as the properties above since subshells are copies of the shell process. Notable exceptions are:

  • Signal handlers registered by the trap built-in are all reset in subshells except for ones whose action is set to “ignore”.

  • The interactive mode and job control are disabled in subshells. Jobs are not inherited by subshells.

Subshells are executed independently of the original shell, so changes of any properties above do not affect those of the original shell.

yash-2.35/doc/_times.txt0000644000175000017500000000145712154557026015343 0ustar magicantmagicant= Times built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Times built-in The dfn:[times built-in] prints CPU time usage. [[syntax]] == Syntax - +times+ [[description]] == Description The times built-in prints the CPU times consumed by the shell process and its child processes to the standard output. The built-in prints two lines: the first line shows the CPU time of the shell process and the second one that of its child processes (not including those which have not terminated). Each line shows the CPU times consumed in the user and system mode. [[exitstatus]] == Exit status The exit status of the times built-in is zero unless there is any error. [[notes]] == Notes The times built-in is a link:builtin.html#types[special built-in]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_pushd.txt0000644000175000017500000000331412154557026015337 0ustar magicantmagicant= Pushd built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Pushd built-in The dfn:[pushd built-in] pushes a directory into the directory stack. [[syntax]] == Syntax - +pushd [-L|-P] [{{directory}}]+ [[description]] == Description The pushd built-in changes the working directory to {{directory}} in the same manner as the link:_cd.html[cd built-in] and adds it to the directory stack. If the working directory could not be changed successfully, the stack is not modified. [[options]] == Options The pushd built-in accepts the following option as well as the link:_cd.html#options[options that can be used for the cd built-in]: +--remove-duplicates+:: If the new working directory has already been in the directory stack, the existing entry is removed from the stack before the new directory is pushed into the stack. [[operands]] == Operands {{directory}}:: The pathname of the new working directory. + If {{directory}} is a single hyphen (`-'), the value of the link:params.html#sv-oldpwd[+OLDPWD+ variable] is assumed for the new directory pathname, which is printed to the standard output. + If {{directory}} is an integer with a plus or minus sign, it is considered as an entry index of the directory stack. The entry is removed from the stack and then pushed to the stack again. + If {{directory}} is omitted, the working directory is changed to the directory specified by the +--default-directory=...+ option. If that option is not specified either, the default is index `+1`. [[exitstatus]] == Exit status The exit status of the pushd built-in is zero unless there is any error. [[notes]] == Notes The pushd built-in is not defined in the POSIX standard. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_continue.html0000644000175000017500000000652412154557026016173 0ustar magicantmagicant Continue built-in

The continue built-in skips an iteration of a loop being executed.

Syntax

  • continue [nest]

  • continue -i

Description

When executed without the -i (--iteration) option, the built-in aborts the current iteration of for, while, or until loop and starts the next iteration of the loop. When executed in nested loops, it affects the nestth innermost loop. The default nest is one. If the number of currently executed nested loops is less than nest, the built-in affects the outermost loop.

When executed with the -i (--iteration) option, the built-in aborts the current iteration of (innermost) iterative execution.

Options

-i
--iteration

Skip an iterative execution instead of a loop.

Operands

nest

The nestth innermost loop is affected. nest must be a positive integer.

Exit status

The exit status of the continue built-in is:

  • zero if loop iteration was successfully skipped.

  • that of the command that was executed just before the continue built-in if iterative execution was successfully skipped.

Notes

The continue built-in is a special built-in.

The POSIX standard defines no options for the continue built-in; the built-in accepts no options in the POSIXly-correct mode.

yash-2.35/doc/_suspend.html0000644000175000017500000000500012154557026016014 0ustar magicantmagicant Suspend built-in

The suspend built-in suspends the shell.

Syntax

  • suspend [-f]

Description

The suspend built-in sends a SIGSTOP signal to all processes in the process group to which the shell process belongs. The signal suspends the processes (including the shell). The suspended processes resume when they receive a SIGCONT signal.

If the shell is interactive and its process group ID is equal to the process ID of the session leader, the shell prints a warning message and refuses to send a signal unless the -f (--force) option is specified. (In such a case, there is no other job-controlling shell that can send a SIGCONT signal to resume the suspended shell, so the shell could never be resumed.)

Options

-f
--force

Suppress warnings that would prevent the shell from sending a signal.

Exit status

The exit status is zero if the signal was successfully sent and non-zero otherwise.

Notes

The suspend built-in is not defined in the POSIX standard.

yash-2.35/doc/syntax.html0000644000175000017500000006264612154557026015545 0ustar magicantmagicant Syntax

The shell reads, parses, and executes command line by line. If there is more than one command on a line, all the commands are parsed before executed. If a command is continued to next lines, the shell reads more enough lines to complete the command. On a syntax error, the shell neither reads nor executes any more commands.

Tokens and keywords

A command is composed of one or more tokens. In the shell syntax, a token is a word that is part of a command. Normally, tokens are separated by whitespaces, that is, the space or tab character. Whitespaces inside a command substitution or a parameter expansion, however, do not separate tokens.

The following symbols have special meanings in the shell syntax and in most cases separate tokens:

; & | < > ( ) [newline]

The following symbols do not separate tokens, but have syntactic meanings:

$ ` \ " ' * ? [ # ~ = %

The following tokens are treated as keywords depending on the context in which they appear:

! { } case do done elif else esac fi
for function if in then until while

A token is treated as a keyword when:

  • it is the first token of a command,

  • it follows another keyword (except case, for, and in), or

  • it is a non-first token of a command and is supposed to be a keyword to compose a composite command.

If a token begins with #, then the # and any following characters up to the end of the line are treated as a comment, which is completely ignored in syntax parsing.

Quotations

If you want whitespaces, separator characters, or keywords described above to be treated as a normal characters, you must quote the characters using appropriate quotation marks. Quotation marks are not treated as normal characters unless they are themselves quoted. You can use the following three quotation marks:

  • A backslash (\) quotes a character that immediately follows.
    The only exception about a backslash is the case where a backslash is followed by a newline. In this case, the two characters are treated as a line continuation rather than a newline being quoted. The two characters are removed from the input and the two lines surrounding the line continuation are concatenated into a single line.

  • A pair of single-quotation marks (') quote any characters between them except another single-quotation. Note that newlines can be quoted using single-quotations.

  • Double-quotation marks (") are like single-quotations, but they have a few exceptions: Parameter expansion, command substitution, and arithmetic expansion are interpreted as usual even between double-quotations. A backslash between double-quotations is treated as a quotation mark only when it is followed by $, `, ", \, or a newline; other backslashes are treated as normal characters.

Aliases

Tokens that compose a command are subject to alias substitution. A token that matches the name of an alias that has already been defined is substituted with the value of the alias before the command is parsed.

Tokens that contain quotations are not alias-substituted since an alias name cannot contain quotation marks. Keywords and command separator characters are not alias-substituted either.

There are two kinds of aliases: normal aliases and global aliases. A normal alias can only substitute the first token of a command while a global alias can substitute any part of a command. Global aliases are yash extension that is not defined in POSIX.

If a token is alias-substituted with the value of a normal alias that ends with a whitespace, the next token is exceptionally subject to alias substitution for normal aliases.

The results of alias substitution are again subject to alias substitution for other aliases (but not for the aliases that have been already applied).

You can define aliases using the alias built-in and remove using the unalias built-in.

Simple commands

A command that does not start with a keyword token is a simple command. Simple commands are executed as defined in Execution of simple commands.

If the first and any number of following tokens of a simple command have the form name=value, they are interpreted as variable assignments. A variable name must consist of one or more alphabets, digits and/or underlines (_) and must not start with a digit. The first token that is not a variable assignment is considered as a command name and all the following tokens (whether or not they have the form name=value) as command arguments.

A variable assignment of the form var=(tokens) is interpreted as assignment to an array. You can write any number of tokens between a pair of parentheses. Tokens can be separated by not only spaces and tabs but also newlines.

Pipelines

A pipeline is a sequence of one or more simple commands, compound commands, and/or function definitions that are separated by |.

A pipeline that has more than one subcommand is executed by executing each subcommand of the pipeline in a subshell simultaneously. The standard output of each subcommand except the last one is redirected to the standard input of the next subcommand. The standard input of the first subcommand and the standard output of the last subcommand are not redirected. The exit status of the pipeline is that of the last subcommand.

A pipeline can be prefixed by !, in which case the exit status of the pipeline is reversed: the exit status of the pipeline is 1 if that of the last subcommand is 0, and 0 otherwise.

Note
When the execution of a pipeline finishes, at least the execution of the last subcommand has finished since the exit status of the last subcommand defines that of the whole pipeline. The execution of other subcommands, however, may not have finished then. On the other hand, the execution of the pipeline may not finish soon after that of the last subcommand finished because the shell may choose to wait for the execution of other subcommands to finish.
Note
The POSIX standard allows executing any of subcommands in the current shell rather than subshells, though yash does not do so.

And/or lists

An and/or list is a sequence of one or more pipelines separated by && or ||.

An and/or list is executed by executing some of the pipelines conditionally. The first pipeline is always executed. The other pipelines are either executed or not executed according to the exit status of the previous pipelines.

  • If two pipelines are separated by && and the exit status of the first pipeline is zero, the second pipeline is executed.

  • If two pipelines are separated by || and the exit status of the first pipeline is not zero, the second pipeline is executed.

  • In other cases, the execution of the and/or list ends: the second and any remaining pipelines are not executed.

The exit status of an and/or list is that of the last pipeline that was executed.

Normally, an and/or list must be terminated by a semicolon, ampersand, or newline. See Command separators and asynchronous commands.

Command separators and asynchronous commands

The whole input to the shell must be composed of any number of and/or lists separated by a semicolon or ampersand. A terminating semicolon can be omitted if it is followed by ;;, ), or a newline. Otherwise, an and/or list must be terminated by a semicolon or ampersand.

If an and/or list is terminated by a semicolon, it is executed synchronously: the shell waits for the and/or list to finish before executing the next and/or list. If an and/or list is terminated by an ampersand, it is executed asynchronously: after the execution of the and/or list is started, the next and/or list is executed immediately. An asynchronous and/or list is always executed in a subshell and its exit status is zero.

If the shell is not doing job control, the standard input of an asynchronous and/or list is automatically redirected to /dev/null. Signal handlers of the and/or list for the SIGINT and SIGQUIT signals are set to “ignore” the signal so that the execution of the and/or list cannot be stopped by those signals. (In the POSIXly-correct mode, the standard input is redirected if and only if the shell is interactive, regardless of whether job control is on. Moreover, the SIGINT and SIGQUIT signals are ignored even if job control is on.)

When the execution of an asynchronous and/or list is started, the shell remembers its process ID. You can obtain the ID by referencing the ! special parameter. You can obtain the current and exit status of the asynchronous list as well by using the jobs and wait built-ins.

Compound commands

Compound commands provide you with programmatic control of shell command execution.

Grouping

A grouping is a list of commands that is treated as a simple command.

Normal grouping syntax

{ command…; }

Subshell grouping syntax

(command…)

The { and } tokens are keywords, which must be separated from other tokens. The ( and ) tokens, however, are special separators that need not to be separated.

In the normal grouping syntax, the commands in a grouping are executed in the current shell. In the subshell grouping syntax, the commands are executed in a new subshell.

In the POSIXly-correct mode, a grouping must contain at least one command. If the shell is not in the POSIXly-correct mode, a grouping may contain no commands.

The exit status of a grouping is that of the last command in the grouping. If the grouping contains no commands, its exit status is that of the last executed command before the grouping.

If command

The if command performs a conditional branch.

Basic if command syntax

if condition…; then body…; fi

Syntax with the else clause

if condition…; then body…; else body…; fi

Syntax with the elif clause

if condition…; then body…; elif condition…; then body…; fi

Syntax with the elif clause

if condition…; then body…; elif condition…; then body…; else body…; fi

For all the syntaxes, the execution of an if command starts with the execution of the condition commands that follows the if token. If the exit status of the condition commands is zero, the condition is considered as “true”. In this case, the body commands that follows the then token are executed and the execution of the if command finishes. If the exit status of the condition commands is non-zero, the condition is considered as “false”. In this case, the condition commands for the next elif clause are executed and the exit status is tested in the same manner as above. If there is no elif clause, the body commands that follow the else token are executed and the execution of the if command finishes. If there is no else clause either, the execution of the if command just ends.

An if command may have more than one elif-then clause.

The exit status of an if command is that of the body commands that were executed. The exit status is zero if no body commands were executed, that is, all the conditions were false and there was no else clause.

While and until loops

The while loop and until loop are simple loops with condition.

While loop syntax

while condition…; do body…; done

Until loop syntax

until condition…; do body…; done

If the shell is not in the POSIXly-correct mode, you can omit the condition and/or body commands of a while/until loop.

The execution of a while loop is started by executing the condition commands. If the exit status of the condition commands is zero, the shell executes the body commands and returns to the execution of the condition commands. The condition and body commands are repeatedly executed until the exit status of the condition commands is non-zero.

Note
The body commands are not executed at all if the first execution of the condition commands yields a non-zero exit status.

An until loop is executed in the same manner as a while loop except that the condition to repeat the loop is reversed: the body commands are executed when the exit status of the condition commands is non-zero.

The exit status of a while/until loop is that of the last executed body command. The exit status is zero if the body commands are empty or were not executed at all.

For loop

The for loop repeats commands with a variable assigned one of given values in each round.

For loop syntax

for varname in word…; do command…; done
for varname do command…; done

The word list after the in token may be empty, but the semicolon (or newline) before the do token is required even in that case. The words are not treated as keywords, but you need to quote separator characters (such as & and |) to include them as part of a word. If you omit the in token and the following words, you must also omit the semicolon before the do token. However, the shell does not complain about the existence of the semicolon if not in the POSIXly-correct mode. The command list may be empty if not in the POSIXly-correct mode.

The execution of a for loop is started by expanding the words in the same manner as in the execution of a simple command. If the in and word tokens are omitted, the shell assumes the word tokens to be "$@". Next, the following steps are taken for each word expanded (in the order the words were expanded):

  1. Assign the word to the variable whose name is varname.

  2. Execute the commands.

Each word is assigned as a local variable except in the POSIXly-correct mode. If the expansion of the words yielded no words as a result, the commands are not executed at all.

The exit status of a for loop is that of the last executed command. The exit status is zero if the commands are not empty and not executed at all. If the commands are empty, the exit status is that of the last executed command before the for loop.

Case command

The case command performs a pattern matching to select commands to execute.

Case command syntax

case word in caseitem… esac

Case item syntax

(patterns) command…;;

The word between the case and in tokens must be exactly one word. The word is not treated as a keyword, but you need to quote separator characters (such as & and |) to include them as part of the word. Between the in and esac tokens you can put any number of case items (may be none). You can omit the first ( token of a case item and the last ;; token before the esac token. If the last command of a case item is terminated by a semicolon, you can omit the semicolon as well. The commands in a case item may be empty.

The patterns in a case item are one or more tokens each separated by a | token.

The execution of a case command starts with subjecting the word to the four expansions. Next, the following steps are taken for each case item (in the order of appearance):

  1. For each word in the patterns, expand the word in the same manner as the word and test if the expanded pattern matches the expanded word. (If a pattern is found that matches the word, the remaining patterns are not expanded nor tested, so some of the patterns may not be expanded. Yash expands and tests the patterns in the order of appearance, but it may not be the case for other shells.)

  2. If one of the patterns was found to match the word in the previous step, the commands in this case item are executed and the execution of the whole case item ends. Otherwise, proceed to the next case item.

The exit status of a case command is that of the commands executed. The exit status is zero if no commands were executed, that is, there were no case items, no matching pattern was found, or no commands were associated with the matching pattern.

In the POSIXly-correct mode, the first pattern in a case item cannot be esac (even if you do not omit the ( token).

Function definition

The function definition command defines a function.

Function definition syntax

funcname ( ) compound_command
function funcname compound_command
function funcname ( ) compound_command

In the first syntax without the function keyword, funcname cannot contain any special characters such as semicolons and quotation marks. In the second and third syntax, which cannot be used in the POSIXly-correct mode, funcname is subjected to the four expansions when executed.

When a function definition command is executed, a function whose name is funcname is defined with its body being compound_command.

A function definition command cannot be directly redirected. Any redirections that follow a function definition are associated with compound_command rather than the whole function definition command. In func() { cat; } >/dev/null, for example, it is not func() { cat; } but { cat; } that is redirected.

The exit status of a function definition is zero if the function was defined without errors, and non-zero otherwise.

yash-2.35/doc/_test.txt0000644000175000017500000001324212154557026015174 0ustar magicantmagicant= Test built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Test built-in The dfn:[test built-in] evaluates an expression. [[syntax]] == Syntax - +test {{expression}}+ - +[ {{expression}} ]+ The test built-in does not distinguish options and operands; all command line arguments are interpreted as {{expression}}. If the built-in is executed with the name +[+, {{expression}} must be followed by +]+. [[description]] == Description The test built-in evaluates {{expression}} as a conditional expression that is made up of operators and operands described below. The exit status is 0 if the condition is true and 1 otherwise. The unary operators below test a file. If the operand {{file}} is a symbolic link, the file referred to by the link is tested (except for the +-h+ and +-L+ operators). +-b {{file}}+:: {{file}} is a block special file +-c {{file}}+:: {{file}} is a character special file +-d {{file}}+:: {{file}} is a directory +-e {{file}}+:: {{file}} exists +-f {{file}}+:: {{file}} is a regular file +-G {{file}}+:: {{file}}'s group ID is same as the shell's effective group ID +-g {{file}}+:: {{file}}'s set-group-ID flag is set +-h {{file}}+:: same as -L +-k {{file}}+:: {{file}}'s sticky bit is set +-L {{file}}+:: {{file}} is a symbolic link +-N {{file}}+:: {{file}} has not been accessed since last modified +-O {{file}}+:: {{file}}'s user ID is same as the shell's effective user ID +-p {{file}}+:: {{file}} is a FIFO (named pipe) +-r {{file}}+:: {{file}} is readable +-S {{file}}+:: {{file}} is a socket +-s {{file}}+:: {{file}} is not empty +-u {{file}}+:: {{file}}'s set-user-ID flag is set +-w {{file}}+:: {{file}} is writable +-x {{file}}+:: {{file}} is executable The unary operator below tests a file descriptor: +-t {{fd}}+:: {{fd}} is associated with a terminal The unary operators below test a string: +-n {{string}}+:: {{string}} is not empty +-z {{string}}+:: {{string}} is empty The unary operator below tests a link:_set.html[shell option]: +-o ?{{option}}+:: {{option}} is a valid shell option name +-o {{option}}+:: {{option}} is a valid shell option name that is enabled The binary operators below compare files. Non-existing files are considered older than any existing files. +{{file1}} -nt {{file2}}+:: {{file1}} is newer than {{file2}} +{{file1}} -ot {{file2}}+:: {{file1}} is older than {{file2}} +{{file1}} -ef {{file2}}+:: {{file1}} is a hard link to {{file2}} The binary operators below compare strings: +{{string1}} = {{string2}}+:: {{string1}} is the same string as {{string2}} +{{string1}} != {{string2}}+:: {{string1}} is not the same string as {{string2}} The binary operators below compare strings according to the alphabetic order in the current locale: +{{string1}} === {{string2}}+:: {{string1}} is equal to {{string2}} +{{string1}} !== {{string2}}+:: {{string1}} is not equal to {{string2}} +{{string1}} < {{string2}}+:: {{string1}} is less than {{string2}} +{{string1}} <= {{string2}}+:: {{string1}} is less than or equal to {{string2}} +{{string1}} > {{string2}}+:: {{string1}} is greater than {{string2}} +{{string1}} >= {{string2}}+:: {{string1}} is greater than or equal to {{string2}} The binary operator below performs pattern matching: +{{string}} =~ {{pattern}}+:: extended regular expression {{pattern}} matches {{string}} The binary operators below compare integers: +{{v1}} -eq {{v2}}+:: {{v1}} is equal to {{v2}} +{{v1}} -ne {{v2}}+:: {{v1}} is not equal to {{v2}} +{{v1}} -gt {{v2}}+:: {{v1}} is greater than {{v2}} +{{v1}} -ge {{v2}}+:: {{v1}} is greater than or equal to {{v2}} +{{v1}} -lt {{v2}}+:: {{v1}} is less than {{v2}} +{{v1}} -le {{v2}}+:: {{v1}} is less than or equal to {{v2}} The binary operators below compare version numbers: +{{v1}} -veq {{v2}}+:: {{v1}} is equal to {{v2}} +{{v1}} -vne {{v2}}+:: {{v1}} is not equal to {{v2}} +{{v1}} -vgt {{v2}}+:: {{v1}} is greater than {{v2}} +{{v1}} -vge {{v2}}+:: {{v1}} is greater than or equal to {{v2}} +{{v1}} -vlt {{v2}}+:: {{v1}} is less than {{v2}} +{{v1}} -vle {{v2}}+:: {{v1}} is less than or equal to {{v2}} The operators below can be used to make complex expressions: +! {{expression}}+:: negate (reverse) the result +( {{expression}} )+:: change operator precedence +{{expression1}} -a {{expression2}}+:: logical conjunction (and) +{{expression1}} -o {{expression2}}+:: logical disjunction (or) If the expression is a single word without operators, the +-n+ operator is assumed. An empty expression evaluates to false. [[version-compare]] === Comparison of version numbers Comparison of version numbers is similar to comparison of strings in alphabetic order. The differences are: - Adjacent digits are treated as an integer. Integers are compared in mathematical order rather than alphabetic order. - Digits are considered larger than any non-digit characters. For example, version numbers +0.1.2-3+ and +00.001.02-3+ are equal and +0.2.1+ is smaller than +0.10.0+. [[exitstatus]] == Exit status The exit status of the test built-in is 0 if {{expression}} is true and 1 otherwise. The exit status is 2 if {{expression}} cannot be evaluated because of a syntax error or any other reasons. [[notes]] == Notes Complex expressions may cause confusion and should be avoided. Use the shell's link:syntax.html#compound[compound commands]. For example, +[ 1 -eq 1 ] && [ -t = 1 ] && ! [ foo ]+ is preferred over +[ 1 -eq 1 -a -t = 1 -a ! foo ]+. The POSIX standard provides that the exit status should be larger than 1 on error. The POSIX standard does not define the following operators: +-nt+, +-ot+, +-ef+, +==+, +===+, +!==+, +<+, +<=+, +>+, +>=+, +=~+, +-veq+, +-vne+, +-vgt+, +-vge+, +-vlt+, and +-vle+. POSIX neither specifies +-o+ as a unary operator. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_break.txt0000644000175000017500000000276312154557026015307 0ustar magicantmagicant= Break built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Break built-in The dfn:[break built-in] aborts a loop being executed. [[syntax]] == Syntax - +break [{{nest}}]+ - +break -i+ [[description]] == Description When executed without the +-i+ (+--iteration+) option, the built-in aborts a currently executed link:syntax.html#for[for], link:syntax.html#while-until[while], or link:syntax.html#while-until[until] loop. When executed in nested loops, it aborts the {{nest}}th innermost loop. The default {{nest}} is one. If the number of currently executed nested loops is less than {{nest}}, the built-in aborts the outermost loop. When executed with the +-i+ (+--iteration+) option, the built-in aborts the currently executed (innermost) link:_eval.html#iter[iterative execution]. [[options]] == Options +-i+:: +--iteration+:: Abort an iterative execution instead of a loop. [[operands]] == Operands {{nest}}:: The number of loops to abort, which must be a positive integer. [[exitstatus]] == Exit status The exit status of the break built-in is: - zero if a loop was successfully aborted. - that of the command that was executed just before the break built-in if an iterative execution was successfully aborted. [[notes]] == Notes The break built-in is a link:builtin.html#types[special built-in]. The POSIX standard defines no options for the break built-in; the built-in accepts no options in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_test.html0000644000175000017500000003104012154557026015315 0ustar magicantmagicant Test built-in

The test built-in evaluates an expression.

Syntax

  • test expression

  • [ expression ]

The test built-in does not distinguish options and operands; all command line arguments are interpreted as expression. If the built-in is executed with the name [, expression must be followed by ].

Description

The test built-in evaluates expression as a conditional expression that is made up of operators and operands described below. The exit status is 0 if the condition is true and 1 otherwise.

The unary operators below test a file. If the operand file is a symbolic link, the file referred to by the link is tested (except for the -h and -L operators).

-b file

file is a block special file

-c file

file is a character special file

-d file

file is a directory

-e file

file exists

-f file

file is a regular file

-G file

file's group ID is same as the shell’s effective group ID

-g file

file's set-group-ID flag is set

-h file

same as -L

-k file

file's sticky bit is set

-L file

file is a symbolic link

-N file

file has not been accessed since last modified

-O file

file's user ID is same as the shell’s effective user ID

-p file

file is a FIFO (named pipe)

-r file

file is readable

-S file

file is a socket

-s file

file is not empty

-u file

file's set-user-ID flag is set

-w file

file is writable

-x file

file is executable

The unary operator below tests a file descriptor:

-t fd

fd is associated with a terminal

The unary operators below test a string:

-n string

string is not empty

-z string

string is empty

The unary operator below tests a shell option:

-o ?option

option is a valid shell option name

-o option

option is a valid shell option name that is enabled

The binary operators below compare files. Non-existing files are considered older than any existing files.

file1 -nt file2

file1 is newer than file2

file1 -ot file2

file1 is older than file2

file1 -ef file2

file1 is a hard link to file2

The binary operators below compare strings:

string1 = string2

string1 is the same string as string2

string1 != string2

string1 is not the same string as string2

The binary operators below compare strings according to the alphabetic order in the current locale:

string1 === string2

string1 is equal to string2

string1 !== string2

string1 is not equal to string2

string1 < string2

string1 is less than string2

string1 <= string2

string1 is less than or equal to string2

string1 > string2

string1 is greater than string2

string1 >= string2

string1 is greater than or equal to string2

The binary operator below performs pattern matching:

string =~ pattern

extended regular expression pattern matches string

The binary operators below compare integers:

v1 -eq v2

v1 is equal to v2

v1 -ne v2

v1 is not equal to v2

v1 -gt v2

v1 is greater than v2

v1 -ge v2

v1 is greater than or equal to v2

v1 -lt v2

v1 is less than v2

v1 -le v2

v1 is less than or equal to v2

The binary operators below compare version numbers:

v1 -veq v2

v1 is equal to v2

v1 -vne v2

v1 is not equal to v2

v1 -vgt v2

v1 is greater than v2

v1 -vge v2

v1 is greater than or equal to v2

v1 -vlt v2

v1 is less than v2

v1 -vle v2

v1 is less than or equal to v2

The operators below can be used to make complex expressions:

! expression

negate (reverse) the result

( expression )

change operator precedence

expression1 -a expression2

logical conjunction (and)

expression1 -o expression2

logical disjunction (or)

If the expression is a single word without operators, the -n operator is assumed. An empty expression evaluates to false.

Comparison of version numbers

Comparison of version numbers is similar to comparison of strings in alphabetic order. The differences are:

  • Adjacent digits are treated as an integer. Integers are compared in mathematical order rather than alphabetic order.

  • Digits are considered larger than any non-digit characters.

For example, version numbers 0.1.2-3 and 00.001.02-3 are equal and 0.2.1 is smaller than 0.10.0.

Exit status

The exit status of the test built-in is 0 if expression is true and 1 otherwise. The exit status is 2 if expression cannot be evaluated because of a syntax error or any other reasons.

Notes

Complex expressions may cause confusion and should be avoided. Use the shell’s compound commands. For example, [ 1 -eq 1 ] && [ -t = 1 ] && ! [ foo ] is preferred over [ 1 -eq 1 -a -t = 1 -a ! foo ].

The POSIX standard provides that the exit status should be larger than 1 on error. The POSIX standard does not define the following operators: -nt, -ot, -ef, ==, ===, !==, <, <=, >, >=, =~, -veq, -vne, -vgt, -vge, -vlt, and -vle. POSIX neither specifies -o as a unary operator.

yash-2.35/doc/_wait.txt0000644000175000017500000000351312154557026015161 0ustar magicantmagicant= Wait built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Wait built-in The dfn:[wait built-in] waits for jobs to terminate. [[syntax]] == Syntax - +wait [{{job}}...]+ [[description]] == Description The wait built-in waits for background jobs to terminate. If link:job.html[job] control is enabled, stopped jobs are considered as terminated. The built-in can be used to wait for link:syntax.html#async[asynchronous commands] if job control is disabled. If the shell receives a signal while the built-in is waiting and if a link:_trap.html[trap] has been set for the signal, then the trap is executed and the built-in immediately finishes (without waiting for the jobs). If the shell receives a SIGINT signal when job control is enabled, the built-in aborts waiting. [[operands]] == Operands {{job}}:: The link:job.html#jobid[job ID] of the job or the process ID of a process in the job. If no {{job}}s are specified, the built-in waits for all existing jobs. If the specified job does not exist, the job is considered to have terminated with the exit status of 127. [[exitstatus]] == Exit status If no {{job}}s were specified and the built-in successfully waited for all the jobs, the exit status is zero. If one or more {{job}}s were specified, the exit status is that of the last {{job}}. If the built-in was aborted by a signal, the exit status is an integer (> 128) that denotes the signal. If there was any other error, the exit status is between 1 and 126 (inclusive). [[notes]] == Notes The wait built-in is a link:builtin.html#types[semi-special built-in]. The process ID of the last process of a job can be obtained by the link:params.html#sp-exclamation[+!+ special parameter]. You can use the link:_jobs.html[jobs built-in] as well to obtain process IDs of job processes. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_history.txt0000644000175000017500000000404212154557026015714 0ustar magicantmagicant= History built-in :encoding: UTF-8 :lang: en //:title: Yash manual - History built-in The dfn:[history built-in] prints or edits link:interact.html#history[command history]. [[syntax]] == Syntax - +history [-cF] [-d {{entry}}] [-s {{command}}] [-r {{file}}] [-w {{file}}] [{{count}}]+ [[description]] == Description The history built-in prints or edits link:interact.html#history[command history]. When executed with an option, the built-in edits history according to the option. If more than one option is specified, each option is processed in order. When executed with the {{count}} operand, the built-in prints the most recent {{count}} history entries to the standard output in the same manner as the link:_fc.html[fc built-in]. When executed with neither options nor operands, the built-in prints the whole history. [[options]] == Options +-c+:: +--clear+:: Clear all history entries completely. +-d {{entry}}+:: +--delete={{entry}}+:: Delete the specified {{entry}}. The {{entry}} should be specified in the same manner as the {{start}} and {{end}} operands of the link:_fc.html[fc built-in]. +-F+:: +--flush-file+:: Rebuild the history file. This operation removes unused old data from the file. +-r {{file}}+:: +--read={{file}}+:: Read command lines from {{file}} and add them to the history. The file contents are treated as lines of simple text. +-s {{command}}+:: +--set={{command}}+:: Add {{command}} as a new history entry after removing the most recent entry. +-w {{file}}+:: +--write={{file}}+:: Write the whole history to {{file}}. Any existing data in the file will be lost. The output format is lines of simple text, each of which is a command string. [[operands]] == Operands {{count}}:: The number of entries to be printed. [[exitstatus]] == Exit status The exit status of the history built-in is zero unless there is any error. [[notes]] == Notes The history built-in is not defined in the POSIX standard. Command history cannot be modified during link:lineedit.html[line-editing]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_disown.txt0000644000175000017500000000200112154557026015507 0ustar magicantmagicant= Disown built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Disown built-in The dfn:[disown built-in] removes jobs. [[syntax]] == Syntax - +disown [-a] [{{job}}...}+ [[description]] == Description The disown built-in removes the specified jobs from the job list. The removed jobs will no longer be link:job.html[job-controlled], but the job processes continue execution (unless they have been suspended). [[options]] == Options +-a+:: +--all+:: Removes all jobs. [[operands]] == Operands {{job}}:: The link:job.html#jobid[job ID] of the job to be removed. + You can specify more than one job ID. If you do not specify any job ID, the current job is removed. If the shell is not in the link:posix.html[POSIXly-correct mode], the %-prefix of the job ID can be omitted. [[exitstatus]] == Exit status The exit status of the disown built-in is zero unless there is any error. [[notes]] == Notes The disown built-in is not defined in the POSIX standard. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/yash.txt0000644000175000017500000000326412154557026015025 0ustar magicantmagicant= YASH(1) Yuki Watanabe v{yashversion}, :encoding: UTF-8 :lang: en == Name yash - a POSIX-compliant command line shell == Synopsis +yash [options...] [--] [operands...]+ :leveloffset: 1 include::intro.txt[] include::invoke.txt[] include::syntax.txt[] include::params.txt[] include::expand.txt[] include::pattern.txt[] include::redir.txt[] include::exec.txt[] include::interact.txt[] include::job.txt[] include::builtin.txt[] include::lineedit.txt[] include::posix.txt[] include::fgrammar.txt[] include::_alias.txt[] include::_array.txt[] include::_bg.txt[] include::_bindkey.txt[] include::_break.txt[] include::_cd.txt[] include::_colon.txt[] include::_command.txt[] include::_complete.txt[] include::_continue.txt[] include::_dirs.txt[] include::_disown.txt[] include::_dot.txt[] include::_echo.txt[] include::_eval.txt[] include::_exec.txt[] include::_exit.txt[] include::_export.txt[] include::_false.txt[] include::_fc.txt[] include::_fg.txt[] include::_getopts.txt[] include::_hash.txt[] include::_help.txt[] include::_history.txt[] include::_jobs.txt[] include::_kill.txt[] include::_popd.txt[] include::_printf.txt[] include::_pushd.txt[] include::_pwd.txt[] include::_read.txt[] include::_readonly.txt[] include::_return.txt[] include::_set.txt[] include::_shift.txt[] include::_suspend.txt[] include::_test.txt[] include::_times.txt[] include::_trap.txt[] include::_true.txt[] include::_type.txt[] include::_typeset.txt[] include::_ulimit.txt[] include::_umask.txt[] include::_unalias.txt[] include::_unset.txt[] include::_wait.txt[] :leveloffset: 0 // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_printf.html0000644000175000017500000002763712154557026015661 0ustar magicantmagicant Printf built-in

The printf built-in prints formatted values.

Syntax

  • printf format [value…]

Description

The printf built-in formats values according to format and prints them to the standard output. Unlike the echo built-in, the printf built-in does not print a newline automatically.

The formatting process is very similar to that of the printf function in the C programming language. You can use conversion specifications (which start with %) and escape sequences (which start with \) in format. Any other characters that are not part of a conversion specification or escape sequence are printed literally.

Conversion specifications

A conversion specification starts with a percent sign (%).

A conversion specification except %% consumes a value, which is formatted according to the specification and printed. Each conversion specification consumes one value in the order of appearance. If there are more values than conversion specifications, the entire format is re-processed until all the values are consumed. If a value to be consumed is missing, it is assumed to be an empty string (if the specification requires a string) or zero (if a number). If no values are given, format is processed just once.

Available conversion specifications are:

%d
%i

prints a signed integer in decimal

%u

prints an unsigned integer in decimal

%o

prints an unsigned integer in octal

%x

prints an unsigned integer in lowercase hexadecimal

%X

prints an unsigned integer in uppercase hexadecimal

%f

prints a floating-point number in lowercase

%F

prints a floating-point number in uppercase

%e

prints a floating-point number with exponent in lowercase

%E

prints a floating-point number with exponent in uppercase

%g

the same as %f or %e, automatically selected

%G

the same as %F or %E, automatically selected

%c

prints the first character of string

%s

prints a string

%b

prints a string (recognizing escape sequences like the echo built-in)

%%

prints a percent sign (%)

For %g and %G, the specification that is actually used is %f or %F if the exponent part is between -5 and the precision (exclusive); %e or %E otherwise.

In a conversion specification except %%, the leading percent sign may be followed by flags, field width, and/or precision in this order.

Flags

The flags are a sequence of any number of the following characters:

Minus sign (-)

With this flag, spaces are appended to the formatted value to fill up to the field width. Otherwise, spaces are prepended.

Plus sign (+)

A plus or minus sign is always prepended to a number.

Space ( )

A space is prepended to a formatted number if it has no plus or minus sign.

Hash sign (#)

The value is formatted in an alternative form: For %o, the printed octal integer has at least one leading zero. For %x and %X, a non-zero integer is formatted with 0x and 0X prefixes, respectively. For %e, %E, %f, %F, %g, and %G, a decimal mark (a.k.a. radix character) is always printed even if the value is an exact integer. For %g and %G, the printed number has at least one digit in the fractional part.

Zero (0)

Zeros are prepended to a formatted number to fill up to the field width. This flag is ignored if the minus flag is specified or if the conversion specification is %d, %i, %u, %o, %x, or %X with a precision.

Field width

A field width is specified as a decimal integer that has no leading zeros.

A field width defines a minimum byte count of a formatted value. If the formatted value does not reach the minimum byte count, so many spaces are prepended that the printed value has the specified byte count.

Precision

A precision is specified as a period (.) followed by a decimal integer. If the integer is omitted after the period, the precision is assumed to be zero.

For conversion specifications %d, %i, %u, %o, %x, and %X, a precision defines a minimum digit count. If the formatted integer does not reach the minimum digit count, so many zeros are prepended that the printed integer has the specified number of digits. The default precision is one for these conversion specifications.

For conversion specifications %e, %E, %f, and %F, a precision defines the number of digits after the decimal mark. The default precision is six for these conversion specifications.

For conversion specifications %g, and %G, a precision defines a maximum number of significant digits in the printed value. The default precision is six for these conversion specifications.

For conversion specifications %s, and %b, a precision defines a maximum byte count of the printed string. The default precision is infinity for these conversion specifications.

Examples

In the conversion specification %08.3f, the zero flag is specified, the field width is 8, and the precision is 3. If this specification is applied to value 12.34, the output will be 0012.340.

Escape sequences

The following escape sequences are recognized in format:

\a

Bell character (ASCII code: 7)

\b

Backspace (ASCII code: 8)

\f

Form feed character (ASCII code: 12)

\n

Newline character (ASCII code: 10)

\r

Carriage return character (ASCII code: 13)

\t

Horizontal tab character (ASCII code: 9)

\v

Vertical tab character (ASCII code: 11)

\\

Backslash

\"

Double quotation

\'

Single quotation (apostrophe)

\xxx

Character whose code is xxx, where xxx is an octal number of at most three digits.

Operands

format

A string that defines how values should be formatted.

values

Values that are formatted according to format.

A value is either a number or a string.

When a numeric value is required, value can be a single or double quotation followed by a character, instead of a normal number. For example, the command printf '%d' '"3' will print 51 on a typical environment where character 3 has character code 51.

Exit status

The exit status of the printf built-in is zero unless there is any error.

Notes

The POSIX standard does not precisely define how multibyte characters should be handled by the built-in. When you use the %s conversion specification with precision or the %c conversion specification, you may obtain unexpected results if the formatted value contains a character that is represented by more than one byte. Yash never prints only part of the bytes that represent a single multibyte character because all multibyte characters are converted to wide characters when processed in the shell.

yash-2.35/doc/pattern.html0000644000175000017500000002413312154557026015661 0ustar magicantmagicant Pattern matching notation

Pattern matching notation is a syntax of patterns that represent particular sets of strings. When a string is included in the set of strings a pattern represents, the pattern is said to match the string. Whether a pattern matches a string or not is defined as follows.

Normal characters

A character that is not quoted or any of special characters defined below is a normal character, which matches the character itself.

For example, the pattern abc matches the string abc, and not any other strings.

Single-character wildcard

The character ? matches any single character.

For example, the pattern a?c matches any three-character strings that starts with a and ends with c, such as aac, abc, and a;c.

Multi-character wildcard

The character * matches any strings (of any length, including the empty string).

For example, the pattern a*c matches any string that starts with a and ends with c, such as ac, abc, and a;xyz;c.

Bracket expression

A pattern that is enclosed by brackets ([ and ]) is a bracket expression. A bracket expression must have at least one character between the brackets. The characters between the brackets are interpreted as a bracket expression pattern, which is a below-defined special notation for bracket expression. A bracket expression pattern represents a set of characters. The bracket expression matches any one of the characters in the set the bracket expression pattern represents.

If the opening bracket ([) is followed by an exclamation mark (!), the exclamation is not treated as part of the bracket expression pattern and the whole bracket expression instead matches a character that is not included in the set the bracket expression pattern represents. If the opening bracket is followed by a caret (^), it is treated like an exclamation mark as above (but shells other than yash may treat the caret differently).

If the opening bracket (or the following exclamation or caret, if any) is followed by a closing bracket (]), it is treated as part of the bracket expression pattern rather than the end of the bracket expression. You cannot quote characters in the bracket expression pattern because quotation is treated before bracket expression.

An opening bracket in a pattern is treated as a normal character if it is not the beginning of a valid bracket expression.

Normal characters (in bracket expression pattern)

A character that is not any of special characters defined below is a normal character, which represents the character itself.

For example, the bracket expression pattern abc represents the set of the three characters a, b, and c. The bracket expression [abc] therefore matches any of the three characters.

Range expressions

A hyphen preceded and followed by a character (or collating symbol) is a range expression, which represents the set of the two characters and all characters between the two in the collation order. A collation order is an order of characters that is defined in the locale data.

If a hyphen is followed by a closing bracket (]), the bracket is treated as the end of the bracket expression and the hyphen as a normal character.

For example, the range expression 3-5 represents the set of the three characters 3, 4, and 5. The bracket expression [3-5-] therefore matches one of the four characters 3, 4, 5, and -.

Collating symbols

A collating symbol allows more than one character to be treated as a single character in matching. A collating symbol is made up of one or more characters enclosed by the special brackets [. and .].

One or more characters that are treated as a single character in matching are called a collating element. Precisely, a bracket expression pattern represents a set of collating elements and a bracket expression matches a collating element rather than a character, but we do not differentiate them for brevity here.

For example, the character combination “ch” was treated as a single character in the traditional Spanish language. If this character combination is registered as a collating element in the locale data, the bracket expression [[.ch.]df] matches one of ch, d, and f.

Equivalence classes

An equivalence class represents a set of characters that are considered equivalent. A equivalence class is made up of a character (or more precisely, a collating element) enclosed by the special brackets [= and =].

An equivalence class represents the set of characters that consists of the character enclosed by the brackets and the characters that are in the same primary equivalence class as the enclosed character. The shell consults the locale data for the definition of equivalence classes in the current locale.

For example, if the six characters a, à, á, â, ã, ä are defined to be in the same primary equivalence class, the bracket expressions [[=a=]], [[=à=]], and [[=á=]] match one of the six.

Character classes

A character class represents a predefined set of characters. A character class is made up of a class name enclosed by the special brackets [: and :]. The shell consults the locale data for which class a character belongs to.

The following character classes can be used in all locales:

[:lower:]

set of lowercase letters

[:upper:]

set of uppercase letters

[:alpha:]

set of letters, including the [:lower:] and [:upper:] classes.

[:digit:]

set of decimal digits

[:xdigit:]

set of hexadecimal digits

[:alnum:]

set of letters and digits, including the [:alpha:] and [:digit:] classes.

[:blank:]

set of blank characters, not including the newline character

[:space:]

set of space characters, including the newline character

[:punct:]

set of punctuations

[:print:]

set of printable characters

[:cntrl:]

set of control characters

For example, the bracket expression [[:lower:][:upper:]] matches a lower or upper case character. In addition to the classes listed above, other classes may be used depending on the definition of the current locale.

yash-2.35/doc/_shift.html0000644000175000017500000000432312154557026015457 0ustar magicantmagicant Shift built-in

The shift built-in removes some positional parameters.

Syntax

  • shift [count]

Description

The shift built-in removes the first count positional parameters.

Operands

count

The number of positional parameters to be removed.

It is an error if the actual number of positional parameters is less than count. If omitted, the default value is one.

Exit status

The exit status of the shift built-in is zero unless there is any error.

Notes

The shift built-in is a special built-in.

The number of positional parameters can be obtained with the # special parameter.

yash-2.35/doc/_history.html0000644000175000017500000001044212154557026016042 0ustar magicantmagicant History built-in

The history built-in prints or edits command history.

Syntax

  • history [-cF] [-d entry] [-s command] [-r file] [-w file] [count]

Description

The history built-in prints or edits command history.

When executed with an option, the built-in edits history according to the option. If more than one option is specified, each option is processed in order.

When executed with the count operand, the built-in prints the most recent count history entries to the standard output in the same manner as the fc built-in.

When executed with neither options nor operands, the built-in prints the whole history.

Options

-c
--clear

Clear all history entries completely.

-d entry
--delete=entry

Delete the specified entry. The entry should be specified in the same manner as the start and end operands of the fc built-in.

-F
--flush-file

Rebuild the history file. This operation removes unused old data from the file.

-r file
--read=file

Read command lines from file and add them to the history. The file contents are treated as lines of simple text.

-s command
--set=command

Add command as a new history entry after removing the most recent entry.

-w file
--write=file

Write the whole history to file. Any existing data in the file will be lost. The output format is lines of simple text, each of which is a command string.

Operands

count

The number of entries to be printed.

Exit status

The exit status of the history built-in is zero unless there is any error.

Notes

The history built-in is not defined in the POSIX standard.

Command history cannot be modified during line-editing.

yash-2.35/doc/_dirs.txt0000644000175000017500000000364712154557026015166 0ustar magicantmagicant= Dirs built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Dirs built-in The dfn:[dirs built-in] prints the contents of the directory stack. [[syntax]] == Syntax - +dirs [-cv] [{{index}}..]+ [[description]] == Description The dfn:[directory stack] is a feature that records history of working directories. You can use the link:_pushd.html[pushd built-in] to save a working directory in the directory stack, the link:_popd.html[popd built-in] to recall the saved working directory, and the dirs built-in to see the stack contents. Those built-ins use the link:params.html#sv-dirstack[+DIRSTACK+ array] and the link:params.html#sv-pwd[+PWD+ variable] to save the stack contents. Modifying the array means modifying the stack contents. Directory stack entries are indexed by signed integers. The entry of index +0 is the current working directory, +1 is the last saved directory, +2 is the second last, and so on. Negative indices are in the reverse order: the entry of index -0 is the first saved directory, -1 is the second, and -{{n}} is the current working directory if the stack has {{n}} entries, When executed without the +-c+ (+--clear+) option, the dirs built-in prints the current contents of the directory stack to the standard output. With the +-c+ (+--clear+) option, the built-in clears the directory stack. [[options]] == Options +-c+:: +--clear+:: Clear the directory stack contents except for the current working directory, which has index +0. +-v+:: +--verbose+:: Print indices when printing stack contents. [[operands]] == Operands {{index}}:: The index of a stack entry to be printed. + You can specify more than one index. If you do not specify any index, all the entries are printed. [[exitstatus]] == Exit status The exit status of the dirs built-in is zero unless there is any error. [[notes]] == Notes The dirs built-in is not defined in the POSIX standard. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/ja/0000755000175000017500000000000012154557026013705 5ustar magicantmagicantyash-2.35/doc/ja/exec.txt0000644000175000017500000003313412154557026015376 0ustar magicantmagicant= コマンドã®å®Ÿè¡Œã¨ãã®ç’°å¢ƒ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - コマンドã®å®Ÿè¡Œã¨ãã®ç’°å¢ƒ :description: ã“ã®ãƒšãƒ¼ã‚¸ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ãŒã©ã®ã‚ˆã†ã«å®Ÿè¡Œã•れるã‹ã‚’説明ã—ã¾ã™ã€‚ ã“ã®ç¯€ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ãŒã©ã®ã‚ˆã†ã«å®Ÿè¡Œã•れるã‹ã‚’説明ã—ã¾ã™ã€‚ [[simple]] == å˜ç´”コマンドã®å®Ÿè¡Œ link:syntax.html#simple[å˜ç´”コマンド]ã¯ä»¥ä¸‹ã®æ‰‹é †ã«å¾“ã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ . å˜ç´”コマンドã«å«ã¾ã‚Œã‚‹ã€å¤‰æ•°ä»£å…¥ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆä»¥å¤–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’å…¨ã¦link:expand.html[展開]ã—ã¾ã™ã€‚展開エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。 + 以下ã€å±•é–‹ã®çµæžœå¾—ã‚‰ã‚ŒãŸæœ€åˆã®å˜èªžã‚’dfn:[コマンドå]ã€ãれ以外ã®å˜èªžã‚’dfn:[コマンド引数]ã¨å‘¼ã³ã¾ã™ã€‚得られãŸå˜èªžãŒä¸€ã¤ã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ã¯å­˜åœ¨ã—ã¾ã›ã‚“。得られãŸå˜èªžãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰åもコマンド引数も存在ã—ã¾ã›ã‚“。 . å˜ç´”コマンドã«å¯¾ã™ã‚‹link:redir.html[リダイレクト]を実行ã—ã¾ã™ã€‚リダイレクトã«å«ã¾ã‚Œã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹ã¯ã“ã“ã§è¡Œã‚れã¾ã™ã€‚リダイレクトエラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。リダイレクトã«å«ã¾ã‚Œã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•開時ã®ã‚¨ãƒ©ãƒ¼ã¯ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã«å«ã¾ã‚Œã¾ã™ã€‚ . å˜ç´”コマンドã«å«ã¾ã‚Œã‚‹å¤‰æ•°ä»£å…¥ã‚’実行ã—ã¾ã™ (é…列ã®ä»£å…¥ã‚’å«ã‚€)。ãれãžã‚Œã®å¤‰æ•°ä»£å…¥ã«ã¤ã„ã¦ã€å€¤ãŒå±•é–‹ã•ã‚Œã€æŒ‡å®šã•れãŸåå‰ã®link:params.html#variables[変数]ã«ä»£å…¥ã•れã¾ã™ã€‚代入エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。代入ã•れる値ã®å±•開時ã®ã‚¨ãƒ©ãƒ¼ã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ã«å«ã¾ã‚Œã¾ã™ã€‚ + -- - コマンドåãŒå­˜åœ¨ã—ãªã„ã‹ã€ã‚ã‚‹ã„ã¯ã‚³ãƒžãƒ³ãƒ‰åãŒlink:builtin.html#types[特殊組込ã¿]ã¾ãŸã¯<>を示ã—ã¦ã„ã‚‹å ´åˆã¯ã€å¤‰æ•°ä»£å…¥ã¯æ’ä¹…çš„ã§ã™ã€‚ã™ãªã‚ã¡ã€ä»£å…¥ã®çµæžœã¯ã“ã®å˜ç´”コマンドã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã‚‚ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ã€‚ - ãれ以外ã®å ´åˆã¯ã€å¤‰æ•°ä»£å…¥ã¯ä¸€æ™‚çš„ã§ã™ã€‚ã™ãªã‚ã¡ã€ä»£å…¥ã®åŠ¹æžœã¯ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œä¸­ã®ã¿æœ‰åйã§ã€å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã«ä»£å…¥ã¯å–り消ã•れã¾ã™ã€‚ -- + コマンドåãŒæŒ‡å®šã•れãŸå ´åˆã¾ãŸã¯ link:_set.html#so-allexport[all-export オプション]ãŒæœ‰åйãªå ´åˆã¯ã€ä»£å…¥ã•れる変数ã¯è‡ªå‹•çš„ã«link:params.html#variables[エクスãƒãƒ¼ãƒˆ]対象ã«ãªã‚Šã¾ã™ã€‚ . コマンドåãŒå­˜åœ¨ã—ãªã„å ´åˆã¯ã€å˜ç´”コマンドã®å®Ÿè¡Œã¯ã“れã§çµ‚ã‚りã§ã™ã€‚å˜ç´”コマンドã®çµ‚了ステータス㯠0 ã«ãªã‚Šã¾ã™ (ãŸã ã—å˜ç´”コマンド実行中ã«link:expand.html#cmdsub[コマンド置æ›]ãŒè¡Œã‚ã‚ŒãŸæ™‚ã¯ã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒå˜ç´”コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™)。 . 後述ã®<>ã®ä»•æ–¹ã«å¾“ã£ã¦å®Ÿè¡Œã™ã¹ãコマンドを特定ã—ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ + -- - コマンドãŒå¤–部コマンドã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯<>ã§ exec システムコールを呼ã³å‡ºã™ã“ã¨ã«ã‚ˆã‚Šå®Ÿè¡Œã•れã¾ã™ã€‚コマンドåã¨ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ãŒèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ã¾ãŸã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã¨ãªã£ã¦ã„る変数ãŒç’°å¢ƒå¤‰æ•°ã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ - コマンドãŒlink:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰å¼•数を引数ã¨ã—ã¦çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ - コマンドãŒ<>ã®å ´åˆã¯ã€ãã®é–¢æ•°ã®å†…容ãŒå®Ÿè¡Œã•れã¾ã™ã€‚コマンド引数ãŒé–¢æ•°ã®å¼•æ•°ã¨ã—ã¦æ¸¡ã•れã¾ã™ã€‚ 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒã“ã®å˜ç´”コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œã•れãšçµ‚了ステータス㯠127 ã«ãªã‚Šã¾ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã£ãŸãŒèµ·å‹•ã«å¤±æ•—ã—ãŸå ´åˆã¯ã€çµ‚了ステータス㯠126 ã«ãªã‚Šã¾ã™ã€‚コマンドãŒèµ·å‹•ã•れãŸãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã¯ã€çµ‚了ステータスã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã®ç•ªå·ã« 384 ã‚’è¶³ã—ãŸæ•°ã«ãªã‚Šã¾ã™ã€‚ [NOTE] POSIX ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã®çµ‚了ステータス㯠128 より大ããªæ•°ã¨ã—ã‹å®šã‚られã¦ã„ãªã„ã®ã§ã€yash 以外ã®ã‚·ã‚§ãƒ«ã§ã¯çµ‚了ステータスãŒç•°ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ éž link:posix.html[POSIX 準拠モード]ã«ãŠã„ã¦ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ ifdef::basebackend-html[] pass:[+link:_eval.html[eval] -i -- "${COMMAND_NOT_FOUND_HANDLER-}"+] endif::basebackend-html[] ifndef::basebackend-html[`eval -i -- "${COMMAND_NOT_FOUND_HANDLER-}"`] ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãŸã ã—ã“ã®ã¨ãlink:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã¯ã‚³ãƒžãƒ³ãƒ‰åã¨ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ã«ä¸€æ™‚çš„ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ã¾ãŸã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œä¸­ã«å®šç¾©ã•れãŸ<>ã¯ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了時ã«å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œæ™‚ã«ã¯ link:params.html#sv-handled[++HANDLED++ ローカル変数]ãŒç©ºæ–‡å­—列を値ã¨ã—ã¦ã‚らã‹ã˜ã‚定義ã•れã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œå¾Œã«ã“ã®å¤‰æ•°ã®å€¤ãŒç©ºæ–‡å­—列ã§ãªããªã£ã¦ã„れã°ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒã“ã®å˜ç´”コマンドã®çµ‚了ステータスã¨ãªã‚Šã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã“ã¨ã¯ã‚¨ãƒ©ãƒ¼ã¨ã¯ã¿ãªã•れã¾ã›ã‚“。 -- [[search]] === ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ å˜ç´”コマンドã§å®Ÿè¡Œã™ã¹ãコマンドã¯ã€å±•é–‹ã§å¾—られãŸã‚³ãƒžãƒ³ãƒ‰åã«åŸºã¥ã„ã¦ä»¥ä¸‹ã®æ‰‹é †ã§ç‰¹å®šã•れã¾ã™ã€‚ . コマンドåã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (+/+) ãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã¯ã€ãれãŒå®Ÿè¡Œã™ã¹ã外部コマンドã¸ã®ãƒ‘スåã§ã‚ã‚‹ã¨ç‰¹å®šã•れã¾ã™ã€‚ . コマンドåãŒlink:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚ . コマンドåã¨åŒã˜åå‰ã®<>ãŒå­˜åœ¨ã™ã‚Œã°ã€ãã®é–¢æ•°ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚ . コマンドåãŒlink:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚ . コマンドåãŒlink:builtin.html#types[通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚(link:posix.html[POSIX 準拠モード]ã®ã¨ãを除ã) . link:params.html#sv-path[+PATH+ 変数]ã®å€¤ã«å¾“ã£ã¦ã€å®Ÿè¡Œã™ã¹ã外部コマンドを検索ã—ãã®ãƒ‘スåを特定ã—ã¾ã™ã€‚ + -- +PATH+ 変数ã®å€¤ã¯ã€ã„ãã¤ã‹ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スåをコロン (+:+) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ (空ã®ãƒ‘スåã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™)。ãれらã®å„ディレクトリã«ã¤ã„ã¦é †ã«ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ä¸­ã«ã‚³ãƒžãƒ³ãƒ‰åã¨åŒã˜åå‰ã®å®Ÿè¡Œå¯èƒ½ãªé€šå¸¸ã®ãƒ•ァイルãŒã‚ã‚‹ã‹èª¿æŸ»ã—ã¾ã™ã€‚ãã®ã‚ˆã†ãªãƒ•ァイルãŒã‚れã°ã€ãã®ãƒ•ァイルãŒå®Ÿè¡Œã™ã¹ã外部コマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ (ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰åã¨åŒã˜åå‰ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒã‚れã°ã€ä»£ã‚りã«ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™)。ã©ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã‚‚ãã®ã‚ˆã†ãªãƒ•ァイルãŒè¦‹ã¤ã‹ã‚‰ãªã‘れã°ã€å®Ÿè¡Œã™ã¹ãコマンドã¯è¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚ -- å¤–éƒ¨ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ãŒæˆåŠŸã—パスåãŒç‰¹å®šã§ããŸå ´åˆã€ãã®ãƒ‘スåãŒçµ¶å¯¾ãƒ‘スãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ‘スåを記憶ã—ã€å†ã³åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹éš›ã«æ¤œç´¢ã®æ‰‹é–“ã‚’çœãã¾ã™ã€‚ãŸã ã—ã€å†ã³ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—よã†ã¨ã—ãŸéš›ã«ã€è¨˜æ†¶ã—ã¦ã„るパスåã«å®Ÿè¡Œå¯èƒ½ãƒ•ァイルãŒè¦‹å½“ãŸã‚‰ãªã„å ´åˆã¯ã€æ¤œç´¢ã‚’やり直ã—ã¾ã™ã€‚シェルãŒè¨˜æ†¶ã—ã¦ã„るパスå㯠link:_hash.html[hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ç®¡ç†ã§ãã¾ã™ã€‚ [[exit]] == シェルã®çµ‚了 シェルã¯ã€å…¥åŠ›ãŒçµ‚ã‚りã«é”ã—ã¦å…¨ã¦ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’解釈・実行ã—終ãˆãŸæ™‚ã‚„ã€link:_exit.html[exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を実行ã—ãŸã¨ããªã©ã«çµ‚了ã—ã¾ã™ã€‚シェルã®çµ‚了ステータスã¯ã€ã‚·ã‚§ãƒ«ãŒæœ€å¾Œã«å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを 256 ã§å‰²ã£ãŸä½™ã‚Šã§ã™ (一ã¤ã‚‚コマンドを実行ã—ãªã‹ã£ãŸã¨ã㯠0)。 link:_trap.html[Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚·ã‚§ãƒ«çµ‚了時ã®ãƒãƒ³ãƒ‰ãƒ©ãŒç™»éŒ²ã•れã¦ã„ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ãŒçµ‚了ã™ã‚‹ç›´å‰ã«ãã®ãƒãƒ³ãƒ‰ãƒ©ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãŸã ã—ã“ã®ãƒãƒ³ãƒ‰ãƒ©å†…ã§å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®çµ‚了ステータスã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。 link:interact.html[対話モード]ã§ãªã„シェルã®å®Ÿè¡Œä¸­ã«ä¸‹è¨˜ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ã“ã®ã¨ãシェルã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ - 文法エラーã®ãŸã‚コマンドを解釈ã§ããªã„ã¨ã (link:invoke.html#init[シェルã®åˆæœŸåŒ–]中を除ã) - link:posix.html[POSIX 準拠モード]ã§ã€link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹ã¨ã - POSIX 準拠モードã§ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã—ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã¾ãŸã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸã¨ã - 展開エラーãŒç™ºç”Ÿã—ãŸã¨ã (シェルã®åˆæœŸåŒ–中を除ã) [NOTE] Yash ã¯ãã†ã§ã¯ã‚りã¾ã›ã‚“ãŒã€<>ã«ãŠã„ã¦å®Ÿè¡Œã™ã¹ãコマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã«ç›´ã¡ã«çµ‚了ã™ã‚‹ã‚ˆã†ãªã‚·ã‚§ãƒ«ã‚‚ã‚りã¾ã™ã€‚ [[function]] == 関数 dfn:[関数]ã¯ä¸€ã¤ã®è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã‚’å˜ç´”コマンドã®ã‚ˆã†ã«å‘¼ã³å‡ºã›ã‚‹ã‚ˆã†ã«ã™ã‚‹æ©Ÿæ§‹ã§ã™ã€‚関数ã¯link:syntax.html#funcdef[関数定義コマンド]ã«ã‚ˆã£ã¦å®šç¾©ã§ãã€link:syntax.html#simple[å˜ç´”コマンド]ã«ã‚ˆã£ã¦å®Ÿè¡Œã§ãã¾ã™ã€‚関数を削除ã™ã‚‹ã«ã¯ link:_unset.html[unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を使ã„ã¾ã™ã€‚ Yash ã«ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰å®šç¾©ã•れã¦ã„る関数ã¯ä¸€ã¤ã‚‚ã‚りã¾ã›ã‚“。 関数ã®å®Ÿè¡Œã¯ã€é–¢æ•°ã®å†…容ã§ã‚る複åˆã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦è¡Œã‚れã¾ã™ã€‚関数ã®å®Ÿè¡Œä¸­ã¯ã€é–¢æ•°ã®å¼•æ•°ãŒlink:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã«ãªã‚Šã¾ã™ã€‚ãれã¾ã§ã®ä½ç½®ãƒ‘ラメータã¯ä¸€æ™‚çš„ã«ä½¿ãˆãªããªã‚Šã¾ã™ãŒé–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸæ™‚ã«å…ƒã®ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã«æˆ»ã‚Šã¾ã™ã€‚ [[localvar]] === ローカル変数 dfn:[ローカル変数]ã¨ã¯ã€é–¢æ•°ã®å®Ÿè¡Œä¸­ã«ã ã‘有効ãªä¸€æ™‚çš„ãªå¤‰æ•°ã§ã™ã€‚ローカル変数㯠link:_typeset.html[typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を使ã£ã¦ä½œã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚関数ã®å®Ÿè¡Œä¸­ã«ä½œã‚‰ã‚ŒãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸæ™‚ã«å‰Šé™¤ã•れã€ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’作るå‰ã®å…ƒã®å¤‰æ•°ã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚ 関数内ã§å®šç¾©ã—ãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯ã€é–¢æ•°ã®å®Ÿè¡Œã«å…ˆç«‹ã£ã¦å®šç¾©ã—ã¦ã‚ã£ãŸåŒåã®ä»–ã®å¤‰æ•°ã‚’__隠蔽__ã—ã¾ã™ã€‚隠蔽ã•れãŸå¤‰æ•°ã¯ã€é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ã¦ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒãªããªã‚‹ã¾ã§ä½¿ãˆãªããªã‚Šã¾ã™ã€‚ 関数ã®å®Ÿè¡Œä¸­ã§ãªã„ã¨ãã«ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’作るã“ã¨ã¯ã§ãã¾ã›ã‚“。ローカル変数を作ã‚ã†ã¨ã—ã¦ã‚‚ã€é€šå¸¸ã®å¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚ [[environment]] == コマンドã®å®Ÿè¡Œç’°å¢ƒ シェルã¯å®Ÿè¡Œæ™‚ã«ä»¥ä¸‹ã®æƒ…å ±ã‚’ä¿æŒã—ã¾ã™ã€‚ - 作業ディレクトリ - é–‹ã„ã¦ã„ã‚‹ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ - ファイル作æˆãƒžã‚¹ã‚¯ (link:_umask.html[umask]) - å—ä¿¡æ™‚ã®æŒ™å‹•㌠``無視'' ã«è¨­å®šã•れãŸã‚·ã‚°ãƒŠãƒ«ã®é›†åˆ (link:_trap.html[trap]) - link:params.html#variables[環境変数] - ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™ (link:_ulimit.html[ulimit]) ã“ã‚Œã‚‰ã®æƒ…å ±ã¯ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã«å…ƒã®ãƒ—ログラムã‹ã‚‰ã‚·ã‚§ãƒ«ã«å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚ãã—ã¦ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å¤–部コマンドやサブシェルã«ã‚‚シェルã‹ã‚‰å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚ ã“ã‚Œã‚‰ã®æƒ…å ±ã¯æ‰€å®šã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ç­‰ã‚’使ã£ã¦å¤‰æ›´å¯èƒ½ã§ã™ã€‚ [[subshell]] === サブシェル dfn:[サブシェル]ã¯ã€å®Ÿè¡Œä¸­ã®ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã®ã‚³ãƒ”ーã§ã™ã€‚ã‚µãƒ–ã‚·ã‚§ãƒ«ã¯æ‹¬å¼§ +( )+ ã§å›²ã‚“ã link:syntax.html#grouping[グルーピング]ã‚„link:syntax.html#pipelines[パイプライン]ã§ä½¿ã‚れã¾ã™ã€‚ サブシェルã¯ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã®ã‚³ãƒ”ーã§ã‚ã‚‹ãŸã‚ã€ä¸Šè¨˜ã®æƒ…å ±ã®ä»–ã«ã‚·ã‚§ãƒ«ã§å®šç¾©ã•れãŸé–¢æ•°ã‚„エイリアスãªã©ã®æƒ…報も元ã®ã‚·ã‚§ãƒ«ã‹ã‚‰å—ã‘ç¶™ãŽã¾ã™ã€‚ãŸã ã—〠- link:_trap.html[Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ç™»éŒ²ã—ãŸã‚·ã‚°ãƒŠãƒ«ãƒãƒ³ãƒ‰ãƒ©ã¯ã€(å—ä¿¡æ™‚ã®æŒ™å‹•㌠``無視'' ã®ã‚‚ã®ã‚’除ã) サブシェルã§ã¯ã™ã¹ã¦è§£é™¤ã•れã¾ã™ã€‚ - サブシェルã§ã¯link:interact.html[対話モード]ã¨link:job.html[ジョブ制御]ã¯è§£é™¤ã•れã€å…ƒã®ã‚·ã‚§ãƒ«ã®ã‚¸ãƒ§ãƒ–ã®æƒ…å ±ã¯å—ã‘ç¶™ãŒã‚Œã¾ã›ã‚“。 サブシェルã¯å…ƒã®ã‚·ã‚§ãƒ«ã¨ã¯ç‹¬ç«‹ã—ã¦ã„ã‚‹ãŸã‚ã€ã‚µãƒ–シェルã§ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å¤‰æ›´ã‚„変数代入ã¯å…ƒã®ã‚·ã‚§ãƒ«ã«å½±éŸ¿ã—ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/posix.txt0000644000175000017500000001263012154557026015612 0ustar magicantmagicant= POSIX 準拠モード :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - POSIX 準拠モード :description: Yash ã® POSIX 準拠モードã®å‹•作ã«ã¤ã„㦠Yash ã¯åŸºæœ¬çš„ã« POSIX.1-2008 ã®ã‚·ã‚§ãƒ«ã®è¦å®šã«å¾“ã£ã¦å‹•作ã—ã¾ã™ãŒã€åˆ©ä¾¿æ€§ã‚„分ã‹ã‚Šã‚„ã™ã•ã®ãŸã‚ã« POSIX ã®è¦å®šã¨ã¯ç•°ãªã‚‹å‹•作をã™ã‚‹ç‚¹ã‚‚ã‚りã¾ã™ã€‚ãã®ãŸã‚標準状態㮠yash 㯠POSIX ã®è¦å®šã™ã‚‹ã‚·ã‚§ãƒ«ã¨ã—ã¦ä¾›ã™ã‚‹ã«ã¯å‘ãã¾ã›ã‚“。dfn:[POSIX 準拠モード]を有効ã«ã™ã‚‹ã¨ã€yash ã¯ã§ãã‚‹é™ã‚Š POSIX ã®è¦å®šé€šã‚Šã«å‹•作ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚POSIX 準拠シェルã¨ã—ã¦ã®äº’æ›æ€§ãŒå¿…è¦ãªå ´é¢ã§ã¯ã€POSIX 準拠モードを有効ã«ã—ã¦ãã ã•ã„。 link:invoke.html[シェルã®èµ·å‹•]時ã®èµ·å‹•時ã®åå‰ãŒ +sh+ ãªã‚‰ã°ã‚·ã‚§ãƒ«ã¯è‡ªå‹•的㫠POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚ã¾ãŸèµ·å‹•時㫠+-o posixlycorrect+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã‚‚ POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚ã¾ãŸèµ·å‹•後ã¯ã€+link:_set.html[set] -o posixlycorrect+ を実行ã™ã‚‹ã“ã¨ã§ POSIX 準拠モードを有効ã«ã§ãã¾ã™ã€‚ POSIX 準拠モードを有効ã«ã™ã‚‹ã¨ã€yash 㯠POSIX ã®è¦å®šã«ã§ãã‚‹ã ã‘従ã†ã‚ˆã†ã«ãªã‚‹ã ã‘ã§ãªãã€POSIX ãŒ__未定義__ã‚„__未è¦å®š__ã¨å®šã‚ã¦ã„ã‚‹å ´åˆã®ã»ã¨ã‚“ã©ã‚’エラーã«ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ã™ãªã‚ã¡ã€yash ç‹¬è‡ªã®æ‹¡å¼µæ©Ÿèƒ½ã®å¤šãã¯ä½¿ãˆãªããªã‚Šã¾ã™ã€‚具体的ã«ã¯ã€POSIX 準拠モードを有効ã«ã™ã‚‹ã¨ä»¥ä¸‹ã®ã‚ˆã†ãªæŒ™å‹•ã®å¤‰åŒ–ãŒã‚りã¾ã™ã€‚ - シェルã®èµ·å‹•時ã®link:invoke.html#init[åˆæœŸåŒ–]ã§èª­ã¿è¾¼ã‚€ã‚¹ã‚¯ãƒªãƒ—トファイルãŒç•°ãªã‚Šã¾ã™ã€‚ - グローãƒãƒ«link:syntax.html#aliases[エイリアス]ã®ç½®æ›ã‚’行ã„ã¾ã›ã‚“。 - link:syntax.html#compound[複åˆã‚³ãƒžãƒ³ãƒ‰]ã®link:syntax.html#grouping[グルーピング]ã‚„ link:syntax.html#if[if æ–‡]ã®å†…容ãŒç©ºã®å ´åˆã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ - link:syntax.html#for[For ループ]ã§å±•é–‹ã—ãŸå˜èªžã¯ã‚°ãƒ­ãƒ¼ãƒãƒ«å¤‰æ•°ã¨ã—ã¦ä»£å…¥ã—ã¾ã™ã€‚ - link:syntax.html#case[Case æ–‡]ã®æœ€åˆã®ãƒ‘ターンを +esac+ ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 - 予約語 +function+ を用ã„ã‚‹å½¢å¼ã®link:syntax.html#funcdef[関数定義]æ§‹æ–‡ã¯ä½¿ãˆã¾ã›ã‚“。 - link:syntax.html#simple[å˜ç´”コマンド]ã§ã®link:params.html#arrays[é…列]ã®ä»£å…¥ã¯ã§ãã¾ã›ã‚“。 - シェル実行中㫠link:params.html#sv-lc_ctype[+LC_CTYPE+ 変数]ã®å€¤ãŒå¤‰ã‚ã£ã¦ã‚‚ã€ãれをシェルã®ãƒ­ã‚±ãƒ¼ãƒ«æƒ…å ±ã«å映ã—ã¾ã›ã‚“。 - link:params.html#sv-random[+RANDOM+ 変数]ã¯ä½¿ãˆã¾ã›ã‚“。 - link:expand.html#tilde[ãƒãƒ«ãƒ€å±•é–‹]ã§ +~+ 㨠+~{{ユーザå}}+ 以外ã®å½¢å¼ã®å±•é–‹ãŒä½¿ãˆã¾ã›ã‚“。 - link:expand.html#params[パラメータ展開]ã®link:expand.html#param-name[入れå­]ã¯ã§ãã¾ã›ã‚“。ã¾ãŸlink:expand.html#param-index[インデックス]ã®æŒ‡å®šã¯ã§ãã¾ã›ã‚“。 - +$(+ 㨠+)+ ã§å›²ã‚“ã link:expand.html#cmdsub[コマンド置æ›]ã«å«ã¾ã‚Œã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒå®Ÿè¡Œã•ã‚Œã‚‹æ™‚ã«æ¯Žå›žè§£æžã•れã¾ã™ã€‚ - link:expand.html#arith[æ•°å¼å±•é–‹]ã§å°æ•°ãªã‚‰ã³ã« `++` ãŠã‚ˆã³ `--` 演算å­ãŒä½¿ãˆã¾ã›ã‚“。 - link:redir.html#file[ファイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ]ã§ã€link:expand.html#glob[パスå展開]ã®çµæžœãŒä¸€ã¤ã§ãªã„å ´åˆã€ã™ãã«ã¯ã‚¨ãƒ©ãƒ¼ã«ã›ãšã€ãƒ‘スå展開を行ã‚ãªã‹ã£ãŸã¨ãã¨åŒæ§˜ã«æ‰±ã„ã¾ã™ã€‚ - link:redir.html#socket[ソケットリダイレクト]・link:redir.html#here[ヒアストリング]・link:redir.html#pipe[パイプリダイレクト]・link:redir.html#process[プロセスリダイレクト]ã¯ä½¿ç”¨ã§ãã¾ã›ã‚“。 - link:exec.html#simple[å˜ç´”コマンドã®å®Ÿè¡Œ]時ã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªãã¦ã‚‚ link:params.html#sv-command_not_found_handler[+COMMAND_NOT_FOUND_HANDLER+ 変数]ã®å€¤ã¯å®Ÿè¡Œã—ã¾ã›ã‚“。 - link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢]ã«ãŠã„ã¦link:builtin.html#types[通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯å¯¾å¿œã™ã‚‹å¤–部コマンドãŒãªã„ã¨è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“。 - link:job.html[ジョブ制御]ãŒæœ‰åйã§ã‚‚ã€link:syntax.html#async[éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰]㯠SIGINT 㨠SIGQUIT を無視ã—ã¾ã™ã€‚ã¾ãŸéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力を /dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã™ã‚‹æ¡ä»¶ãŒå¤‰ã‚りã¾ã™ (ジョブ制御ãŒç„¡åйã®ã¨ãã§ã¯ãªãã€link:interact.html[対話モード]ãŒç„¡åйãªã¨ãã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ)。 - ã„ãã¤ã‹ã®link:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ç‰¹å®šã®ã‚ªãƒ—ションãŒä½¿ãˆãªããªã‚‹ãªã©æŒ™å‹•ãŒå¤‰ã‚りã¾ã™ã€‚ - link:interact.html[対話モード]ã§ãªã„ã¨ãã€link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ã¾ãŸç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ä»£å…¥ã‚¨ãƒ©ãƒ¼ã‚„リダイレクトエラーãŒç™ºç”Ÿã—ãŸã¨ãã‚‚ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ - link:interact.html[対話モード]ã®ãƒ—ロンプトを出ã™å‰ã« link:params.html#sv-prompt_command[+PROMPT_COMMAND+ 変数]ã®å€¤ã‚’実行ã—ã¾ã›ã‚“。link:params.html#sv-ps1[+PS1+ 変数]・link:params.html#sv-ps2[+PS2+ 変数]・link:params.html#sv-ps4[+PS4+ 変数]ã®å€¤ã®è§£é‡ˆã®ä»•æ–¹ãŒé•ã„ã¾ã™ã€‚ - link:interact.html#mailcheck[メールãƒã‚§ãƒƒã‚¯]ã«ãŠã„ã¦ã€ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ›´æ–°ã•れã¦ã„ã‚‹å ´åˆã¯ãƒ•ァイルãŒç©ºã§ã‚‚æ–°ç€ãƒ¡ãƒ¼ãƒ«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_array.html0000644000175000017500000001206712154557026016056 0ustar magicantmagicant Array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯é…列ã®è¡¨ç¤ºã‚„æ“作を行ã„ã¾ã™ã€‚

æ§‹æ–‡

  • array

  • array é…列å [値…]

  • array -d é…列å [インデックス…]

  • array -i é…列å インデックス [値…]

  • array -s é…列å インデックス 値

説明

オプションもオペランドも指定ã›ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€array コマンドã¯å…¨ã¦ã®é…列ã®å®šç¾©ã‚’ (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

オプションを指定ã›ãšã«é…列åã¨å€¤ã‚’与ãˆã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array コマンドã¯ãã®é…列ã®å†…容を指定ã•れãŸå€¤ã«è¨­å®šã—ã¾ã™ã€‚

-d (--delete) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã‚’削除ã—ã¾ã™ã€‚é…列ã®è¦ç´ æ•°ã¯å‰Šé™¤ã—ãŸè¦ç´ ã®åˆ†ã ã‘å°‘ãªããªã‚Šã¾ã™ã€‚存在ã—ãªã„è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’指定ã—ãŸã¨ãã¯ç„¡è¦–ã—ã¾ã™ã€‚

-i (--insert) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã®ç›´å¾Œã«æŒ‡å®šã—ãŸå€¤ã‚’è¦ç´ ã¨ã—ã¦è¿½åŠ ã—ã¾ã™ã€‚é…列ã®è¦ç´ æ•°ã¯è¿½åŠ ã—ãŸè¦ç´ ã®åˆ†ã ã‘増ãˆã¾ã™ã€‚インデックス ã¨ã—㦠0 を指定ã™ã‚‹ã¨é…列ã®å…ˆé ­ã«è¦ç´ ã‚’追加ã—ã¾ã™ã€‚インデックスã¨ã—ã¦é…列ã®è¦ç´ æ•°ã‚ˆã‚Šå¤§ããªæ•°ã‚’指定ã™ã‚‹ã¨é…åˆ—ã®æœ«å°¾ã«è¦ç´ ã‚’追加ã—ã¾ã™ã€‚

-s (--set) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã®å€¤ã‚’指定ã—ãŸå€¤ã«å¤‰æ›´ã—ã¾ã™ã€‚

オプション

-d
--delete

é…列ã®è¦ç´ ã‚’削除ã—ã¾ã™ã€‚

-i
--insert

é…列ã«è¦ç´ ã‚’挿入ã—ã¾ã™ã€‚

-s
--set

é…列ã®è¦ç´ ã‚’変更ã—ã¾ã™ã€‚

オペランド

é…列å

表示ã¾ãŸã¯æ“作ã™ã‚‹é…列ã®åå‰ã§ã™ã€‚

インデックス

é…列ã®è¦ç´ ã‚’指定ã™ã‚‹è‡ªç„¶æ•°ã§ã™ã€‚ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯æœ€åˆã®è¦ç´ ã‹ã‚‰é †ã« 1, 2, 3, … ã¨å‰²ã‚ŠæŒ¯ã‚‰ã‚Œã¾ã™ã€‚

値

é…列ã®è¦ç´ ã¨ãªã‚‹æ–‡å­—列ã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š array コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

POSIX ã«ã¯ array コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

array é…列å [値…] ã®å½¢å¼ã® array コマンドã¯å¤‰æ•°ä»£å…¥ã‚’用ã„㦠é…列å=(値…) ã¨æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ã€‚

yash-2.35/doc/ja/intro.txt0000644000175000017500000000267712154557026015615 0ustar magicantmagicant= ã¯ã˜ã‚ã« :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - ã¯ã˜ã‚ã« :description: Yash マニュアルã®å°Žå…¥ãƒšãƒ¼ã‚¸ dfn:[Yet another shell] (yash) 㯠Unix ç³» OS 用コマンドラインシェルã§ã™ã€‚POSIX.1-2008 è¦æ ¼ã« (一部ã®ä¾‹å¤–を除ã„ã¦) 準拠ã—ã¦ã„ã¾ã™ã€‚POSIX 準拠を謳ã†ä»–ã®ã‚·ã‚§ãƒ«ã‚ˆã‚Šã‚‚ç²¾ç¢ºãªæº–拠を目指ã—ã¦ã„ã¾ã™ã€‚ã¾ãŸã€ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚„コマンドライン編集ãªã©ã€å¯¾è©±ã‚·ã‚§ãƒ«ã¨ã—ã¦æ¨™æº–çš„ãªæ©Ÿèƒ½ã‚‚å‚™ãˆã¦ã„ã¾ã™ã€‚ ã“ã®ãƒ—ログラム㯠http://www.gnu.org/licenses/gpl.html[GNU General Public License] (Version 2) ã®å…ƒã§è‡ªç”±ã«å†é…布・変更ãªã©ãŒã§ãã¾ã™ã€‚**ãŸã ã—ã€ãƒ—ログラムã®åˆ©ç”¨ã¯å…¨ã¦å„自ã®è‡ªå·±è²¬ä»»ã®ä¸‹ã§è¡Œã£ã¦ã„ãŸã ãã“ã¨ã«ãªã‚Šã¾ã™ã€‚**作者ã¯ãƒ—ログラムã®ç‘•ç–µã«å¯¾ã—ã¦ä¸€åˆ‡è²¬ä»»ã‚’å–りã¾ã›ã‚“。ã¾ãŸã€ã“ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã¯http://creativecommons.org/licenses/by-sa/2.1/jp/[クリエイティブ・コモンズã®è¡¨ç¤º-継承 2.1 日本ライセンス]ã®ä¸‹ã§è‡ªç”±ã«å†é…布・変更ãªã©ãŒã§ãã¾ã™ã€‚ Yash ã¯æ¸¡é‚Šè£•è²´ (通称ã¾ã˜ã‹ã‚“ã¨) ã¨ã„ã†ä¸€äººã®é–‹ç™ºè€…ã«ã‚ˆã£ã¦é–‹ç™ºã•れã¦ã„ã¾ã™ã€‚Yash ã®http://sourceforge.jp/projects/yash/[開発プロジェクト]ãŠã‚ˆã³ http://yash.sourceforge.jp/[ホームページ]㯠http://sourceforge.jp/[SourceForge.jp] ãŒãƒ›ã‚¹ãƒˆã—ã¦ã„ã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_return.html0000644000175000017500000001114112154557026016247 0ustar magicantmagicant Return 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Return 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®é–¢æ•°ã¾ãŸã¯ã‚¹ã‚¯ãƒªãƒ—トã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚

æ§‹æ–‡

  • return [-n] [終了ステータス]

説明

-n (--no-return) オプションを付ã‘ãšã« return コマンドを実行ã™ã‚‹ã¨ã€ä»¥ä¸‹ã®ã†ã¡å½“ã¦ã¯ã¾ã‚‹å‹•作を行ã„ã¾ã™:

  • 関数ã®å®Ÿè¡Œä¸­ã®å ´åˆã¯ã€ãã®é–¢æ•°ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚

  • ドットコマンドã§ãƒ•ァイルを開ã„ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã„る途中ã®å ´åˆã¯ã€ãã®ãƒ•ァイルã®èª­ã¿è¾¼ã¿ãƒ»å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚

  • Eval コマンドã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã„る途中ã®å ´åˆã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚

  • ã“れ以外ã®å ´åˆã¯ã€(対話モードã®ã¨ãを除ã„ã¦) シェルã¯çµ‚了ã—ã¾ã™ã€‚

-n (--no-return) オプションを付ã‘㦠return コマンドを実行ã™ã‚‹ã¨ã€return コマンドã¯ãŸã å˜ã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã•れã¦ã„る終了ステータスを返ã—ã¾ã™ã€‚

オプション

-n
--no-return

コマンドã®å®Ÿè¡Œã‚’中断ã—ã¾ã›ã‚“。

オペランド

終了ステータス

Return コマンドã®çµ‚了ステータスを指定ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚

ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€return コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを用ã„ã¾ã™ (ãŸã ã—トラップを実行中ã®å ´åˆã¯ãƒˆãƒ©ãƒƒãƒ—ã«å…¥ã‚‹ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス)。

終了ステータス

Return コマンドã®çµ‚了ステータスã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸå€¤ã§ã™ã€‚Return コマンドã®çµ‚了ステータス㯠return コマンドãŒçµ‚了ã™ã‚‹é–¢æ•°ãƒ»ãƒ‰ãƒƒãƒˆã‚³ãƒžãƒ³ãƒ‰ãƒ»eval コマンド・シェル自身ã®çµ‚了ステータスã«ã‚‚ãªã‚Šã¾ã™ã€‚

補足

Return コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã§ã¯ã€çµ‚了ステータスã®å€¤ã¯ 0 以上 256 未満ã§ãªã‘れã°ãªã‚‰ãªã„ã¨ã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯æ‹¡å¼µã¨ã—㦠256 以上ã®å€¤ã‚‚å—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚

POSIX ã§ã¯é–¢æ•°ã‚ã‚‹ã„ã¯ãƒ‰ãƒƒãƒˆã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œä¸­ä»¥å¤–ã«ãŠã‘ã‚‹ return コマンドã®å‹•作を定ã‚ã¦ã„ã¾ã›ã‚“。

POSIX ã«ã¯ -n (--no-return) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/_bg.html0000644000175000017500000000565012154557026015330 0ustar magicantmagicant Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚¸ãƒ§ãƒ–ã‚’ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚

æ§‹æ–‡

  • bg [ジョブ…]

説明

Bg コマンドã¯ã‚¸ãƒ§ãƒ–ã‚’ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚ジョブã«ã¯ SIGCONT シグナルãŒé€ã‚‰ã‚Œã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ã¦ã„ã‚‹å ´åˆã¯å†é–‹ã•れã¾ã™ã€‚

ジョブã®å®Ÿè¡Œã‚’å†é–‹ã™ã‚‹å‰ã« bg コマンドã¯ã‚¸ãƒ§ãƒ–ã®åå‰ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

Bg コマンドã¯ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã—ã‹ä½¿ãˆã¾ã›ã‚“。

オペランド

ジョブ

実行ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID。

ジョブを複数指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を実行ã—ã¾ã™ã€‚

éž POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® % ã¯çœç•¥ã§ãã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š bg コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Bg ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã¯æŒ‡å®šã—ãŸã‚¸ãƒ§ãƒ–ãŒæ—¢ã«å®Ÿè¡Œä¸­ã®å ´åˆã¯ bg コマンドã¯ä½•ã‚‚ã—ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ãŒã€yash ã® bg コマンドã¯ã‚¸ãƒ§ãƒ–ãŒå®Ÿè¡Œä¸­ã‹ã©ã†ã‹ã«ã‹ã‹ã‚ら㚠SIGCONT シグナルをé€ä¿¡ã—ã¾ã™ã€‚

yash-2.35/doc/ja/_echo.txt0000644000175000017500000000745612154557026015537 0ustar magicantmagicant= Echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +echo [{{文字列}}...]+ Echo コマンドã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã‚’å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚オプションã¯ã€ä»¥ä¸‹ã«è¿°ã¹ã‚‹ä¾‹å¤–を除ã„ã¦ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。オプションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«ç½®ãå¿…è¦ãŒã‚りã¾ã™ã€‚Echo コマンドã§ã¯æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã¯çµ¶å¯¾ã«èµ·ãã¾ã›ã‚“。 [[description]] == 説明 Echo コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨æ”¹è¡Œã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚引数ãŒãªã„å ´åˆã¯æ”¹è¡Œã ã‘を出力ã—ã¾ã™ã€‚引数ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãれãžã‚Œã‚’空白文字ã§åŒºåˆ‡ã£ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ [[escapes]] === エスケープシーケンス Echo コマンドã«ä¸Žãˆã‚‹å¼•æ•°ã§ã¯ã€å¾Œè¿°ã® +ECHO_STYLE+ 変数㨠+-e+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ +\a+:: ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7) +\b+:: ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 8) +\c+:: ã“れ以é™ä½•も出力ã—ãªã„。 +\e+:: エスケープ文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 27) +\f+:: フォームフィード (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 12) +\n+:: 改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10) +\r+:: 復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13) +\t+:: 水平タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 9) +\v+:: 垂直タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 11) +\\+:: ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ +\0{{xxx}}+:: 八進数 {{xxx}} (最大三æ¡) ã§è¡¨ã‚ã•れるコード番å·ã®æ–‡å­— エスケープシーケンスãŒç„¡åŠ¹ã®æ™‚ã¯ã€ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¯è§£é‡ˆã›ãšã«ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚ [[echo_style]] === +ECHO_STYLE+ 変数 Echo コマンドãŒã‚ªãƒ—ションやエスケープシーケンスを解釈ã™ã‚‹ã‹ã©ã†ã‹ã¯ link:params.html#sv-echo_style[+ECHO_STYLE+ 変数]ã®å€¤ã«ã‚ˆã‚Šã¾ã™ã€‚以下ã«ã€ã“ã®å¤‰æ•°ã®å€¤ã¨ echo コマンドã®å‹•作ã¨ã®å¯¾å¿œã‚’示ã—ã¾ã™ã€‚ +SYSV+:: +XSI+:: オプションã¯ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。常ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ã¾ã™ã€‚ +BSD+:: +-n+ オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンスã¯ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。 +GNU+:: +-n+, +-e+, +-E+ オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンス㯠+-e+ オプションを指定ã—ãŸã¨ãã ã‘解釈ã—ã¾ã™ã€‚ +ZSH+:: +-n+, +-e+, +-E+ オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンス㯠+-E+ オプションを指定ã—ãªã„ã‹ãŽã‚Šè§£é‡ˆã—ã¾ã™ã€‚ +DASH+:: +-n+ オプションを解釈ã—ã¾ã™ã€‚常ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ã¾ã™ã€‚ +RAW+:: オプションもエスケープシーケンスも一切解釈ã—ã¾ã›ã‚“。 +ECHO_STYLE+ 変数ãŒè¨­å®šã•れã¦ã„ãªã„ã¨ãã¯ã€å€¤ãŒ +SYSV+ ã¾ãŸã¯ +XSI+ ã®å ´åˆã®å‹•作をã—ã¾ã™ã€‚ [[options]] == オプション +-n+:: æœ€å¾Œã«æ”¹è¡Œã‚’出力ã—ãªã„よã†ã«ã™ã‚‹ã€‚ +-e+:: エスケープシーケンスを解釈ã™ã‚‹ã‚ˆã†ã«ã™ã‚‹ã€‚ +-E+:: エスケープシーケンスを解釈ã›ãšã€å…¨ã¦ã®æ–‡å­—ã‚’ãã®ã¾ã¾å‡ºåŠ›ã™ã‚‹ã‚ˆã†ã«ã™ã‚‹ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š echo コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ +ECHO_STYLE+ 変数ãŠã‚ˆã³ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。POSIX ã§ã¯ã€+-n+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れãŸã¨ãã¾ãŸã¯å¼•æ•°ã«ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã®å‹•作をè¦å®šã—ã¦ã„ã¾ã›ã‚“ã€‚å¯æ¬æ€§ã®ã‚るシェルスクリプトを書ãã«ã¯ã€echo コマンドよりも link:_printf.html[printf コマンド]ã®ä½¿ç”¨ã‚’推奨ã—ã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_hash.txt0000644000175000017500000000574612154557026015544 0ustar magicantmagicant= Hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯å¤–部コマンドã®ãƒ‘スを検索・表示ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +hash {{コマンド}}...+ - +hash -r [{{コマンド}}...]+ - +hash [-a]+ - +hash -d {{ユーザå}}...+ - +hash -dr [{{ユーザå}}...]+ - +hash -d+ [[description]] == 説明 オプションを指定ã—ãªã„å ´åˆã€hash コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸlink:exec.html#search[外部コマンドã®ãƒ‘スを検索]ã—ã€çµæžœã‚’記憶ã—ã¾ã™ (æ—¢ã«è¨˜æ†¶ã—ã¦ã„ã‚‹å ´åˆã¯å†åº¦æ¤œç´¢ãƒ»è¨˜æ†¶ã—ã¾ã™)。 +-r+ (+--remove+) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€hash コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤–部コマンドã®ãƒ‘スã«é–¢ã™ã‚‹è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚+-r+ (+--remove+) オプションを指定ã—ã‹ã¤{{コマンド}}を指定ã—ãªã„å ´åˆã€å…¨ã¦ã®è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚ +-r+ (+--remove+) オプションを指定ã›ãš{{コマンド}}も指定ã—ãªã„å ´åˆã€è¨˜æ†¶ã—ã¦ã„るパスã®ä¸€è¦§ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ +-d+ (+--directory+) オプションを指定ã—ãŸå ´åˆã€hash コマンドã¯å¤–部コマンドã®ãƒ‘スã®ä»£ã‚りã«ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを検索・記憶ã¾ãŸã¯è¡¨ç¤ºã—ã¾ã™ã€‚記憶ã—ãŸãƒ‘スã¯link:expand.html#tilde[ãƒãƒ«ãƒ€å±•é–‹]ã§ä½¿ç”¨ã—ã¾ã™ã€‚ [[options]] == オプション +-a+:: +--all+:: シェルãŒè¨˜æ†¶ã—ã¦ã„ã‚‹å…¨ã¦ã®ãƒ‘スを出力ã—ã¾ã™ã€‚ + ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€ã‚·ã‚§ãƒ«ãŒè¨˜æ†¶ã—ã¦ã„るパスã®ã†ã¡çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã™ã‚‹ã‚‚ã®ã¯å‡ºåŠ›ã—ã¾ã›ã‚“。 +-d+:: +--directory+:: 外部コマンドã®ãƒ‘スã®ä»£ã‚りã«ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを扱ã„ã¾ã™ã€‚ +-r+:: +--remove+:: 指定ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¾ãŸã¯ãƒ¦ãƒ¼ã‚¶åã«å¯¾ã™ã‚‹ãƒ‘スã®è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚ [[operands]] == オペランド {{コマンド}}:: パスを記憶・消去ã™ã‚‹å¤–部コマンドã®åå‰ã§ã™ã€‚スラッシュをå«ã‚€ãƒ‘スを指定ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 {{ユーザå}}:: ホームディレクトリã®ãƒ‘スを記憶・消去ã™ã‚‹ãƒ¦ãƒ¼ã‚¶åã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š hash コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 シェルã¯ã€å¤–部コマンド (ã¾ãŸã¯ãƒãƒ«ãƒ€å±•é–‹) を実行ã™ã‚‹éš›ã«è‡ªå‹•çš„ã«ã‚³ãƒžãƒ³ãƒ‰ (ã¾ãŸã¯ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒª) ã®ãƒ‘スを記憶ã™ã‚‹ã®ã§ã€é€šå¸¸ã¯ã‚ã–ã‚ã– hash コマンドを使ã£ã¦ãƒ‘スを記憶ã•ã›ã‚‹å¿…è¦ã¯ã‚りã¾ã›ã‚“。 link:params.html#sv-path[+PATH+ 変数]ã®å€¤ãŒå¤‰ã‚ã£ãŸæ™‚ã¯ã€è¨˜æ†¶ã—ãŸå¤–部コマンドã®ãƒ‘スã¯è‡ªå‹•çš„ã«ã™ã¹ã¦æ¶ˆåŽ»ã•れã¾ã™ã€‚ POSIX ãŒè¦å®šã—ã¦ã„るオプション㯠+-r+ ã ã‘ã§ã™ã€‚よã£ã¦ä»–ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_dot.txt0000644000175000017500000000717212154557026015402 0ustar magicantmagicant= ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ãƒ†ã‚­ã‚¹ãƒˆãƒ•ァイルを開ã„ã¦ã€ãã®å†…容をコマンドã¨ã—ã¦è§£é‡ˆã—実行ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +. [-AL] {{ファイルå}} [{{引数}}...]+ [[description]] == 説明 ドットコマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸ{{ファイルå}}ã®ãƒ•ァイルを開ãã€ãã®å†…容をコマンドã¨ã—ã¦è§£é‡ˆã—link:exec.html#environment[ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒ]ã§å®Ÿè¡Œã—ã¾ã™ã€‚ {{ファイルå}}ã«ç¶šã‘ã¦{{引数}}ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€link:exec.html#function[関数]ã®å®Ÿè¡Œã®æ™‚ã¨åŒæ§˜ã«ã€ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œå‰ã«{{引数}}ãŒlink:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã«è¨­å®šã•れã€å®Ÿè¡Œå¾Œã«å…ƒã®ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã«æˆ»ã‚Šã¾ã™ã€‚ {{ファイルå}}ã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (+/+) ãŒä¸€ã¤ã‚‚å…¥ã£ã¦ã„ãªã„å ´åˆã¯ã€link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢]ã®ã¨ãã¨åŒæ§˜ã« link:params.html#sv-path[+PATH+ 変数]ã®æ¤œç´¢ã‚’行ã„ã€é–‹ãã¹ãファイルを探ã—ã¾ã™ã€‚ãŸã ã—ファイルã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ã•ãˆã‚れã°å®Ÿè¡Œå¯èƒ½ã§ã‚ã‚‹å¿…è¦ã¯ã‚りã¾ã›ã‚“。検索ã®çµæžœãƒ•ァイルãŒè¦‹ã¤ã‹ã‚Œã°ã€ãã®ãƒ•ァイルã®å†…容を解釈・実行ã—ã¾ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã€link:posix.html[POSIX 準拠モード]ã§ã¯ç›´ã¡ã«ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚POSIX 準拠モードã§ãªã„ã¨ãã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ•ァイルを開ãã“ã¨ã‚’試ã¿ã¾ã™ã€‚ [[options]] == オプション +-A+:: +--no-alias+:: ファイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã™ã‚‹éš›ã€ã‚¨ã‚¤ãƒªã‚¢ã‚¹å±•開を行ã„ã¾ã›ã‚“。 +-L+:: +--autoload+:: {{ファイルå}}ãŒã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’å«ã‚“ã§ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€+PATH+ 変数ã®ä»£ã‚り㫠link:params.html#sv-yash_loadpath[+YASH_LOADPATH+ 変数]を検索ã—ã¦é–‹ãã¹ãファイルを探ã—ã¾ã™ã€‚{{ファイルå}}ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘スåã¨ã¯ã¿ãªã—ã¾ã›ã‚“。 ドットコマンドã§ã¯ã€æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ [[operands]] == オペランド {{ファイルå}}:: 読ã¿è¾¼ã‚€ãƒ•ァイルã®ãƒ‘スåã§ã™ã€‚ {{引数}}...:: ファイルã®å†…容を実行ã—ã¦ã„ã‚‹é–“ã«ä½ç½®ãƒ‘ラメータã«è¨­å®šã™ã‚‹æ–‡å­—列ã§ã™ã€‚ [[exitstatus]] == 終了ステータス ドットコマンドã®çµ‚了ステータスã¯ã€ãƒ•ァイルã‹ã‚‰èª­ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ãŸæœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚ファイルã®å†…容ã«ä¸€ã¤ã‚‚コマンドãŒå…¥ã£ã¦ã„ãªã‹ã£ãŸã¨ãã¯çµ‚了ステータス㯠0 ã§ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚Šé–‹ã‘ãªã‹ã£ãŸã‚Šã—ãŸã¨ãã¯çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 ドットコマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ シェル㌠link:posix.html[POSIX 準拠モード]ã§ã€ã‹ã¤link:interact.html[対話モード]ã§ãªã„ã¨ãã€èª­ã¿è¾¼ã‚€ã¹ãファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚Šé–‹ã‘ãªã‹ã£ãŸã‚Šã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 POSIX ã«ã¯{{引数}}オペランドã«ã‚ˆã£ã¦ä½ç½®ãƒ‘ラメータを変更ã§ãã‚‹ã“ã¨ã«ã¤ã„ã¦ã®è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ POSIX 準拠モードã§ã¯{{引数}}オペランドを与ãˆã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/fgrammar.txt0000644000175000017500000001664012154557026016251 0ustar magicantmagicant= æ§‹æ–‡ã®å½¢å¼çš„定義 :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - æ§‹æ–‡ã®å½¢å¼çš„定義 :description: Yash ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ§‹æ–‡è¦å‰‡ã®å½¢å¼çš„ãªå®šç¾© ã“ã“ã« yash ã®æ–‡æ³•ã®å½¢å¼çš„定義を示ã—ã¾ã™ã€‚Yash ã®æ–‡æ³•ã¯è§£æžè¡¨ç¾æ–‡æ³•ã§å®šç¾©ã•れã¾ã™ã€‚ Yash ã®æ–‡æ³•ã«ãŠã‘る終端記å·ã®é›†åˆã¯ã€yash を実行ã™ã‚‹ç’°å¢ƒãŒæ‰±ãˆã‚‹ä»»æ„ã®æ–‡å­—ã®é›†åˆ (実行文字集åˆ) ã§ã™ (ãŸã ã—ナル文字 `'\0'` を除ã)。 以下ã¯ã€yash ã®æ–‡æ³•ã‚’æ§‹æˆã™ã‚‹éžçµ‚端記å·ã¨ãれã«å¯¾å¿œã™ã‚‹çµ‚端記å·ã®ä¸€è¦§ã§ã™ã€‚ãŸã ã—ã“ã“ã«æŒ™ã’る文法ã®å®šç¾©ã«ã¯link:redir.html#here[ヒアドキュメント]ã®å†…容ã¨ãã®çµ‚ã‚りを表ã™è¡Œã®è§£æžã®ãŸã‚ã®è¦å‰‡ã¯å«ã¾ã‚Œã¦ã„ã¾ã›ã‚“。ã¾ãŸ link:posix.html[POSIX 準拠モード]ã§ã¯æ§‹æ–‡ãŒè‹¥å¹²å¤‰ã‚りã¾ã™ãŒã€ã“ã“ã«ã¯ç¤ºã—ã¾ã›ã‚“。 [[d-complete-command]]CompleteCommand:: <> <> [[d-sequence]]Sequence:: <>* <>* [[d-list]]List:: <> ((+&&+ / +||+) <>* Pipeline)* <> [[d-pipeline]]Pipeline:: <>? <> (+|+ <>* Command)* [[d-command]]Command:: <> <>* / + !<> <> / + !R <> [[d-compound-command]]CompoundCommand:: <> / + <> / + <> / + <> / + <> / + <> / + <> [[d-subshell]]Subshell:: +(+ <> +)+ <>* [[d-grouping]]Grouping:: <> <> <> [[d-if-command]]IfCommand:: <> <> <> Sequence (<> Sequence <> Sequence)* (<> Sequence)? <> [[d-for-command]]ForCommand:: <> <> <>* <>? (<> <>* <>)? <> <> <> [[d-while-command]]WhileCommand:: (<> / <>) <> <> Sequence <> [[d-case-command]]CaseCommand:: <> <> <>* <> N* <>* <> [[d-case-item]]CaseItem:: !<> (+(+ <>*)? <> (+|+ S* Word)* +)+ <> (+;;+ / &Esac) [[d-function-command]]FunctionCommand:: <> <> (+(+ <>* +)+)? <>* <> <>* [[d-function-definition]]FunctionDefinition:: <> <>* +(+ S* +)+ <>* <> <>* [[d-simple-command]]SimpleCommand:: &(<> / <>) (<> / Redirection)* (Word / Redirection)* [[d-assignment]]Assignment:: <> +=+ <> / + Name +=(+ <>* (Word N*)* +)+ [[d-name]]Name:: !\[[:digit:]] [[:alnum:] +_+]+ [[d-portable-name]]PortableName:: ![++0++-++9++] [++0++-++9++ ++ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_++]+ [[d-word]]Word:: (<> / !<> .)+ <>* [[d-word-element]]WordElement:: +\+ . / + `'` (!`'` .)* `'` / + +"+ <>* +"+ / + <> / + <> / + <> [[d-quote-element]]QuoteElement:: +\+ ([+$`"\+] / <>) / + <> / + <> / + <> / + ![+`"\+] . [[d-parameter]]Parameter:: +$+ [+@*#?-$!+ [:digit:]] / + +$+ <> / + +$+ <> [[d-parameter-body]]ParameterBody:: +{+ <>? (<> / ParameterBody / <>) <>? <>? +}+ [[d-parameter-number]]ParameterNumber:: `#` ![`+=:/%`] !([`-?#`] `}`) [[d-parameter-name]]ParameterName:: [+@*#?-$!+] / + [[:alnum:] +_+]+ [[d-parameter-index]]ParameterIndex:: +[+ <> (+,+ ParameterIndexWord)? +]+ [[d-parameter-index-word]]ParameterIndexWord:: (<> / ![+"'],+] .)+ [[d-parameter-match]]ParameterMatch:: `:`? [`-+=?`] <> / + (`#` / `##` / `%` / `%%`) ParameterMatchWord / + (`:/` / `/` [`#%/`]?) <> (+/+ ParameterMatchWord)? [[d-parameter-match-word]]ParameterMatchWord:: (<> / ![+"'}+] .)* [[d-parameter-match-word-no-slash]]ParameterMatchWordNoSlash:: (<> / ![+"'/}+] .)* [[d-arithmetic]]Arithmetic:: `$((` <>* `))` [[d-arithmetic-body]]ArithmeticBody:: +\+ . / + <> / + <> / + <> / + +(+ ArithmeticBody +)+ / + ![+`()+] . [[d-command-substitution]]CommandSubstitution:: +$(+ <> +)+ / + +`+ <>* +`+ [[d-command-substitution-body]]CommandSubstitutionBody:: +\+ [+$`\+] / + !++`++ . [[d-redirection]]Redirection:: <> <> <>* <> / + RedirectionFD +<(+ <> +)+ / + RedirectionFD +>(+ Sequence +)+ [[d-redirection-fd]]RedirectionFD:: \[[:digit:]]* [[d-redirection-operator]]RedirectionOperator:: `<` / `<>` / `>` / `>|` / `>>` / `>>|` / `<&` / `>&` / `<<` / `<<-` / `<<<` [[d-list-separator]]ListSeparator:: <> / + +&+ <>* / + &++)++ / + &++;;++ [[d-separator]]Separator:: +;+ <>* / + <>+ / + <> [[d-n]]N:: <>* <> [[d-s]]S:: \[[:blank:]] / + <> [[d-comment]]Comment:: +#+ (!<> .)* [[d-r]]R:: <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> / <> [[d-bang]]Bang:: +!+ <> [[d-left-brace]]LeftBrace:: +{+ <> [[d-right-brace]]RightBrace:: +}+ <> [[d-case]]Case:: +case+ <> [[d-do]]Do:: +do+ <> [[d-done]]Done:: +done+ <> [[d-elif]]Elif:: +elif+ <> [[d-else]]Else:: +else+ <> [[d-esac]]Esac:: +esac+ <> [[d-fi]]Fi:: +fi+ <> [[d-for]]For:: +for+ <> [[d-function]]Function:: +function+ <> [[d-if]]If:: +if+ <> [[d-in]]In:: +in+ <> [[d-then]]Then:: +then+ <> [[d-until]]Until:: +until+ <> [[d-while]]While:: +while+ <> [[d-d]]D:: !<> <>* [[d-special-char]]SpecialChar:: [+|&;<>()`\"'+ [:blank:]] / <> [[d-nl]]NL:: [[d-eof]]EOF:: !. // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_dirs.html0000644000175000017500000001171712154557026015702 0ustar magicantmagicant Dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を表示ã—ã¾ã™ã€‚

æ§‹æ–‡

  • dirs [-cv] [インデックス..]

説明

ディレクトリスタックã¨ã¯ã€ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å¤‰æ›´ã®å±¥æ­´ã‚’ã¨ã‚‹ä»•組ã¿ã§ã™ã€‚Pushd コマンドã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã™ã‚‹ã¨ã€å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«è¿½åŠ ã•れã¾ã™ã€‚Popd コマンドを使ã†ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«ä¿å­˜ã—ã¦ã‚ã‚‹å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«æˆ»ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚Dirs コマンドを使ã†ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を表示ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ディレクトリスタックã®å†…容㯠DIRSTACK é…列㨠PWD 変数ã«ä¿å­˜ã•れã¾ã™ã€‚ã“れらã®å€¤ã‚’変更ã™ã‚‹ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚

ディレクトリスタックã«ä¿å­˜ã—ã¦ã‚るディレクトリã¯ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§åŒºåˆ¥ã—ã¾ã™ã€‚インデックス㯠-v (--verbose) オプションを付ã‘㦠dirs コマンドを実行ã™ã‚‹ã“ã¨ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯æ­£å· (+) ã¾ãŸã¯è² å· (-) ã®ä»˜ã„ãŸæ•´æ•°ã®å½¢ã§è¡¨ã‚ã—ã¾ã™ã€‚整数㯠pushd コマンドã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«è¿½åŠ ã—ãŸé †ã«æŒ¯ã‚‰ã‚Œã¾ã™ã€‚例ãˆã°ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +0 ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚インデックス +1 ã¯æœ€å¾Œã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã§ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +2 ã¯ãã®ä¸€ã¤å‰ã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚インデックス -0 ã¯æœ€åˆã« 追加ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ -1 ã¯ãã®æ¬¡ã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚

-c (--clear) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€dirs コマンドã¯ç¾åœ¨ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã‚’一ã¤ãšã¤æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ -c (--clear) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€dirs コマンドã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +0 以外ã®è¦ç´ ã‚’ã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚

オプション

-c
--clear

ディレクトリスタックã®è¦ç´ ã‚’ (ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã™ã‚‹ã‚‚ã®ã‚’除ã„ã¦) ã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚

-v
--verbose

ディレクトリスタックã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚‚出力ã—ã¾ã™ã€‚

オペランド

インデックス

表示ã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã™ã€‚インデックスを一ã¤ã‚‚指定ã—ãªã„ã¨ãã¯ã€å…¨ã¦ã®è¦ç´ ã‚’インデックス +0 ã®ã‚‚ã®ã‹ã‚‰é †ã«è¡¨ç¤ºã—ã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š dirs コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

POSIX ã«ã¯ dirs コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/_pwd.txt0000644000175000017500000000255012154557026015401 0ustar magicantmagicant= Pwd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Pwd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Pwd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ã®ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表示ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +pwd [-L|-P]+ [[description]] == 説明 Pwd コマンドã¯ã‚·ã‚§ãƒ«ã®ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’çµ¶å¯¾ãƒ‘ã‚¹ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ [[options]] == オプション +-L+:: +--logical+:: link:params.html#sv-pwd[+PWD+ 変数]ã®å€¤ãŒç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スã§ã€ä¸­ã« +.+ ã‚„ +..+ ã‚’å«ã‚“ã§ã„ãªã‘れã°ã€ãれを出力ã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ +-P+ を指定ã—ãŸå ´åˆã¨åŒæ§˜ã«å‡ºåŠ›ã—ã¾ã™ã€‚ +-P+:: +--physical+:: ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スをã€ä¸­ã«ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’å«ã¾ãªã„ã‹ãŸã¡ã§å‡ºåŠ›ã—ã¾ã™ã€‚ +-L+ (+--logical+) オプション㨠+-P+ (+--physical+) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€+-L+ を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š pwd コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Pwd コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/yash.10000644000175000017500000133256712154557026014754 0ustar magicantmagicant'\" t .\" Title: yash .\" Author: 渡邊 裕貴[FAMILY Given] .\" Generator: DocBook XSL Stylesheets v1.78.1 .\" Date: 2013-06-08 .\" Manual: \ \& .\" Source: \ \& 2.35 .\" Language: Japanese .\" .TH "YASH" "1" "2013\-06\-08" "\ \& 2\&.35" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "åå‰" yash \- POSIX 準拠コマンドラインシェル .SH "概è¦" .sp \fByash [オプション\&...] [\-\-] [オペランド\&...]\fR .SH "ã¯ã˜ã‚ã«" .sp \fIYet another shell\fR (yash) 㯠Unix ç³» OS 用コマンドラインシェルã§ã™ã€‚POSIX\&.1\-2008 è¦æ ¼ã« (一部ã®ä¾‹å¤–を除ã„ã¦) 準拠ã—ã¦ã„ã¾ã™ã€‚POSIX 準拠を謳ã†ä»–ã®ã‚·ã‚§ãƒ«ã‚ˆã‚Šã‚‚ç²¾ç¢ºãªæº–拠を目指ã—ã¦ã„ã¾ã™ã€‚ã¾ãŸã€ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚„コマンドライン編集ãªã©ã€å¯¾è©±ã‚·ã‚§ãƒ«ã¨ã—ã¦æ¨™æº–çš„ãªæ©Ÿèƒ½ã‚‚å‚™ãˆã¦ã„ã¾ã™ã€‚ .sp ã“ã®ãƒ—ログラム㯠GNU General Public License (Version 2) ã®å…ƒã§è‡ªç”±ã«å†é…布・変更ãªã©ãŒã§ãã¾ã™ã€‚\fBãŸã ã—ã€ãƒ—ログラムã®åˆ©ç”¨ã¯å…¨ã¦å„自ã®è‡ªå·±è²¬ä»»ã®ä¸‹ã§è¡Œã£ã¦ã„ãŸã ãã“ã¨ã«ãªã‚Šã¾ã™ã€‚\fR作者ã¯ãƒ—ログラムã®ç‘•ç–µã«å¯¾ã—ã¦ä¸€åˆ‡è²¬ä»»ã‚’å–りã¾ã›ã‚“。ã¾ãŸã€ã“ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã¯ã‚¯ãƒªã‚¨ã‚¤ãƒ†ã‚£ãƒ–・コモンズã®è¡¨ç¤º\-継承 2\&.1 日本ライセンスã®ä¸‹ã§è‡ªç”±ã«å†é…布・変更ãªã©ãŒã§ãã¾ã™ã€‚ .sp Yash ã¯æ¸¡é‚Šè£•è²´ (通称ã¾ã˜ã‹ã‚“ã¨) ã¨ã„ã†ä¸€äººã®é–‹ç™ºè€…ã«ã‚ˆã£ã¦é–‹ç™ºã•れã¦ã„ã¾ã™ã€‚Yash ã®é–‹ç™ºãƒ—ロジェクトãŠã‚ˆã³ ホームページ㯠SourceForge\&.jp ãŒãƒ›ã‚¹ãƒˆã—ã¦ã„ã¾ã™ã€‚ .SH "シェルã®èµ·å‹•" .sp Yash ãŒãƒ—ログラムã¨ã—ã¦èµ·å‹•ã•れるã¨ã€yash ã¯ã„ãã¤ã‹ã®åˆæœŸåŒ–処ç†ã‚’行ã£ãŸå¾Œã€ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦å®Ÿè¡Œã™ã‚‹å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ã“れらã®å‡¦ç†ã®å†…容ã¯ã€ä¸»ã«èµ·å‹•時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«ã‚ˆã£ã¦æ±ºã¾ã‚Šã¾ã™ã€‚ .SS "起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°" .sp Yash ã®èµ·å‹•時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数㯠POSIX ã«æº–æ‹ ã—ã¦ã„ã¾ã™ã€‚POSIX ã§å®šã‚られã¦ã„ã‚‹ã¨ãŠã‚Šã€å¼•数㯠\fIオプション\fR 㨠\fIオペランド\fR ã«åˆ†é¡žã•れã¾ã™ã€‚å¼•æ•°ã®æ›¸å¼ã«é–¢ã™ã‚‹ä¸€èˆ¬çš„ãªèª¬æ˜Žã«ã¤ã„ã¦ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã®æ§‹æ–‡ã‚’å‚ç…§ã—ã¦ãã ã•ã„。オプションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«æŒ‡å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ .sp オプション㫠\fB\-c\fR (\fB\-\-cmdline\fR) オプションãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’å°‘ãªãã¨ã‚‚一ã¤ä¸Žãˆã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚シェルã¯ã€ã“ã®æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚二ã¤ç›®ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ç‰¹æ®Šãƒ‘ラメータ \fB0\fR ãŒãれã«åˆæœŸåŒ–ã•れã¾ã™ã€‚三ã¤ç›®ä»¥é™ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€ä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚ \fB\-c\fR (\fB\-\-cmdline\fR) オプションを指定ã—ãŸå ´åˆã¯ã€ãƒ•ァイルや標準入力ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€ã“ã¨ã¯ã‚りã¾ã›ã‚“ (ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã—ãŸã¨ãを除ã)。 .sp オプション㫠\fB\-s\fR (\fB\-\-stdin\fR) オプションãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯æ¨™æº–入力ã‹ã‚‰ä¸€è¡Œãšã¤ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦ã€è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚オペランドã¯ã™ã¹ã¦ä½ç½®ãƒ‘ラメータã®åˆæœŸåŒ–ã«ä½¿ã‚れã¾ã™ã€‚特殊パラメータ \fB0\fR ã¯ã“ã®ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã«å…ƒã®ãƒ—ログラムã‹ã‚‰å—ã‘å–ã£ãŸæœ€åˆã®å¼•æ•°ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .sp \fB\-c\fR (\fB\-\-cmdline\fR) オプションも \fB\-s\fR (\fB\-\-stdin\fR) オプションも指定ã•れãªã‹ã£ãŸå ´åˆã¯ã€ã‚·ã‚§ãƒ«ã¯ãƒ•ァイルã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒèª­ã¿è¾¼ã‚€ãƒ•ァイルåã¨è¦‹ãªã•れã€ç‰¹æ®Šãƒ‘ラメータ \fB0\fR ã®å€¤ã¨ãªã‚Šã¾ã™ã€‚残りã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚オペランドãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¯ã€ \fB\-s\fR (\fB\-\-stdin\fR) オプションを指定ã—ãŸã¨ãã¨åŒæ§˜ã«æ¨™æº–入力ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã¿ã¾ã™ã€‚ .sp \fB\-c\fR (\fB\-\-cmdline\fR) オプション㨠\fB\-s\fR (\fB\-\-stdin\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .sp \fB\-\-help\fR オプションã¾ãŸã¯ \fB\-\-version\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€é€šå¸¸ã®åˆæœŸåŒ–処ç†ã‚„コマンドã®è§£é‡ˆãƒ»å®Ÿè¡Œã¯ä¸€åˆ‡è¡Œã„ã¾ã›ã‚“。ãれãžã‚Œã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®ç°¡å˜ãªèª¬æ˜Žã¨ãƒãƒ¼ã‚¸ãƒ§ãƒ³æƒ…報を標準出力ã«å‡ºåŠ›ã—ãŸå¾Œã€ãã®ã¾ã¾ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚ \fB\-\-version\fR オプションを \fB\-\-verbose\fR オプションã¨å…±ã«ä½¿ç”¨ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã§åˆ©ç”¨å¯èƒ½ãªæ©Ÿèƒ½ã®ä¸€è¦§ã‚‚出力ã•れã¾ã™ã€‚ .sp \fB\-i\fR (\fB\-\-interactive\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚逆㫠\fB+i\fR (\fB++interactive\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã›ã‚“。 .sp \fB\-l\fR (\fB\-\-login\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯ãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¾ã™ã€‚ .sp \fB\-\-noprofile\fR, \fB\-\-norcfile\fR, \fB\-\-profile\fR, \fB\-\-rcfile\fR å„オプションã¯ã€ã‚·ã‚§ãƒ«ã®åˆæœŸåŒ–処ç†ã®å‹•作を指定ã—ã¾ã™ (後述)。 .sp ãã®ä»–ã®ã‚ªãƒ—ションã¨ã—ã¦ã€set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§æŒ‡å®šå¯èƒ½ãªå„種オプションをシェルã®èµ·å‹•æ™‚ã«æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚(\fB+\fR ã§å§‹ã¾ã‚‹ã‚ªãƒ—ションをå«ã‚€) .sp 最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ \fB\-\fR ã§ã‚りã€ã‹ã¤ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ \fB\-\-\fR ã§åŒºåˆ‡ã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€ãã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ç‰¹åˆ¥ã«ç„¡è¦–ã•れã¾ã™ã€‚ .SS "シェルã®åˆæœŸåŒ–処ç†" .sp シェルã®åˆæœŸåŒ–処ç†ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«è¡Œã‚れã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} Yash ã¯ã¾ãšã€(コマンドライン引数ã®å‰ã«æ¸¡ã•れる) ãれ自身ã®èµ·å‹•時ã®åå‰ã‚’è§£æžã—ã¾ã™ã€‚ãã®åå‰ãŒ \fB\-\fR ã§å§‹ã¾ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ã¯ãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¾ã™ã€‚ã¾ãŸåå‰ãŒ \fBsh\fR ã§ã‚ã‚‹å ´åˆ (\fB/bin/sh\fR ã®ã‚ˆã†ã« \fBsh\fR ã§çµ‚ã‚ã‚‹å ´åˆã‚’å«ã‚€) ã¯ã€ã‚·ã‚§ãƒ«ã¯ POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} オペランドãŒä¸€ã¤ã‚‚ãªãã€ã‹ã¤æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã©ã¡ã‚‰ã‚‚端末ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯è‡ªå‹•çš„ã«å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚ãŸã ã— \fB+i\fR (\fB++interactive\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ãã¡ã‚‰ã‚’優先ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} 対話モードã®ã‚·ã‚§ãƒ«ã§ã¯è‡ªå‹•çš„ã«ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйã«ãªã‚Šã¾ã™ã€‚ãŸã ã— \fB+m\fR (\fB++monitor\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ãã¡ã‚‰ã‚’優先ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} シェルã¯ä»¥ä¸‹ã®åˆæœŸåŒ–スクリプトを読ã¿è¾¼ã‚“ã§è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã—シェルプロセスã®å®Ÿãƒ¦ãƒ¼ã‚¶ ID ã¨å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ãŒç•°ãªã£ã¦ã„ã‚‹ã‹ã€å®Ÿã‚°ãƒ«ãƒ¼ãƒ— ID ã¨å®ŸåŠ¹ã‚°ãƒ«ãƒ¼ãƒ— ID ãŒç•°ãªã£ã¦ã„ã‚‹å ´åˆã‚’除ã) .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} シェルãŒãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¦ã„ã‚‹å ´åˆã¯ã€ \fB\-\-profile=\fR\fB\fIファイルå\fR\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸãƒ•ァイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã— \fB\-\-noprofile\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã‹ POSIX 準拠モードã®å ´åˆã‚’除ã) \fB\-\-profile=\fR\fB\fIファイルå\fR\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€ ~/\&.yash_profile ãŒãƒ‡ãƒ•ォルトã®ãƒ•ァイルã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®å ´åˆã¯ã€ \fB\-\-rcfile=\fR\fB\fIファイルå\fR\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸãƒ•ァイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã— \fB\-\-norcfile\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã‚’除ã) \fB\-\-rcfile\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€éž POSIX 準拠モードã§ã¯ãƒ•ァイル ~/\&.yashrc ãŒãƒ‡ãƒ•ォルトã®ãƒ•ァイルã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚POSIX 準拠モードã§ã¯ã€ \fBENV\fR 環境変数ã®å€¤ãŒãƒ‘ラメータ展開ã•れã€ãã®çµæžœã‚’ファイルåã¨è¦‹ãªã—ã¦ãƒ•ァイルを読ã¿è¾¼ã¿ã¾ã™ã€‚ .RE .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB注記\fR .ps -1 .br .sp Yash 㯠/etc/profile ã‚„ /etc/yashrc ã‚„ ~/\&.profile を自動的ã«èª­ã‚€ã“ã¨ã¯ã‚りã¾ã›ã‚“。 .sp .5v .RE .SH "ã‚³ãƒžãƒ³ãƒ‰ã®æ–‡æ³•" .sp シェルã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’一行ãšã¤èª­ã¿è¾¼ã‚“ã§è§£é‡ˆã—ã€å®Ÿè¡Œã—ã¾ã™ã€‚一行ã«è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ãれら全ã¦ã‚’解釈ã—ã¦ã‹ã‚‰å®Ÿè¡Œã—ã¾ã™ã€‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãŒè¤‡æ•°è¡Œã«ã¾ãŸãŒã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’解釈ã—終ãˆã‚‹ã®ã«å¿…è¦ãªã ã‘後続ã®è¡ŒãŒèª­ã¿è¾¼ã¾ã‚Œã¾ã™ã€‚コマンドを正ã—ã解釈ã§ããªã„å ´åˆã¯ã€æ–‡æ³•エラーã¨ãªã‚Šã€ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œã•れã¾ã›ã‚“。 .sp éžå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§æ–‡æ³•エラーãŒç™ºç”Ÿã—ãŸæ™‚ã¯ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®èª­ã¿è¾¼ã¿ã‚’中止ã™ã‚‹ãŸã‚ã€ãれ以é™ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ä¸€åˆ‡èª­ã¿è¾¼ã¾ã‚Œã¾ã›ã‚“。 .SS "トークンã®è§£æžã¨äºˆç´„語" .sp コマンドã¯ã€ã„ãã¤ã‹ã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã‚ˆã£ã¦æ§‹æˆã•れã¾ã™ã€‚\fIトークン\fRã¨ã¯ã€ã‚·ã‚§ãƒ«ã®æ–‡æ³•ã«ãŠã‘る一ã¤ä¸€ã¤ã®å˜èªžã®ã“ã¨ã‚’言ã„ã¾ã™ã€‚トークンã¯åŽŸå‰‡ã¨ã—ã¦ç©ºç™½ (空白文字ã¾ãŸã¯ã‚¿ãƒ–文字) ã«ã‚ˆã£ã¦åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ãŸã ã—コマンド置æ›ãªã©ã«å«ã¾ã‚Œã‚‹ç©ºç™½ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ã¯è¦‹ãªã—ã¾ã›ã‚“。 .sp 以下ã®è¨˜å·ã¯ã€ã‚·ã‚§ãƒ«ã®æ–‡æ³•ã«ãŠã„ã¦ç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚ã“れらã®è¨˜å·ã‚‚多ãã®å ´åˆä»–ã®é€šå¸¸ã®ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ãªã‚Šã¾ã™ã€‚ .sp .if n \{\ .RS 4 .\} .nf ; & | < > ( ) [newline] .fi .if n \{\ .RE .\} .sp 以下ã®è¨˜å·ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã«ã¯ãªã‚Šã¾ã›ã‚“ãŒã€æ–‡æ³•ä¸Šç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚ .sp .if n \{\ .RS 4 .\} .nf $ ` \e " \*(Aq * ? [ # ~ = % .fi .if n \{\ .RE .\} .sp 以下ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ç‰¹å®šã®å ´é¢ã«ãŠã„ã¦\fI予約語\fRã¨è¦‹ãªã•れã¾ã™ã€‚予約語ã¯è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ãªã©ã‚’æ§‹æˆã™ã‚‹ä¸€éƒ¨ã¨ãªã‚Šã¾ã™ã€‚ .sp .if n \{\ .RS 4 .\} .nf ! { } case do done elif else esac fi for function if in then until while .fi .if n \{\ .RE .\} .sp ã“れらã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ä»¥ä¸‹ã®å ´é¢ã«ãŠã„ã¦äºˆç´„語ã¨ãªã‚Šã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãれãŒã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã®ã¨ã .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãれãŒä»–ã®äºˆç´„語 (\fBcase\fR, \fBfor\fR, \fBin\fR を除ã) ã®ç›´å¾Œã®ãƒˆãƒ¼ã‚¯ãƒ³ã®ã¨ã .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãれãŒã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã§ã¯ãªã„ãŒã€è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã®ä¸­ã§äºˆç´„語ã¨ã—ã¦æ‰±ã‚れるã¹ãトークンã§ã‚ã‚‹ã¨ã .RE .sp トークン㌠\fB#\fR ã§å§‹ã¾ã‚‹å ´åˆã€ãã® \fB#\fR ã‹ã‚‰è¡Œæœ«ã¾ã§ã¯\fIコメント\fRã¨è¦‹ãªã•れã¾ã™ã€‚コマンドã®è§£é‡ˆã«ãŠã„ã¦ã‚³ãƒ¡ãƒ³ãƒˆã¯å®Œå…¨ã«ç„¡è¦–ã•れã¾ã™ã€‚ .SS "クォート" .sp 空白や上記ã®åŒºåˆ‡ã‚Šè¨˜å·ãƒ»äºˆç´„語ãªã©ã‚’é€šå¸¸ã®æ–‡å­—ã¨åŒã˜ã‚ˆã†ã«æ‰±ã†ã«ã¯ã€é©åˆ‡ãªå¼•用符ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚引用符ã¯ã€ãれ自体をクォートã—ãªã„é™ã‚Šé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦ã¯æ‰±ã‚れã¾ã›ã‚“。シェルã§ã¯ä»¥ä¸‹ã®ä¸‰ç¨®é¡žã®å¼•用符ãŒä½¿ãˆã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\fB\e\fR) ã¯ç›´å¾Œã®ä¸€æ–‡å­—をクォートã—ã¾ã™ã€‚ 例外ã¨ã—ã¦ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã®ç›´å¾Œã«æ”¹è¡ŒãŒã‚ã‚‹å ´åˆã€ãã‚Œã¯æ”¹è¡Œã‚’クォートã—ã¦ã„ã‚‹ã®ã§ã¯ãªãã€\fI行ã®é€£çµ\fRã¨è¦‹ãªã•れã¾ã™ã€‚ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¨æ”¹è¡ŒãŒå‰Šé™¤ã•れã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒã‚ã£ãŸè¡Œã¨ãã®æ¬¡ã®è¡ŒãŒå…ƒã€…一ã¤ã®è¡Œã§ã‚ã£ãŸã‹ã®ã‚ˆã†ã«æ‰±ã‚れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 二ã¤ã®ä¸€é‡å¼•用符 (\fB\*(Aq\fR) ã§å›²ã‚“ã éƒ¨åˆ†ã§ã¯ã€å…¨ã¦ã®æ–‡å­—ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒã˜ã‚ˆã†ã«æ‰±ã‚れã¾ã™ã€‚改行を一é‡å¼•用符ã§å›²ã‚€ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ãŸã ã—ã€ä¸€é‡å¼•用符を一é‡å¼•用符ã§å›²ã‚€ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 二ã¤ã®äºŒé‡å¼•用符 (\fB"\fR) ã§å›²ã‚“ã éƒ¨åˆ†ã‚‚一é‡å¼•用符ã§å›²ã‚“ã éƒ¨åˆ†ã¨åŒæ§˜ã«ã‚¯ã‚©ãƒ¼ãƒˆã•れã¾ã™ãŒã€ã„ãã¤ã‹ä¾‹å¤–ãŒã‚りã¾ã™ã€‚二é‡å¼•用符ã§å›²ã‚“ã éƒ¨åˆ†ã§ã¯ã€ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ãŒé€šå¸¸é€šã‚Šè§£é‡ˆã•れã¾ã™ã€‚ã¾ãŸãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯ \fB$\fR, \fB`\fR, \fB"\fR, \fB\e\fR ã®ç›´å‰ã«ã‚ã‚‹å ´åˆãŠã‚ˆã³è¡Œã®é€£çµã‚’行ã†å ´åˆã«ã®ã¿å¼•用符ã¨ã—ã¦æ‰±ã‚れã€ãれ以外ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒæ§˜ã«æ‰±ã‚れã¾ã™ã€‚ .RE .SS "エイリアス" .sp コマンドを構æˆã™ã‚‹å„トークンã¯ã€ãれãŒäºˆã‚登録ã•れãŸã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã«ä¸€è‡´ã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã‚‰ã‚Œã¾ã™ã€‚一致ã™ã‚‹ã‚‚ã®ãŒã‚れã°ã€ãã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ãã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®å†…容ã«ç½®ãæ›ãˆã‚‰ã‚Œã¦ã€ãã®å¾Œã‚³ãƒžãƒ³ãƒ‰ã®è§£æžãŒç¶šã‘られã¾ã™ã€‚ã“れを\fIエイリアス置æ›\fRã¨ã„ã„ã¾ã™ã€‚ .sp エイリアスã®åå‰ã«å¼•用符をå«ã‚ã‚‹ã“ã¨ã¯ã§ããªã„ã®ã§ã€å¼•用符をå«ã‚€ãƒˆãƒ¼ã‚¯ãƒ³ã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ç½®æ›ã•れã¾ã›ã‚“。ã¾ãŸã€äºˆç´„語やコマンドを区切る記å·ã‚‚エイリアス置æ›ã•れã¾ã›ã‚“。 .sp エイリアスã«ã¯é€šå¸¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¨ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®äºŒç¨®é¡žãŒã‚りã¾ã™ã€‚\fI通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹\fRã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã®ã¿ä¸€è‡´ã—ã¾ã™ã€‚\fIグローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹\fRã¯ã‚³ãƒžãƒ³ãƒ‰å†…ã®å…¨ã¦ã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒä¸€è‡´ã®å¯¾è±¡ã§ã™ã€‚グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ POSIX è¦æ ¼ã«ã¯ãªã„拡張機能ã§ã™ã€‚ .sp 通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã§ç½®æ›ã•れãŸéƒ¨åˆ†ã®æœ€å¾Œã®æ–‡å­—ãŒç©ºç™½ã®å ´åˆã€ç‰¹ä¾‹ã¨ã—ã¦ãã®ç›´å¾Œã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã‚‚通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®ç½®æ›ãŒè¡Œã‚れã¾ã™ã€‚ .sp エイリアス置æ›ã®çµæžœãŒã•らã«åˆ¥ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ä¸€è‡´ã—ã¦ç½®æ›ã•れる場åˆã‚‚ã‚りã¾ã™ã€‚ã—ã‹ã—ã€åŒã˜ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«å†ã³ä¸€è‡´ã™ã‚‹ã“ã¨ã¯ã‚りã¾ã›ã‚“。 .sp エイリアスを登録ã™ã‚‹ã«ã¯ alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’ã€ç™»éŒ²ã‚’削除ã™ã‚‹ã«ã¯ unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã—ã¾ã™ã€‚ .SS "å˜ç´”コマンド" .sp 最åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒäºˆç´„語ã§ãªã„コマンドã¯ã€\fIå˜ç´”コマンド\fRã§ã™ã€‚å˜ç´”コマンドã¯å˜ç´”コマンドã®å®Ÿè¡Œã®ã—ã‹ãŸã«å¾“ã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ .sp å˜ç´”コマンドã®åˆã‚ã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒ \fIåå‰\fR=\fI値\fR ã®å½¢å¼ã«ãªã£ã¦ã„ã‚‹å ´åˆã¯ã€ãれã¯å¤‰æ•°ä»£å…¥ã¨è¦‹ãªã•れã¾ã™ã€‚ãŸã ã—ã“ã“ã§ã®\fIåå‰\fRã¯ã€ä¸€æ–‡å­—以上ã®ã‚¢ãƒ«ãƒ•ァベット・数字ã¾ãŸã¯ä¸‹ç·š (\fB_\fR) ã§ã€ã‹ã¤æœ€åˆãŒæ•°å­—ã§ãªã„ã‚‚ã®ã§ã™ã€‚変数代入ã§ã¯ãªã„最åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã¨è§£é‡ˆã•れã¾ã™ã€‚ãれ以é™ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ (ãŸã¨ãˆå¤‰æ•°ä»£å…¥ã®å½¢å¼ã‚’ã—ã¦ã„ãŸã¨ã—ã¦ã‚‚) コマンドã®å¼•æ•°ã¨è§£é‡ˆã•れã¾ã™ã€‚ .sp \fIåå‰\fR=(\fIトークン列\fR) ã®å½¢ã«ãªã£ã¦ã„る変数代入ã¯ã€é…列ã®ä»£å…¥ã¨ãªã‚Šã¾ã™ã€‚括弧内ã«ã¯ä»»æ„ã®å€‹æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’書ãã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸã“れらã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ç©ºç™½ãƒ»ã‚¿ãƒ–ã ã‘ã§ãªã改行ã§åŒºåˆ‡ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .SS "パイプライン" .sp \fIパイプライン\fRã¯ã€ä¸€ã¤ä»¥ä¸Šã®ã‚³ãƒžãƒ³ãƒ‰ (å˜ç´”コマンドã€è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã€ã¾ãŸã¯é–¢æ•°å®šç¾©) ã‚’è¨˜å· \fB|\fR ã§ç¹‹ã„ã ã‚‚ã®ã§ã™ã€‚ .sp 二ã¤ä»¥ä¸Šã®ã‚³ãƒžãƒ³ãƒ‰ã‹ã‚‰ãªã‚‹ãƒ‘イプラインã®å®Ÿè¡Œã¯ã€ãƒ‘イプラインã«å«ã¾ã‚Œã‚‹å„コマンドをãれãžã‚Œç‹¬ç«‹ã—ãŸã‚µãƒ–シェルã§åŒæ™‚ã«å®Ÿè¡Œã™ã‚‹ã“ã¨ã§è¡Œã‚れã¾ã™ã€‚ã“ã®æ™‚ã€å„ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å‡ºåŠ›ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力ã«ãƒ‘イプã§å—ã‘æ¸¡ã•れã¾ã™ã€‚最åˆã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å…¥åŠ›ã¨æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ã¯å…ƒã®ã¾ã¾ã§ã™ã€‚最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒãƒ‘イプラインã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .sp パイプラインã®å…ˆé ­ã«ã¯ã€è¨˜å· \fB!\fR を付ã‘ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘イプラインã®çµ‚了ステータスãŒ\fI逆転\fRã—ã¾ã™ã€‚ã¤ã¾ã‚Šã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ã®ã¨ãã¯ãƒ‘イプラインã®çµ‚了ステータス㯠1 ã«ãªã‚Šã€ãれ以外ã®å ´åˆã¯ 0 ã«ãªã‚Šã¾ã™ã€‚ .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB注記\fR .ps -1 .br .sp 最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒãƒ‘イプラインã®çµ‚了ステータスã«ãªã‚‹ãŸã‚ã€ãƒ‘イプラインã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã®ã¯å°‘ãªãã¨ã‚‚最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸå¾Œã§ã™ã€‚ã—ã‹ã—ãã®ã¨ãä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ã¦ã„ã‚‹ã¨ã¯é™ã‚Šã¾ã›ã‚“。ã¾ãŸã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸã‚‰ã™ãã«ãƒ‘イプラインã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã¨ã‚‚é™ã‚Šã¾ã›ã‚“。(シェルã¯ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã‚‹ã¾ã§å¾…ã¤å ´åˆãŒã‚りã¾ã™) .sp .5v .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB注記\fR .ps -1 .br .sp POSIX è¦æ ¼ã§ã¯ã€ãƒ‘イプライン内ã®å„コマンドã¯ã‚µãƒ–シェルã§ã¯ãªãç¾åœ¨ã®ã‚·ã‚§ãƒ«ã§å®Ÿè¡Œã—ã¦ã‚‚よã„ã“ã¨ã«ãªã£ã¦ã„ã¾ã™ã€‚ .sp .5v .RE .SS "And/or リスト" .sp \fIAnd/or リスト\fRã¯ä¸€ã¤ä»¥ä¸Šã®ãƒ‘ã‚¤ãƒ—ãƒ©ã‚¤ãƒ³ã‚’è¨˜å· \fB&&\fR ã¾ãŸã¯ \fB||\fR ã§ç¹‹ã„ã ã‚‚ã®ã§ã™ã€‚ .sp And/or リストã®å®Ÿè¡Œã¯ã€and/or リストã«å«ã¾ã‚Œã‚‹å„パイプラインをæ¡ä»¶ä»˜ãã§å®Ÿè¡Œã™ã‚‹ã“ã¨ã§è¡Œã‚れã¾ã™ã€‚最åˆã®ãƒ‘イプラインã¯å¸¸ã«å®Ÿè¡Œã•れã¾ã™ã€‚ãれ以é™ã®ãƒ‘イプラインã®å®Ÿè¡Œã¯ã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータスã«ã‚ˆã‚Šã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 二ã¤ã®ãƒ‘イプライン㌠\fB&&\fR ã§ç¹‹ãŒã‚Œã¦ã„ã‚‹å ´åˆã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータス㌠0 ãªã‚‰ã°å¾Œã®ãƒ‘イプラインãŒå®Ÿè¡Œã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 二ã¤ã®ãƒ‘イプライン㌠\fB||\fR ã§ç¹‹ãŒã‚Œã¦ã„ã‚‹å ´åˆã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータス㌠0 ã§ãªã‘れã°å¾Œã®ãƒ‘イプラインãŒå®Ÿè¡Œã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãれ以外ã®å ´åˆã¯ã€and/or リストã®å®Ÿè¡Œã¯ãã“ã§çµ‚了ã—ã€ãれ以é™ã®ãƒ‘イプラインã¯å®Ÿè¡Œã•れã¾ã›ã‚“。 .RE .sp 最後ã«å®Ÿè¡Œã—ãŸãƒ‘イプラインã®çµ‚了ステータス㌠and/or リストã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .sp 構文上ã€and/or リストã®ç›´å¾Œã«ã¯åŽŸå‰‡ã¨ã—ã¦è¨˜å· \fB;\fR ã¾ãŸã¯ \fB&\fR ãŒå¿…è¦ã§ã™ (コマンドã®åŒºåˆ‡ã‚Šã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰å‚ç…§)。 .SS "コマンドã®åŒºåˆ‡ã‚Šã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰" .sp シェルãŒå—ã‘å–るコマンドã®å…¨ä½“ã¯ã€and/or リストを \fB;\fR ã¾ãŸã¯ \fB&\fR ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚行末〠\fB;;\fR ã¾ãŸã¯ \fB)\fR ã®ç›´å‰ã«ã‚ã‚‹ \fB;\fR ã¯çœç•¥ã§ãã¾ã™ãŒã€ãれ以外ã®å ´åˆã¯ and/or リストã®ç›´å¾Œã«ã¯å¿…ãš \fB;\fR 㨠\fB&\fR ã®ã©ã¡ã‚‰ã‹ãŒå¿…è¦ã§ã™ã€‚ .sp And/or リストã®ç›´å¾Œã« \fB;\fR ãŒã‚ã‚‹å ´åˆã¯ã€ãã® and/or リストã¯åŒæœŸçš„ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã® and/or リストã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã«æ¬¡ã® and/or リストãŒå®Ÿè¡Œã•れã¾ã™ã€‚And/or リストã®ç›´å¾Œã« \fB&\fR ãŒã‚ã‚‹å ´åˆã¯ã€ãã® and/or リストã¯éžåŒæœŸçš„ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã® and/or リストã®å®Ÿè¡Œã‚’é–‹å§‹ã—ãŸå¾Œã€çµ‚了を待ãŸãšã«ã€ã™ãã•ã¾æ¬¡ã® and/or リストã®å®Ÿè¡Œã«ç§»ã‚Šã¾ã™ã€‚éžåŒæœŸãª and/or リストã¯å¸¸ã«ã‚µãƒ–シェルã§å®Ÿè¡Œã•れã¾ã™ã€‚ã¾ãŸçµ‚了ステータスã¯å¸¸ã« 0 ã§ã™ã€‚ .sp ジョブ制御を行ã£ã¦ã„ãªã„シェルã«ãŠã‘ã‚‹éžåŒæœŸãª and/or リストã§ã¯ã€æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れるã¨ã¨ã‚‚ã«ã€SIGINT 㨠SIGQUIT ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作㌠『無視〠ã«è¨­å®šã•れã“れらã®ã‚·ã‚°ãƒŠãƒ«ã‚’å—ã‘ã¦ã‚‚プログラムãŒçµ‚了ã—ãªã„よã†ã«ã—ã¾ã™ã€‚(POSIX 準拠モードã§ã¯ã€æ¨™æº–入力を /dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã™ã‚‹ã®ã¯ã‚¸ãƒ§ãƒ–制御を行ã£ã¦ã„ãªã„シェルã§ã¯ãªã対話モードã®ã‚·ã‚§ãƒ«ã§ã™ã€‚ã¾ãŸ POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ–制御を行ã£ã¦ã„ã¦ã‚‚ SIGINT 㨠SIGQUIT ㌠『無視〠ã«è¨­å®šã•れã¾ã™) .sp ジョブ制御を行ã£ã¦ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ãã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID を記憶ã—ã¾ã™ã€‚特殊パラメータ \fB!\fR ã‚’å‚ç…§ã™ã‚‹ã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID を知るã“ã¨ãŒã§ãã¾ã™ã€‚éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çŠ¶æ…‹ã‚„çµ‚äº†ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ã¯ jobs ã‚„ wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .SS "複åˆã‚³ãƒžãƒ³ãƒ‰" .sp 複åˆã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚ˆã‚Šè¤‡é›‘ãªãƒ—ログラムã®åˆ¶å¾¡ã‚’è¡Œã†æ‰‹æ®µã‚’æä¾›ã—ã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBグルーピング\fR .RS 4 .sp グルーピングを使ã†ã¨ã€è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãã¾ã™ã€‚ .PP 通常ã®ã‚°ãƒ«ãƒ¼ãƒ”ãƒ³ã‚°ã®æ§‹æ–‡ .RS 4 \fB{ \fR\fB\fIコマンド\fR\fR\fB\&...; }\fR .RE .PP サブシェルã®ã‚°ãƒ«ãƒ¼ãƒ”ãƒ³ã‚°ã®æ§‹æ–‡ .RS 4 \fB(\fR\fB\fIコマンド\fR\fR\fB\&...)\fR .RE .sp \fB{\fR 㨠\fB}\fR ã¯äºˆç´„語ãªã®ã§ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‘ã¦æ›¸ã„ã¦ã¯ã„ã‘ã¾ã›ã‚“。一方 \fB(\fR 㨠\fB)\fR ã¯ç‰¹æ®ŠãªåŒºåˆ‡ã‚Šè¨˜å·ã¨è¦‹ãªã•れるã®ã§ã€ä»–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‘ã¦æ›¸ãã“ã¨ãŒã§ãã¾ã™ã€‚ .sp 通常ã®ã‚°ãƒ«ãƒ¼ãƒ”ング構文 (\fB{\fR 㨠\fB}\fR ã§å›²ã‚€) ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ (ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«) ç¾åœ¨ã®ã‚·ã‚§ãƒ«ã§å®Ÿè¡Œã•れã¾ã™ã€‚サブシェルã®ã‚°ãƒ«ãƒ¼ãƒ”ング構文 (\fB(\fR 㨠\fB)\fR ã§å›²ã‚€) ã§ã¯ã€æ‹¬å¼§å†…ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–°ãŸãª\:サブシェルã§å®Ÿè¡Œã•れã¾ã™ã€‚ .sp POSIX 準拠モードã§ã¯æ‹¬å¼§å†…ã«å°‘ãªãã¨ã‚‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãŒå¿…è¦ã§ã™ãŒã€éž POSIX 準拠モードã§ã¯ã‚³ãƒžãƒ³ãƒ‰ã¯ä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 .sp グルーピングã®çµ‚了ステータスã¯ã€ã‚°ãƒ«ãƒ¼ãƒ”ングã®ä¸­ã§å®Ÿè¡Œã•ã‚ŒãŸæœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚グルーピング内ã«ã‚³ãƒžãƒ³ãƒ‰ãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã‚°ãƒ«ãƒ¼ãƒ”ングã®çµ‚了ステータスã¯ã‚°ãƒ«ãƒ¼ãƒ”ングã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBIf æ–‡\fR .RS 4 .sp If æ–‡ã¯æ¡ä»¶åˆ†å²ã‚’行ã„ã¾ã™ã€‚分å²ã®è¤‡é›‘ã•ã«å¿œã˜ã¦ã„ãã¤ã‹æ§‹æ–‡ã®ãƒãƒªã‚¨ãƒ¼ã‚·ãƒ§ãƒ³ãŒã‚りã¾ã™ã€‚ .PP If æ–‡ã®åŸºæœ¬æ§‹æ–‡ .RS 4 \fBif \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; then \fR\fB\fI内容コマンド\fR\fR\fB\&...; fi\fR .RE .PP Else ãŒã‚ã‚‹å ´åˆ .RS 4 \fBif \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; then \fR\fB\fI内容コマンド\fR\fR\fB\&...; else \fR\fB\fI内容コマンド\fR\fR\fB\&...; fi\fR .RE .PP Elif ãŒã‚ã‚‹å ´åˆ .RS 4 \fBif \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; then \fR\fB\fI内容コマンド\fR\fR\fB\&...; elif \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; then \fR\fB\fI内容コマンド\fR\fR\fB\&...; fi\fR .RE .PP Elif 㨠else ãŒã‚ã‚‹å ´åˆ .RS 4 \fBif \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; then \fR\fB\fI内容コマンド\fR\fR\fB\&...; elif \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; then \fR\fB\fI内容コマンド\fR\fR\fB\&...; else \fR\fB\fI内容コマンド\fR\fR\fB\&...; fi\fR .RE .sp If æ–‡ã®å®Ÿè¡Œã§ã¯ã€ã©ã®æ§‹æ–‡ã®å ´åˆã§ã‚‚ã€\fBif\fR ã®ç›´å¾Œã«ã‚ã‚‹\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fRãŒã¾ãšå®Ÿè¡Œã•れã¾ã™ã€‚æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ãªã‚‰ã°ã€æ¡ä»¶ãŒçœŸã§ã‚ã‚‹ã¨è¦‹ãªã•れ㦠\fBthen\fR ã®ç›´å¾Œã«ã‚ã‚‹\fI内容コマンド\fRãŒå®Ÿè¡Œã•れã€if æ–‡ã®å®Ÿè¡Œã¯ãれã§çµ‚了ã—ã¾ã™ã€‚終了ステータス㌠0 ã§ãªã‘れã°ã€æ¡ä»¶ãŒå½ã§ã‚ã‚‹ã¨è¦‹ãªã•れã¾ã™ã€‚ã“ã“ã§ \fBelse\fR ã‚‚ \fBelif\fR ã‚‚ãªã‘れã°ã€if æ–‡ã®å®Ÿè¡Œã¯ã“れã§çµ‚ã‚りã§ã™ã€‚\fBelse\fR ãŒã‚ã‚‹å ´åˆã¯ã€\fBelse\fR ã®ç›´å¾Œã®\fI内容コマンド\fRãŒå®Ÿè¡Œã•れã¾ã™ã€‚\fBelif\fR ãŒã‚ã‚‹å ´åˆã¯ã€\fBelif\fR ã®ç›´å¾Œã®\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fRãŒå®Ÿè¡Œã•れã€ãã®çµ‚了ステータス㌠0 ã§ã‚ã‚‹ã‹ã©ã†ã‹åˆ¤å®šã•れã¾ã™ã€‚ãã®å¾Œã¯å…ˆç¨‹ã¨åŒæ§˜ã«æ¡ä»¶åˆ†å²ã‚’行ã„ã¾ã™ã€‚ .sp \fBelif \&...; then \&...;\fR ã¯ä¸€ã¤ã® if 文内ã«è¤‡æ•°ã‚ã£ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 .sp If 文全体ã®çµ‚了ステータスã¯ã€å®Ÿè¡Œã•れãŸå†…容コマンドã®çµ‚了ステータスã§ã™ã€‚内容コマンドãŒå®Ÿè¡Œã•れãªã‹ã£ãŸå ´åˆ (ã©ã®æ¡ä»¶ã‚‚å½ã§ã€\fBelse\fR ãŒãªã„å ´åˆ) 㯠0 ã§ã™ã€‚ .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBWhile ãŠã‚ˆã³ until ループ\fR .RS 4 .sp While ループ㨠until ループã¯å˜ç´”ãªãƒ«ãƒ¼ãƒ—æ§‹æ–‡ã§ã™ã€‚ .PP While ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡ .RS 4 \fBwhile \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; do \fR\fB\fI内容コマンド\fR\fR\fB\&...; done\fR .RE .PP Until ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡ .RS 4 \fBuntil \fR\fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...; do \fR\fB\fI内容コマンド\fR\fR\fB\&...; done\fR .RE .sp éž POSIX 準拠モードã§ã¯ \fB\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fR\fR\fB\&...;\fR ãŠã‚ˆã³ \fB\fI内容コマンド\fR\fR\fB\&...;\fR ã¯çœç•¥å¯èƒ½ã§ã™ã€‚ .sp While ループã®å®Ÿè¡Œã§ã¯ã¾ãš\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fRãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ãªã‚‰ã°ã€\fI内容コマンド\fRãŒå®Ÿè¡Œã•れãŸã®ã¡ã€å†ã³\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fRã®å®Ÿè¡Œã«æˆ»ã‚Šã¾ã™ã€‚ã“ã®ç¹°ã‚Šè¿”ã—ã¯\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fRã®çµ‚了ステータス㌠0 ã§ãªããªã‚‹ã¾ã§ç¶šãã¾ã™ã€‚ .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB注記\fR .ps -1 .br .sp \fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fRã®çµ‚äº†ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ãŒæœ€åˆã‹ã‚‰ 0 ã§ãªã„ã¨ãã¯ã€\fI内容コマンド\fRã¯ä¸€åº¦ã‚‚実行ã•れã¾ã›ã‚“。 .sp .5v .RE .sp Until ループã¯ã€ãƒ«ãƒ¼ãƒ—を続行ã™ã‚‹æ¡ä»¶ãŒé€†ã«ãªã£ã¦ã„る以外㯠while ループã¨åŒã˜ã§ã™ã€‚ã™ãªã‚ã¡ã€\fIæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰\fRã®çµ‚了ステータス㌠0 ã§ãªã‘れã°\fI内容コマンド\fRãŒå®Ÿè¡Œã•れã¾ã™ã€‚ .sp While/until ループ全体ã®çµ‚了ステータスã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸ\fI内容コマンド\fRã®çµ‚了ステータスã§ã™ã€‚(\fI内容コマンド\fRãŒå­˜åœ¨ã—ãªã„ã‹ã€ä¸€åº¦ã‚‚実行ã•れãªã‹ã£ãŸã¨ã㯠0) .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBFor ループ\fR .RS 4 .sp For ãƒ«ãƒ¼ãƒ—ã¯æŒ‡å®šã•れãŸãれãžã‚Œã®å˜èªžã«ã¤ã„ã¦åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ .PP For ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡ .RS 4 \fBfor \fR\fB\fI変数å\fR\fR\fB in \fR\fB\fIå˜èªž\fR\fR\fB\&...; do \fR\fB\fIコマンド\fR\fR\fB\&...; done\fR\fBfor \fR\fB\fI変数å\fR\fR\fB do \fR\fB\fIコマンド\fR\fR\fB\&...; done\fR .RE .sp \fBin\fR ã®ç›´å¾Œã®\fIå˜èªž\fRã¯ä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“ãŒã€\fBdo\fR ã®ç›´å‰ã® \fB;\fR (ã¾ãŸã¯æ”¹è¡Œ) ã¯å¿…è¦ã§ã™ã€‚ã“れらã®å˜èªžãƒˆãƒ¼ã‚¯ãƒ³ã¯äºˆç´„語ã¨ã—ã¦ã¯èªè­˜ã•れã¾ã›ã‚“ãŒã€\fB&\fR ãªã©ã®è¨˜å·ã‚’å«ã‚ã‚‹ã«ã¯é©åˆ‡ãªã‚¯ã‚©ãƒ¼ãƒˆãŒå¿…è¦ã§ã™ã€‚\fBin \&...;\fR ã‚’çœç•¥ã™ã‚‹å ´åˆã¯ã€æœ¬æ¥ã¯å¤‰æ•°å㨠\fBdo\fR ã®é–“ã« \fB;\fR を入れã¦ã¯ã„ã‘ã¾ã›ã‚“ãŒã€éž POSIX 準拠モードã§ã¯ \fB;\fR ãŒã‚ã£ã¦ã‚‚許容ã•れã¾ã™ã€‚ã¾ãŸéž POSIX 準拠モードã§ã¯ \fB\fIコマンド\fR\fR\fB\&...;\fR ãŒãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 .sp For ループã®å®Ÿè¡Œã§ã¯ã¾ãš\fIå˜èªž\fRãŒå˜ç´”コマンド実行時ã®å˜èªžã®å±•é–‹ã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ (\fBin \&...;\fR ãŒãªã„構文を使用ã—ã¦ã„ã‚‹å ´åˆã¯ã€\fBin "$@";\fR ãŒçœç•¥ã•れã¦ã„ã‚‹ã‚‚ã®ã¨è¦‹ãªã•れã¾ã™)。続ã„ã¦ã€å±•é–‹ã§ç”Ÿæˆã•れãŸãれãžã‚Œã®å˜èªžã«ã¤ã„ã¦é †ç•ªã«ä¸€åº¦ãšã¤ä»¥ä¸‹ã®å‡¦ç†ã‚’行ã„ã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} å˜èªžã‚’\fI変数å\fRã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ä»£å…¥ã™ã‚‹ .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} \fIコマンド\fRを実行ã™ã‚‹ .RE .sp å˜èªžã¯ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¨ã—ã¦ä»£å…¥ã•れã¾ã™ (POSIX 準拠モードã®ã¨ãを除ã)。展開ã®çµæžœå˜èªžãŒä¸€ã¤ã‚‚生æˆã•れãªã‹ã£ãŸå ´åˆã¯ã€\fIコマンド\fRã¯ä¸€åˆ‡å®Ÿè¡Œã•れã¾ã›ã‚“。 .sp For ループ全体ã®çµ‚了ステータスã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸ\fIコマンド\fRã®çµ‚了ステータスã§ã™ã€‚\fIコマンド\fRãŒã‚ã‚‹ã®ã«ä¸€åº¦ã‚‚実行ã•れãªã‹ã£ãŸã¨ã㯠0 ã§ã™ã€‚\fIコマンド\fRãŒãªã„å ´åˆã€for ループã®çµ‚了ステータス㯠for ループã®ä¸€ã¤å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBCase æ–‡\fR .RS 4 .sp Case æ–‡ã¯å˜èªžã«å¯¾ã—ã¦ãƒ‘ターンマッãƒãƒ³ã‚°ã‚’行ã„ã€ãã®çµæžœã«å¯¾å¿œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ .PP Case æ–‡ã®æ§‹æ–‡ .RS 4 \fBcase \fR\fB\fIå˜èªž\fR\fR\fB in \fR\fB\fIcaseitem\fR\fR\fB\&... esac\fR .RE .PP Caseitem ã®æ§‹æ–‡ .RS 4 \fB(\fR\fB\fIパターン\fR\fR\fB) \fR\fB\fIコマンド\fR\fR\fB\&...;;\fR .RE .sp \fBcase\fR 㨠\fBin\fR ã®é–“ã®å˜èªžã¯ã¡ã‚‡ã†ã©ä¸€ãƒˆãƒ¼ã‚¯ãƒ³ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®å˜èªžãƒˆãƒ¼ã‚¯ãƒ³ã¯äºˆç´„語ã¨ã—ã¦ã¯èªè­˜ã•れã¾ã›ã‚“ãŒã€\fB&\fR ãªã©ã®è¨˜å·ã‚’å«ã‚ã‚‹ã«ã¯é©åˆ‡ãªã‚¯ã‚©ãƒ¼ãƒˆãŒå¿…è¦ã§ã™ã€‚\fBin\fR 㨠\fBesac\fR ã®é–“ã«ã¯ä»»æ„ã®å€‹æ•°ã® caseitem ã‚’ç½®ãã¾ã™ (0 個ã§ã‚‚よã„)。Caseitem ã®æœ€åˆã® \fB(\fR 㨠\fBesac\fR ã®ç›´å‰ã® \fB;;\fR ã¯çœç•¥ã§ãã¾ã™ã€‚ã¾ãŸ\fIコマンド\fR㌠\fB;\fR ã§çµ‚ã‚ã‚‹å ´åˆã¯ãã® \fB;\fR ã‚‚çœç•¥ã§ãã¾ã™ã€‚Caseitem ã® \fB)\fR 㨠\fB;;\fR ã¨ã®é–“ã«\fIコマンド\fRãŒä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 .sp Caseitem ã®\fIパターン\fRã«ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã‚’指定ã—ã¾ã™ã€‚å„トークンを \fB|\fR ã§åŒºåˆ‡ã‚‹ã“ã¨ã§è¤‡æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’パターンã¨ã—ã¦æŒ‡å®šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .sp Case æ–‡ã®å®Ÿè¡Œã§ã¯ã€ã¾ãš\fIå˜èªž\fRãŒå››ç¨®å±•é–‹ã•れã¾ã™ã€‚ãã®å¾Œã€å„ caseitem ã«å¯¾ã—ã¦é †ã«ä»¥ä¸‹ã®å‹•作を行ã„ã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} \fIパターン\fRトークンを\fIå˜èªž\fRã¨åŒæ§˜ã«å±•é–‹ã—ã€å±•é–‹ã—ãŸãƒ‘ターンãŒå±•é–‹ã—ãŸå˜èªžã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ (パターンマッãƒãƒ³ã‚°è¨˜æ³•å‚ç…§)。\fIパターン\fRã¨ã—ã¦æŒ‡å®šã•れãŸãƒˆãƒ¼ã‚¯ãƒ³ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãれらå„トークンã«å¯¾ã—ã¦ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ (ã©ã‚Œã‹ã®ãƒ‘ターントークンãŒãƒžãƒƒãƒã—ãŸã‚‰ãれ以é™ã®ãƒ‘ターントークンã¯å±•é–‹ã•れã¾ã›ã‚“。Yash ã¯ãƒˆãƒ¼ã‚¯ãƒ³ãŒæ›¸ã‹ã‚Œã¦ã„る順番ã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹ã‚’調ã¹ã¾ã™ãŒã€ä»–ã®ã‚·ã‚§ãƒ«ã‚‚ã“ã®é †åºã§èª¿ã¹ã‚‹ã¨ã¯é™ã‚Šã¾ã›ã‚“)。 .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} マッãƒã—ãŸå ´åˆã¯ã€ç›´å¾Œã®\fIコマンド\fRを実行ã—ã€ãれã§ã“ã® case æ–‡ã®å®Ÿè¡Œã¯çµ‚了ã§ã™ã€‚マッãƒã—ãªã‹ã£ãŸå ´åˆã¯ã€æ¬¡ã® caseitem ã®å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ .RE .sp Case 文全体ã®çµ‚了ステータスã¯ã€å®Ÿè¡Œã—ãŸ\fIコマンド\fRã®çµ‚了ステータスã§ã™ã€‚\fIコマンド\fRãŒå®Ÿè¡Œã•れãªã‹ã£ãŸå ´åˆ (ã©ã®ãƒ‘ターンもマッãƒã—ãªã‹ã£ãŸã‹ã€caseitem ãŒä¸€ã¤ã‚‚ãªã„ã‹ã€ãƒžãƒƒãƒã—ãŸãƒ‘ターンã®å¾Œã«ã‚³ãƒžãƒ³ãƒ‰ãŒãªã„å ´åˆ) ã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚ .sp POSIX 準拠モードã§ã¯ã€(\fB|\fR ã§åŒºåˆ‡ã‚‰ã‚ŒãŸæœ€åˆã®) \fIパターン\fRトークンを \fBesac\fR ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .SS "関数定義" .sp 関数定義コマンドã¯ã€é–¢æ•°ã‚’定義ã—ã¾ã™ã€‚ .PP é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã®æ§‹æ–‡ .RS 4 \fB\fI関数å\fR\fR\fB ( ) \fR\fB\fI複åˆã‚³ãƒžãƒ³ãƒ‰\fR\fR\fBfunction \fR\fB\fI関数å\fR\fR\fB \fR\fB\fI複åˆã‚³ãƒžãƒ³ãƒ‰\fR\fR\fBfunction \fR\fB\fI関数å\fR\fR\fB ( ) \fR\fB\fI複åˆã‚³ãƒžãƒ³ãƒ‰\fR\fR .RE .sp 予約語 \fBfunction\fR を用ã„ãªã„一ã¤ç›®ã®å½¢å¼ã§ã¯ã€\fI関数å\fRã«ã¯å¼•用符ãªã©ã®ç‰¹æ®Šãªè¨˜å·ã‚’å«ã‚ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。予約語 \fBfunction\fR を用ã„る二ã¤ç›®ã¾ãŸã¯ä¸‰ã¤ç›®ã®å½¢å¼ã§ã¯ã€\fI関数å\fRã¯å®Ÿè¡Œæ™‚ã«å››ç¨®å±•é–‹ã•れã¾ã™ã€‚(POSIX 準拠モードã§ã¯äºˆç´„語 \fBfunction\fR を用ã„ã‚‹å½¢å¼ã®é–¢æ•°å®šç¾©ã¯ä½¿ãˆã¾ã›ã‚“。) .sp 関数定義コマンドを実行ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ\fI関数å\fRã®é–¢æ•°ãŒ\fI複åˆã‚³ãƒžãƒ³ãƒ‰\fRを内容ã¨ã—ã¦å®šç¾©ã•れã¾ã™ã€‚ .sp 関数定義コマンドã«å¯¾ã—ã¦ç›´æŽ¥ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚’行ã†ã“ã¨ã¯ã§ãã¾ã›ã‚“ã€‚é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã®æœ€å¾Œã«ã‚るリダイレクトã¯ã€é–¢æ•°ã®å†…容ã§ã‚ã‚‹\fI複åˆã‚³ãƒžãƒ³ãƒ‰\fRã«å¯¾ã™ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¨è¦‹ãªã•れã¾ã™ã€‚例ãˆã° \fBfunc() { cat; } >/dev/null\fR ã¨æ›¸ã„ãŸå ´åˆã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れるã®ã¯ \fBfunc() { cat; }\fR ã§ã¯ãªã \fB{ cat; }\fR ã§ã™ã€‚ .sp 関数定義コマンドã®çµ‚了ステータスã¯ã€é–¢æ•°ãŒæ­£ã—ã定義ã•れãŸå ´åˆã¯ 0ã€ãã†ã§ãªã‘れã°éž 0 ã§ã™ã€‚ .SH "パラメータã¨å¤‰æ•°" .sp \fIパラメータ\fRã¨ã¯ã€ãƒ‘ラメータ展開ã§å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã‚‹ãƒ‡ãƒ¼ã‚¿ã‚’言ã„ã¾ã™ã€‚パラメータã«ã¯ä½ç½®ãƒ‘ラメータ・特殊パラメータ・変数ã®ä¸‰ç¨®é¡žãŒã‚りã¾ã™ã€‚ .SS "ä½ç½®ãƒ‘ラメータ" .sp \fIä½ç½®ãƒ‘ラメータ\fR㯠1 以上ã®è‡ªç„¶æ•°ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるパラメータã§ã™ã€‚例ãˆã°ä½ç½®ãƒ‘ラメータãŒä¸‰ã¤ã‚ã‚‹å ´åˆã€ãれらã¯é †ã« \fB1\fR, \fB2\fR, \fB3\fR ã¨ã„ã†åç§°ã§è­˜åˆ¥ã•れã¾ã™ã€‚ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã¯ç‰¹æ®Šãƒ‘ラメータ \fB#\fR ã§å–å¾—ã§ãã¾ã™ã€‚ã¾ãŸå…¨ã¦ã®ä½ç½®ãƒ‘ラメータを表ã™ç‰¹æ®Šãƒ‘ラメータã¨ã—㦠\fB*\fR 㨠\fB@\fR ãŒã‚りã¾ã™ã€‚ .sp ä½ç½®ãƒ‘ラメータã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã€ã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã‚’å…ƒã«åˆæœŸåŒ–ã•れã¾ã™ (起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°å‚ç…§)。引数ã®ã†ã¡ã€ä½ç½®ãƒ‘ラメータã®å€¤ã¨ã—ã¦ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒé †ã«ä¸€ã¤ãšã¤ä½ç½®ãƒ‘ラメータã¨ãªã‚Šã¾ã™ã€‚ .sp シェルã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œä¸­ã«é–¢æ•°ãŒå‘¼ã³å‡ºã•れるã¨ãã€ä½ç½®ãƒ‘ラメータã¯ãã®é–¢æ•°ã®å‘¼ã³å‡ºã—ã«å¯¾ã™ã‚‹å¼•æ•°ã«å¤‰æ›´ã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€é–¢æ•°ã®å®Ÿè¡Œä¸­ã¯ä½ç½®ãƒ‘ラメータã«ã‚ˆã£ã¦é–¢æ•°ã®å¼•æ•°ã‚’å‚ç…§ã§ãã¾ã™ã€‚関数呼ã³å‡ºã—ã®ç›´å‰ã®ä½ç½®ãƒ‘ラメータã®å€¤ã¯ä¿å­˜ã•れã¦ãŠã‚Šã€é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹éš›ã«å…ƒã®å€¤ã«æˆ»ã‚Šã¾ã™ã€‚ .sp ä½ç½®ãƒ‘ラメータã¯ã€set ã‚„ shift ãªã©ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ã‚ˆã£ã¦å¤‰æ›´ã§ãã¾ã™ã€‚ .sp \fB0\fR ã¯ä½ç½®ãƒ‘ラメータã¨ã¯è¦‹ãªã•れã¾ã›ã‚“ (特殊パラメータã®ä¸€ã¤ã§ã™)。 .SS "特殊パラメータ" .sp \fI特殊パラメータ\fRã¯ä¸€æ–‡å­—ã®è¨˜å·ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるパラメータã§ã™ã€‚特殊パラメータã«ã¯ãƒ¦ãƒ¼ã‚¶ãŒæ˜Žç¤ºçš„ã«å€¤ã‚’代入ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .sp Yash ã§ã¯ä»¥ä¸‹ã®ç‰¹æ®Šãƒ‘ラメータãŒåˆ©ç”¨å¯èƒ½ã§ã™ã€‚ .PP \fB0\fR .RS 4 ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ä¸Žãˆã‚‰ã‚ŒãŸã‚·ã‚§ãƒ«ã®å®Ÿè¡Œãƒ•ァイルã®åç§°ã¾ãŸã¯ã‚¹ã‚¯ãƒªãƒ—トファイルã®åç§°ã§ã™ã€‚(起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°å‚ç…§) .RE .PP \fB#\fR .RS 4 ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã®ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’表㙠0 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚ .RE .PP \fB$\fR .RS 4 ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ã‚·ã‚§ãƒ«è‡ªèº«ã®ãƒ—ロセス ID ã‚’è¡¨ã™æ­£ã®æ•´æ•°ã§ã™ã€‚ã“ã®å€¤ã¯ã‚µãƒ–シェルã«ãŠã„ã¦ã‚‚変ã‚りã¾ã›ã‚“。 .RE .PP \fB\-\fR .RS 4 ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã‚·ã‚§ãƒ«ã§æœ‰åŠŸã«ãªã£ã¦ã„ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—ã‚’ã¤ãªã’ãŸã‚‚ã®ã§ã™ã€‚ã“ã®å€¤ã«ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§æŒ‡å®šã§ãる一文字ã®ã‚ªãƒ—ションã®ã†ã¡ç¾åœ¨æœ‰åйã«ãªã£ã¦ã„ã‚‹ã‚‚ã®ãŒå…¨ã¦å«ã¾ã‚Œã¾ã™ã€‚set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ªãƒ—ションを変更ã—ãŸå ´åˆã¯ã€ãã®å¤‰æ›´ãŒã“ã®ãƒ‘ラメータã®å€¤ã«ã‚‚åæ˜ ã•れã¾ã™ã€‚ .RE .PP \fB?\fR .RS 4 ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€æœ€å¾Œã«çµ‚了ã—ãŸãƒ‘イプラインã®çµ‚了ステータスを表㙠0 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚ .RE .PP \fB!\fR .RS 4 ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã§ã™ã€‚ .RE .PP \fB*\fR .RS 4 ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã®ä½ç½®ãƒ‘ラメータã®å€¤ã§ã™ã€‚ä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã“ã®ãƒ‘ラメータã®å€¤ã¯ç©ºæ–‡å­—列ã§ã™ã€‚ä½ç½®ãƒ‘ラメータãŒè¤‡æ•°ã‚ã‚‹å ´åˆã€ã“ã®ãƒ‘ラメータã®å€¤ã¯å…¨ã¦ã®ä½ç½®ãƒ‘ラメータã®å€¤ã‚’連çµã—ãŸã‚‚ã®ã§ã™ã€‚å„ä½ç½®ãƒ‘ラメータã®å€¤ã®é–“ã¯ä»¥ä¸‹ã«å¾“ã£ã¦åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 変数 \fBIFS\fR ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºã§ãªã„å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯å¤‰æ•° \fBIFS\fR ã®å€¤ã®æœ€åˆã®æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 変数 \fBIFS\fR ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºã®å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯é–“ã«ä½•ã‚‚ç½®ã‹ãšã«é€£çµã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 変数 \fBIFS\fR ãŒå­˜åœ¨ã—ãªã„å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯ç©ºç™½æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ .RE .RE .PP \fB@\fR .RS 4 ã“ã®ãƒ‘ラメータã¯ã€ãƒ‘ラメータ \fB*\fR ã¨åŒæ§˜ã«ç¾åœ¨ã®å…¨ã¦ã®ä½ç½®ãƒ‘ラメータを表ã—ã¾ã™ã€‚ãŸã ã—ã€ã“ã®ãƒ‘ラメータãŒäºŒé‡å¼•用符ã«ã‚ˆã‚‹ã‚¯ã‚©ãƒ¼ãƒˆã®ä¸­ã§å±•é–‹ã•れる場åˆã®æ‰±ã„ãŒãƒ‘ラメータ \fB*\fR ã¨ç•°ãªã‚Šã¾ã™ã€‚ã“ã®å ´åˆã€å„ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã¯æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã‚‹ã®ã§ã¯ãªãã€(クォートã®å†…部ã§ã‚ã‚‹ã«ã‚‚ã‹ã‹ã‚らãš) å˜èªžåˆ†å‰²ã•れã¾ã™ã€‚ã¾ãŸä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã“ã®ãƒ‘ラメータã¯å±•開後ã®å˜èªžã«ã¯æ®‹ã‚Šã¾ã›ã‚“。 .sp 例ãˆã°ä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ \fBecho 1 "$@" 2\fR 㯠\fBecho\fRã€\fB1\fRã€\fB2\fR ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚ä½ç½®ãƒ‘ラメータ㌠\fB1\fRã€\fB2 2\fRã€\fB3\fR ã®ä¸‰ã¤ã®ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ \fBecho "$@"\fR 㯠\fBecho\fRã€\fB1\fRã€\fB2 2\fRã€\fB3\fR ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ \fBecho "a$@b"\fR 㯠\fBecho\fRã€\fBa1\fRã€\fB2 2\fRã€\fB3b\fR ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚ .RE .SS "変数" .sp \fI変数\fRã¨ã¯ãƒ¦ãƒ¼ã‚¶ãŒè‡ªç”±ã«ä»£å…¥å¯èƒ½ãªãƒ‘ラメータã§ã™ã€‚å„変数ã¯åå‰ã§åŒºåˆ¥ã•れã€ãれãžã‚ŒãŒæ–‡å­—列ã®å€¤ã‚’æŒã¡ã¾ã™ã€‚ .sp 変数ã®åå‰ã¯ã€è‹±æ•°å­—ã¨ä¸‹ç·š (\fB_\fR) ã‹ã‚‰æ§‹æˆã•れã¾ã™ã€‚ãŸã ã—変数åã®é ­æ–‡å­—ã‚’æ•°å­—ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。環境ã«ã‚ˆã£ã¦ã¯ã“ã‚Œä»¥å¤–ã®æ–‡å­—も変数åã«ä½¿ç”¨ã§ãã¾ã™ã€‚ .sp ã‚·ã‚§ãƒ«ãŒæ‰±ã†å¤‰æ•°ã®ã†ã¡ã€ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã®å¯¾è±¡ã¨ãªã£ã¦ã„ã‚‹ã‚‚ã®ã¯\fI環境変数\fRã¨ã„ã„ã¾ã™ã€‚ã“れらã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ãŒå¤–部コマンドを起動ã™ã‚‹éš›ã«å¤–éƒ¨ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚シェルãŒèµ·å‹•ã•れãŸã¨ãã«ã‚·ã‚§ãƒ«ã‚’èµ·å‹•ã—ãŸãƒ—ログラムã‹ã‚‰æ¸¡ã•れãŸå¤‰æ•°ã¯è‡ªå‹•çš„ã«ç’°å¢ƒå¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚ .sp 変数ã¯ã€å˜ç´”コマンドã«ã‚ˆã£ã¦ä»£å…¥ã§ãã¾ã™ã€‚ã¾ãŸ typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ã‚‚変数ã«ä»£å…¥ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚変数を削除ã™ã‚‹ã«ã¯ unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã„ã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBシェルãŒä½¿ç”¨ã™ã‚‹å¤‰æ•°\fR .RS 4 .sp 以下ã®åå‰ã®å¤‰æ•°ã¯ã€yash ã®å®Ÿè¡Œã«ãŠã„ã¦ç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚ .PP \fBCDPATH\fR .RS 4 ã“ã®å¤‰æ•°ã¯ cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç§»å‹•先ディレクトリを検索ã™ã‚‹ãŸã‚ã«ä½¿ã‚れã¾ã™ã€‚ .RE .PP \fBCOLUMNS\fR .RS 4 ã“ã®å¤‰æ•°ã¯ç«¯æœ«ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®æ¨ªå¹… (文字数) を指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã€ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã®æ¨ªå¹…ã§ã¯ãªãã“ã®å¤‰æ•°ã®å€¤ã§æŒ‡å®šã•ã‚ŒãŸæ¨ªå¹…ãŒè¡Œç·¨é›†ã§ä½¿ã‚れã¾ã™ã€‚ .RE .PP \fBCOMMAND_NOT_FOUND_HANDLER\fR .RS 4 シェルãŒå®Ÿè¡Œã—よã†ã¨ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œã•れã¾ã™ã€‚䏿˜Žãªã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ãã«ä½•ã‹åˆ¥ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã•ã›ãŸã„時ã«ä¾¿åˆ©ã§ã™ã€‚å˜ç´”コマンドã®å®Ÿè¡Œã‚’å‚照。 .sp ã“ã®æ©Ÿèƒ½ã¯ POSIX 準拠モードã§ã¯åƒãã¾ã›ã‚“。 .RE .PP \fBDIRSTACK\fR .RS 4 ã“ã®é…列変数ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å®Ÿè£…ã«ä½¿ã‚れã¦ã„ã¾ã™ã€‚pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’移動ã—ãŸã¨ãã€å‰ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’覚ãˆã¦ãŠããŸã‚ã«ãã®ãƒ‘スåãŒã“ã®é…列ã«å…¥ã‚Œã‚‰ã‚Œã¾ã™ã€‚ã“ã®é…列ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を直接変更ã™ã‚‹ã“ã¨ã«ãªã‚Šã¾ã™ã€‚ .RE .PP \fBECHO_STYLE\fR .RS 4 ã“ã®å¤‰æ•°ã¯ echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®æŒ™å‹•を指定ã—ã¾ã™ã€‚ .RE .PP \fBENV\fR .RS 4 POSIX 準拠モードã§å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ã§ç¤ºã•れるパスã®ãƒ•ァイルãŒåˆæœŸåŒ–スクリプトã¨ã—ã¦èª­ã¿è¾¼ã¾ã‚Œã¾ã™ (シェルã®åˆæœŸåŒ–処ç†å‚ç…§)。 .RE .PP \fBFCEDIT\fR .RS 4 Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã™ã‚‹éš›ã€ã“ã®å¤‰æ•°ã®å€¤ã§ç¤ºã•れãŸã‚¨ãƒ‡ã‚£ã‚¿ãŒã‚³ãƒžãƒ³ãƒ‰ã®ç·¨é›†ã«ä½¿ã‚れã¾ã™ã€‚ .RE .PP \fBHANDLED\fR .RS 4 ã“ã®å¤‰æ•°ã¯ \fBCOMMAND_NOT_FOUND_HANDLER\fR 変数ã®å€¤ãŒå®Ÿè¡Œã•れãŸå¾Œã«ã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã“ã¨ã‚’エラーã¨ã™ã‚‹ã‹ã©ã†ã‹ã‚’指示ã—ã¾ã™ã€‚å˜ç´”コマンドã®å®Ÿè¡Œã‚’å‚照。 .RE .PP \fBHISTFILE\fR .RS 4 コマンド履歴をä¿å­˜ã™ã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚ .RE .PP \fBHISTRMDUP\fR .RS 4 コマンド履歴ã®é‡è¤‡ã‚’ãƒã‚§ãƒƒã‚¯ã™ã‚‹å€‹æ•°ã‚’指定ã—ã¾ã™ã€‚履歴ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’追加ã™ã‚‹éš›ã€æ—¢ã«å±¥æ­´ã«ã‚るコマンドã®ã†ã¡ã“ã“ã§æŒ‡å®šã—ãŸå€‹æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ãŒæ–°ã—ã追加ã•れるコマンドã¨åŒã˜ã‹ã©ã†ã‹ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚åŒã˜ã‚³ãƒžãƒ³ãƒ‰ãŒæ—¢ã«å±¥æ­´ã«ã‚れã°ã€ãれã¯å±¥æ­´ã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚ .sp 例ãˆã°ã“ã®å¤‰æ•°ã®å€¤ãŒ \fB1\fR ã®ã¨ãã¯ã€å±¥æ­´ã«è¿½åŠ ã•れるコマンドãŒä¸€ã¤å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒã˜ãªã‚‰ã°ãれã¯å‰Šé™¤ã•れã¾ã™ã€‚ãれよりå¤ã„履歴ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€(履歴ã«è¿½åŠ ã•れるコマンドã¨åŒã˜ã§ã‚‚) 削除ã•れã¾ã›ã‚“。もã—ã“ã®å¤‰æ•°ã®å€¤ãŒ \fBHISTSIZE\fR 変数ã®å€¤ã¨åŒã˜ãªã‚‰ã€å±¥æ­´ã®ä¸­ã§é‡è¤‡ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã™ã¹ã¦å‰Šé™¤ã•れã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã‚‚ã—ã“ã®å¤‰æ•°ã®å€¤ãŒ \fB0\fR ãªã‚‰ã€é‡è¤‡ã™ã‚‹å±¥æ­´ã¯ä¸€åˆ‡å‰Šé™¤ã•れã¾ã›ã‚“。 .RE .PP \fBHISTSIZE\fR .RS 4 コマンド履歴ã«ä¿å­˜ã•れる履歴項目ã®å€‹æ•°ã‚’指定ã—ã¾ã™ã€‚ .RE .PP \fBHOME\fR .RS 4 ユーザã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを指定ã—ã¾ã™ã€‚ãƒãƒ«ãƒ€å±•é–‹ã‚„ cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚ .RE .PP \fBIFS\fR .RS 4 ã“ã®å¤‰æ•°ã¯å˜èªžåˆ†å‰²ã®åŒºåˆ‡ã‚Šã‚’指定ã—ã¾ã™ã€‚シェルã®èµ·å‹•時ã«ã“ã®å¤‰æ•°ã®å€¤ã¯ç©ºç™½æ–‡å­—・タブ・改行ã®ä¸‰æ–‡å­—ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .RE .PP \fBLANG\fR, \fBLC_ALL\fR, \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_MONETARY\fR, \fBLC_NUMERIC\fR, \fBLC_TIME\fR .RS 4 ã“れらã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ãŒå‹•作ã™ã‚‹ãƒ­ã‚±ãƒ¼ãƒ«ã‚’指定ã—ã¾ã™ã€‚シェルãŒèª­ã¿æ›¸ãã™ã‚‹ãƒ•ァイルã®ã‚¨ãƒ³ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°ã‚„エラーメッセージã®å†…容ãªã©ã¯ã“ã®å¤‰æ•°ã§æŒ‡å®šã•れãŸãƒ­ã‚±ãƒ¼ãƒ«ã«å¾“ã„ã¾ã™ã€‚ .sp \fBLC_CTYPE\fR 変数ã®å€¤ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã®ã¿å映ã•れã¾ã™ã€‚シェルã®å®Ÿè¡Œä¸­ã«ã“ã®å¤‰æ•°ã‚’変更ã—ã¦ã‚‚シェルã®ãƒ­ã‚±ãƒ¼ãƒ«ã¯å¤‰ã‚りã¾ã›ã‚“ (シェルãŒéž POSIX 準拠モードã§å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®å ´åˆã‚’除ã)。 .RE .PP \fBLINENO\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€ç¾åœ¨ã‚·ã‚§ãƒ«ãŒèª­ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¦ã„るファイルã«ãŠã‘ã‚‹ã€ç¾åœ¨å®Ÿè¡Œä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã®ã‚る行番å·ã‚’示ã—ã¾ã™ã€‚(対話モードã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã—ã¦å®Ÿè¡Œã™ã‚‹ãŸã³ã«è¡Œç•ªå·ã¯ 1 ã«æˆ»ã‚Šã¾ã™) .sp 一度ã“ã®å¤‰æ•°ã«ä»£å…¥ã—ãŸã‚Šå¤‰æ•°ã‚’削除ã—ãŸã‚Šã™ã‚‹ã¨ã€ã“ã®å¤‰æ•°ã‚’用ã„ã¦è¡Œç•ªå·ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ .RE .PP \fBLINES\fR .RS 4 ã“ã®å¤‰æ•°ã¯ç«¯æœ«ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®è¡Œæ•°ã‚’指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã€ãƒ‡ãƒ•ォルトã®è¡Œæ•°ã§ã¯ãªãã“ã®å¤‰æ•°ã®å€¤ã§æŒ‡å®šã•れãŸè¡Œæ•°ãŒè¡Œç·¨é›†ã§ä½¿ã‚れã¾ã™ã€‚ .RE .PP \fBMAIL\fR .RS 4 ã“ã®å¤‰æ•°ã¯ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã®å¯¾è±¡ã¨ãªã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚ .RE .PP \fBMAILCHECK\fR .RS 4 ã“ã®å¤‰æ•°ã¯ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã‚’行ã†é–“隔を秒å˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠\fB600\fR ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .RE .PP \fBMAILPATH\fR .RS 4 ã“ã®å¤‰æ•°ã¯ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã®å¯¾è±¡ã¨ãªã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚ .RE .PP \fBNLSPATH\fR .RS 4 POSIX ã«ã‚ˆã‚‹ã¨ã“ã®å¤‰æ•°ã®å€¤ã¯ãƒ­ã‚±ãƒ¼ãƒ«ä¾å­˜ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒ‡ãƒ¼ã‚¿ãƒ•ァイルã®ãƒ‘スを指示ã™ã‚‹ã“ã¨ã«ãªã£ã¦ã„ã¾ã™ãŒã€yash ã§ã¯ä½¿ç”¨ã—ã¦ã„ã¾ã›ã‚“。 .RE .PP \fBOLDPWD\fR .RS 4 Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ãŸã¨ãã«ã€å¤‰æ›´å‰ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ‘スãŒã“ã®å¤‰æ•°ã«è¨­å®šã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ãƒ‡ãƒ•ォルトã§ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚ .RE .PP \fBOPTARG\fR .RS 4 Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¼•数付ãã®ã‚ªãƒ—ションを読ã¿è¾¼ã‚“ã ã¨ãã€ãã®å¼•æ•°ã®å€¤ãŒã“ã®å¤‰æ•°ã«è¨­å®šã•れã¾ã™ã€‚ .RE .PP \fBOPTIND\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§æ¬¡ã«èª­ã¿è¾¼ã‚€ã‚ªãƒ—ションã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’表ã—ã¾ã™ã€‚シェルã®èµ·å‹•時ã«ã“ã®å¤‰æ•°ã¯ \fB1\fR ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .RE .PP \fBPATH\fR .RS 4 ã“ã®å¤‰æ•°ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢æ™‚ã«ã‚³ãƒžãƒ³ãƒ‰ã®ã‚りã‹ã‚’示ã™ãƒ‘スを指定ã—ã¾ã™ã€‚ .RE .PP \fBPPID\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€ã‚·ã‚§ãƒ«ã®è¦ªãƒ—ロセスã®ãƒ—ロセス ID ã‚’è¡¨ã™æ­£ã®æ•´æ•°ã§ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ã‚µãƒ–シェルã«ãŠã„ã¦ã‚‚変ã‚りã¾ã›ã‚“。 .RE .PP \fBPROMPT_COMMAND\fR .RS 4 POSIX 準拠モードã§ãªã„対話モードã®ã‚·ã‚§ãƒ«ã«ãŠã„ã¦ã€ã‚·ã‚§ãƒ«ãŒå„コマンドã®ãƒ—ロンプトを出ã™ç›´å‰ã«ã€ã“ã®å¤‰æ•°ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ã€‚ã“れã¯ã€ãƒ—ロンプトを出ã™ç›´å‰ã«æ¯Žå›ž \fBeval \-i \-\- "${PROMPT_COMMAND\-}"\fR ã¨ã„ã†ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã®ã¨åŒã˜ã§ã™ãŒã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œçµæžœã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã® \fB?\fR 特殊パラメータã®å€¤ã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。 .RE .PP \fBPS1\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‡ºåŠ›ã™ã‚‹æ¨™æº–ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ—ロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 .sp ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠\fB\e$ \fR ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚(POSIX 準拠モード ãªã‚‰å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ㌠0 ã‹ã©ã†ã‹ã«ã‚ˆã£ã¦ \fB$ \fR 㨠\fB# \fR ã®ã©ã¡ã‚‰ã‹) .RE .PP \fBPS1R\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€éš›ã«ã€å…¥åŠ›ã•れるコマンドã®å³å´ã«è¡¨ç¤ºã•れるプロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 .RE .PP \fBPS1S\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€éš›ã«ã€å…¥åŠ›ã•れるコマンドを表示ã™ã‚‹ãƒ•ã‚©ãƒ³ãƒˆã®æ›¸å¼ã‚’指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 .RE .PP \fBPS2\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‡ºåŠ›ã™ã‚‹è£œåŠ©çš„ãªã‚³ãƒžãƒ³ãƒ‰ãƒ—ロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠\fB> \fR ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .RE .PP \fBPS2R\fR .RS 4 ã“ã®å¤‰æ•°ã¯ \fBPS1R\fR 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠\fBPS1\fR 変数ã§ã¯ãªã \fBPS2\fR 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚ .RE .PP \fBPS2S\fR .RS 4 ã“ã®å¤‰æ•°ã¯ \fBPS1S\fR 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠\fBPS1\fR 変数ã§ã¯ãªã \fBPS2\fR 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚ .RE .PP \fBPS4\fR .RS 4 Xtrace ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ãŒå„トレース出力ã®å‰ã«å‡ºåŠ›ã•れã¾ã™ã€‚ãŸã ã—出力ã®å‰ã«ã“ã®å¤‰æ•°ã®å€¤ã«å¯¾ã—ã¦ãƒ‘ラメータ展開ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã€æ•°å¼å±•開を行ã„ã¾ã™ã€‚ã¾ãŸ POSIX 準拠モードã§ãªã‘れã°ã€\fBPS1\fR 変数ã¨åŒæ§˜ã«ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ç‰¹æ®Šãªè¨˜æ³•ãŒåˆ©ç”¨ã§ãã¾ã™ã€‚ .sp ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠\fB+ \fR ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .RE .PP \fBPS4S\fR .RS 4 ã“ã®å¤‰æ•°ã¯ \fBPS1S\fR 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠\fBPS1\fR 変数ãŒä½¿ç”¨ã•れるã¨ãã§ã¯ãªãã€ãƒˆãƒ¬ãƒ¼ã‚¹å‡ºåŠ›ã®éš›ã« \fBPS4\fR 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã‚’使ã†ã¨ãƒˆãƒ¬ãƒ¼ã‚¹å‡ºåŠ›ã®ãƒ•ã‚©ãƒ³ãƒˆã®æ›¸å¼ã‚’変更ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .RE .PP \fBPWD\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スを表ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æ­£ã—ã„パスã«åˆæœŸåŒ–ã•れã€cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã™ã‚‹åº¦ã«å†è¨­å®šã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ãƒ‡ãƒ•ォルトã§ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚ .RE .PP \fBRANDOM\fR .RS 4 ã“ã®å¤‰æ•°ã¯ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ 0 以上 32768 未満ã®ä¸€æ§˜åˆ†å¸ƒä¹±æ•°ã«ãªã£ã¦ã„ã¾ã™ã€‚ .sp ã“ã®å¤‰æ•°ã«éžè² æ•´æ•°ã‚’代入ã™ã‚‹ã¨ä¹±æ•°ã‚’生æˆã™ã‚‹\fI種\fRã‚’å†è¨­å®šã§ãã¾ã™ã€‚ .sp 一度ã“ã®å¤‰æ•°ã‚’削除ã™ã‚‹ã¨ã€ã“ã®å¤‰æ•°ã‚’用ã„ã¦ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ã¾ãŸã‚·ã‚§ãƒ«ãŒ POSIX 準拠モードã§èµ·å‹•ã•れãŸå ´åˆã€ã“ã®å¤‰æ•°ã§ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .PP \fBTERM\fR .RS 4 ã“ã®å¤‰æ•°ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‹•作ã—ã¦ã„る端末ã®ç¨®é¡žã‚’指定ã—ã¾ã™ã€‚ã“ã“ã§æŒ‡å®šã•れãŸç«¯æœ«ã®ç¨®é¡žã«å¾“ã£ã¦è¡Œç·¨é›†æ©Ÿèƒ½ã¯ç«¯æœ«ã‚’制御ã—ã¾ã™ã€‚ .RE .PP \fBYASH_AFTER_CD\fR .RS 4 ã“ã®å¤‰æ•°ã®å€¤ã¯ã€cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„ pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒå¤‰æ›´ã•れãŸå¾Œã«ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ã€‚ã“れã¯ã€ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒå¤‰ã‚ã£ãŸå¾Œã«æ¯Žå›ž \fBeval \-i \-\- "${YASH_AFTER_CD\-}"\fR ã¨ã„ã†ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã®ã¨åŒã˜ã§ã™ã€‚ .RE .PP \fBYASH_LOADPATH\fR .RS 4 ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§èª­ã¿è¾¼ã‚€ã‚¹ã‚¯ãƒªãƒ—トファイルã®ã‚るディレクトリを指定ã—ã¾ã™ã€‚\fBPATH\fR 変数ã¨åŒæ§˜ã«ã€ã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦è¤‡æ•°ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’指定ã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã€yash ã«ä»˜å±žã—ã¦ã„る共通スクリプトã®ã‚るディレクトリåã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .RE .PP \fBYASH_LE_TIMEOUT\fR .RS 4 ã“ã®å¤‰æ•°ã¯è¡Œç·¨é›†æ©Ÿèƒ½ã§æ›–æ˜§ãªæ–‡å­—シーケンスãŒå…¥åŠ›ã•れãŸã¨ãã«ã€å…¥åŠ›æ–‡å­—ã‚’ç¢ºå®šã•ã›ã‚‹ãŸã‚ã«ã‚·ã‚§ãƒ«ãŒå¾…ã¤æ™‚間をミリ秒å˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚行編集を行ã†éš›ã«ã“ã®å¤‰æ•°ãŒå­˜åœ¨ã—ãªã‘れã°ã€ãƒ‡ãƒ•ォルトã¨ã—㦠100 ãƒŸãƒªç§’ãŒæŒ‡å®šã•れã¾ã™ã€‚ .RE .PP \fBYASH_VERSION\fR .RS 4 ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã‚·ã‚§ãƒ«ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBé…列\fR .RS 4 .sp \fIé…列\fRã¨ã¯ã€ä¸€ã¤ã®å¤‰æ•°ã«è¤‡æ•°ã®å€¤ (文字列) ã‚’æŒãŸã›ãŸã‚‚ã®ã§ã™ã€‚一ã¤ã®é…列ã®è¤‡æ•°ã®å€¤ã¯ä½ç½®ãƒ‘ラメータã¨åŒæ§˜ã« 1 以上ã®è‡ªç„¶æ•°ã§è­˜åˆ¥ã•れã¾ã™ã€‚ .sp é…列ã¯ã€å˜ç´”コマンドã«ã‚ˆã£ã¦ä»£å…¥ã§ãã¾ã™ã€‚ã¾ãŸ array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ã‚‚é…列ã«ä»£å…¥ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚é…列を削除ã™ã‚‹ã«ã¯å¤‰æ•°ã¨åŒæ§˜ã« unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã„ã¾ã™ã€‚ .sp é…列をé…列ã®ã¾ã¾ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。é…列をエクスãƒãƒ¼ãƒˆã—よã†ã¨ã™ã‚‹ã¨ã€é…列ã®å„値をコロンã§åŒºåˆ‡ã£ã¦ç¹‹ã„ã ä¸€ã¤ã®æ–‡å­—列ã®å€¤ã‚’æŒã¤å¤‰æ•°ã¨ã—ã¦ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã•れã¾ã™ã€‚ .sp POSIX 準拠モードã§ã¯é…列ã¯ä½¿ãˆã¾ã›ã‚“。 .RE .SH "å˜èªžã®å±•é–‹" .sp コマンドを構æˆã™ã‚‹å„å˜èªžã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã¨ãã«å±•é–‹ã•れã¾ã™ã€‚\fI展開\fRã¨ã¯å˜èªžã«å«ã¾ã‚Œã‚‹ãƒ‘ラメータやパターンを処ç†ã—ã¦å…·ä½“çš„ãªæ–‡å­—列値ã«ç½®ãæ›ãˆã‚‹ã“ã¨ã§ã™ã€‚展開ã«ã¯ä»¥ä¸‹ã®ä¸ƒç¨®é¡žãŒã‚りã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} ãƒãƒ«ãƒ€å±•é–‹ .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} パラメータ展開 .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} ã‚³ãƒžãƒ³ãƒ‰ç½®æ› .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} æ•°å¼å±•é–‹ .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} ブレース展開 .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} å˜èªžåˆ†å‰² .RE .sp .RS 4 .ie n \{\ \h'-04' 7.\h'+01'\c .\} .el \{\ .sp -1 .IP " 7." 4.2 .\} パスå展開 .RE .sp ã“れらã®å±•é–‹ã¯ä¸Šã«æŒ™ã’ãŸé †åºã§è¡Œã‚れã¾ã™ã€‚ç‰¹ã«æœ€åˆã®å››ã¤ (ãƒãƒ«ãƒ€å±•開・パラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹) ã‚’\fI四種展開\fRã¨ã„ã„ã¾ã™ã€‚ .SS "ãƒãƒ«ãƒ€å±•é–‹" .sp \fIãƒãƒ«ãƒ€å±•é–‹\fRã¯ã€\fB~\fR ã§å§‹ã¾ã‚‹å˜èªžã‚’特定ã®ãƒ‘スåã«ç½®ãæ›ãˆã‚‹å±•é–‹ã§ã™ã€‚å˜èªžã®å…ˆé ­ã«ã‚ã‚‹ \fB~\fR ã‹ã‚‰æœ€åˆã® \fB/\fR ã¾ã§ (\fB/\fR ãŒãªã„å ´åˆã¯å˜èªžå…¨ä½“) ãŒæŒ‡å®šã•れãŸãƒ‘スåã«å¤‰æ›ã•れã¾ã™ã€‚ãŸã ã—ã€ç½®ãæ›ãˆã‚‰ã‚Œã‚‹éƒ¨åˆ†ãŒä¸€æ–‡å­—ã§ã‚‚クォートã•れã¦ã„ã‚‹å ´åˆã¯ã€ãƒãƒ«ãƒ€å±•é–‹ã¯è¡Œã‚れã¾ã›ã‚“。 .sp 展開ã•れる内容ã¯ã€ç½®ãæ›ãˆã‚‰ã‚Œã‚‹éƒ¨åˆ†ã®æ›¸å¼ã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«æ±ºã¾ã‚Šã¾ã™ã€‚ .PP \fB~\fR .RS 4 å˜ãªã‚‹ \fB~\fR ã¯ã€\fBHOME\fR 変数ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ .RE .PP \fB~\fR\fB\fIusername\fR\fR .RS 4 \fB~\fR ã®å¾Œã«ãƒ¦ãƒ¼ã‚¶åãŒæ›¸ã‹ã‚Œã¦ã„ã‚‹å ´åˆã¯ã€ãã®ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スåã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ .RE .PP \fB~+\fR .RS 4 \fB~+\fR ã¯ã€\fBPWD\fR 変数ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ .RE .PP \fB~\-\fR .RS 4 \fB~\-\fR ã¯ã€\fBOLDPWD\fR 変数ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ .RE .PP \fB~+\fR\fB\fIn\fR\fR, \fB~\-\fR\fB\fIn\fR\fR .RS 4 ã“ã® \fIn\fR 㯠0 ä»¥ä¸Šã®æ•´æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®å½¢å¼ã®ãƒãƒ«ãƒ€å±•é–‹ã¯ã€+\fIn\fR ã¾ãŸã¯ \-\fIn\fR ã§æŒ‡å®šã•れるディレクトリスタック内ã®ãƒ‘スã®ä¸€ã¤ã«å±•é–‹ã•れã¾ã™ã€‚(dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰å‚ç…§) .RE .sp 変数代入ã®å€¤ã«å¯¾ã—ã¦ãƒãƒ«ãƒ€å±•é–‹ãŒè¡Œã‚れる際ã€å€¤ãŒã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦ã‚ã‚‹å ´åˆã¯ã€ã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦ã‚ã‚‹å„部分をãれãžã‚Œå˜èªžã¨ã¿ãªã—ã¦ãƒãƒ«ãƒ€å±•é–‹ã—ã¾ã™ã€‚例ãˆã° \fBHOME\fR 変数ã®å€¤ãŒ \fB/home/foo\fR ã®ã¨ã〠.sp .if n \{\ .RS 4 .\} .nf VAR=~/a:~/b:~/c .fi .if n \{\ .RE .\} .sp 㯠.sp .if n \{\ .RS 4 .\} .nf VAR=/home/foo/a:/home/foo/b:/home/foo/c .fi .if n \{\ .RE .\} .sp ã¨ç­‰ä¾¡ã§ã™ã€‚ .sp ãƒãƒ«ãƒ€å±•é–‹ã«å¤±æ•—ã—ãŸå ´åˆ (指定ã•れãŸãƒ‘スåãŒä½•らã‹ã®åŽŸå› ã§å¾—られãªã‹ã£ãŸå ´åˆ) ã®å‹•作㯠POSIX ã§ã¯è¦å®šã•れã¦ã„ã¾ã›ã‚“ãŒã€yash ã§ã¯ä½•事もãªã‹ã£ãŸã‹ã®ã‚ˆã†ã«å‡¦ç†ã‚’続行ã—ã¾ã™ (ç½®ãæ›ãˆã‚‰ã‚Œã‚‹ã¯ãšã ã£ãŸéƒ¨åˆ†ã¯ãã®ã¾ã¾æ®‹ã•れã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãªã©ã¯å‡ºã¾ã›ã‚“)。 .sp POSIX 準拠モードã§ã¯ \fB~\fR 㨠\fB~\fR\fB\fIユーザå\fR\fR ã®å½¢å¼ã®å±•é–‹ã®ã¿ãŒæœ‰åйã§ã™ã€‚ .SS "パラメータ展開" .sp \fIパラメータ展開\fRã¯ã€å˜èªžã®ä¸€éƒ¨ã‚’パラメータã®å€¤ã«ç½®ãæ›ãˆã‚‹å±•é–‹ã§ã™ã€‚ .sp よã使ã‚れるå˜ç´”ãªãƒ‘ラメータ展開ã®å½¢å¼ã¯ \fB${\fR\fB\fIパラメータå\fR\fR\fB}\fR ã§ã™ã€‚ã“れã¯\fIパラメータå\fRã§æŒ‡å®šã•れãŸãƒ‘ラメータã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚ã•らã«ã€ä»¥ä¸‹ã®å ´åˆã«ã¯\fIパラメータå\fRを囲む括弧をçœç•¥ã—㦠\fB$\fR\fB\fIパラメータå\fR\fR ã®ã‚ˆã†ã«æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIパラメータå\fRãŒç‰¹æ®Šãƒ‘ラメータã®å ´åˆ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIパラメータå\fRãŒä¸€æ¡ã®ä½ç½®ãƒ‘ラメータã®å ´åˆ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIパラメータå\fRãŒå¤‰æ•°åã§ã€ç›´å¾Œã«å¤‰æ•°åã®ä¸€éƒ¨ã¨ã—ã¦èª¤è§£ã•れるæã‚Œã®ã‚る文字ãŒãªã„å ´åˆã€‚例ãˆã° \fB${path}\-name\fR ã¨ã„ã†å˜èªžã¯ \fB$path\-name\fR ã¨æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ãŒã€ \fB${path}name\fR ã‚’ \fB$pathname\fR ã¨æ›¸ãã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .sp \fIパラメータå\fRã¨ã—ã¦ç‰¹æ®Šãƒ‘ラメータã§ã‚‚ä½ç½®ãƒ‘ラメータã§ã‚‚変数åã§ã‚‚ãªã„ã‚‚ã®ã‚’指定ã—ãŸå ´åˆã¯ã€æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚(Yash 以外ã®ã‚·ã‚§ãƒ«ã§ã¯æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã§ã¯ãªã展開エラーã«ãªã‚‹ã‚‚ã®ã‚‚ã‚りã¾ã™) .sp シェル㮠unset オプションãŒç„¡åйãªå ´åˆã€\fIパラメータå\fRã«å­˜åœ¨ã—ãªã„変数を指定ã™ã‚‹ã¨å±•開エラーã«ãªã‚Šã¾ã™ã€‚Unset ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªå ´åˆã¯ã€å­˜åœ¨ã—ãªã„変数ã¯ç©ºæ–‡å­—列ã«å±•é–‹ã•れã¾ã™ã€‚ .sp より複雑ãªãƒ‘ラメータ展開ã®å½¢å¼ã§ã¯ã€ãƒ‘ラメータã®å€¤ã‚’加工ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚パラメータ展開ã®ä¸€èˆ¬å½¢ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP パラメータ展開 .RS 4 \fB${ \fR\fB\fIå‰ç½®è©ž\fR\fR\fB \fR\fB\fIパラメータå\fR\fR\fB \fR\fB\fIインデックス\fR\fR\fB \fR\fB\fI加工指定\fR\fR\fB }\fR .RE .sp ã“ã“ã§ã¯ä¾¿å®œä¸Š\fIパラメータå\fRã‚„\fIインデックス\fRã®å‘¨ã‚Šã«ç©ºç™½ã‚’入れã¾ã—ãŸãŒã€å®Ÿéš›ã«ã¯ç©ºç™½ã‚’入れã¦ã¯ã„ã‘ã¾ã›ã‚“。\fIパラメータå\fR以外ã®éƒ¨åˆ†ã¯ã„ãšã‚Œã‚‚çœç•¥å¯èƒ½ã§ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBå‰ç½®è©ž\fR .RS 4 .sp \fIå‰ç½®è©ž\fRã¨ã—ã¦\fIパラメータå\fRã®ç›´å‰ã«è¨˜å· \fB#\fR ã‚’ç½®ãã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚展開ã—よã†ã¨ã—ã¦ã„ã‚‹ã®ãŒé…列変数ã®å ´åˆã€å„è¦ç´ ãŒãれãžã‚Œæ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBパラメータå\fR .RS 4 .sp \fIパラメータå\fRã«ã¯ã€ç‰¹æ®Šãƒ‘ラメータ・ä½ç½®ãƒ‘ラメータ・変数を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿å±•é–‹ã¯æŒ‡å®šã•れãŸãƒ‘ラメータã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚指定ã—ãŸ\fIパラメータå\fRãŒé…列変数ã®å ´åˆã€é…列ã®å„è¦ç´ ãŒç‰¹æ®Šãƒ‘ラメータ \fB@\fR ã®å ´åˆã¨åŒæ§˜ã«å˜èªžåˆ†å‰²ã•れã¾ã™ (インデックス \fB[*]\fR ãŒæŒ‡å®šã•れãŸå ´åˆã‚’除ã)。 .sp \fIパラメータå\fRã¨ã—ã¦ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•開を指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“れã¯ç‰¹ã«\fI展開ã®å…¥ã‚Œå­\fRã¨è¨€ã„ã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘ラメータ展開ã¯å†…å´ã®å±•é–‹ã®å±•é–‹çµæžœã«å±•é–‹ã•れã¾ã™ã€‚ãªãŠã€å†…å´ã®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿å±•é–‹ã®æ‹¬å¼§ \fB{ }\fR ã¯çœç•¥ã§ãã¾ã›ã‚“。ã¾ãŸå±•é–‹ã®å…¥ã‚Œå­ã¯ POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBインデックス\fR .RS 4 .sp \fIインデックス\fRã¯å±•é–‹ã™ã‚‹å€¤ã®ä¸€éƒ¨ã‚’抜ã出ã™ã®ã«ä½¿ã„ã¾ã™ã€‚インデックスã¯ä»¥ä¸‹ã®æ›¸å¼ã‚’ã—ã¦ã„ã¾ã™ã€‚ .PP インデックス .RS 4 \fB[\fR\fB\fIå˜èªž1\fR\fR\fB]\fR .sp \fB[\fR\fB\fIå˜èªž1\fR\fR\fB,\fR\fB\fIå˜èªž2\fR\fR\fB]\fR .RE .sp ã“ã“ã§ã®\fIå˜èªž1\fRãŠã‚ˆã³\fIå˜èªž2\fRã¯é€šå¸¸ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨åŒæ§˜ã«è§£é‡ˆã•れã¾ã™ãŒã€\fB,\fR 㨠\fB]\fR ã§å¼·åˆ¶çš„ã«åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ã¾ãŸç©ºç™½ã‚„タブã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ã¯ã¿ãªã—ã¾ã›ã‚“。 .sp インデックスã¯ã€ä»¥ä¸‹ã®ã‚ˆã†ã«è§£é‡ˆã•れã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} ã¾ãšã€\fIインデックス\fRã«å«ã¾ã‚Œã‚‹\fIå˜èªž1\fR・\fIå˜èªž2\fRã«å¯¾ã—ã¦ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•開を行ã„ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} \fIインデックス\fR㌠\fB[\fR\fB\fIå˜èªž1\fR\fR\fB]\fR ã®æ›¸å¼ã‚’ã—ã¦ã„ã¦ã€\fIå˜èªž1\fRã®ä¸Šè¨˜å±•é–‹çµæžœãŒ \fB*\fRã€\fB@\fRã€\fB#\fR ã®ã„ãšã‚Œã‹ã®å ´åˆã¯ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®è§£é‡ˆã¯çµ‚了ã§ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} \fIå˜èªž1\fRã¨\fIå˜èªž2\fRã®ä¸Šè¨˜å±•é–‹çµæžœã‚’æ•°å¼ã¨ã¿ãªã—ã¦ã€æ•°å¼å±•é–‹ã¨åŒæ§˜ã«è¨ˆç®—ã—ã¾ã™ã€‚計算ã®çµæžœå¾—られる整数ãŒã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¨ãªã‚Šã¾ã™ã€‚æ•°å¼å±•é–‹ã®çµæžœãŒæ•´æ•°ã§ãªã„å ´åˆã¯å±•開エラーã§ã™ã€‚\fIå˜èªž2\fRãŒãªã„å½¢å¼ã§ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’指定ã—ã¦ã„ã‚‹å ´åˆã¯ã€\fIå˜èªž2\fRã¯\fIå˜èªž1\fRã¨åŒã˜æ•´æ•°ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚ .RE .sp \fIパラメータå\fRãŒé…列変数ã®å ´åˆã¾ãŸã¯ç‰¹æ®Šãƒ‘ラメータ \fB*\fR ã¾ãŸã¯ \fB@\fR ã®å ´åˆã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯é…列ã®è¦ç´ ã¾ãŸã¯ä½ç½®ãƒ‘ラメータã®ä¸€éƒ¨ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚\fIパラメータå\fRãŒä¸Šè¨˜ä»¥å¤–ã®å ´åˆã¯ã€ãƒ‘ラメータã®å€¤ã®ä¸€éƒ¨ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚インデックスã§é¸æŠžã•れãŸé…列ã®è¦ç´ ã¾ãŸã¯ãƒ‘ラメータã®å€¤ã®ä¸€éƒ¨ã®ã¿ãŒã€ãƒ‘ラメータ展開ã®çµæžœã¨ã—ã¦å±•é–‹çµæžœã«æ®‹ã‚Šã¾ã™ã€‚インデックスã«ã‚ˆã‚‹é¸æŠžã«ã¤ã„ã¦ä»¥ä¸‹ã®è¦å‰‡ãŒé©ç”¨ã•れã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ãŒè² æ•°ã®ã¨ãã¯ã€è¦ç´ ã¾ãŸã¯æ–‡å­—を最後ã‹ã‚‰æ•°ãˆã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚例ãˆã°ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB[\-2,\-1]\fR ã¯é…åˆ—ã®æœ€å¾Œã®äºŒã¤ã®è¦ç´  (ã¾ãŸã¯ãƒ‘ラメータã®å€¤ã®æœ€å¾Œã® 2 文字) ã‚’é¸æŠžã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ãŒå­˜åœ¨ã—ãªã„è¦ç´ ã¾ãŸã¯æ–‡å­—を指示ã—ã¦ã„ã‚‹å ´åˆã§ã‚‚ã€ã‚¨ãƒ©ãƒ¼ã«ã¯ãªã‚Šã¾ã›ã‚“。例ãˆã°é…列ã®è¦ç´ æ•°ãŒ 4 ã®ã¨ãã«ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB[3,5]\fR ãŒä¸Žãˆã‚‰ã‚ŒãŸã¨ã㯠3 番目以é™ã®å…¨ã¦ã®è¦ç´ ãŒé¸æŠžã•れã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB[5,7]\fR ãŒä¸Žãˆã‚‰ã‚ŒãŸæ™‚ã¯ã©ã®è¦ç´ ã‚‚é¸æŠžã•れã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ã®ä¸€æ–¹ãŒ 0 ãªã‚‰ã°ã€(ã‚‚ã†ä¸€æ–¹ãŒä½•ã§ã‚れ) å±•é–‹çµæžœã«ã¯ä½•も残りã¾ã›ã‚“。 .RE .sp \fIインデックス\fR㌠\fB[\fR\fB\fIå˜èªž1\fR\fR\fB]\fR ã®æ›¸å¼ã‚’ã—ã¦ã„ã¦ã€\fIå˜èªž1\fRã®å±•é–‹çµæžœãŒ \fB*\fRã€\fB@\fRã€\fB#\fR ã®ã„ãšã‚Œã‹ã ã£ãŸå ´åˆã¯ã€ãƒ‘ラメータã¯ä»¥ä¸‹ã®ã‚ˆã†ã«å‡¦ç†ã•れã¾ã™ã€‚ .PP \fB*\fR .RS 4 \fIパラメータå\fRãŒé…列変数ã®å ´åˆã€é…列ã®å…¨è¦ç´ ã‚’連çµã—一ã¤ã®æ–‡å­—列ã«ã—ã¾ã™ã€‚\fIパラメータå\fRãŒç‰¹æ®Šãƒ‘ラメータ \fB*\fR ã¾ãŸã¯ \fB@\fR ã®å ´åˆã€å…¨ã¦ã®ä½ç½®ãƒ‘ラメータを連çµã—一ã¤ã®æ–‡å­—列ã«ã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB[1,\-1]\fR ã¨åŒæ§˜ã§ã™ã€‚(連çµã®ä»•æ–¹ã¯ç‰¹æ®Šãƒ‘ラメータ \fB*\fR ã®ä½ç½®ãƒ‘ラメータã®é€£çµã®ä»•æ–¹ã¨åŒã˜ã§ã™) .RE .PP \fB@\fR .RS 4 インデックス \fB[1,\-1]\fR ã¨åŒæ§˜ã§ã™ã€‚ .RE .PP \fB#\fR .RS 4 \fIパラメータå\fRãŒé…列変数ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯é…列ã®è¦ç´ æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚\fIパラメータå\fRãŒç‰¹æ®Šãƒ‘ラメータ \fB*\fR ã¾ãŸã¯ \fB@\fR ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚ãれ以外ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚ .RE .sp パラメータ展開ã«\fIインデックス\fRãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€\fIインデックス\fRã¨ã—㦠\fB[@]\fR ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚\fIインデックス\fRã¯POSIX 準拠モードã§ã¯ä¸€åˆ‡ä½¿ãˆã¾ã›ã‚“。 .PP \fB例1 通常ã®å¤‰æ•°ã®å±•é–‹\fR .sp 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 \fBABC\fR を出力ã—ã¾ã™: .sp .if n \{\ .RS 4 .\} .nf var=\*(Aq123ABC789\*(Aq echo "${var[4,6]}" .fi .if n \{\ .RE .\} .PP \fB例2 ä½ç½®ãƒ‘ラメータã®å±•é–‹\fR .sp 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 \fB2 3 4\fR を出力ã—ã¾ã™: .sp .if n \{\ .RS 4 .\} .nf set 1 2 3 4 5 echo "${*[2,\-2]}" .fi .if n \{\ .RE .\} .PP \fB例3 é…列ã®å±•é–‹\fR .sp 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 \fB2 3 4\fR を出力ã—ã¾ã™: .sp .if n \{\ .RS 4 .\} .nf array=(1 2 3 4 5) echo "${array[2,\-2]}" .fi .if n \{\ .RE .\} .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB加工指定\fR .RS 4 .sp \fI加工指定\fRã¯ãƒ‘ラメータã®å€¤ã‚’加工ã—ã¾ã™ã€‚加工ã•れãŸå¾Œã®å€¤ãŒãƒ‘ラメータ展開ã®çµæžœã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚加工指定ã«ã¯ä»¥ä¸‹ã®å½¢å¼ãŒã‚りã¾ã™ã€‚ .PP \fB\-\fR\fB\fIå˜èªž\fR\fR .RS 4 \fIパラメータå\fRãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã“ã®ãƒ‘ラメータ展開ã¯\fIå˜èªž\fRã«å±•é–‹ã•れã¾ã™ã€‚(Unset オプションãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“) .RE .PP \fB+\fR\fB\fIå˜èªž\fR\fR .RS 4 \fIパラメータå\fRãŒå­˜åœ¨ã™ã‚‹å¤‰æ•°ã‚’指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã“ã®ãƒ‘ラメータ展開ã¯\fIå˜èªž\fRã«å±•é–‹ã•れã¾ã™ã€‚(Unset オプションãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“) .RE .PP \fB=\fR\fB\fIå˜èªž\fR\fR .RS 4 \fIパラメータå\fRãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€\fIå˜èªž\fRã®å±•é–‹çµæžœãŒãã®å¤‰æ•°ã«ä»£å…¥ã•れãŸå¾Œã€ã“ã®ãƒ‘ラメータ展開ã¯ãã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚変数以外ã®ã‚‚ã®ã«å¯¾ã—ã¦ä»£å…¥ã—よã†ã¨ã™ã‚‹ã¨å±•開エラーã«ãªã‚Šã¾ã™ã€‚(Unset オプションãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“) .RE .PP \fB?\fR\fB\fIå˜èªž\fR\fR .RS 4 \fIパラメータå\fRãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¨ã—ã¦\fIå˜èªž\fRを標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚(\fIå˜èªž\fRãŒãªã„å ´åˆã¯ãƒ‡ãƒ•ォルトã®ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒå‡ºã¾ã™) .RE .PP \fB:\-\fR\fB\fIå˜èªž\fR\fR, \fB:+\fR\fB\fIå˜èªž\fR\fR, \fB:=\fR\fB\fIå˜èªž\fR\fR, \fB:?\fR\fB\fIå˜èªž\fR\fR .RS 4 ã“れらã¯ä¸Šè¨˜ã® \fB\-\fRã€\fB+\fRã€\fB=\fRã€\fB?\fR ã¨\fIå˜èªž\fRã®çµ„ã¿åˆã‚ã›ã®åŠ å·¥æŒ‡å®šã¨åŒæ§˜ã§ã™ãŒã€\fIå˜èªž\fRを使用ã™ã‚‹æ¡ä»¶ãŒç•°ãªã‚Šã¾ã™ã€‚先頭㫠\fB:\fR ãŒä»˜ã‹ãªã„ã‚‚ã®ã§ã¯ 『変数ãŒå­˜åœ¨ã™ã‚‹ã‹ã©ã†ã‹ã€ ã§åˆ¤å®šã•れã¾ã™ãŒã€\fB:\fR ãŒä»˜ãã‚‚ã®ã§ã¯ 『変数ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹ã€ ã§åˆ¤å®šã•れã¾ã™ã€‚ .RE .PP \fB#\fR\fB\fIå˜èªž\fR\fR .RS 4 \fIå˜èªž\fRをパターンã¨ã—ã¦è¦‹ãŸã¨ãã€ãれãŒã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®å…ˆé ­éƒ¨åˆ†ã«ãƒžãƒƒãƒã™ã‚‹ãªã‚‰ã°ã€ãã®ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã‚’削除ã—ã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã“ã®ãƒ‘ラメータ展開ã¯ãƒžãƒƒãƒã—ãªã‹ã£ãŸæ®‹ã‚Šã®éƒ¨åˆ†ã«å±•é–‹ã•れã¾ã™ã€‚マッãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘短ãマッãƒã•ã›ã¾ã™ã€‚ .RE .PP \fB##\fR\fB\fIå˜èªž\fR\fR .RS 4 ã“ã®åŠ å·¥æŒ‡å®šã¯ \fB#\fR\fB\fIå˜èªž\fR\fR ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB%\fR\fB\fIå˜èªž\fR\fR .RS 4 ã“ã®åŠ å·¥æŒ‡å®šã¯ \fB#\fR\fB\fIå˜èªž\fR\fR ã¨åŒæ§˜ã§ã™ãŒã€å€¤ã®å…ˆé ­éƒ¨åˆ†ã§ã¯ãªã末尾部分ã«ãƒžãƒƒãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB%%\fR\fB\fIå˜èªž\fR\fR .RS 4 ã“ã®åŠ å·¥æŒ‡å®šã¯ \fB%\fR\fB\fIå˜èªž\fR\fR ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB/\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR .RS 4 \fIå˜èªž1\fRをパターンã¨ã—ã¦è¦‹ãŸã¨ãã€ãれãŒã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®ä¸€éƒ¨ã«ãƒžãƒƒãƒã™ã‚‹ãªã‚‰ã°ã€ãã®ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã‚’\fIå˜èªž2\fRã«ç½®ãæ›ãˆã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã“ã®ãƒ‘ラメータ展開ã¯ãƒžãƒƒãƒã—ãŸéƒ¨åˆ†ã‚’\fIå˜èªž2\fRã«ç½®ãæ›ãˆãŸå€¤ã«å±•é–‹ã•れã¾ã™ã€‚マッãƒã™ã‚‹ç®‡æ‰€ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ã€æœ€åˆã®ç®‡æ‰€ãŒé¸ã°ã‚Œã¾ã™ã€‚マッãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã¾ã™ã€‚ .sp ã“ã®åŠ å·¥æŒ‡å®šã¯ POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .RE .PP \fB/#\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR .RS 4 ã“ã®åŠ å·¥æŒ‡å®šã¯ \fB/\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®å…ˆé ­éƒ¨åˆ†ã«ã—ã‹ãƒžãƒƒãƒã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB/%\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR .RS 4 ã“ã®åŠ å·¥æŒ‡å®šã¯ \fB/\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æœ«å°¾éƒ¨åˆ†ã«ã—ã‹ãƒžãƒƒãƒã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB//\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR .RS 4 ã“ã®åŠ å·¥æŒ‡å®šã¯ \fB/\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã™ã‚‹ç®‡æ‰€ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯æœ€åˆã®ç®‡æ‰€ã ã‘ã§ã¯ãªãå…¨ã¦ã®ç®‡æ‰€ã‚’\fIå˜èªž2\fRã«ç½®ãæ›ãˆã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB:/\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR .RS 4 ã“ã®åŠ å·¥æŒ‡å®šã¯ \fB/\fR\fB\fIå˜èªž1\fR\fR\fB/\fR\fB\fIå˜èªž2\fR\fR ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値全体ã«ãƒžãƒƒãƒã™ã‚‹å ´åˆã—ã‹å¯¾è±¡ã¨ã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .sp ã„ãšã‚Œã®å½¢å¼ã«ãŠã„ã¦ã‚‚ã€åŠ å·¥æŒ‡å®šã«å«ã¾ã‚Œã‚‹å˜èªžã¯ (ãれãŒä½¿ç”¨ã•れるã¨ãã®ã¿) 四種展開ã•れã¾ã™ã€‚ .sp 展開ã—よã†ã¨ã—ã¦ã„ã‚‹\fIパラメータå\fRãŒé…列変数ã¾ãŸã¯ç‰¹æ®Šãƒ‘ラメータ \fB@\fR ã¾ãŸã¯ \fB*\fR ã®å ´åˆã€åŠ å·¥æŒ‡å®šã¯é…列ã®å„è¦ç´ ã¾ãŸã¯å„ä½ç½®ãƒ‘ラメータã«å¯¾ã—ã¦ãれãžã‚Œä½œç”¨ã—ã¾ã™ã€‚ .RE .SS "コマンド置æ›" .sp \fIコマンド置æ›\fRã¯ã€æŒ‡å®šã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ãã®å‡ºåŠ›ã‚’ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å±•é–‹ã—ã¾ã™ã€‚コマンド置æ›ã®æ›¸å¼ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP ã‚³ãƒžãƒ³ãƒ‰ç½®æ› .RS 4 \fB$(\fR\fB\fIコマンド\fR\fR\fB)\fR .sp \fB`\fR\fB\fIコマンド\fR\fR\fB`\fR .RE .sp コマンド置æ›ã§ã¯ã€\fIコマンド\fRãŒã‚µãƒ–シェルã§å®Ÿè¡Œã•れã¾ã™ã€‚ã“ã®ã¨ãã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ãŒãƒ‘イプを通ã˜ã¦ã‚·ã‚§ãƒ«ã«é€ã‚‰ã‚Œã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å‡ºåŠ›çµæžœã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã®å‡ºåŠ›ã®æœ«å°¾ã«ã‚る改行ã¯é™¤ãã¾ã™ã€‚ .sp \fB$(\fR 㨠\fB)\fR ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®\fIコマンド\fRã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®å…¥ã‚Œå­ã‚„リダイレクトãªã©ã‚’考慮ã—ã¦äºˆã‚è§£æžã•れã¾ã™ã€‚従ã£ã¦ã€\fB$(\fR 㨠\fB)\fR ã®é–“ã«ã¯åŸºæœ¬çš„ã«é€šå¸¸é€šã‚Šã‚³ãƒžãƒ³ãƒ‰ã‚’書ãã“ã¨ãŒã§ãã¾ã™ã€‚ãŸã ã—ã€æ•°å¼å±•é–‹ã¨ã®æ··åŒã‚’é¿ã‘ã‚‹ãŸã‚ã€ä¸­ã®\fIコマンド\fR㌠\fB(\fR ã§å§‹ã¾ã‚‹å ´åˆã¯\fIコマンド\fRã®æœ€åˆã«ç©ºç™½ã‚’æŒ¿ã—æŒŸã‚“ã§ãã ã•ã„。 .sp \fB`\fR ã§å›²ã‚€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®å…¥ã‚Œå­ãªã©ã¯è€ƒæ…®ã›ãšã«ã€\fIコマンド\fRã®ä¸­ã«æœ€åˆã« (ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã—ã¦ã„ãªã„) \fB`\fR ãŒç¾ã‚ŒãŸã¨ã“ã‚ã§ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®çµ‚ã‚りã¨ã¿ãªã•れã¾ã™ã€‚\fB`\fR ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã« \fB`\fR ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚’書ãå ´åˆã¯ã€å†…å´ã® \fB`\fR ã‚’ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ãã®ä»–ã€\fIコマンド\fRã®ä¸€éƒ¨ã¨ã—㦠\fB`\fR を入れãŸã„ã¨ãã¯ã€(ãれãŒ\fIコマンド\fR内部ã§ä¸€é‡ã¾ãŸã¯äºŒé‡å¼•用符ã§ã‚¯ã‚©ãƒ¼ãƒˆã•れã¦ã„ã¦ã‚‚) ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ .sp \fB$(\fR 㨠\fB)\fR ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚’å«ã‚€ã‚³ãƒžãƒ³ãƒ‰ã‚’è§£æžã™ã‚‹æ™‚ã«ä¸€ç·’ã«è§£æžã•れã¾ã™ (POSIX 準拠モードを除ã)。\fB`\fR ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«é–¢ã‚らãšã€ãã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒå®Ÿè¡Œã•ã‚Œã‚‹æ™‚ã«æ¯Žå›žè§£æžã•れã¾ã™ã€‚ .SS "æ•°å¼å±•é–‹" .sp \fIæ•°å¼å±•é–‹\fRã¯ã€æ–‡å­—列を数å¼ã¨ã—ã¦è§£é‡ˆã—ã¦ã€ãã®è¨ˆç®—çµæžœã‚’è¡¨ã™æ•°å€¤ã«å±•é–‹ã—ã¾ã™ã€‚æ•°å¼å±•é–‹ã®æ›¸å¼ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP æ•°å¼å±•é–‹ .RS 4 \fB$((\fR\fB\fIå¼\fR\fR\fB))\fR .RE .sp æ•°å¼å±•é–‹ã§ã¯ã€ã¾ãš\fIå¼\fRã«å¯¾ã—ã¦ãƒ‘ラメータ展開・コマンド置æ›ãƒ»(入れå­ã®) æ•°å¼å±•é–‹ãŒè¡Œã‚れã¾ã™ã€‚ãã®çµæžœå¾—ã‚‰ã‚ŒãŸæ–‡å­—列を以下ã®ã‚ˆã†ã«æ•°å¼ã¨ã—ã¦è§£é‡ˆã—ã€ãã®è¨ˆç®—çµæžœã‚’è¡¨ã™æ•°å€¤ã«å±•é–‹ã•れã¾ã™ã€‚ .sp Yash ã§ã¯ã€æ•°å¼ã®ä¸­ã§æ•´æ•° (C 言語㮠long åž‹) ã¨æµ®å‹•å°æ•°ç‚¹æ•° (C 言語㮠double åž‹) を扱ã†ã“ã¨ãŒã§ãã¾ã™ã€‚ãŸã ã— POSIX 準拠モードã§ã¯æµ®å‹•å°æ•°ç‚¹æ•°ã¯ä½¿ãˆã¾ã›ã‚“。整数åŒå£«ã®æ¼”ç®—ã®çµæžœã¯æ•´æ•°ã«ã€æµ®å‹•å°æ•°ç‚¹æ•°ã‚’å«ã‚€æ¼”ç®—ã®çµæžœã¯æµ®å‹•å°æ•°ç‚¹æ•°ã«ãªã‚Šã¾ã™ã€‚ .sp æ•°å¼ã§ã¯ C 言語㨠(ã»ã¼) åŒæ§˜ã«ä»¥ä¸‹ã®æ¼”ç®—å­ãŒä½¿ãˆã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} \fB( )\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} \fB++\fR\fB\-\-\fR (後置演算å­) .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} \fB++\fR\fB\-\-\fR\fB+\fR\fB\-\fR\fB~\fR\fB!\fR (å‰ç½®æ¼”ç®—å­) .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} \fB*\fR\fB/\fR\fB%\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} \fB+\fR\fB\-\fR (二項演算å­) .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} \fB<<\fR\fB>>\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 7.\h'+01'\c .\} .el \{\ .sp -1 .IP " 7." 4.2 .\} \fB<\fR\fB<=\fR\fB>\fR\fB>=\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 8.\h'+01'\c .\} .el \{\ .sp -1 .IP " 8." 4.2 .\} \fB==\fR\fB!=\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 9.\h'+01'\c .\} .el \{\ .sp -1 .IP " 9." 4.2 .\} \fB&\fR .RE .sp .RS 4 .ie n \{\ \h'-04'10.\h'+01'\c .\} .el \{\ .sp -1 .IP "10." 4.2 .\} \fB^\fR .RE .sp .RS 4 .ie n \{\ \h'-04'11.\h'+01'\c .\} .el \{\ .sp -1 .IP "11." 4.2 .\} \fB|\fR .RE .sp .RS 4 .ie n \{\ \h'-04'12.\h'+01'\c .\} .el \{\ .sp -1 .IP "12." 4.2 .\} \fB&&\fR .RE .sp .RS 4 .ie n \{\ \h'-04'13.\h'+01'\c .\} .el \{\ .sp -1 .IP "13." 4.2 .\} \fB||\fR .RE .sp .RS 4 .ie n \{\ \h'-04'14.\h'+01'\c .\} .el \{\ .sp -1 .IP "14." 4.2 .\} \fB? :\fR (三項演算å­) .RE .sp .RS 4 .ie n \{\ \h'-04'15.\h'+01'\c .\} .el \{\ .sp -1 .IP "15." 4.2 .\} \fB=\fR\fB*=\fR\fB/=\fR\fB%=\fR\fB+=\fR\fB\-=\fR\fB<<=\fR\fB>>=\fR\fB&=\fR\fB^=\fR\fB|=\fR .RE .sp \fB++\fR ãŠã‚ˆã³ \fB\-\-\fR 演算å­ã¯ POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .sp 原å­å¼ã¨ã—ã¦ã¯æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ãƒ»æµ®å‹•å°æ•°ç‚¹æ•°ãƒªãƒ†ãƒ©ãƒ«ãƒ»å¤‰æ•°ãŒä½¿ç”¨ã§ãã¾ã™ã€‚æ•°ãƒªãƒ†ãƒ©ãƒ«ã®æ›¸å¼ã¯ C è¨€èªžã«æº–ã˜ã¾ã™ã€‚\fB0\fR ã§å§‹ã¾ã‚‹æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ã¯å…«é€²æ•°ã€\fB0x\fR ã§å§‹ã¾ã‚‹æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ã¯å六進数ã¨ã¿ãªã•れã¾ã™ã€‚æµ®å‹•å°æ•°ç‚¹æ•°ãƒªãƒ†ãƒ©ãƒ«ã§ã¯æŒ‡æ•°è¡¨è¨˜ã‚‚使ãˆã¾ã™ (例ãˆã° 1\&.23\(mu106 㯠\fB1\&.23e+6\fR)。変数ã¯ã€ãã®å€¤ãŒæ•°å€¤ã§ãªã„å ´åˆã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ .SS "ブレース展開" .sp \fIブレース展開\fRã¯ã€ãƒ–レース (\fB{ }\fR) ã§å›²ã‚“ã éƒ¨åˆ†ã‚’ã„ãã¤ã‹ã®å˜èªžã«åˆ†å‰²ã—ã¾ã™ã€‚ブレース展開㯠brace\-expand ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã®ã¿è¡Œã‚れã¾ã™ã€‚ブレース展開ã«ã¯äºŒç¨®é¡žã®å½¢å¼ãŒã‚りã¾ã™ã€‚ .PP カンマ区切りã®ãƒ–レース展開 .RS 4 \fB{\fR\fB\fIå˜èªž1\fR\fR\fB,\fR\fB\fIå˜èªž2\fR\fR\fB,\&...,\fR\fB\fIå˜èªžn\fR\fR\fB}\fR .RE .PP 連続ã—ãŸæ•°å€¤ã®ãƒ–レース展開 .RS 4 \fB{\fR\fB\fI始点\fR\fR\fB\&.\&.\fR\fB\fI終点\fR\fR\fB}\fR .sp \fB{\fR\fB\fI始点\fR\fR\fB\&.\&.\fR\fB\fI終点\fR\fR\fB\&.\&.\fR\fB\fI差分\fR\fR\fB}\fR .RE .sp 一ã¤ç›®ã®å½¢å¼ã¯ã€ãƒ–レースã§å›²ã‚“ã éƒ¨åˆ†ã‚’一ã¤ä»¥ä¸Šã®ã‚«ãƒ³ãƒž (\fB,\fR) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚区切られãŸãれãžã‚Œã®éƒ¨åˆ†ãŒãƒ–レース展開ã®å‰å¾Œã®éƒ¨åˆ†ã¨çµåˆã•れã¦ã€ãれãžã‚Œå˜èªžã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚例ãˆã° \fBa{1,2,3}b\fR 㯠\fBa1b\fRã€\fBa2b\fRã€\fBa3b\fR ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚ .sp 二ã¤ç›®ã®å½¢å¼ã¯ \fB\fI{始点\fR\fR\fB\&.\&.\fR\fB\fI終点\fR\fR\fB}\fR ã¾ãŸã¯ \fB\fI{始点\fR\fR\fB\&.\&.\fR\fB\fI終点\fR\fR\fB\&.\&.\fR\fB\fI差分\fR\fR\fB}\fR ã§ã™ã€‚\fI始点\fR・\fI終点\fR・\fI差分\fRã¯å…¨ã¦æ•´æ•°ã§ã‚ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ã“ã®å½¢å¼ã®ãƒ–レース展開ã§ã¯ã€\fI始点\fRã‹ã‚‰\fI終点\fRã¾ã§ã®å„æ•´æ•°ãŒãƒ–レース展開ã®å‰å¾Œã®éƒ¨åˆ†ã¨çµåˆã•れã¦ã€ãれãžã‚Œå˜èªžã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚\fI差分\fRã¯æ•´æ•°ã®é–“隔を指定ã—ã¾ã™ã€‚例ãˆã° \fBa{1\&.\&.3}b\fR 㯠\fBa1b\fRã€\fBa2b\fRã€\fBa3b\fR ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã€\fBa{1\&.\&.7\&.\&.2}b\fR 㯠\fBa1b\fRã€\fBa3b\fRã€\fBa5b\fRã€\fBa7b\fR ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚\fI始点\fRãŒ\fI終点\fRより大ãã„å ´åˆã¯æ•´æ•°ã¯é™é †ã«å±•é–‹ã•れã¾ã™ã€‚ .sp 複数ã®ãƒ–レース展開を組ã¿åˆã‚ã›ãŸã‚Šã€å…¥ã‚Œå­ã«ã—ãŸã‚Šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ブレースをブレース展開ã¨ã—ã¦ã§ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã«ã¯ã€ãƒ–レースをクォートã—ã¦ãã ã•ã„。ã¾ãŸã‚«ãƒ³ãƒžã‚’区切りã¨ã—ã¦ã§ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã«ã¯ã€ã‚«ãƒ³ãƒžã‚’クォートã—ã¦ãã ã•ã„。 .sp ブレース展開ã§ã¯å±•開エラーã¯ç™ºç”Ÿã—ã¾ã›ã‚“ã€‚ãƒ–ãƒ¬ãƒ¼ã‚¹å±•é–‹ãŒæ­£ã—ãã§ããªã„å ´åˆã¯ã€å˜ã«ãれã¯ãƒ–レース展開ã§ã¯ãªã‹ã£ãŸã‚‚ã®ã¨ã—ã¦ã€ãã®ã¾ã¾æ®‹ã•れã¾ã™ã€‚ .SS "å˜èªžåˆ†å‰²" .sp \fIå˜èªžåˆ†å‰²\fRã¯ã€å±•é–‹ã®çµæžœã‚’ã„ãã¤ã‹ã®å˜èªžã«åˆ†å‰²ã—ã¾ã™ã€‚ .sp å˜èªžåˆ†å‰²ã§åˆ†å‰²ã®å¯¾è±¡ã¨ãªã‚‹ã®ã¯ã€ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ã§å±•é–‹ã•れãŸçµæžœã®éƒ¨åˆ†ã ã‘ã§ã™ã€‚ã¾ãŸã€äºŒé‡å¼•用符ã«ã‚ˆã‚‹ã‚¯ã‚©ãƒ¼ãƒˆã®ä¸­ã§å±•é–‹ã•れãŸéƒ¨åˆ†ã¯ã€(特殊パラメータ \fB@\fR ã®å±•開を除ã„ã¦) 分割ã®å¯¾è±¡ã¨ãªã‚Šã¾ã›ã‚“。 .sp å˜èªžåˆ†å‰²ã¯ \fBIFS\fR 変数ã®å€¤ã«å¾“ã£ã¦è¡Œã‚れã¾ã™ã€‚\fBIFS\fR 変数ãŒå­˜åœ¨ã—ãªã„å ´åˆã¯ã€ç©ºç™½æ–‡å­—・タブ・改行ã®ä¸‰æ–‡å­—㌠\fBIFS\fR 変数ã®å€¤ã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚ .sp \fBIFS\fR 変数ã®å€¤ã«å«ã¾ã‚Œã¦ã„る文字を \fIIFS 文字\fRã¨ã„ã„ã¾ã™ã€‚IFS 文字ã®ã†ã¡ç©ºç™½æ–‡å­—ã¾ãŸã¯ã‚¿ãƒ–ã¾ãŸã¯æ”¹è¡Œã§ã‚ã‚‹ã‚‚ã®ã‚’ \fIIFS 空白類\fRã¨ã„ã„ã¾ã™ã€‚IFS 空白類以外㮠IFS 文字を \fIIFS éžç©ºç™½é¡ž\fRã¨ã„ã„ã¾ã™ã€‚ .sp 分割ã¯ä»¥ä¸‹ã®è¦å‰‡ã«å¾“ã£ã¦è¡Œã‚れã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} 分割ã¯ã€åˆ†å‰²ã®å¯¾è±¡ã¨ãªã‚‹å±•é–‹çµæžœã®éƒ¨åˆ†ã®ä¸­ã§ã€IFS 文字ãŒç¾ã‚Œã‚‹ç®‡æ‰€ã§è¡Œã‚れã¾ã™ã€‚以下ã“ã®ã‚ˆã†ãªç®‡æ‰€ã‚’\fI分割点\fRã¨å‘¼ã³ã¾ã™ã€‚複数㮠IFS 文字ãŒé€£ç¶šã—ã¦ç¾ã‚Œã‚‹å ´åˆã¯ã€ãれらをã¾ã¨ã‚ã¦ä¸€ã¤ã®åˆ†å‰²ç‚¹ã¨ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} 分割点㫠IFS éžç©ºç™½é¡žãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ãã®åˆ†å‰²ç‚¹ã«å«ã¾ã‚Œã‚‹ IFS 空白類ã¯ã™ã¹ã¦ç„¡è¦–ã•れã¾ã™ã€‚ãã—ã¦åˆ†å‰²ç‚¹ã«å«ã¾ã‚Œã‚‹å„ IFS éžç©ºç™½é¡žã®å‰å¾Œã§å˜èªžãŒåˆ†å‰²ã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} 分割点㫠IFS éžç©ºç™½é¡žãŒå«ã¾ã‚Œã¦ã„ãªã„ (分割点㌠IFS 空白類ã ã‘ã‹ã‚‰ãªã‚‹) å ´åˆã€ãã®åˆ†å‰²ç‚¹ã®å‰å¾Œã§å˜èªžãŒåˆ†å‰²ã•れã¾ã™ã€‚ãŸã ã—ã€ã“ã®ã‚ˆã†ãªåˆ†å‰²ç‚¹ãŒå…ƒã®å˜èªžã®å…ˆé ­ã¾ãŸã¯æœ«å°¾ã«ã‚ã‚‹å ´åˆã‚’除ãã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} ã„ãšã‚Œã®å ´åˆã‚‚ã€åˆ†å‰²ç‚¹ã¯å˜èªžåˆ†å‰²å¾Œã®å˜èªžã«ã¯æ®‹ã‚Šã¾ã›ã‚“。 .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB注記\fR .ps -1 .br .sp \fBIFS\fR 変数ã®å€¤ãŒç©ºæ–‡å­—列ã®å ´åˆã¯ã€å˜èªžã¯ä¸€åˆ‡åˆ†å‰²ã•れã¾ã›ã‚“。 .sp .5v .RE .SS "パスå展開" .sp \fIパスå展開\fRã¯ã€å˜èªžã‚’パターンã¨ã¿ãªã—ã¦ãƒ•ァイルを検索ã—ã€ãƒ‘ターンã«ãƒžãƒƒãƒã™ã‚‹å®Ÿåœ¨ã®ãƒ•ァイルã¸ã®ãƒ‘スåã«å±•é–‹ã—ã¾ã™ã€‚ パスå展開㯠glob オプションãŒç„¡åŠ¹ãªæ™‚ã¯è¡Œã‚れã¾ã›ã‚“。 .sp パスå展開ã«ãŠã„ã¦ãƒ‘ターンãŒãƒžãƒƒãƒã™ã‚‹ã«ã¯ã€æ¤œç´¢ã®å¯¾è±¡ã¨ãªã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®èª­ã¿è¾¼ã¿æ¨©é™ãŒå¿…è¦ã§ã™ã€‚検索ã—よã†ã¨ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒã‚·ã‚§ãƒ«ã«ã¨ã£ã¦èª­ã¿è¾¼ã¿å¯èƒ½ã§ãªã‘れã°ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯ç©ºã§ã‚ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚ .sp 以下ã®ã‚ªãƒ—ションãŒãƒ‘スå展開ã®çµæžœã«å½±éŸ¿ã—ã¾ã™ã€‚ .PP null\-glob .RS 4 マッãƒã™ã‚‹ãƒ•ァイルãŒãªã„時ã€é€šå¸¸ (ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚) ã¯ãƒ‘ターンã¯ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ãƒ‘ターンã¯å‰Šé™¤ã•れ何も残りã¾ã›ã‚“。 .RE .PP case\-glob .RS 4 通常 (ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚) ã¯ã€å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¦ãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã¯å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã›ãšãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ã€‚ .RE .PP dot\-glob .RS 4 通常 (ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚) ã¯ã€\fB*\fR ã‚„ \fB?\fR ãªã©ã®ãƒ¯ã‚¤ãƒ«ãƒ‰ã‚«ãƒ¼ãƒ‰ã‚„ブラケット記法ã§å§‹ã¾ã‚‹ãƒ‘ターンã¯ãƒ”リオドã§å§‹ã¾ã‚‹ãƒ•ァイルåã«ãƒžãƒƒãƒã—ã¾ã›ã‚“。ã—ã‹ã—ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã“ã®ã‚ˆã†ãªåˆ¶ç´„ã¯è§£é™¤ã•れã¾ã™ã€‚ .RE .PP mark\-dirs .RS 4 ã“ã®ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãƒžãƒƒãƒã—ãŸãƒ•ァイルã®ç¨®é¡žãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å ´åˆã«å±•é–‹ã•れるパスåã®æœ€å¾Œã« \fB/\fR ãŒä»˜ãã¾ã™ã€‚ .RE .PP extended\-glob .RS 4 ã“ã®ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãƒ‘スå展開ã«ãŠã‘る拡張機能 (後述) ãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ .RE .sp パスå展開ã§ã¯ã‚¨ãƒ©ãƒ¼ã¯ç™ºç”Ÿã—ã¾ã›ã‚“。マッãƒã™ã‚‹ãƒ•ァイルãŒãªã„å ´åˆã¾ãŸã¯ãƒ‘ターンãŒä¸æ­£ãªå ´åˆã¯ã€å±•é–‹ã¯è¡Œã‚れãšãƒ‘ターンã¯ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ (null\-glob ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚を除ã)。 .sp ãƒ•ã‚¡ã‚¤ãƒ«ã®æ¤œç´¢ã¨ãƒ‘ターンマッãƒãƒ³ã‚°ã¯ \fB/\fR ã§åŒºåˆ‡ã‚‰ã‚ŒãŸãƒ‘スåã®æ§‹æˆè¦ç´ ã”ã¨ã«è¡Œã‚れã¾ã™ã€‚ワイルドカードやブラケット記法を全ãå«ã¾ãªã„æ§‹æˆè¦ç´ ã¯ãƒ‘ターンã¨ã¯ã¿ãªã•れãšã€æ¤œç´¢ã¨ãƒžãƒƒãƒãƒ³ã‚°ã¯è¡Œã‚れã¾ã›ã‚“。従ã£ã¦ã€case\-glob オプションãŒç„¡åŠ¹ãªæ™‚ã€\fB/*/foo\fR 㨠\fB/*/fo[o]\fR ã®å±•é–‹çµæžœãŒç•°ãªã‚‹å¯èƒ½æ€§ãŒã‚りã¾ã™ (å‰è€…ã§ã¯ \fBfoo\fR ã®éƒ¨åˆ†ãŒãƒ‘ターンã¨ã¯ã¿ãªã•れãªã„ã®ã§ã€ä¾‹ãˆã° /bar/FOO ã¨ã„ã†ãƒ•ァイルãŒã‚ã£ã¦ã‚‚マッãƒã—ã¾ã›ã‚“。)。 .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBパスåå±•é–‹ã®æ‹¡å¼µæ©Ÿèƒ½\fR .RS 4 .sp Extended-glob ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ä»¥ä¸‹ã®ç‰¹æ®Šãªãƒ‘ターンãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ .PP \fB**\fR .RS 4 指定ã•れãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ„リーã«å¯¾ã—å†å¸°çš„ã«æ¤œç´¢ã‚’行ã„ã¾ã™ã€‚ã™ãªã‚ã¡ã€æŒ‡å®šã•れãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¨ã€ãã®ã‚µãƒ–ディレクトリã€ã•らã«ãã®ã‚µãƒ–ディレクトリãªã©ã«å¯¾ã—検索を行ã„ã¾ã™ã€‚ãŸã ã—åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯æ¤œç´¢ã®å¯¾è±¡ã«ãªã‚Šã¾ã›ã‚“。例ãˆã° \fBdir/**/file\fR ã¨ã„ã†ãƒ‘ターンã¯ã€dir/file ã‚„ dir/foo/file ã‚„ dir/a/b/c/file ãªã©ã€dir ディレクトリã®ä¸­ã«ã‚ã‚‹å…¨ã¦ã® file ファイルã¸ã®ãƒ‘スã«å±•é–‹ã•れã¾ã™ã€‚ .sp ã“ã®ç‰¹æ®Šãªãƒ‘ターンã¯ã€ \fBfoo/bar/**\fR ã®ã‚ˆã†ã«ãƒ‘ã‚¿ãƒ¼ãƒ³å…¨ä½“ã®æœ€å¾Œã«ã‚ã‚‹å ´åˆã«ã¯åŠ¹æžœãŒã‚りã¾ã›ã‚“。 .RE .PP \fB\&.**\fR .RS 4 \fB**\fR パターンã¨åŒæ§˜ã§ã™ãŒã€åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚‚å«ã‚ã¦æ¤œç´¢ã™ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB***\fR .RS 4 \fB**\fR パターンã¨åŒæ§˜ã§ã™ãŒã€æ¤œç´¢ã®ä¸­ã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¸ã®ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ä¸­ã‚‚検索ã®å¯¾è±¡ã«å«ã‚る点ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .PP \fB\&.***\fR .RS 4 \fB***\fR パターンã¨åŒæ§˜ã§ã™ãŒã€åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚‚å«ã‚ã¦æ¤œç´¢ã™ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .RE .SH "パターンマッãƒãƒ³ã‚°è¨˜æ³•" .sp \fIパターンマッãƒãƒ³ã‚°è¨˜æ³•\fRã¯ç‰¹å®šã®æ–‡å­—列ã®é›†åˆã‚’表ã™\fIパターン\fRã®æ›¸å¼ã¨æ„味ã®å®šç¾©ã§ã™ã€‚ã‚る文字列ãŒã‚るパターンã®è¡¨ã™æ–‡å­—列ã®é›†åˆã«å«ã¾ã‚Œã‚‹æ™‚ã€ãã®æ–‡å­—列ã¯ãã®ãƒ‘ターンã«\fIマッãƒã™ã‚‹\fRã¨ã„ã„ã¾ã™ã€‚文字列ãŒãƒ‘ターンã«å½“ã¦ã¯ã¾ã‚‹ã‹ã©ã†ã‹ã¯ã€ä»¥ä¸‹ã«ç¤ºã™å®šç¾©ã«å¾“ã£ã¦åˆ¤å®šã•れã¾ã™ã€‚ .SS "é€šå¸¸ã®æ–‡å­—" .sp クォートã—ã¦ã‚る文字ãŠã‚ˆã³ä»¥ä¸‹ã«ç¤ºã™ç‰¹æ®Šãªæ„味をæŒã¤æ–‡å­—以外ã®ã™ã¹ã¦ã®æ–‡å­—ã¯ã€é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚パターンã«å«ã¾ã‚Œã‚‹é€šå¸¸ã®æ–‡å­—ã¯ã€ãã®æ–‡å­—自身ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ .sp 例ãˆã° \fBabc\fR ã¨ã„ã†ãƒ‘ターン㯠\fBabc\fR ã¨ã„ã†æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚(ãã—ã¦ã“ã‚Œä»¥å¤–ã®æ–‡å­—列ã«ã¯ä¸€åˆ‡å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“) .SS "一文字ワイルドカード" .sp 文字 \fB?\fR ã¯ä»»æ„ã®ä¸€æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ .sp 例ãˆã° \fBa?c\fR ã¨ã„ã†ãƒ‘ターン㯠\fBaac\fRã€\fBabc\fRã€\fBa;c\fR ãªã©ã€\fBa\fR ã§å§‹ã¾ã‚Š \fBc\fR ã§çµ‚ã‚ã‚‹ä»»æ„ã® 3 æ–‡å­—ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ .SS "複数文字ワイルドカード" .sp 文字 \fB*\fR ã¯ä»»æ„ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ã“ã“ã§ã„ã†ä»»æ„ã®æ–‡å­—列ã«ã¯ç©ºæ–‡å­—列もå«ã¾ã‚Œã¾ã™ã€‚ 例ãˆã° \fBa*c\fR ã¨ã„ã†ãƒ‘ターン㯠\fBac\fRã€\fBabc\fRã€\fBa;xyz;c\fR ãªã©ã€\fBa\fR ã§å§‹ã¾ã‚Š \fBc\fR ã§çµ‚ã‚ã‚‹ä»»æ„ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ .SS "ブラケット記法" .sp 括弧 \fB[\fR 㨠\fB]\fR ã§å›²ã¾ã‚ŒãŸéƒ¨åˆ†ã¯\fIブラケット記法\fRã¨ã¿ãªã•れã¾ã™ã€‚ãŸã ã—ã€æ‹¬å¼§ã®é–“ã«ã¯å°‘ãªãã¨ã‚‚一文字挟ã¾ã‚Œã¦ã„ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚括弧ã®é–“ã«ã‚る文字ã¯ä»¥ä¸‹ã«ç¤ºã™ãƒ–ラケット記法ã®ãŸã‚ã®ç‰¹æ®Šãªãƒ‘ターン (\fIブラケット記法パターン\fR) ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ブラケット記法ã¯ã€æ‹¬å¼§ã®é–“ã«ã‚るブラケット記法パターンãŒç¤ºã™æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ .sp 最åˆã®æ‹¬å¼§ \fB[\fR ã®ç›´å¾Œã«è¨˜å· \fB!\fR ãŒã‚ã‚‹å ´åˆã€ãƒ–ラケット記法ã«å½“ã¦ã¯ã¾ã‚‹æ–‡å­—ã¨å½“ã¦ã¯ã¾ã‚‰ãªã„文字ã¨ãŒé€†è»¢ã—ã¾ã™ (ãã—ã¦ã“ã® \fB!\fR ã¯ãƒ–ラケット記法パターンã®ä¸€éƒ¨ã¨ã¯ã¿ãªã•れã¾ã›ã‚“)。Yash ã§ã¯ \fB[\fR ã®ç›´å¾Œã« \fB^\fR ãŒã‚ã‚‹å ´åˆã‚‚åŒæ§˜ã«å½“ã¦ã¯ã¾ã‚‹æ–‡å­—ã¨å½“ã¦ã¯ã¾ã‚‰ãªã„文字ã¨ãŒé€†è»¢ã—ã¾ã™ (ãŒã€ä»–ã®ã‚·ã‚§ãƒ«ã§ã¯ \fB^\fR ã®æ‰±ã„ãŒç•°ãªã‚‹ã“ã¨ã‚‚ã‚りã¾ã™)。 .sp 最åˆã®æ‹¬å¼§ \fB[\fR ã®ç›´å¾Œ (ã‚ã‚‹ã„ã¯ä¸Šè¿°ã® \fB!\fR ã¾ãŸã¯ \fB^\fR ãŒã‚ã‚‹å ´åˆã¯ãã®ç›´å¾Œ) ã«æ‹¬å¼§ \fB]\fR ãŒã‚ã‚‹å ´åˆã¯ã€ãれã¯ãƒ–ラケット記法ã®çµ‚ã‚ã‚Šã‚’ç¤ºã™æ‹¬å¼§ã¨ã—ã¦ã§ã¯ãªãブラケット記法パターンã®ä¸€éƒ¨ã¨ã¿ãªã•れã¾ã™ã€‚ブラケット記法パターンã®è§£é‡ˆã¯ã‚¯ã‚©ãƒ¼ãƒˆã®å‡¦ç†ã®å¾Œã«è¡Œã‚れるã®ã§ã€ã‚¯ã‚©ãƒ¼ãƒˆã«ã‚ˆã£ã¦ãƒ–ãƒ©ã‚±ãƒƒãƒˆè¨˜æ³•ãƒ‘ã‚¿ãƒ¼ãƒ³å†…ã®æ–‡å­—ã‚’é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚ã›ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .sp パターンã®ä¸­ã« \fB[\fR ãŒå«ã¾ã‚Œã¦ã„ã¦ã‚‚ã€ãã‚ŒãŒæ­£ã—ã„ブラケット記法ã®å½¢å¼ã«ãªã£ã¦ã„ãªã„å ´åˆã¯ã€ãã® \fB[\fR ã¯ãƒ–ラケット記法ã§ã¯ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚ .SS "(ブラケット記法パターンã«ãŠã‘ã‚‹) é€šå¸¸ã®æ–‡å­—" .sp 以下ã«ç¤ºã™ç‰¹æ®Šãªæ„味をæŒã¤è¨˜å·ä»¥å¤–ã®æ–‡å­—ã¯ã™ã¹ã¦é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚é€šå¸¸ã®æ–‡å­—ã¯ãã®æ–‡å­—自身を表ã—ã¾ã™ã€‚ .sp 例ãˆã° \fB[abc]\fR ã¨ã„ã†ãƒ–ラケット記法㯠\fBa\fRã€\fBb\fRã€\fBc\fR ã®ã©ã‚Œã‹ã®æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚従ã£ã¦ \fBa[abc]c\fR ã¨ã„ã†ãƒ‘ターン㯠\fBaac\fRã€\fBabc\fRã€\fBacc\fR ã¨ã„ã†ä¸‰ã¤ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ (ãã—ã¦ã“ã‚Œä»¥å¤–ã®æ–‡å­—列ã«ã¯å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“)。 .SS "範囲指定" .sp 二ã¤ã®æ–‡å­— (ã¾ãŸã¯ç…§åˆã‚·ãƒ³ãƒœãƒ«) ã‚’ãƒã‚¤ãƒ•ン (\fB\-\fR) ã§ã¤ãªã„ã ã‚‚ã®ã¯\fI範囲指定\fRã¨ã¿ãªã•れã¾ã™ã€‚範囲指定ã¯ã€ãã®äºŒã¤ã®æ–‡å­—ã¨ç…§åˆé †åºä¸Šãã®é–“ã«ã‚ã‚‹å…¨ã¦ã®æ–‡å­—を表ã—ã¾ã™ã€‚\fIç…§åˆé †åº\fRã¨ã¯æ–‡å­—を辞書順ã«ä¸¦ã¹ã‚‹ãŸã‚ã«ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«å®šç¾©ã•れる文字ã®é †åºé–¢ä¿‚ã§ã™ã€‚使用中ã®ãƒ­ã‚±ãƒ¼ãƒ«ã«å®šç¾©ã•れã¦ã„ã‚‹ç…§åˆé †åºã«å¾“ã£ã¦äºŒã¤ã®æ–‡å­—ã®é–“ã«ã‚ã‚‹æ–‡å­—ãŒæ±ºã¾ã‚Šã¾ã™ã€‚ .sp ãƒã‚¤ãƒ•ンã®å¾Œã« \fB]\fR ã‚’ç½®ã„ãŸå ´åˆã¯ã€ã“ã® \fB]\fR ã¯ãƒ–ラケット記法ã®çµ‚ã‚ã‚Šã‚’ç¤ºã™æ‹¬å¼§ã¨ã¿ãªã•れã€ãƒã‚¤ãƒ•ンã¯é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚ .sp 例ãˆã° \fB[1\-5]\fR ã¨ã„ã†ãƒ–ラケット記法㯠\fB1\fRã€\fB2\fRã€\fB3\fRã€\fB4\fRã€\fB5\fR ã¨ã„ã†äº”ã¤ã®æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ .SS "ç…§åˆã‚·ãƒ³ãƒœãƒ«" .sp \fIç…§åˆã‚·ãƒ³ãƒœãƒ«\fRを用ã„ã‚‹ã“ã¨ã§è¤‡æ•°ã®æ–‡å­—ã‹ã‚‰ãªã‚‹ç…§åˆè¦ç´ ã‚’一ã¤ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãã¾ã™ã€‚(\fIç…§åˆè¦ç´ \fRã¨ã¯è¤‡æ•°ã®æ–‡å­—ã‚’ã¾ã¨ã‚ã¦ä¸€ã¤ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãるよã†ã«ã™ã‚‹ãŸã‚ã«è€ƒãˆã‚‰ã‚ŒãŸã€ã‚ˆã‚Šä¸€èˆ¬çš„ãªæ–‡å­—ã®æ¦‚念ã§ã™ã€‚パターンマッãƒãƒ³ã‚°ã«ãŠã„ã¦å…¨ã¦ã®æ–‡å­—ã¯å®Ÿéš›ã«ã¯ç…§åˆè¦ç´ ã¨ã—ã¦æ‰±ã‚れã¦ã„ã¾ã™ã€‚) ç…§åˆã‚·ãƒ³ãƒœãƒ«ã¯æ‹¬å¼§ \fB[\&. \&.]\fR ã®ä¸­ã«ç…§åˆè¦ç´ ã‚’挟んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚æ‹¬å¼§å†…ã«æ›¸ã‘ã‚‹ç…§åˆè¦ç´ ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãŠã„ã¦ç…§åˆè¦ç´ ã¨ã—ã¦ç™»éŒ²ã•れã¦ã„ã‚‹ã‚‚ã®ã«é™ã‚Šã¾ã™ã€‚ .sp 例ãˆã°å¾“æ¥ã‚¹ãƒšã‚¤ãƒ³èªžã§ã¯ 『ch〠ã¨ã„ã†äºŒæ–‡å­—ã‚’åˆã‚ã›ã¦ä¸€æ–‡å­—ã¨ã—ã¦æ‰±ã£ã¦ã„ã¾ã—ãŸã€‚ã“ã®äºŒæ–‡å­—ã®çµ„ã¿åˆã‚ã›ãŒç…§åˆè¦ç´ ã¨ã—ã¦ãƒ­ã‚±ãƒ¼ãƒ«ã«ç™»éŒ²ã•れã¦ã„ã‚‹ãªã‚‰ã°ã€\fB[[\&.ch\&.]df]\fR ã¨ã„ã†ãƒ–ラケット記法㯠\fBch\fRã€\fBd\fRã€\fBf\fR ã®ã©ã‚Œã‹ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ã‚‚ã—ã“ã“ã§ \fB[chdf]\fR ã¨ã„ã†ãƒ–ラケット記法を使ã†ã¨ã€ã“れ㯠\fBc\fRã€\fBh\fRã€\fBd\fRã€\fBf\fR ã®ã©ã‚Œã‹ã«å½“ã¦ã¯ã¾ã‚Šã€\fBch\fR ã«ã¯å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“。 .SS "等価クラス" .sp 等価クラスを用ã„ã‚‹ã“ã¨ã§ã€ã‚る文字ã¨\fI等価\fRã§ã‚ã‚‹ã¨ã¿ãªã•れる文字を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã¯æ‹¬å¼§ \fB[= =]\fR ã®ä¸­ã«æ–‡å­—を挟んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚括弧ã®é–“ã«ã¯ç…§åˆã‚·ãƒ³ãƒœãƒ«ã®ã‚ˆã†ã«è¤‡æ•°ã®æ–‡å­—ã‹ã‚‰ãªã‚‹ç…§åˆè¦ç´ ã‚’書ãã“ã¨ã‚‚ã§ãã¾ã™ (上記å‚ç…§)。等価クラスã¯ã€æ‹¬å¼§ã§æŒŸã‚“ã æ–‡å­—ãã®ã‚‚ã®ã®ä»–ã«ã€ãã®æ–‡å­—ã¨åŒã˜ç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹å…¨ã¦ã®æ–‡å­—を表ã—ã¾ã™ã€‚ã©ã®æ–‡å­—ãŒç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹ã‹ã®å®šç¾©ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¾“ã„ã¾ã™ã€‚ .sp 例ãˆã°ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãŠã„㦠a, \(`a, \('a, \(^a, \(~a, \(:a ã® 6 文字ãŒåŒã˜ç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹ã¨å®šç¾©ã•れã¦ã„ã‚‹ã¨ãã€\fB[[=a=]]\fR ã¨ã„ã†ãƒ–ラケット記法ã¯ã“れら六ã¤ã®æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚\fB[[=\(`a=]]\fR ã‚„ \fB[[=\('a=]]\fR ã‚‚åŒæ§˜ã§ã™ã€‚ .SS "文字クラス" .sp \fI文字クラス\fRã¯ç‰¹å®šã®ç¨®é¡žã®æ–‡å­—ã®é›†åˆã‚’表ã—ã¾ã™ã€‚æ–‡å­—ã‚¯ãƒ©ã‚¹ã¯æ‹¬å¼§ \fB[: :]\fR ã®é–“ã«æ–‡å­—クラスã®åå‰ã‚’囲んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚文字クラスã®åå‰ã¨ã—ã¦ã¯ã€ä»¥ä¸‹ã«æŒ™ã’ã‚‹å…±é€šã®æ–‡å­—クラスã®ä»–ã«ã€ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ã§å®šç¾©ã•れãŸç‹¬è‡ªã®æ–‡å­—クラスãŒä½¿ç”¨ã§ãã¾ã™ã€‚ã„ãšã‚Œã®æ–‡å­—クラスã®å ´åˆã‚‚ã€æ–‡å­—クラスã«ã©ã®æ–‡å­—ãŒå«ã¾ã‚Œã‚‹ã®ã‹ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ã«ãŠã‘る文字クラスã®å®šç¾©ã«å¾“ã„ã¾ã™ã€‚ .PP \fB[:lower:]\fR .RS 4 å°æ–‡å­—ã®é›†åˆ .RE .PP \fB[:upper:]\fR .RS 4 大文字ã®é›†åˆ .RE .PP \fB[:alpha:]\fR .RS 4 アルファベットã®é›†åˆ (\fB[:lower:]\fR 㨠\fB[:upper:]\fR ã‚’å«ã‚€) .RE .PP \fB[:digit:]\fR .RS 4 åé€²æ³•ã®æ•°å­—ã®é›†åˆ .RE .PP \fB[:xdigit:]\fR .RS 4 åå…­é€²æ³•ã®æ•°å­—ã®é›†åˆ .RE .PP \fB[:alnum:]\fR .RS 4 ã‚¢ãƒ«ãƒ•ã‚¡ãƒ™ãƒƒãƒˆã¨æ•°å­—ã®é›†åˆ (\fB[:alpha:]\fR 㨠\fB[:digit:]\fR ã‚’å«ã‚€) .RE .PP \fB[:blank:]\fR .RS 4 空白文字ã®é›†åˆ (改行をå«ã¾ãªã„) .RE .PP \fB[:space:]\fR .RS 4 空白文字ã®é›†åˆ (改行等をå«ã‚€) .RE .PP \fB[:punct:]\fR .RS 4 å¥èª­ç‚¹ç­‰ã®é›†åˆ .RE .PP \fB[:print:]\fR .RS 4 表示å¯èƒ½ãªæ–‡å­—ã®é›†åˆ .RE .PP \fB[:cntrl:]\fR .RS 4 制御文字ã®é›†åˆ .RE .sp 例ãˆã° \fB[[:lower:][:upper:]]\fR ã¨ã„ã†ãƒ–ラケット記法ã¯ä¸€æ–‡å­—ã®å°æ–‡å­—ã¾ãŸã¯å¤§æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ .SH "リダイレクト" .sp \fIリダイレクト\fRã¯ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ァイル記述å­ã‚’変更ã™ã‚‹æ©Ÿèƒ½ã§ã™ã€‚リダイレクトを使用ã™ã‚‹ã¨ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力や標準出力を通常ã¨ã¯ç•°ãªã‚‹ãƒ•ァイルã«ç¹‹ãŽæ›ãˆãŸçŠ¶æ…‹ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .sp リダイレクトã¯ã‚³ãƒžãƒ³ãƒ‰ (å˜ç´”コマンドã¾ãŸã¯è¤‡åˆã‚³ãƒžãƒ³ãƒ‰) ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’付ã™ã‚‹ã“ã¨ã§è¡Œã„ã¾ã™ã€‚å˜ç´”コマンドã§ã¯ (ä»–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‹ãªã„é™ã‚Š) ã©ã“ã§ã‚‚リダイレクト演算å­ã‚’ç½®ãã“ã¨ãŒã§ãã¾ã™ã€‚複åˆã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ã®æœ€å¾Œã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’付ã‘ã¾ã™ã€‚ .sp リダイレクトã¯ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒå§‹ã¾ã‚‹å‰ã«å‡¦ç†ã•れã¾ã™ã€‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆãŒã‚ã‚‹å ´åˆã¯ã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ãŒæ›¸ã„ã¦ã‚ã‚‹é †åºã§å‡¦ç†ã•れã¾ã™ã€‚オペランドãªã—ã® exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹å ´åˆã‚’除ãã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯å¯¾è±¡ã¨ãªã£ã¦ã„るコマンドã«å¯¾ã—ã¦ã®ã¿åƒãã¾ã™ã€‚ã™ãªã‚ã¡ã€å¯¾è±¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã‚‹ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã«ã‚ˆã£ã¦å¤‰æ›´ã•れãŸãƒ•ァイル記述å­ã¯å…ƒã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚ .sp リダイレクト演算å­ã¯ã€\fB<\fR ã¾ãŸã¯ \fB>\fR ã§å§‹ã¾ã‚Šã¾ã™ã€‚\fB<\fR ã§å§‹ã¾ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã¯ãƒ‡ãƒ•ォルトã§ã¯æ¨™æº–入力 (ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ 0) ã«ä½œç”¨ã—ã¾ã™ã€‚\fB>\fR ã§å§‹ã¾ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã¯ãƒ‡ãƒ•ォルトã§ã¯æ¨™æº–出力 (ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ 1) ã«ä½œç”¨ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã®ç¨®é¡žã®æ¼”ç®—å­ã§ã‚‚ã€æ¼”ç®—å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ãƒ‡ãƒ•ォルト以外ã®ãƒ•ァイル記述å­ã«ä½œç”¨ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ (ã“ã®ã¨ãæ•´æ•°ã¨æ¼”ç®—å­ã¨ã®é–“ã«ä¸€åˆ‡ç©ºç™½ãªã©ã‚’入れã¦ã¯ã„ã‘ã¾ã›ã‚“。ã¾ãŸæ•´æ•°ã‚’クォートã—ã¦ã‚‚ã„ã‘ã¾ã›ã‚“)。 .SS "ファイルã¸ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ" .sp 最もよã使ã‚れるリダイレクトã¯ã€ãƒ•ァイルã¸ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã™ã€‚ .PP 入力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ .RS 4 \fB< \fR\fB\fIトークン\fR\fR .RE .PP 出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ .RS 4 \fB> \fR\fB\fIトークン\fR\fR .sp \fB>| \fR\fB\fIトークン\fR\fR .sp \fB>> \fR\fB\fIトークン\fR\fR .RE .PP 入出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ .RS 4 \fB<> \fR\fB\fIトークン\fR\fR .RE .sp リダイレクトã«å«ã¾ã‚Œã‚‹\fIトークン\fRã¯å››ç¨®å±•é–‹ã•れã¾ã™ã€‚対話シェルã§ã¯ã•らã«ãƒ‘スå展開も行ã‚れã¾ã™ (パスå展開ã®çµæžœãŒä¸€ã¤ã®ãƒ•ァイルã§ãªã‘れã°ã‚¨ãƒ©ãƒ¼ã§ã™)。\fIトークン\fRã®å±•é–‹çµæžœãŒãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆå¯¾è±¡ã®ãƒ•ァイルåã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚ .sp 入力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–入力ãŒå¯¾è±¡ãƒ•ァイルã‹ã‚‰ã®èª­ã¿è¾¼ã¿å°‚用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルを開ãã“ã¨ãŒã§ããªã‘れã°ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ .sp 出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–出力ãŒå¯¾è±¡ãƒ•ァイルã¸ã®æ›¸ãè¾¼ã¿å°‚用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルãŒå­˜åœ¨ã—ãªã‘れã°ç©ºã®é€šå¸¸ãƒ•ァイルãŒä½œæˆã•れã¾ã™ã€‚å¯¾è±¡ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ—¢ã«ã‚ã‚‹å ´åˆã¯ãã®ãƒ•ァイルãŒé–‹ã‹ã‚Œã¾ã™ã€‚ãŸã ã—演算å­ã®ç¨®é¡žã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«æŒ™å‹•ãŒç•°ãªã‚Šã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} æ¼”ç®—å­ \fB>|\fR ã§ã¯ã€å¯¾è±¡ãƒ•ァイルãŒå­˜åœ¨ã—ãれãŒé€šå¸¸ã®ãƒ•ァイルã®å ´åˆã€ãƒ•ァイルを開ãéš›ã«ãƒ•ァイルã®å†…容を空ã«ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} æ¼”ç®—å­ \fB>\fR ã¯ã€clobber ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã‚‰ã°æ¼”ç®—å­ \fB>|\fR ã¨åŒã˜ã§ã™ã€‚ã—ã‹ã— clobber オプションãŒç„¡åйãªã‚‰ã°ã€å¯¾è±¡ãƒ•ァイルãŒå­˜åœ¨ã—ãれãŒé€šå¸¸ã®ãƒ•ァイルã®å ´åˆã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} æ¼”ç®—å­ \fB>>\fR ã§ã¯ã€ãƒ•ァイルを追記モードã§é–‹ãã¾ã™ã€‚ファイルã¸ã®æ›¸ãè¾¼ã¿ã¯å¸¸ã«ãƒ•ã‚¡ã‚¤ãƒ«ã®æœ«å°¾ã¸è¿½è¨˜ã™ã‚‹å½¢ã§è¡Œã‚れã¾ã™ã€‚ .RE .sp 入出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–入力ãŒå¯¾è±¡ãƒ•ァイルã¸ã®èª­ã¿æ›¸ã両用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルãŒå­˜åœ¨ã—ãªã‘れã°ç©ºã®é€šå¸¸ãƒ•ァイルãŒä½œæˆã•れã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBソケットリダイレクト\fR .RS 4 .sp ファイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã«ãŠã„ã¦ã€å¯¾è±¡ãƒ•ァイルå㌠\fB/dev/tcp/\fR\fB\fIホストå\fR\fR\fB/\fR\fB\fIãƒãƒ¼ãƒˆ\fR\fR ã¾ãŸã¯ \fB/dev/udp/\fR\fB\fIホストå\fR\fR\fB/\fR\fB\fIãƒãƒ¼ãƒˆ\fR\fR ã®å½¢å¼ã‚’ã—ã¦ã„ã¦ã€ãã®ãƒ•ァイルを開ãã“ã¨ãŒã§ããªã„å ´åˆã€ãƒ•ァイルåã«å«ã¾ã‚Œã‚‹\fIホストå\fRã¨\fIãƒãƒ¼ãƒˆ\fRã«å¯¾ã—ã¦é€šä¿¡ã‚’行ã†ãŸã‚ã®ã‚½ã‚±ãƒƒãƒˆãŒé–‹ã‹ã‚Œã¾ã™ã€‚ .sp \fB/dev/tcp/\fR\fB\fIホストå\fR\fR\fB/\fR\fB\fIãƒãƒ¼ãƒˆ\fR\fR ãŒå¯¾è±¡ã®å ´åˆã¯ã‚¹ãƒˆãƒªãƒ¼ãƒ é€šä¿¡ã‚½ã‚±ãƒƒãƒˆã‚’ã€\fB/dev/udp/\fR\fB\fIホストå\fR\fR\fB/\fR\fB\fIãƒãƒ¼ãƒˆ\fR\fR ãŒå¯¾è±¡ã®å ´åˆã¯ãƒ‡ãƒ¼ã‚¿ã‚°ãƒ©ãƒ é€šä¿¡ã‚½ã‚±ãƒƒãƒˆã‚’é–‹ãã¾ã™ã€‚典型的ã«ã¯ã€å‰è€…㯠TCP ã‚’ã€å¾Œè€…㯠UDP をプロトコルã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚ .sp ソケットリダイレクトã¯ã©ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’使ã£ã¦ã„ã‚‹ã‹ã«ã‹ã‹ã‚らãšå¸¸ã«èª­ã¿æ›¸ã両用ã®ãƒ•ァイル記述å­ã‚’é–‹ãã¾ã™ã€‚ .sp ソケットリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚ãŸã ã—ã€bash ã«ã‚‚åŒæ§˜ã®æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚ .RE .SS "ファイル記述å­ã®è¤‡è£½" .sp ファイル記述å­ã®è¤‡è£½ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯ã€æ—¢å­˜ã®ãƒ•ァイル記述å­ã‚’コピーã—ãŸã‚Šé–‰ã˜ãŸã‚Šã§ãã¾ã™ã€‚ .PP ファイル記述å­ã®è¤‡è£½ .RS 4 \fB<& \fR\fB\fIトークン\fR\fR .sp \fB>& \fR\fB\fIトークン\fR\fR .RE .sp \fIトークン\fRã¯ãƒ•ァイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ãŒã€ã“れã¯ãƒ•ァイルåã§ã¯ãªãファイル記述å­ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€\fIトークン\fRã®å±•é–‹çµæžœã¯ãƒ•ァイル記述å­ã‚’表ã™éžè² æ•´æ•°ã¨ãªã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ .sp æ¼”ç®—å­ \fB<&\fR ã¯\fIトークン\fRã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ã‚’標準入力ã«è¤‡è£½ã—ã¾ã™ã€‚æ¼”ç®—å­ \fB>&\fR ã¯\fIトークン\fRã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ã‚’標準出力ã«è¤‡è£½ã—ã¾ã™ã€‚演算å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ã€è¤‡è£½å…ˆã®ãƒ•ァイル記述å­ã‚’変更ã§ãã¾ã™ã€‚ .sp \fIトークン\fRã®å±•é–‹çµæžœãŒéžè² æ•´æ•°ã§ã¯ãªããƒã‚¤ãƒ•ン (\fB\-\fR) ã¨ãªã£ãŸå ´åˆã¯ã€ãƒ•ァイル記述å­ã‚’複製ã™ã‚‹ä»£ã‚りã«é–‰ã˜ã¾ã™ã€‚æ¼”ç®—å­ \fB<&\fR ã§ã¯æ¨™æº–入力ãŒã€æ¼”ç®—å­ \fB>&\fR ã§ã¯æ¨™æº–出力ãŒãƒ‡ãƒ•ォルトã§é–‰ã˜ã‚‰ã‚Œã¾ã™ãŒã€æ¼”ç®—å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ã€é–‰ã˜ã‚‹ãƒ•ァイル記述å­ã‚’変更ã§ãã¾ã™ã€‚ .sp POSIX 準拠モードã§ã¯ã€\fB<&\fR ã§è¤‡è£½ã™ã‚‹ãƒ•ァイル記述å­ã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ãªã‘れã°ãªã‚‰ãšã€\fB>&\fR ã§è¤‡è£½ã™ã‚‹ãƒ•ァイル記述å­ã¯æ›¸ãè¾¼ã¿å¯èƒ½ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。 .SS "ヒアドキュメントã¨ãƒ’アストリング" .sp \fIヒアドキュメント\fR・\fIヒアストリング\fRを使ã†ã¨ã‚³ãƒžãƒ³ãƒ‰ã«ç›´æŽ¥ãƒ†ã‚­ã‚¹ãƒˆã‚’渡ã™ã“ã¨ãŒã§ãã¾ã™ã€‚ .PP ヒアドキュメント .RS 4 \fB<< \fR\fB\fIトークン\fR\fR .sp \fB<<\- \fR\fB\fIトークン\fR\fR .RE .PP ヒアストリング .RS 4 \fB<<< \fR\fB\fIトークン\fR\fR .RE .sp ヒアドキュメント・ヒアストリングã§ã¯ã€æ¨™æº–入力ãŒãƒ’アドキュメント・ヒアストリングã®å†…容を読ã¿è¾¼ã¿å¯èƒ½ãªãƒ•ァイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ .sp ãƒ’ã‚¢ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆæ¼”ç®—å­ (\fB<<\fR ã¾ãŸã¯ \fB<<\-\fR) ãŒã‚³ãƒžãƒ³ãƒ‰ä¸­ã«ç¾ã‚Œã‚‹ã¨ã€ãã®æ¼”ç®—å­ã®ã‚ã‚‹è¡Œã®æ¬¡ã®è¡Œã‹ã‚‰ã¯ãƒ’アドキュメントã®å†…容ã¨ã¿ãªã•れã¾ã™ã€‚ヒアドキュメントã®å†…容ã®éƒ¨åˆ†ã¯ã€ã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦ã¯è§£é‡ˆã•れã¾ã›ã‚“。演算å­ã®å¾Œã«ã‚ã‚‹\fIトークン\fRã¯ãƒ’アドキュメントã®å†…容ã®çµ‚ã‚りを表ã—ã¾ã™ã€‚(\fIトークン\fRã§ã¯å±•é–‹ã¯è¡Œã‚れã¾ã›ã‚“ãŒã€ã‚¯ã‚©ãƒ¼ãƒˆã¯èªè­˜ã•れã¾ã™ã€‚) 演算å­ã®ã‚る行より後ã®è¡Œã§\fIトークン\fRã ã‘ã‹ã‚‰ãªã‚‹è¡ŒãŒç¾ã‚ŒãŸæ™‚点ã§ãƒ’アドキュメントã®å†…容ã¯çµ‚ã‚りã ã¨åˆ¤æ–­ã•れã¾ã™ã€‚終ã‚りを表ã™è¡Œã¯ãƒ’アドキュメントã®å†…容ã«ã¯å«ã¾ã‚Œã¾ã›ã‚“ã€‚æ¼”ç®—å­ \fB<<\-\fR を使ã£ã¦ã„ã‚‹å ´åˆã¯ã€ãƒ’アドキュメントã®å†…容ã®å„行頭ã«ã‚るタブã¯ã™ã¹ã¦å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®ã¨ã\fIトークン\fRã®å‰ã«ã‚¿ãƒ–ãŒã‚ã£ã¦ã‚‚ (ãã®è¡Œã«ä»–ã®ä½™è¨ˆãªæ–‡å­—ãŒãªã‘れã°) ヒアドキュメントã®å†…容ã®çµ‚ã‚りã¨ã—ã¦èªè­˜ã—ã¾ã™ã€‚ .sp 一行ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ãŒã‚ã‚‹å ´åˆã¯ã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¯é †ç•ªã«å‡¦ç†ã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã®è¡Œã®æ¬¡ã®è¡Œã‹ã‚‰ã¯æœ€åˆã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¨ã—ã¦æ‰±ã‚れã€ãã®å†…容ãŒçµ‚ã‚ã£ãŸã‚‰ã€ãã®æ¬¡ã®è¡Œã‹ã‚‰ã¯æ¬¡ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚最後ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ãŒçµ‚ã‚ã£ãŸã‚‰ã€ãã®æ¬¡ã®è¡Œã‹ã‚‰ã¯å†ã³ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ .sp リダイレクトã®å†…容ã¯åŸºæœ¬çš„ã«å˜ãªã‚‹æ–‡å­—列ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚内容ã«å«ã¾ã‚Œã‚‹ç©ºç™½ã‚„タブã€ãã®ä»–ã®è¨˜å·ã¯ãã®ã¾ã¾ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ãŸã ã—ã€\fIトークン\fRãŒå…¨ãクォートã•れã¦ã„ãªã„å ´åˆã¯ã€ãƒ’アドキュメントã®å†…容ã¯ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ã•れã€\fB$\fR, \fB`\fR, \fB"\fR, \fB\e\fR ã®ç›´å‰ã«ã‚ã‚‹å ´åˆãŠã‚ˆã³è¡Œã®é€£çµã‚’行ã†å ´åˆã«ã®ã¿ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’引用符ã¨ã—ã¦æ‰±ãˆã¾ã™ã€‚ .sp ヒアストリングã§ã¯ã€æ¼”ç®—å­ã®å¾Œã«ã‚ã‚‹\fIトークン\fRã¯ãƒ•ァイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ã€‚ã“ã®å±•é–‹çµæžœãŒãƒ’アストリングã®å†…容ã¨ãªã‚Šã¾ã™ã€‚ãŸã ã—ヒアストリングã®å†…å®¹ã®æœ«å°¾ã«ã¯è‡ªå‹•çš„ã«æ”¹è¡ŒãŒä»˜ãã¾ã™ã€‚ .sp ヒアストリング㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ãŒã€bash, ksh, zsh ã«ã‚‚åŒæ§˜ã®æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚ .SS "パイプリダイレクト" .sp \fIパイプリダイレクト\fRを用ã„ã‚‹ã¨ãƒ—ロセス間通信ã«åˆ©ç”¨å¯èƒ½ãªãƒ‘イプを開ãã“ã¨ãŒã§ãã¾ã™ã€‚ .PP パイプリダイレクト .RS 4 \fB>>| \fR\fB\fIトークン\fR\fR .RE .sp \fIトークン\fRã¯ãƒ•ァイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ãŒã€ã“れã¯ãƒ•ァイルåã§ã¯ãªãファイル記述å­ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€\fIトークン\fRã®å±•é–‹çµæžœã¯ãƒ•ァイル記述å­ã‚’表ã™éžè² æ•´æ•°ã¨ãªã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ .sp パイプリダイレクトã¯ãƒ‘イプを開ãã¾ã™ã€‚標準出力 (æ¼”ç®—å­ \fB>>|\fR ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã—ã¦ã„ã‚‹å ´åˆã¯ãã®å€¤ã®ãƒ•ァイル記述å­) ãŒãƒ‘ã‚¤ãƒ—ã«æ›¸ãã“ã‚€ãŸã‚ã®ãƒ•ァイル記述å­ã«ãªã‚Šã¾ã™ã€‚ã¾ãŸ\fIトークン\fRã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ãŒãƒ‘イプã‹ã‚‰èª­ã¿è¾¼ã‚€ãŸã‚ã®ãƒ•ァイル記述å­ã«ãªã‚Šã¾ã™ã€‚ .sp パイプリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚ .SS "プロセスリダイレクト" .sp プロセスリダイレクトを用ã„ã‚‹ã¨åˆ¥ã®ã‚³ãƒžãƒ³ãƒ‰ã®å…¥åŠ›ã¾ãŸã¯å‡ºåŠ›ã‚’å—ã‘æ¸¡ã›ã‚‹ãƒ‘イプを開ãã“ã¨ãŒã§ãã¾ã™ã€‚ .PP プロセスリダイレクト .RS 4 \fB<(\fR\fB\fIサブコマンド\fR\fR\fB\&...)\fR .sp \fB>(\fR\fB\fIサブコマンド\fR\fR\fB\&...)\fR .RE .sp プロセスリダイレクトã§ã¯ã€\fIサブコマンド\fRãŒã‚µãƒ–シェルã§å®Ÿè¡Œã•れã¾ã™ã€‚ã“ã®ã¨ãã€\fB<(\fR\fB\fIサブコマンド\fR\fR\fB\&...)\fR ã®å½¢å¼ã®ãƒ—ロセスリダイレクトã§ã¯ã€\fIサブコマンド\fRã®æ¨™æº–出力ãŒã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å…¥åŠ›ã«æ¸¡ã‚‹ã‚ˆã†ãƒ‘イプãŒé–‹ã‹ã‚Œã¾ã™ã€‚\fB>(\fR\fB\fIサブコマンド\fR\fR\fB\&...)\fR ã®å½¢å¼ã®ãƒ—ロセスリダイレクトã§ã¯ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ãŒ\fIサブコマンド\fRã®æ¨™æº–å…¥åŠ›ã«æ¸¡ã‚‹ã‚ˆã†ãƒ‘イプãŒé–‹ã‹ã‚Œã¾ã™ã€‚ .sp プロセスリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚Bash 㨠zsh ã«ã¯ãƒ—ロセスリダイレクトã¨åŒæ§˜ã®æ§‹æ–‡ã‚’用ã„るプロセス置æ›ã¨ã„ã†æ©Ÿèƒ½ãŒã‚りã¾ã™ãŒã€ãƒ—ロセスリダイレクトã¨ãƒ—ロセス置æ›ã®æŒ™å‹•ã¯ç•°ãªã£ã¦ãŠã‚Šã€äº’æ›æ€§ã¯ã‚りã¾ã›ã‚“。 .SH "コマンドã®å®Ÿè¡Œã¨ãã®ç’°å¢ƒ" .sp ã“ã®ç¯€ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ãŒã©ã®ã‚ˆã†ã«å®Ÿè¡Œã•れるã‹ã‚’説明ã—ã¾ã™ã€‚ .SS "å˜ç´”コマンドã®å®Ÿè¡Œ" .sp å˜ç´”コマンドã¯ä»¥ä¸‹ã®æ‰‹é †ã«å¾“ã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} å˜ç´”コマンドã«å«ã¾ã‚Œã‚‹ã€å¤‰æ•°ä»£å…¥ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆä»¥å¤–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’å…¨ã¦å±•é–‹ã—ã¾ã™ã€‚展開エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。 以下ã€å±•é–‹ã®çµæžœå¾—ã‚‰ã‚ŒãŸæœ€åˆã®å˜èªžã‚’\fIコマンドå\fRã€ãれ以外ã®å˜èªžã‚’\fIコマンド引数\fRã¨å‘¼ã³ã¾ã™ã€‚得られãŸå˜èªžãŒä¸€ã¤ã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ã¯å­˜åœ¨ã—ã¾ã›ã‚“。得られãŸå˜èªžãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰åもコマンド引数も存在ã—ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} å˜ç´”コマンドã«å¯¾ã™ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚’実行ã—ã¾ã™ã€‚リダイレクトã«å«ã¾ã‚Œã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹ã¯ã“ã“ã§è¡Œã‚れã¾ã™ã€‚リダイレクトエラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。リダイレクトã«å«ã¾ã‚Œã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•開時ã®ã‚¨ãƒ©ãƒ¼ã¯ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã«å«ã¾ã‚Œã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} å˜ç´”コマンドã«å«ã¾ã‚Œã‚‹å¤‰æ•°ä»£å…¥ã‚’実行ã—ã¾ã™ (é…列ã®ä»£å…¥ã‚’å«ã‚€)。ãれãžã‚Œã®å¤‰æ•°ä»£å…¥ã«ã¤ã„ã¦ã€å€¤ãŒå±•é–‹ã•ã‚Œã€æŒ‡å®šã•れãŸåå‰ã®å¤‰æ•°ã«ä»£å…¥ã•れã¾ã™ã€‚代入エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。代入ã•れる値ã®å±•開時ã®ã‚¨ãƒ©ãƒ¼ã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ã«å«ã¾ã‚Œã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンドåãŒå­˜åœ¨ã—ãªã„ã‹ã€ã‚ã‚‹ã„ã¯ã‚³ãƒžãƒ³ãƒ‰åãŒç‰¹æ®Šçµ„è¾¼ã¿ã¾ãŸã¯é–¢æ•°ã‚’示ã—ã¦ã„ã‚‹å ´åˆã¯ã€å¤‰æ•°ä»£å…¥ã¯æ’ä¹…çš„ã§ã™ã€‚ã™ãªã‚ã¡ã€ä»£å…¥ã®çµæžœã¯ã“ã®å˜ç´”コマンドã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã‚‚ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãれ以外ã®å ´åˆã¯ã€å¤‰æ•°ä»£å…¥ã¯ä¸€æ™‚çš„ã§ã™ã€‚ã™ãªã‚ã¡ã€ä»£å…¥ã®åŠ¹æžœã¯ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œä¸­ã®ã¿æœ‰åйã§ã€å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã«ä»£å…¥ã¯å–り消ã•れã¾ã™ã€‚ .RE .sp コマンドåãŒæŒ‡å®šã•れãŸå ´åˆã¾ãŸã¯ all\-export ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªå ´åˆã¯ã€ä»£å…¥ã•れる変数ã¯è‡ªå‹•çš„ã«ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} コマンドåãŒå­˜åœ¨ã—ãªã„å ´åˆã¯ã€å˜ç´”コマンドã®å®Ÿè¡Œã¯ã“れã§çµ‚ã‚りã§ã™ã€‚å˜ç´”コマンドã®çµ‚了ステータス㯠0 ã«ãªã‚Šã¾ã™ (ãŸã ã—å˜ç´”コマンド実行中ã«ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒè¡Œã‚ã‚ŒãŸæ™‚ã¯ã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒå˜ç´”コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™)。 .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} 後述ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®ä»•æ–¹ã«å¾“ã£ã¦å®Ÿè¡Œã™ã¹ãコマンドを特定ã—ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンドãŒå¤–部コマンドã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚µãƒ–シェル㧠exec システムコールを呼ã³å‡ºã™ã“ã¨ã«ã‚ˆã‚Šå®Ÿè¡Œã•れã¾ã™ã€‚コマンドåã¨ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ãŒèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ã¾ãŸã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã¨ãªã£ã¦ã„る変数ãŒç’°å¢ƒå¤‰æ•°ã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンドãŒçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰å¼•数を引数ã¨ã—ã¦çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンドãŒé–¢æ•°ã®å ´åˆã¯ã€ãã®é–¢æ•°ã®å†…容ãŒå®Ÿè¡Œã•れã¾ã™ã€‚コマンド引数ãŒé–¢æ•°ã®å¼•æ•°ã¨ã—ã¦æ¸¡ã•れã¾ã™ã€‚ .RE .sp 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒã“ã®å˜ç´”コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œã•れãšçµ‚了ステータス㯠127 ã«ãªã‚Šã¾ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã£ãŸãŒèµ·å‹•ã«å¤±æ•—ã—ãŸå ´åˆã¯ã€çµ‚了ステータス㯠126 ã«ãªã‚Šã¾ã™ã€‚コマンドãŒèµ·å‹•ã•れãŸãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã¯ã€çµ‚了ステータスã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã®ç•ªå·ã« 384 ã‚’è¶³ã—ãŸæ•°ã«ãªã‚Šã¾ã™ã€‚ .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB注記\fR .ps -1 .br POSIX ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã®çµ‚了ステータス㯠128 より大ããªæ•°ã¨ã—ã‹å®šã‚られã¦ã„ãªã„ã®ã§ã€yash 以外ã®ã‚·ã‚§ãƒ«ã§ã¯çµ‚了ステータスãŒç•°ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ .sp .5v .RE éž POSIX 準拠モードã«ãŠã„ã¦ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ \fBeval \-i \-\- "${COMMAND_NOT_FOUND_HANDLER\-}"\fR ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãŸã ã—ã“ã®ã¨ãä½ç½®ãƒ‘ラメータã¯ã‚³ãƒžãƒ³ãƒ‰åã¨ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ã«ä¸€æ™‚çš„ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ã¾ãŸã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œä¸­ã«å®šç¾©ã•れãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了時ã«å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œæ™‚ã«ã¯ \fBHANDLED\fR ローカル変数ãŒç©ºæ–‡å­—列を値ã¨ã—ã¦ã‚らã‹ã˜ã‚定義ã•れã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œå¾Œã«ã“ã®å¤‰æ•°ã®å€¤ãŒç©ºæ–‡å­—列ã§ãªããªã£ã¦ã„れã°ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒã“ã®å˜ç´”コマンドã®çµ‚了ステータスã¨ãªã‚Šã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã“ã¨ã¯ã‚¨ãƒ©ãƒ¼ã¨ã¯ã¿ãªã•れã¾ã›ã‚“。 .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢\fR .RS 4 .sp å˜ç´”コマンドã§å®Ÿè¡Œã™ã¹ãコマンドã¯ã€å±•é–‹ã§å¾—られãŸã‚³ãƒžãƒ³ãƒ‰åã«åŸºã¥ã„ã¦ä»¥ä¸‹ã®æ‰‹é †ã§ç‰¹å®šã•れã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} コマンドåã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\fB/\fR) ãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã¯ã€ãれãŒå®Ÿè¡Œã™ã¹ã外部コマンドã¸ã®ãƒ‘スåã§ã‚ã‚‹ã¨ç‰¹å®šã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} コマンドåãŒç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} コマンドåã¨åŒã˜åå‰ã®é–¢æ•°ãŒå­˜åœ¨ã™ã‚Œã°ã€ãã®é–¢æ•°ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} コマンドåãŒæº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} コマンドåãŒé€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚(POSIX 準拠モードã®ã¨ãを除ã) .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} \fBPATH\fR 変数ã®å€¤ã«å¾“ã£ã¦ã€å®Ÿè¡Œã™ã¹ã外部コマンドを検索ã—ãã®ãƒ‘スåを特定ã—ã¾ã™ã€‚ .sp \fBPATH\fR 変数ã®å€¤ã¯ã€ã„ãã¤ã‹ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スåをコロン (\fB:\fR) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ (空ã®ãƒ‘スåã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™)。ãれらã®å„ディレクトリã«ã¤ã„ã¦é †ã«ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ä¸­ã«ã‚³ãƒžãƒ³ãƒ‰åã¨åŒã˜åå‰ã®å®Ÿè¡Œå¯èƒ½ãªé€šå¸¸ã®ãƒ•ァイルãŒã‚ã‚‹ã‹èª¿æŸ»ã—ã¾ã™ã€‚ãã®ã‚ˆã†ãªãƒ•ァイルãŒã‚れã°ã€ãã®ãƒ•ァイルãŒå®Ÿè¡Œã™ã¹ã外部コマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ (ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰åã¨åŒã˜åå‰ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒã‚れã°ã€ä»£ã‚りã«ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™)。ã©ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã‚‚ãã®ã‚ˆã†ãªãƒ•ァイルãŒè¦‹ã¤ã‹ã‚‰ãªã‘れã°ã€å®Ÿè¡Œã™ã¹ãコマンドã¯è¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚ .RE .sp å¤–éƒ¨ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ãŒæˆåŠŸã—パスåãŒç‰¹å®šã§ããŸå ´åˆã€ãã®ãƒ‘スåãŒçµ¶å¯¾ãƒ‘スãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ‘スåを記憶ã—ã€å†ã³åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹éš›ã«æ¤œç´¢ã®æ‰‹é–“ã‚’çœãã¾ã™ã€‚ãŸã ã—ã€å†ã³ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—よã†ã¨ã—ãŸéš›ã«ã€è¨˜æ†¶ã—ã¦ã„るパスåã«å®Ÿè¡Œå¯èƒ½ãƒ•ァイルãŒè¦‹å½“ãŸã‚‰ãªã„å ´åˆã¯ã€æ¤œç´¢ã‚’やり直ã—ã¾ã™ã€‚シェルãŒè¨˜æ†¶ã—ã¦ã„るパスå㯠hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç®¡ç†ã§ãã¾ã™ã€‚ .RE .SS "シェルã®çµ‚了" .sp シェルã¯ã€å…¥åŠ›ãŒçµ‚ã‚りã«é”ã—ã¦å…¨ã¦ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’解釈・実行ã—終ãˆãŸæ™‚ã‚„ã€exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ããªã©ã«çµ‚了ã—ã¾ã™ã€‚シェルã®çµ‚了ステータスã¯ã€ã‚·ã‚§ãƒ«ãŒæœ€å¾Œã«å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを 256 ã§å‰²ã£ãŸä½™ã‚Šã§ã™ (一ã¤ã‚‚コマンドを実行ã—ãªã‹ã£ãŸã¨ã㯠0)。 .sp Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚·ã‚§ãƒ«çµ‚了時ã®ãƒãƒ³ãƒ‰ãƒ©ãŒç™»éŒ²ã•れã¦ã„ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ãŒçµ‚了ã™ã‚‹ç›´å‰ã«ãã®ãƒãƒ³ãƒ‰ãƒ©ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãŸã ã—ã“ã®ãƒãƒ³ãƒ‰ãƒ©å†…ã§å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®çµ‚了ステータスã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。 .sp 対話モードã§ãªã„シェルã®å®Ÿè¡Œä¸­ã«ä¸‹è¨˜ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ã“ã®ã¨ãシェルã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 文法エラーã®ãŸã‚コマンドを解釈ã§ããªã„ã¨ã (シェルã®åˆæœŸåŒ–中を除ã) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} POSIX 準拠モードã§ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹ã¨ã .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} POSIX 準拠モードã§ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã—ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã¾ãŸã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸã¨ã .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 展開エラーãŒç™ºç”Ÿã—ãŸã¨ã (シェルã®åˆæœŸåŒ–中を除ã) .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB注記\fR .ps -1 .br .sp Yash ã¯ãã†ã§ã¯ã‚りã¾ã›ã‚“ãŒã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ãŠã„ã¦å®Ÿè¡Œã™ã¹ãコマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã«ç›´ã¡ã«çµ‚了ã™ã‚‹ã‚ˆã†ãªã‚·ã‚§ãƒ«ã‚‚ã‚りã¾ã™ã€‚ .sp .5v .RE .SS "関数" .sp \fI関数\fRã¯ä¸€ã¤ã®è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã‚’å˜ç´”コマンドã®ã‚ˆã†ã«å‘¼ã³å‡ºã›ã‚‹ã‚ˆã†ã«ã™ã‚‹æ©Ÿæ§‹ã§ã™ã€‚関数ã¯é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã«ã‚ˆã£ã¦å®šç¾©ã§ãã€å˜ç´”コマンドã«ã‚ˆã£ã¦å®Ÿè¡Œã§ãã¾ã™ã€‚関数を削除ã™ã‚‹ã«ã¯ unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã„ã¾ã™ã€‚ .sp Yash ã«ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰å®šç¾©ã•れã¦ã„る関数ã¯ä¸€ã¤ã‚‚ã‚りã¾ã›ã‚“。 .sp 関数ã®å®Ÿè¡Œã¯ã€é–¢æ•°ã®å†…容ã§ã‚る複åˆã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦è¡Œã‚れã¾ã™ã€‚関数ã®å®Ÿè¡Œä¸­ã¯ã€é–¢æ•°ã®å¼•æ•°ãŒä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚ãれã¾ã§ã®ä½ç½®ãƒ‘ラメータã¯ä¸€æ™‚çš„ã«ä½¿ãˆãªããªã‚Šã¾ã™ãŒé–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸæ™‚ã«å…ƒã®ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã«æˆ»ã‚Šã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBローカル変数\fR .RS 4 .sp \fIローカル変数\fRã¨ã¯ã€é–¢æ•°ã®å®Ÿè¡Œä¸­ã«ã ã‘有効ãªä¸€æ™‚çš„ãªå¤‰æ•°ã§ã™ã€‚ローカル変数㯠typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã£ã¦ä½œã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚関数ã®å®Ÿè¡Œä¸­ã«ä½œã‚‰ã‚ŒãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸæ™‚ã«å‰Šé™¤ã•れã€ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’作るå‰ã®å…ƒã®å¤‰æ•°ã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚ .sp 関数内ã§å®šç¾©ã—ãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯ã€é–¢æ•°ã®å®Ÿè¡Œã«å…ˆç«‹ã£ã¦å®šç¾©ã—ã¦ã‚ã£ãŸåŒåã®ä»–ã®å¤‰æ•°ã‚’\fI隠蔽\fRã—ã¾ã™ã€‚隠蔽ã•れãŸå¤‰æ•°ã¯ã€é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ã¦ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒãªããªã‚‹ã¾ã§ä½¿ãˆãªããªã‚Šã¾ã™ã€‚ .sp 関数ã®å®Ÿè¡Œä¸­ã§ãªã„ã¨ãã«ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’作るã“ã¨ã¯ã§ãã¾ã›ã‚“。ローカル変数を作ã‚ã†ã¨ã—ã¦ã‚‚ã€é€šå¸¸ã®å¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚ .RE .SS "コマンドã®å®Ÿè¡Œç’°å¢ƒ" .sp シェルã¯å®Ÿè¡Œæ™‚ã«ä»¥ä¸‹ã®æƒ…å ±ã‚’ä¿æŒã—ã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 作業ディレクトリ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} é–‹ã„ã¦ã„ã‚‹ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ファイル作æˆãƒžã‚¹ã‚¯ (umask) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} å—ä¿¡æ™‚ã®æŒ™å‹•㌠『無視〠ã«è¨­å®šã•れãŸã‚·ã‚°ãƒŠãƒ«ã®é›†åˆ (trap) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 環境変数 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™ (ulimit) .RE .sp ã“ã‚Œã‚‰ã®æƒ…å ±ã¯ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã«å…ƒã®ãƒ—ログラムã‹ã‚‰ã‚·ã‚§ãƒ«ã«å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚ãã—ã¦ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å¤–部コマンドやサブシェルã«ã‚‚シェルã‹ã‚‰å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚ .sp ã“ã‚Œã‚‰ã®æƒ…å ±ã¯æ‰€å®šã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ç­‰ã‚’使ã£ã¦å¤‰æ›´å¯èƒ½ã§ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBサブシェル\fR .RS 4 .sp \fIサブシェル\fRã¯ã€å®Ÿè¡Œä¸­ã®ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã®ã‚³ãƒ”ーã§ã™ã€‚ã‚µãƒ–ã‚·ã‚§ãƒ«ã¯æ‹¬å¼§ \fB( )\fR ã§å›²ã‚“ã ã‚°ãƒ«ãƒ¼ãƒ”ングやパイプラインã§ä½¿ã‚れã¾ã™ã€‚ .sp サブシェルã¯ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã®ã‚³ãƒ”ーã§ã‚ã‚‹ãŸã‚ã€ä¸Šè¨˜ã®æƒ…å ±ã®ä»–ã«ã‚·ã‚§ãƒ«ã§å®šç¾©ã•れãŸé–¢æ•°ã‚„エイリアスãªã©ã®æƒ…報も元ã®ã‚·ã‚§ãƒ«ã‹ã‚‰å—ã‘ç¶™ãŽã¾ã™ã€‚ãŸã ã—〠.sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç™»éŒ²ã—ãŸã‚·ã‚°ãƒŠãƒ«ãƒãƒ³ãƒ‰ãƒ©ã¯ã€(å—ä¿¡æ™‚ã®æŒ™å‹•㌠『無視〠ã®ã‚‚ã®ã‚’除ã) サブシェルã§ã¯ã™ã¹ã¦è§£é™¤ã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} サブシェルã§ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã¨ã‚¸ãƒ§ãƒ–制御ã¯è§£é™¤ã•れã€å…ƒã®ã‚·ã‚§ãƒ«ã®ã‚¸ãƒ§ãƒ–ã®æƒ…å ±ã¯å—ã‘ç¶™ãŒã‚Œã¾ã›ã‚“。 .RE .sp サブシェルã¯å…ƒã®ã‚·ã‚§ãƒ«ã¨ã¯ç‹¬ç«‹ã—ã¦ã„ã‚‹ãŸã‚ã€ã‚µãƒ–シェルã§ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å¤‰æ›´ã‚„変数代入ã¯å…ƒã®ã‚·ã‚§ãƒ«ã«å½±éŸ¿ã—ã¾ã›ã‚“。 .RE .SH "対話モード" .sp \fI対話モード\fRã¯ã€åˆ©ç”¨è€…ãŒç›´æŽ¥ã‚·ã‚§ãƒ«ã‚’æ“作ã™ã‚‹ã“ã¨ã‚’æ„図ã—ãŸãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚シェルã®èµ·å‹•時㫠\fB\-i\fR オプションを指定ã—ãŸå ´åˆ (ãã®ä»–å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åйã«ãªã‚‹æ¡ä»¶ãŒæº€ãŸã•れã¦ã„ã‚‹å ´åˆ)ã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚シェルãŒèµ·å‹•ã—ãŸå¾Œã¯ã€ãã®ã‚·ã‚§ãƒ«ã®å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚ªãƒ³ãƒ»ã‚ªãƒ•を切り替ãˆã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .sp å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åŠ¹ãªæ™‚\&...\&... .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シェルã®åˆæœŸåŒ–時ã«åˆæœŸåŒ–スクリプトを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンドを読ã¿è¾¼ã‚€éš›ã«ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã‚’行ã„ã€ãƒ—ロンプトを表示ã—ã¾ã™ã€‚ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйãªã‚‰ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚‚è¡¨ç¤ºã—ã¾ã™ã€‚端末ã®ç¨®é¡žã«ã‚ˆã£ã¦ã¯è¡Œç·¨é›†ãŒä½¿ãˆã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯è‡ªå‹•çš„ã«ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«ç™»éŒ²ã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒ SIGINT/SIGPIPE 以外ã®ã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸã¨ãã€ã‚·ã‚§ãƒ«ã¯ãã®ã“ã¨ã‚’示ã™è­¦å‘Šãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ファイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å¯¾è±¡ãƒ•ァイルを指示ã™ã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã«å¯¾ã—ã¦ãƒ‘スå展開を行ã„ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れã¾ã›ã‚“。(POSIX 準拠モードã®ã¿) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚³ãƒžãƒ³ãƒ‰è§£é‡ˆãƒ»å®Ÿè¡Œæ™‚ã«æ–‡æ³•エラーや展開エラーãŒç™ºç”Ÿã—ã¦ã‚‚シェルã¯çµ‚了ã—ã¾ã›ã‚“。(シェルã®çµ‚了をå‚ç…§) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} SIGINT, SIGTERM, SIGQUIT シグナルをå—ã‘ã¦ã‚‚ã€ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シグナルå—ä¿¡æ™‚ã®æŒ™å‹•ãŒã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰ 『無視〠ã«è¨­å®šã•れã¦ã„ã¦ã‚‚ trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚·ã‚°ãƒŠãƒ«å—ä¿¡æ™‚ã®æŒ™å‹•を変更ã§ãã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 特殊パラメータ\fB\-\fR ã®å€¤ã« \fBi\fR ãŒå«ã¾ã‚Œã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シェル実行中㫠\fBLC_CTYPE\fR 変数ã®å€¤ãŒå¤‰ã‚ã£ãŸæ™‚ã€ãれを直ã¡ã«ã‚·ã‚§ãƒ«ã®ãƒ­ã‚±ãƒ¼ãƒ«æƒ…å ±ã«å映ã—ã¾ã™ã€‚(POSIX 準拠モードを除ã) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Exec オプションãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚コマンドを実行ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Ignore\-eof オプションãŒåŠ¹æžœã‚’ç™ºæ®ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚·ã‚§ãƒ«ã‚’終了ã—よã†ã¨ã—ãŸæ™‚ã€åœæ­¢ã—ã¦ã„るジョブãŒã‚れã°ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã¦ã™ãã«ã¯çµ‚了ã—ã¾ã›ã‚“。ã“ã®ã¨ãã¯ç¶šã‘ã–ã¾ã«ã‚‚ã†ä¸€åº¦ exit コマンドを実行ã™ã‚‹ã¨æœ¬å½“ã«ã‚·ã‚§ãƒ«ã‚’終了ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚シェルã¸ã®å…¥åŠ›ãŒçµ‚ã‚りã«é”ã—ãŸå ´åˆã‚‚åŒæ§˜ã§ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Suspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚·ã‚§ãƒ«ã‚’åœæ­¢ã•ã›ã‚ˆã†ã¨ã—ãŸæ™‚ã€ã‚·ã‚§ãƒ«ãŒã‚»ãƒƒã‚·ãƒ§ãƒ³ãƒªãƒ¼ãƒ€ãƒ¼ãªã‚‰ã‚¨ãƒ©ãƒ¼ã‚’出力ã—ã¦åœæ­¢ã—ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§èª­ã¿è¾¼ã‚€ã‚¹ã‚¯ãƒªãƒ—トファイルãŒè¦‹ã¤ã‹ã‚‰ãªãã¦ã‚‚ã€ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã«å¤±æ•—ã—ãŸã¨ãã§ã‚‚シェルã¯çµ‚了ã—ã¾ã›ã‚“。(POSIX 準拠モードã®ã¨ãを除ã) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¾…ã£ã¦ã„るジョブãŒçµ‚了ã—ãŸã¨ãã€ãã®ã“ã¨ã‚’示ã™ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã¾ã™ã€‚(ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã®ã¿ã€‚POSIX 準拠モードを除ã) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Read 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒäºŒè¡Œç›®ä»¥é™ã‚’読むã¨ãプロンプトを出ã—ã¾ã™ã€‚ .RE .SS "プロンプト" .sp 対話モードã§ã¯ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å…¥åŠ›ã‚’èª­ã¿å–ã‚‹ç›´å‰ã«\fIプロンプト\fRを標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚プロンプトã®å†…容㯠\fBPS1\fR å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚ãŸã ã—ã€è¤‡æ•°è¡Œã«ã‚ãŸã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã‚‹éš›ã€äºŒè¡Œç›®ä»¥é™ã®èª­ã¿å–りã«ã¯ \fBPS1\fR ã§ã¯ãªã \fBPS2\fR 変数ã®å€¤ãŒãƒ—ロンプトã¨ã—ã¦è¡¨ç¤ºã•れã¾ã™ã€‚ .sp プロンプトã®è¡¨ç¤ºã®éš›ã«ã¯ã€ã¾ãš \fBPS1\fR (ã¾ãŸã¯ \fBPS2\fR) 変数ã®å€¤ãŒãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ã§å±•é–‹ã•れã¾ã™ (ãŸã ã— POSIX ã«ã‚ˆã‚Œã°ãƒ‘ラメータ展開ã ã‘ãŒè¡Œã‚れるã“ã¨ã«ãªã£ã¦ã„ã¾ã™)。ã“ã®å±•開後ã®å€¤ã¯ä»¥ä¸‹ã®é€šã‚Šè§£é‡ˆã•れã€ãã®çµæžœãŒãƒ—ロンプトã¨ã—ã¦æ¨™æº–エラーã«å‡ºåŠ›ã•れã¾ã™ã€‚ .sp POSIX 準拠モードã§ã¯ã€å€¤ã«å«ã¾ã‚Œã‚‹ \fB!\fR ã¯ã“れã‹ã‚‰å…¥åŠ›ã—よã†ã¨ã—ã¦ã„るコマンドã®å±¥æ­´ç•ªå·ã«å¤‰æ›ã•れã¾ã™ã€‚感嘆符ãã®ã‚‚ã®ã‚’プロンプトã«è¡¨ç¤ºã•ã›ã‚‹ã«ã¯ \fB!!\fR ã¨äºŒã¤ç¶šã‘ã¦æ›¸ãã¾ã™ã€‚ã“ã‚Œä»¥å¤–ã®æ–‡å­—ã¯ãƒ—ロンプトã«ãã®ã¾ã¾è¡¨ç¤ºã•れã¾ã™ã€‚ .sp POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ä»¥ä¸‹ã®è¨˜æ³•ãŒè§£é‡ˆã•れã¾ã™ã€‚ã“れらã®è¨˜æ³•ä»¥å¤–ã®æ–‡å­—ã¯ãã®ã¾ã¾ãƒ—ロンプトã«è¡¨ç¤ºã•れã¾ã™ã€‚ .PP \fB\ea\fR .RS 4 ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7) .RE .PP \fB\ee\fR .RS 4 エスケープ文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 27) .RE .PP \fB\ej\fR .RS 4 ç¾åœ¨ã‚·ã‚§ãƒ«ãŒæŠ±ãˆã¦ã„ã‚‹ã‚¸ãƒ§ãƒ–ã®æ•° .RE .PP \fB\en\fR .RS 4 改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10) .RE .PP \fB\er\fR .RS 4 復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13) .RE .PP \fB\e!\fR .RS 4 ã“れã‹ã‚‰å…¥åŠ›ã—よã†ã¨ã—ã¦ã„るコマンドã®å±¥æ­´ç•ªå· .RE .PP \fB\e$\fR .RS 4 シェルã®å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ㌠0 ã®ã¨ã㯠\fB#\fRã€ãã‚Œä»¥å¤–ã®æ™‚㯠\fB$\fR。 .RE .PP \fB\e\e\fR .RS 4 ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\fB\e\fR) .RE .PP \fB\e[\fR, \fB\e]\fR .RS 4 ã“ã®äºŒã¤ã®è¨˜æ³•ã¯ã€å®Ÿéš›ã«ã¯ç«¯æœ«ã«è¡¨ç¤ºã•れãªã„プロンプトã®ä¸€éƒ¨åˆ†ã‚’指示ã™ã‚‹ã®ã«ä½¿ã„ã¾ã™ã€‚\fB\e[\fR 㨠\fB\e]\fR ã§å›²ã‚“ã éƒ¨åˆ†ã¯ã€è¡Œç·¨é›†ãŒãƒ—ãƒ­ãƒ³ãƒ—ãƒˆã®æ–‡å­—数を計算ã™ã‚‹éš›ã«ã€æ–‡å­—æ•°ã«æ•°ãˆã‚‰ã‚Œã¾ã›ã‚“。端末ã«è¡¨ç¤ºã•れãªã„エスケープシーケンスãªã©ã‚’プロンプトã«å«ã‚ã‚‹éš›ã¯ã€ãã®éƒ¨åˆ†ã‚’ \fB\e[\fR 㨠\fB\e]\fR ã§å›²ã‚“ã§ãã ã•ã„。ã“ã®æŒ‡å®šã‚’怠るã¨ã€è¡Œç·¨é›†ã®è¡¨ç¤ºãŒä¹±ã‚Œã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ .RE .PP \fB\ef\fR\fB\fIフォント指定\fR\fR\fB\&.\fR .RS 4 行編集を使用ã—ã¦ã„ã‚‹å ´åˆã€ã“ã®è¨˜æ³•ã¯ç«¯æœ«ã®ãƒ•ォントã®è¡¨ç¤ºã‚’変更ã™ã‚‹ãŸã‚ã®ç‰¹æ®Šãªæ–‡å­—ã®ç¾…列ã«å¤‰æ›ã•れã¾ã™ (端末ãŒå¯¾å¿œã—ã¦ã„ã‚‹å ´åˆã®ã¿)。行編集を使用ã—ã¦ã„ãªã„å ´åˆã‚„端末ãŒå¯¾å¿œã—ã¦ã„ãªã„å ´åˆã¯ã€ã“ã®è¨˜æ³•ã¯å˜ã«ç„¡è¦–ã•れã¾ã™ã€‚\fIフォント指定\fRã®éƒ¨åˆ†ã«ã¯ãƒ•ォントã®ç¨®é¡žã‚’指定ã™ã‚‹ãŸã‚ã®ä»¥ä¸‹ã®æ–‡å­—を指定ã—ã¾ã™ã€‚ .PP \fBk\fR .RS 4 文字ã®è‰²ã‚’é»’ã«ã™ã‚‹ .RE .PP \fBr\fR .RS 4 文字ã®è‰²ã‚’赤ã«ã™ã‚‹ .RE .PP \fBg\fR .RS 4 文字ã®è‰²ã‚’ç·‘ã«ã™ã‚‹ .RE .PP \fBy\fR .RS 4 文字ã®è‰²ã‚’黄ã«ã™ã‚‹ .RE .PP \fBb\fR .RS 4 文字ã®è‰²ã‚’é’ã«ã™ã‚‹ .RE .PP \fBm\fR .RS 4 文字ã®è‰²ã‚’マゼンタã«ã™ã‚‹ .RE .PP \fBc\fR .RS 4 文字ã®è‰²ã‚’シアンã«ã™ã‚‹ .RE .PP \fBw\fR .RS 4 文字ã®è‰²ã‚’白ã«ã™ã‚‹ .RE .PP \fBK\fR .RS 4 背景ã®è‰²ã‚’é»’ã«ã™ã‚‹ .RE .PP \fBR\fR .RS 4 背景ã®è‰²ã‚’赤ã«ã™ã‚‹ .RE .PP \fBG\fR .RS 4 背景ã®è‰²ã‚’ç·‘ã«ã™ã‚‹ .RE .PP \fBY\fR .RS 4 背景ã®è‰²ã‚’黄ã«ã™ã‚‹ .RE .PP \fBB\fR .RS 4 背景ã®è‰²ã‚’é’ã«ã™ã‚‹ .RE .PP \fBM\fR .RS 4 背景ã®è‰²ã‚’マゼンタã«ã™ã‚‹ .RE .PP \fBC\fR .RS 4 背景ã®è‰²ã‚’シアンã«ã™ã‚‹ .RE .PP \fBW\fR .RS 4 背景ã®è‰²ã‚’白ã«ã™ã‚‹ .RE .PP \fBt\fR .RS 4 文字ã¾ãŸã¯èƒŒæ™¯ã®è‰²ã‚’明るãã™ã‚‹ (ä¸Šè¨˜ã®æ–‡å­—・背景ã®è‰²ã‚’変更ã™ã‚‹æ–‡å­—ã®ç›´å¾Œã§ã®ã¿æœ‰åй) .RE .PP \fBd\fR .RS 4 文字ã¨èƒŒæ™¯ã®è‰²ã‚’æ¨™æº–çŠ¶æ…‹ã«æˆ»ã™ .RE .PP \fBs\fR .RS 4 文字を目立ãŸã›ã‚‹ .RE .PP \fBu\fR .RS 4 文字ã«ä¸‹ç·šã‚’引ã .RE .PP \fBv\fR .RS 4 文字ã®è‰²ã‚’å転ã•ã›ã‚‹ .RE .PP \fBb\fR .RS 4 文字を点滅ã•ã›ã‚‹ .RE .PP \fBi\fR .RS 4 文字ã®è‰²ã‚’æš—ãã™ã‚‹ .RE .PP \fBo\fR .RS 4 文字を太ã目立ãŸã›ã‚‹ .RE .PP \fBx\fR .RS 4 文字を見ãˆãªãã™ã‚‹ .RE .PP \fBD\fR .RS 4 色ã¨è£…é£¾ã‚’æ¨™æº–çŠ¶æ…‹ã«æˆ»ã™ .RE .sp 文字ã¨èƒŒæ™¯ã®è‰²ã¯æœ€çµ‚çš„ã«ç«¯æœ«ã«ã‚ˆã£ã¦æ±ºã¾ã‚‹ãŸã‚ã€å®Ÿéš›ã«ã¯ã“ã“ã§æŒ‡å®šã—ãŸè‰²ã¨ç•°ãªã‚‹è‰²ã§è¡¨ç¤ºã•れるã“ã¨ãŒã‚りã¾ã™ã€‚ .RE .sp 入力ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®å³å´ã«è¡¨ç¤ºã•れるプロンプトを指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ (\fIå³ãƒ—ロンプト\fR)。\fBPS1\fR/\fBPS2\fR 変数ã«å¯¾å¿œã™ã‚‹å³ãƒ—ロンプト㯠\fBPS1R\fR/\fBPS2R\fR å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚ .sp ã¾ãŸã€ãƒ—ロンプトã®ãƒ•ォントã ã‘ã§ãªãã€å…¥åŠ›ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ォントを変ãˆã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚\fBPS1S\fR (ã¾ãŸã¯ \fBPS2S\fR) 変数ã«ä¸Šè¿°ã®ãƒ•ォントを指定ã™ã‚‹ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã‚’指定ã™ã‚‹ã“ã¨ã§ã€ã‚³ãƒžãƒ³ãƒ‰å…¥åŠ›æ™‚ã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ォントãŒå¤‰ã‚りã¾ã™ã€‚ .sp POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ãƒ—ロンプトを出ã™å‰ã« \fBPROMPT_COMMAND\fR 変数ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ .SS "コマンド履歴" .sp \fIコマンド履歴\fRã¯å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’記録ã—後ã§å†ã³å®Ÿè¡Œã™ã‚‹ã“ã¨ã®ã§ãる機能ã§ã™ã€‚対話モードã§ã‚·ã‚§ãƒ«ãŒèª­ã¿è¾¼ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ã¯è‡ªå‹•çš„ã«ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã™ã€‚履歴ã«è¨˜éŒ²ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯è¡Œç·¨é›†ã§å‘¼ã³å‡ºã—ã¦å†å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸ fc・history 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å±¥æ­´ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ãŸã‚Šç·¨é›†ã—ãŸã‚Šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .sp コマンドã¯è¡Œå˜ä½ã§å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã™ã€‚ç©ºç™½ä»¥å¤–ã®æ–‡å­—を一切å«ã¾ãªã„行ã¯å±¥æ­´ã«ã¯è¨˜éŒ²ã•れã¾ã›ã‚“。ã¾ãŸ hist\-space ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãã¯ç©ºç™½ã§å§‹ã¾ã‚‹è¡Œã¯å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã›ã‚“。 .sp コマンド履歴ã®å†…容㯠\fBHISTFILE\fR å¤‰æ•°ã§æŒ‡å®šã•れるファイルã«ä¿å­˜ã•れã¾ã™ã€‚対話モードã®ã‚·ã‚§ãƒ«ã®èµ·å‹•後ã«å±¥æ­´é–¢é€£ã®æ©Ÿèƒ½ãŒåˆã‚ã¦ä½¿ç”¨ã•れるã¨ãã€\fBHISTFILE\fR 変数ã®å€¤ã‚’ファイルåã¨ã¿ãªã—ã¦ãƒ•ァイルを開ãã¾ã™ã€‚æ—¢ã«ãƒ•ァイルã«å±¥æ­´ãƒ‡ãƒ¼ã‚¿ãŒä¿å­˜ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれãŒèª­ã¿è¾¼ã¾ã‚Œã¾ã™ã€‚ファイルãŒå­˜åœ¨ã—ãªã„ã‹å†…容ãŒå±¥æ­´ãƒ‡ãƒ¼ã‚¿ã§ã¯ãªã„å ´åˆã¯ã€æ–°ã—ã„履歴ファイルã«åˆæœŸåŒ–ã•れã¾ã™ã€‚\fBHISTFILE\fR 変数ãŒå­˜åœ¨ã—ãªã„å ´åˆã‚„ファイルを開ãã“ã¨ãŒã§ããªã„å ´åˆã¯å±¥æ­´ã¯ãƒ•ァイルã«ä¿å­˜ã•れã¾ã›ã‚“ãŒã€å±¥æ­´æ©Ÿèƒ½è‡ªä½“ã¯ä½¿ç”¨ã§ãã¾ã™ã€‚ .sp シェルãŒè¨˜éŒ²ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®æ•°ã¯ \fBHISTSIZE\fR å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚履歴ã®ä»¶æ•°ãŒã“ã®å¤‰æ•°ã®å€¤ã‚’è¶…ãˆã‚‹ã¨é †æ¬¡å¤ã„データã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒå­˜åœ¨ã—ãªã„å ´åˆã¾ãŸã¯å€¤ãŒè‡ªç„¶æ•°ã§ãªã„å ´åˆã¯ã€å±¥æ­´ã¯ 500 ä»¶ã¾ã§è¨˜éŒ²ã•れã¾ã™ã€‚ .sp \fBHISTFILE\fR ãŠã‚ˆã³ \fBHISTSIZE\fR 変数ã¯å±¥æ­´æ©Ÿèƒ½ãŒåˆã‚ã¦ä½¿ç”¨ã•れるã¨ãã«ã®ã¿å‚ç…§ã•れã€ãれ以é™ã¯å¤‰æ•°ã‚’å†è¨­å®šã—ã¦ã‚‚履歴機能ã®å‹•作ã«å½±éŸ¿ã—ã¾ã›ã‚“。履歴機能ãŒåˆ©ç”¨ã•れるã¨ãã¨ã„ã†ã®ã¯ã€å…·ä½“çš„ã«ã¯ä»¥ä¸‹ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Fc ã¾ãŸã¯ history 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ã .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 行編集を使用ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã™ã‚‹ã¨ã (履歴データを行編集ã®ä¸­ã§ä½¿ã‚ãªãã¦ã‚‚履歴機能ã¯ä½¿ã‚れã¾ã™) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 入力ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒå±¥æ­´ã«ç™»éŒ²ã•れるã¨ã .RE .sp ã“ã®ãŸã‚ \fBHISTFILE\fR ãŠã‚ˆã³ \fBHISTSIZE\fR 変数ã¯åŽŸå‰‡ã¨ã—ã¦ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«èª­ã¿è¾¼ã¾ã‚Œã‚‹åˆæœŸåŒ–スクリプトã®ä¸­ã§è¨­å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ .sp 複数ã®ã‚·ã‚§ãƒ«ãƒ—ロセスãŒåŒã˜å±¥æ­´ãƒ•ァイルを使用ã—ã¦ã„ã‚‹å ´åˆã€ã“れらã®ã‚·ã‚§ãƒ«ã¯ä¸€ã¤ã®å±¥æ­´ãƒ‡ãƒ¼ã‚¿ã‚’共有ã—ã¾ã™ã€‚ã“ã®ã¨ã例ãˆã°ã‚るシェルプロセスã§å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’別ã®ã‚·ã‚§ãƒ«ãƒ—ロセスã§å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚åŒã˜å±¥æ­´ã‚’使用ã—ã¦ã„るシェルã®é–“ã§ \fBHISTSIZE\fR ãŒç•°ãªã£ã¦ã„ã‚‹ã¨å±¥æ­´ãŒæ­£ã—ã共有ã•れãªã„ã®ã§ã€\fBHISTSIZE\fR ã®å€¤ã¯çµ±ä¸€ã™ã‚‹ã‚ˆã†ã«ã—ã¦ãã ã•ã„。 .sp Yash ã¯ç‹¬è‡ªã®å½¢å¼ã®å±¥æ­´ãƒ•ァイルを使用ã—ã¦ã„ã‚‹ãŸã‚ã€å±¥æ­´ãƒ•ァイルを他ã®ç¨®é¡žã®ã‚·ã‚§ãƒ«ã¨å…±ç”¨ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .sp 履歴ã«åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’記録ã™ã‚‹ç„¡é§„を解消ã™ã‚‹ãŸã‚ã€\fBHISTRMDUP\fR 変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚æ–°ã—ãコマンドを履歴ã«è¨˜éŒ²ã—よã†ã¨ã™ã‚‹éš›ã€ã™ã§ã«åŒã˜ã‚³ãƒžãƒ³ãƒ‰ãŒæœ€è¿‘ã® \fI$HISTRMDUP\fR ä»¶ã®å±¥æ­´ãƒ‡ãƒ¼ã‚¿ã®ä¸­ã«è¨˜éŒ²ã•れã¦ã„れã°ã€ãã®æ—¢ã«è¨˜éŒ²ã•れã¦ã„るコマンドã¯å±¥æ­´ã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚ .SS "メールãƒã‚§ãƒƒã‚¯" .sp 対話モードã®ã‚·ã‚§ãƒ«ã«ã¯ã€é›»å­ãƒ¡ãƒ¼ãƒ«ãŒå±Šã„ãŸã‚‰ãれを知らã›ã‚‹æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚ã“ã‚Œã¯æ‰€å®šã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚を調ã¹ã¦ã€æ›´æ–°æ—¥æ™‚ãŒå¤‰ã‚ã£ã¦ã„ãŸã‚‰ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’表示ã™ã‚‹ã¨ã„ã†ã‚‚ã®ã§ã™ã€‚å—ä¿¡ã—ãŸãƒ¡ãƒ¼ãƒ«ã®ãƒ‡ãƒ¼ã‚¿ãŒä¿å­˜ã•れるファイルをãƒã‚§ãƒƒã‚¯å¯¾è±¡ã¨ã—ã¦æŒ‡å®šã—ã¦ãŠãã“ã¨ã§ã€ãƒ¡ãƒ¼ãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒè¡¨ç¤ºã•れるよã†ã«ãªã‚Šã¾ã™ã€‚ .sp ファイル更新ã®ãƒã‚§ãƒƒã‚¯ã¯ã‚·ã‚§ãƒ«ãŒãƒ—ロンプトを出ã™ç›´å‰ã«è¡Œã„ã¾ã™ã€‚ãƒã‚§ãƒƒã‚¯ã‚’行ã†é–“隔を \fBMAILCHECK\fR å¤‰æ•°ã§æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã§æŒ‡å®šã—ãŸç§’æ•°ãŒçµŒéŽã™ã‚‹ã”ã¨ã«ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出ã™ç›´å‰ã«ãƒã‚§ãƒƒã‚¯ã‚’行ã„ã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ãŒ 0 ã«ãªã£ã¦ã„ã‚‹å ´åˆã¯ã€ãƒ—ロンプトを出ã™ç›´å‰ã«æ¯Žå›žãƒã‚§ãƒƒã‚¯ã‚’行ã„ã¾ã™ã€‚ã¾ãŸå¤‰æ•°ã®å€¤ãŒ 0 ä»¥ä¸Šã®æ•´æ•°ã§ãªã„å ´åˆã¯ã€ãƒã‚§ãƒƒã‚¯ã¯ä¸€åˆ‡è¡Œã„ã¾ã›ã‚“。 .sp 更新日時をãƒã‚§ãƒƒã‚¯ã™ã‚‹å¯¾è±¡ã®ãƒ•ァイル㯠\fBMAIL\fR å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã«ãƒã‚§ãƒƒã‚¯ã—ãŸã„ファイルã®ãƒ‘スåを指定ã—ã¦ãŠãã¨ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚ãŒå‰å›žãƒã‚§ãƒƒã‚¯ã—ãŸã¨ãã¨å¤‰ã‚ã£ã¦ã„ãŸã‚‰ã€æ–°ç€ãƒ¡ãƒ¼ãƒ«ã‚’知らã›ã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚(ãŸã ã—ファイルãŒç©ºã®ã¨ãã¯ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¯å‡ºã¾ã›ã‚“ (POSIX 準拠モードã®ã¨ãを除ã)) .sp 複数ã®ãƒ•ァイルをãƒã‚§ãƒƒã‚¯ã®å¯¾è±¡ã«ã—ãŸã„å ´åˆã‚„ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’è‡ªåˆ†ã§æŒ‡å®šã—ãŸã„å ´åˆã¯ã€\fBMAIL\fR 変数ã®ä»£ã‚り㫠\fBMAILPATH\fR 変数を使ã†ã“ã¨ãŒã§ãã¾ã™ã€‚\fBMAILPATH\fR 変数ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€\fBMAIL\fR 変数ã®è¨­å®šã¯ç„¡è¦–ã•れã¾ã™ã€‚\fBMAILPATH\fR 変数ã®å€¤ã«ã¯ã€ä¸€ã¤ä»¥ä¸Šã®ãƒ•ァイルã®ãƒ‘スåをコロン (\fB:\fR) ã§åŒºåˆ‡ã£ã¦æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚·ã‚§ãƒ«ã¯æ¯Žå›žã®ãƒã‚§ãƒƒã‚¯ã§ãれãžã‚Œã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚を調ã¹ã€ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ›´æ–°ã•れã¦ã„ãŸã‚‰ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’表示ã—ã¾ã™ã€‚ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’è‡ªåˆ†ã§æŒ‡å®šã™ã‚‹ã«ã¯ã€ãƒ‘スåã®ç›´å¾Œã«ãƒ‘ーセント (\fB%\fR) ã‚’ç½®ãã€ç¶šã‘ã¦è¡¨ç¤ºã•ã›ãŸã„メッセージを置ãã¾ã™ã€‚ãれãžã‚Œã®ãƒ•ァイルã”ã¨ã«ç•°ãªã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚(パーセントをパスåã¨ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¨ã®åŒºåˆ‡ã‚Šã§ã¯ãªãパスåã®ä¸€éƒ¨ã¨ã—ãŸã„å ´åˆã¯ãƒ‘ーセントをãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã—ã¦ãã ã•ã„) パーセントã®å¾Œã«æŒ‡å®šã•れãŸãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¯ã€è¡¨ç¤ºã®å‰ã«ãƒ‘ラメータ展開ã•れã¾ã™ã€‚ .sp 例ãˆã° \fBMAILPATH\fR 変数ã®å€¤ãŒ \fB/foo/mail%New mail!:/bar/mailbox%You\*(Aqve got mail:/baz/mail\e%data\fR ã ã¨ã™ã‚‹ã¨ã€ãƒ•ァイル /foo/mail ãŒæ›´æ–°ã•れãŸã¨ã㯠\fBNew mail!\fR ãŒã€/bar/mailbox ãŒæ›´æ–°ã•れãŸã¨ã㯠\fBYou\*(Aqve got mail\fR ãŒã€/baz/mail%data ãŒæ›´æ–°ã•れãŸã¨ãã¯ãƒ‡ãƒ•ォルトã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒè¡¨ç¤ºã•れã¾ã™ã€‚ .SH "ジョブ制御" .sp \fIジョブ制御\fRã¨ã¯ã€è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’åŒæ™‚ã«å®Ÿè¡Œã—ã€å¿…è¦ã«å¿œã˜ã¦ãれらを中断・å†é–‹ã•ã›ã‚‹æ©Ÿèƒ½ã§ã™ã€‚シェルã¯ã€ã‚ªãƒšãƒ¬ãƒ¼ãƒ†ã‚£ãƒ³ã‚°ã‚·ã‚¹ãƒ†ãƒ ãŒæä¾›ã™ã‚‹ç«¯æœ«ã®æ©Ÿèƒ½ã‚„ãƒ—ãƒ­ã‚»ã‚¹ã‚°ãƒ«ãƒ¼ãƒ—ç®¡ç†æ©Ÿæ§‹ãªã©ã‚’用ã„ã¦ã€ã‚¸ãƒ§ãƒ–制御を実ç¾ã—ã¾ã™ã€‚ .sp ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚\&...\&... .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シェルãŒèµ·å‹•ã™ã‚‹å„プロセスã¯ã€ãƒ‘イプラインã”ã¨ã«å…±é€šã®ä¸€æ„ãªãƒ—ロセスグループã«å±žã—ã¾ã™ã€‚ã™ãªã‚ã¡ã€ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ãれãžã‚Œãƒ‘イプラインã”ã¨ã«\fIジョブ\fRã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シェルãŒã‚¸ãƒ§ãƒ–ã‚’èµ·å‹•ã—ãã®ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã£ã¦ã„ã‚‹é–“ã«ãã®ãƒ—ロセスãŒåœæ­¢ã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ (プロセスãŒå®Ÿéš›ã«çµ‚了ã—ãŸã¨ãã¨åŒæ§˜ã«) 次ã®ã‚³ãƒžãƒ³ãƒ‰ã®å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ã“ã®ã¨ãシェルã¯ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã“ã¨ã‚’覚ãˆã¦ã„ã‚‹ã®ã§ã€å¾Œã§ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ジョブãŒåŒæœŸçš„ã«å®Ÿè¡Œã•れる場åˆã€ãã®ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡Œä¸­ã¯ãã®ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスグループãŒç«¯æœ«ã®ãƒ•ォアグラウンドプロセスグループã«ãªã‚Šã¾ã™ã€‚ジョブã®å®Ÿè¡ŒãŒçµ‚了 (ã¾ãŸã¯åœæ­¢) ã™ã‚‹ã¨ã€å†ã³ã‚·ã‚§ãƒ«ãŒãƒ•ォアグラウンドã«ãªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンド置æ›ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã‚µãƒ–シェルもã¾ãŸç‹¬ç«‹ã—ãŸãƒ—ロセスグループã«å±žã—ã¾ã™ã€‚ã—ã‹ã—シェルã¯ã“れをジョブã¨ã—ã¦ã¯æ‰±ã‚ãªã„ãŸã‚ã€åœæ­¢ãƒ»å†é–‹ã•ã›ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®å ´åˆã€ãƒ—ロンプトを出ã™å‰ã«æ¯Žå›žã‚³ãƒžãƒ³ãƒ‰ \fBjobs\fR\fB \-n\fR を実行ã™ã‚‹ã®ã¨åŒæ§˜ã«ã—ã¦ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れã¾ã›ã‚“。(POSIX 準拠モードã®ã¨ãを除ã) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} SIGTSTP シグナルをå—ã‘ã¦ã‚‚ã€ã‚·ã‚§ãƒ«ã¯åœæ­¢ã—ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 特殊パラメータ \fB\-\fR ã®å€¤ã« \fBm\fR ãŒå«ã¾ã‚Œã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¾…ã£ã¦ã„るジョブãŒçµ‚了ã—ãŸã¨ãã€ãã®ã“ã¨ã‚’示ã™ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã¾ã™ã€‚(å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®æ™‚ã®ã¿ã€‚POSIX 準拠モードを除ã) .RE .sp ジョブ制御ãŒç„¡åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å„プロセスã¯ã‚·ã‚§ãƒ«ã¨åŒã˜ãƒ—ロセスグループã«å±žã—ã¾ã™ãŒã€å®Ÿè¡Œã—ãŸéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã¯ãれãžã‚Œã‚¸ãƒ§ãƒ–制御ã®å¯¾è±¡ã¨ãªã£ã¦ã„ãªã„ジョブã¨ã—ã¦æ‰±ã„ã¾ã™ã€‚ .sp ã“ã“ã§ã‚¸ãƒ§ãƒ–制御ã«é–¢é€£ã™ã‚‹çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’ç°¡å˜ã«ç´¹ä»‹ã—ã¾ã™ã€‚ .PP jobs .RS 4 ç¾åœ¨ã‚·ã‚§ãƒ«ãŒç®¡ç†ã—ã¦ã„るジョブを表示ã—ã¾ã™ã€‚ .RE .PP fg ãŠã‚ˆã³ bg .RS 4 ジョブをフォアグラウンドã¾ãŸã¯ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚主ã«åœæ­¢ã—ãŸã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã•ã›ã‚‹ã®ã«ä½¿ã„ã¾ã™ã€‚ .RE .PP wait .RS 4 ジョブãŒçµ‚了 (ã¾ãŸã¯åœæ­¢) ã™ã‚‹ã¾ã§å¾…ã¡ã¾ã™ã€‚ .RE .PP disown .RS 4 ジョブã®å­˜åœ¨ã‚’忘れã¾ã™ã€‚ .RE .PP kill .RS 4 プロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Šã¾ã™ã€‚ .RE .sp 対話モードã§ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出ã™ç›´å‰ã«ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚ã“れ以外ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¦ã»ã—ã„å ´åˆã¯ã€ä»¥ä¸‹ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .PP notify .RS 4 タイミングã«ã‹ã‹ã‚らãšã€ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹ãŒå¤‰åŒ–ã—ãŸã‚‰ç›´ã¡ã«ãれを報告ã—ã¾ã™ã€‚ .RE .PP notify\-le .RS 4 行編集を行ã£ã¦ã„る最中ã«ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹ãŒå¤‰åŒ–ã—ãŸã‚‰ç›´ã¡ã«ãれを報告ã—ã¾ã™ã€‚ .RE .sp シェルãŒç®¡ç†ã—ã¦ã„るジョブã¯ä»¥ä¸‹ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§å‰Šé™¤ã•れã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ジョブã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸå¾Œã€ãã®ã“ã¨ã‚’ jobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„プロンプトå‰ã®è‡ªå‹•報告ã§è¡¨ç¤ºã—ãŸã¨ã .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚¸ãƒ§ãƒ–ã®çµ‚了を待ã£ãŸã¨ã .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Disown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚¸ãƒ§ãƒ–を削除ã—ãŸã¨ã .RE .SS "ジョブ ID" .sp ã„ãã¤ã‹ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã€æ“作対象ã®ã‚¸ãƒ§ãƒ–を指定ã™ã‚‹ãŸã‚ã«\fIジョブ ID\fR ã¨ã„ã†ä»¥ä¸‹ã®ã‚ˆã†ãªè¨˜æ³•を用ã„ã¾ã™ã€‚ .PP \fB%\fR, \fB%%\fR, \fB%+\fR .RS 4 ç¾åœ¨ã®ã‚¸ãƒ§ãƒ– .RE .PP \fB%\-\fR .RS 4 å‰ã®ã‚¸ãƒ§ãƒ– .RE .PP \fB%\fR\fB\fIn\fR\fR .RS 4 ジョブ番å·ãŒ \fIn\fR ã®ã‚¸ãƒ§ãƒ– (\fIn\fR ã¯è‡ªç„¶æ•°) .RE .PP \fB%\fR\fB\fIstring\fR\fR .RS 4 ジョブåãŒ\fI文字列\fRã§å§‹ã¾ã‚‹ã‚¸ãƒ§ãƒ– .RE .PP \fB%?\fR\fB\fIstring\fR\fR .RS 4 ジョブåãŒ\fI文字列\fRã‚’å«ã‚€ã‚¸ãƒ§ãƒ– .RE .sp \fIç¾åœ¨ã®ã‚¸ãƒ§ãƒ–\fRåŠã³\fIå‰ã®ã‚¸ãƒ§ãƒ–\fRã¨ã¯ã€ã‚·ã‚§ãƒ«ãŒç‰¹å®šã®æ–¹æ³•ã§é¸ã‚“ã ã‚¸ãƒ§ãƒ–ã®ã“ã¨ã§ã€fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ã‚¸ãƒ§ãƒ–ã‚’é¸æŠžã—ã‚„ã™ãã™ã‚‹ãŸã‚ã«ç”¨æ„ã•れã¦ã„ã¾ã™ã€‚ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¨å‰ã®ã‚¸ãƒ§ãƒ–ã¯ä»¥ä¸‹ã®è¦å‰‡ã‚’満ãŸã™ã‚ˆã†ã«é¸ã°ã‚Œã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹å ´åˆã¯ã€ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯ãã®ä¸­ã‹ã‚‰é¸ã°ã‚Œã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–以外ã«åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹å ´åˆã¯ã€å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãã®ä¸­ã‹ã‚‰é¸ã°ã‚Œã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¨å‰ã®ã‚¸ãƒ§ãƒ–ã¯ç•°ãªã‚‹ã‚¸ãƒ§ãƒ–ã«ãªã‚‹ã‚ˆã†ã«é¸ã°ã‚Œã¾ã™ã€‚ジョブãŒä¸€ã¤ã—ã‹ãªã„ã¨ãã¯ãれãŒç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã€å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãªããªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã—ãŸã¨ãã¯ã€å‰ã®ã‚¸ãƒ§ãƒ–ãŒç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ã“れ以外ã«ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ãŒå¤‰æ›´ã•れる場åˆã¯ã€å…ƒã®ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯å‰ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} フォアグラウンドã§å®Ÿè¡Œã—ã¦ã„ãŸã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãã¯ã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ .RE .sp Yash ã«ã¯ã€ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã‚’é¸æŠžã™ã‚‹æ–¹é‡ã‚’指示ã™ã‚‹ãŸã‚ã«ã„ãã¤ã‹ã®ã‚ªãƒ—ションãŒç”¨æ„ã•れã¦ã„ã¾ã™ã€‚ãŸã ã—ã“れらã®ã‚ªãƒ—ションよりも上記ã®è¦å‰‡ã®ã»ã†ãŒå„ªå…ˆã—ã¾ã™ã€‚ .PP cur\-async .RS 4 æ–°ã—ãéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã—ãŸã¨ãã€ãれã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ .RE .PP cur\-bg .RS 4 Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã—ãŸã¨ãã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ .RE .PP cur\-stop .RS 4 実行中ã®ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ .RE .sp ã“れらã®è¦å‰‡ãƒ»ã‚ªãƒ—ションã«åã—ãªã„é™ã‚Šã€ä¸€åº¦é¸ã°ã‚ŒãŸç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãšã£ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã®ã¾ã¾ã§ã™ã€‚ .sp POSIX ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã®é¸æŠžæ–¹æ³•ã‚’ç´°ã‹ã定ã‚ã¦ã„ãªã„ãŸã‚ã€ä»–ã®ã‚·ã‚§ãƒ«ã§ã¯é¸ã³æ–¹ãŒç•°ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ .SH "組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fI組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¨ã¯ã‚·ã‚§ãƒ«ã«å†…蔵ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¤–部ã®ãƒ—ログラムを起動ã™ã‚‹ã“ã¨ãªãシェル自身ã«ã‚ˆã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ .SS "組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡ž" .sp Yash ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ä¸‰ç¨®é¡žã«åˆ†ã‘られã¾ã™ã€‚ .sp \fI特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ä»–ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚ˆã‚Šã‚‚特ã«é‡è¦ãªã‚³ãƒžãƒ³ãƒ‰ã§ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã¯ç•°ãªã‚‹æ€§è³ªã‚’ã„ãã¤ã‹æŒã£ã¦ã„ã¾ã™ã€‚ã¾ãšã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¯¾å¿œã™ã‚‹å¤–部コマンドã®å­˜åœ¨ã«é–¢ä¿‚ãªã常ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã¾ãŸç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã‘る変数代入ã®çµæžœã¯ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã‚‚残りã¾ã™ã€‚ã•ら㫠POSIX 準拠モードã§ã¯ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã¾ãŸã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã‚ã‚‹ã„ã¯ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ãªã‘れã°ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«éž 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚ .sp \fI準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«æ¬¡ã„ã§é‡è¦ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã€å¯¾å¿œã™ã‚‹å¤–部コマンドã®å­˜åœ¨ã«é–¢ä¿‚ãªã常ã«å®Ÿè¡Œã•れã¾ã™ã€‚ãã®ä»–ã®ç‚¹ã§ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨åŒã˜ã§ã™ã€‚ .sp 外部コマンドã¨ã—ã¦å®Ÿè£…å¯èƒ½ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„ POSIX ã«è¦å®šã•れã¦ã„ãªã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’å«ã‚€ã€é‡è¦åº¦ã®ä½Žã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯\fI通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã§ã™ã€‚POSIX 準拠モードã§ã¯ã€é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¯¾å¿œã™ã‚‹å¤–部コマンド㌠\fBPATH\fR å¤‰æ•°ã®æ¤œç´¢ã§è¦‹ã¤ã‹ã£ãŸå ´åˆã®ã¿å®Ÿè¡Œã•れã¾ã™ã€‚ .SS "コマンドã®å¼•æ•°ã®æ§‹æ–‡" .sp ã“ã“ã§ã¯çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã«é–¢ã™ã‚‹ä¸€èˆ¬çš„ãªè¦å‰‡ã«ã¤ã„ã¦èª¬æ˜Žã—ã¾ã™ã€‚Yash ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã®æŒ‡å®šãƒ»è§£é‡ˆã®ä»•æ–¹ã¯ã€ä»–ã«æ–­ã‚ŠãŒãªã„é™ã‚Šã“ã®è¦å‰‡ã«å¾“ã„ã¾ã™ã€‚ .sp コマンドã®å¼•æ•°ã¯ã€ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®äºŒç¨®é¡žã«åˆ†ã‘られã¾ã™ã€‚\fIオプション\fRã¯ãƒã‚¤ãƒ•ン (\fB\-\fR) ã§å§‹ã¾ã‚‹å¼•æ•°ã§ã€ä¸»ã«ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作を変更ã™ã‚‹ã®ã«ä½¿ã‚れã¾ã™ã€‚オプションã®ä¸­ã«ã¯ãれã«å¯¾å¿œã™ã‚‹å¼•æ•°ã‚’ã¨ã‚‹ã‚‚ã®ã‚‚ã‚りã¾ã™ã€‚\fIオペランド\fRã¯ã‚ªãƒ—ション以外ã®å¼•æ•°ã§ã€ä¸»ã«ã‚³ãƒžãƒ³ãƒ‰ãŒå‡¦ç†ã‚’行ã†å¯¾è±¡ã‚’指定ã™ã‚‹ã®ã«ä½¿ã‚れã¾ã™ã€‚ .sp 一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ã‚ªãƒ—ションを与ãˆã‚‹å ´åˆã€åŽŸå‰‡ã¨ã—ã¦ãれらã®ã‚ªãƒ—ションã®é †åºã¯ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作ã«å½±éŸ¿ã—ã¾ã›ã‚“。ã—ã‹ã—オペランドã®é †åºã«ã¯æ„味ãŒã‚りã¾ã™ã€‚ .sp オプションã«ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã¨é•·ã„オプションã¨ãŒã‚りã¾ã™ã€‚\fI一文字ã®ã‚ªãƒ—ション\fRã¯è‹±æ•°å­—一文字ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるオプションã§ã™ã€‚\fIé•·ã„オプション\fRã¯ã‚‚ã£ã¨é•·ã„文字列ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるオプションã§ã™ã€‚POSIX è¦æ ¼ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã«ã¤ã„ã¦ã—ã‹è¦å®šã—ã¦ã„ãªã„ãŸã‚ã€POSIX 準拠モードã§ã¯é•·ã„オプションã¯ä½¿ãˆã¾ã›ã‚“。 .sp 一文字ã®ã‚ªãƒ—ションã¯ã€ä¸€ã¤ã®ãƒã‚¤ãƒ•ンã¨ä¸€æ–‡å­—ã®è‹±æ•°å­—ã‹ã‚‰ãªã‚Šã¾ã™ã€‚例ãˆã° \fB\-a\fR ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã§ã™ã€‚引数をã¨ã‚‹ã‚ªãƒ—ションã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã«ä¸Žãˆã‚‰ã‚ŒãŸå¼•æ•°ã®ä¸¦ã³ã®ä¸­ã§ãã®ã‚ªãƒ—ションã®ç›´å¾Œã«ä½ç½®ã—ã¦ã„る引数ãŒãã®ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ã¿ãªã•れã¾ã™ã€‚ .PP \fB例4 Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨ä¸€æ–‡å­—ã®ã‚ªãƒ—ション\fR .sp Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ã€\fB\-m\fR ã¯å¼•æ•°ã‚’ã¨ã‚‰ãªã„一文字ã®ã‚ªãƒ—ションã€\fB\-o\fR ã¯å¼•æ•°ã‚’ã¨ã‚‹ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã§ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-o errexit \-m\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-oerrexit \-m\fR .RE .sp ã“ã®äºŒã¤ã®ä¾‹ã§ã¯ã€\fBerrexit\fR ㌠\fB\-o\fR オプションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ãªã‚Šã¾ã™ã€‚ .sp 上ã®äºŒã¤ç›®ã®ä¾‹ã§ã¯ã€\fB\-o\fR オプションã¨ãれã«å¯¾ã™ã‚‹å¼•æ•°ãŒä¸€ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«ãªã£ã¦ã„ã¾ã™ã€‚POSIX ã¯ã“ã®ã‚ˆã†ãªæ›¸ãæ–¹ã¯é¿ã‘ãªã‘れã°ãªã‚‰ãªã„ã¨å®šã‚ã¦ãŠã‚Šã€POSIX ã«å¾“ã†ã‚¢ãƒ—リケーションã¯å¿…ãšä¸€ã¤ç›®ã®ä¾‹ã®ã‚ˆã†ã«ã‚ªãƒ—ションã¨ãれã«å¯¾ã™ã‚‹å¼•数を別々ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸Žãˆãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã—ã‹ã— yash ã¯ã©ã¡ã‚‰ã®æŒ‡å®šã®ä»•方もå—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ .sp 引数をã¨ã‚‰ãªã„複数ã®ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã¯ã€ä¸€ã¤ã«ã¾ã¨ã‚ã¦æ›¸ãã“ã¨ãŒã§ãã¾ã™ã€‚例ãˆã° \fB\-a\fR, \fB\-b\fR, \fB\-c\fR ã¨ã„ã†ä¸‰ã¤ã®ã‚ªãƒ—ション㯠\fB\-abc\fR ã¨æ›¸ã‘ã¾ã™ã€‚ .sp é•·ã„オプションã¯ã€äºŒã¤ã®ãƒã‚¤ãƒ•ンã¨ã‚ªãƒ—ションåã‚’è¡¨ã™æ–‡å­—列ã‹ã‚‰ãªã‚Šã¾ã™ã€‚例ãˆã° \fB\-\-long\-option\fR ã¯é•·ã„オプションã§ã™ã€‚オプションåã¯ä»–ã¨ç´›ã‚‰ã‚ã—ããªã„é™ã‚Šæœ«å°¾ã‚’çœç•¥ã§ãã¾ã™ã€‚例ãˆã°ä»–ã« \fB\-\-long\fR ã§å§‹ã¾ã‚‹é•·ã„オプションãŒãªã‘れã°ã€\fB\-\-long\-option\fR 㯠\fB\-\-long\fR ã¨çœç•¥ã§ãã¾ã™ã€‚引数をã¨ã‚‹ã‚ªãƒ—ションã§ã¯ã€ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã®å ´åˆã¨åŒæ§˜ã«ã€ã‚ªãƒ—ションã®ç›´å¾Œã«ã‚るコマンドライン引数ãŒãã®ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ã¿ãªã•れã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã€ã‚ªãƒ—ションåã®å¾Œã«ç­‰å· (\fB=\fR) ã§åŒºåˆ‡ã£ã¦ç›´æŽ¥å¼•数を与ãˆã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .PP \fB例5 Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨é•·ã„オプション\fR .sp Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ã€\fB\-\-quiet\fR ã¯å¼•æ•°ã‚’ã¨ã‚‰ãªã„é•·ã„オプションã€\fB\-\-editor\fR ã¯å¼•æ•°ã‚’ã¨ã‚‹é•·ã„オプションã§ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-\-editor vi \-\-quiet\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-\-editor=vi \-\-quiet\fR .RE .sp ã“ã®äºŒã¤ã®ä¾‹ã§ã¯ã€\fBvi\fR ㌠\fB\-\-editor\fR オプションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ãªã‚Šã¾ã™ã€‚ .sp オプション (ãŠã‚ˆã³ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°) 以外ã®å¼•æ•°ã¯ã€å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã¿ãªã•れã¾ã™ã€‚POSIX ã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯å…¨ã¦ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚ˆã‚Šå¾Œã«æ›¸ã‹ãªã‘れã°ãªã‚‰ãªã„ã¨å®šã‚ã¦ã„ã¾ã™ã€‚ãã®ãŸã‚ POSIX 準拠モードã§ã¯ã€æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚る引数㯠(ãŸã¨ãˆãれãŒã‚ªãƒ—ションã§ã‚るよã†ã«è¦‹ãˆã¦ã‚‚) å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å¾Œã«ã‚ªãƒ—ションを書ã„ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 .sp POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€ãƒã‚¤ãƒ•ン二ã¤ã‹ã‚‰ãªã‚‹å¼•æ•° (\fB\-\-\fR) ã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã®åŒºåˆ‡ã‚Šã¨ã—ã¦ä½¿ãˆã¾ã™ã€‚ã“ã®åŒºåˆ‡ã‚Šä»¥é™ã®å…¨ã¦ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れるãŸã‚ã€ãƒã‚¤ãƒ•ンã§å§‹ã¾ã‚‹ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’æ­£ã—ãæŒ‡å®šã§ãã¾ã™ã€‚ .PP \fB例6 Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰\fR .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-a \-b \-\- \-c \-d\fR .RE .sp ã“ã®ä¾‹ã§ã¯ã€\fB\-a\fR 㨠\fB\-b\fR ãŒã‚ªãƒ—ションã§ã€\fB\-c\fR 㨠\fB\-d\fR ãŒã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ãªã‚Šã¾ã™ã€‚区切り (\fB\-\-\fR) 自体ã¯ã‚ªãƒ—ションã§ã‚‚オペランドã§ã‚‚ã‚りã¾ã›ã‚“。 .sp POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€ãƒã‚¤ãƒ•ン一ã¤ã‹ã‚‰ãªã‚‹å¼•æ•° (\fB\-\fR) ã¯å¸¸ã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã¿ãªã•れã¾ã™ã€‚ .SH "行編集" .sp \fI行編集\fR機能ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã™ã‚‹éš›ã«ä½¿ãˆã‚‹ã€ã‚³ãƒžãƒ³ãƒ‰ã®ç°¡æ˜“編集機能ã§ã™ã€‚行編集機能ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã™ã‚‹ãŸã‚ã®ç°¡å˜ãªã‚¨ãƒ‡ã‚£ã‚¿ã¨ã—ã¦åƒãã¾ã™ã€‚行編集機能ã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã¨ã‚‚連æºã—ã¦ãŠã‚Šã€fc コマンドを使ã£ã¦ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã™ã‚‹ä»£ã‚りã«è¡Œç·¨é›†ã§ç›´æŽ¥ã‚³ãƒžãƒ³ãƒ‰ã‚’編集・å†å®Ÿè¡Œã§ãã¾ã™ã€‚ .sp 行編集ã«ã¯è¤‡æ•°ã®ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ãŒã‚りã€ãƒ¢ãƒ¼ãƒ‰ã”ã¨ã«ã‚­ãƒ¼æ“作ã®å‰²ã‚Šå½“ã¦ãŒç•°ãªã‚Šã¾ã™ã€‚è¡Œç·¨é›†ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’åˆ‡ã‚Šæ›¿ãˆãŸã‚Šãƒ¢ãƒ¼ãƒ‰ã‚’é¸æŠžã—ãŸã‚Šã™ã‚‹ã«ã¯ã€set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ—ションを設定ã—ã¾ã™ã€‚ã‚るモードã«å¯¾å¿œã™ã‚‹ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãã®ãƒ¢ãƒ¼ãƒ‰ã®è¡Œç·¨é›†ãŒæœ‰åйã«ãªã‚Šã¾ã™ (åŒæ™‚ã«ä»–ã®ãƒ¢ãƒ¼ãƒ‰ã®ã‚ªãƒ—ションã¯è‡ªå‹•çš„ã«ç„¡åйã«ãªã‚Šã¾ã™)。ç¾åœ¨æœ‰åйã«ãªã£ã¦ã„るモードã®ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã¨ã€è¡Œç·¨é›†ã¯ç„¡åйã«ãªã‚Šã¾ã™ã€‚ç¾åœ¨ yash ãŒæ­è¼‰ã—ã¦ã„る編集モード㯠vi 風㨠emacs 風ã®äºŒç¨®é¡žã§ã€ãれãžã‚Œå¯¾å¿œã™ã‚‹ã‚ªãƒ—ション㯠\fB\-o vi\fR 㨠\fB\-o emacs\fR ã§ã™ã€‚ .sp シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§èµ·å‹•ã—ãŸã¨ãã€æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ãªã‚‰ã°ã€vi 風行編集ãŒè‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚ .sp 行編集ã¯ã€æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ã®ã¨ãã ã‘使ãˆã¾ã™ã€‚ã“ã®æ¡ä»¶ãŒæº€ãŸã•れã¦ã„ãªã„ã¨ãã¯ã€è¡Œç·¨é›†ã¯åƒãã¾ã›ã‚“。行編集ãŒåƒãã¨ãã€ã‚·ã‚§ãƒ«ã¯ termios インタフェースを使用ã—ã¦ç«¯æœ«ã®å…¥å‡ºåŠ›ãƒ¢ãƒ¼ãƒ‰ã‚’ä¸€æ™‚çš„ã«å¤‰æ›´ã—ã€terminfo インタフェースを使用ã—ã¦å…¥åŠ›ã•れãŸã‚­ãƒ¼ã®åˆ¤åˆ¥ãªã©ã‚’行ã„ã¾ã™ã€‚ .SS "行編集ã®ã‚ªãƒ—ション" .sp 行編集を有効ã«ã—ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’é¸æŠžã™ã‚‹ã‚ªãƒ—ションã¨ã—ã¦ã€ä»¥ä¸‹ã®ã‚ªãƒ—ション㌠set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§è¨­å®šã§ãã¾ã™ã€‚ .PP vi .RS 4 Vi 風編集モードを有効ã«ã—ã¾ã™ .RE .PP emacs .RS 4 Emacs 風編集モードを有効ã«ã—ã¾ã™ .RE .sp ã“ã®ä»–ã«ã€è¡Œç·¨é›†ã«é–¢ã‚ã‚‹ã‚‚ã®ã¨ã—ã¦ä»¥ä¸‹ã®ã‚ªãƒ—ションãŒè¨­å®šã§ãã¾ã™ã€‚ .PP le\-always\-rp .RS 4 ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã¯ã€é•·ã„コマンドを入力ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ãŒå³ãƒ—ロンプトã«é”ã™ã‚‹ã¨ã€å³ãƒ—ロンプトã¯è¦‹ãˆãªããªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€å³ãƒ—ロンプトã¯è¦‹ãˆãªããªã‚‹ä»£ã‚りã«ä¸‹ã«ç§»å‹•ã—ã¾ã™ã€‚ .RE .PP le\-comp\-debug .RS 4 補完を行ã†éš›ã«ãƒ‡ãƒãƒƒã‚°ç”¨ã®æƒ…報を出力ã—ã¾ã™ .RE .PP le\-conv\-meta .RS 4 Terminfo データベースã§å¾—ã‚‰ã‚ŒãŸæƒ…報を無視ã—ã€å…¥åŠ›ã® 8 ビット目を常㫠meta\-key フラグã¨ã¿ãªã—ã¾ã™ã€‚ .RE .PP le\-no\-conv\-meta .RS 4 Terminfo データベースã§å¾—ã‚‰ã‚ŒãŸæƒ…報を無視ã—ã€å…¥åŠ›ã® 8 ビット目を他ã®ãƒ“ットã¨åŒæ§˜ã«æ‰±ã„ã¾ã™ã€‚ .sp Le\-conv\-meta オプション㨠le\-no\-conv\-meta オプションã¯ç‰‡æ–¹ã—ã‹æœ‰åйã«ã§ãã¾ã›ã‚“ (片方を有効ã«ã™ã‚‹ã¨ã‚‚ã†ç‰‡æ–¹ã¯è‡ªå‹•çš„ã«ç„¡åйã«ãªã‚Šã¾ã™)。ã©ã¡ã‚‰ã‚‚ç„¡åŠ¹ãªæ™‚㯠terminfo ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®æƒ…å ±ã«å¾“ã£ã¦ 8 ビット目を meta\-key ã¨ã¿ãªã™ã‹ã©ã†ã‹åˆ¤æ–­ã—ã¾ã™ã€‚ .RE .PP le\-prompt\-sp .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出力ã™ã‚‹å‰ã«ã€ãƒ—ロンプトãŒå¿…ãšè¡Œé ­ã«æ¥ã‚‹ã‚ˆã†ã«ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã™ã‚‹ãŸã‚ã®ç‰¹æ®Šãªæ–‡å­—列を出力ã—ã¾ã™ã€‚ .sp ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã¯æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ .RE .PP le\-visible\-bell .RS 4 シェルãŒè­¦å‘Šã‚’発ã™ã‚‹éš›ã€è­¦å‘ŠéŸ³ã‚’鳴らã™ä»£ã‚りã«ç«¯æœ«ã‚’点滅ã•ã›ã¾ã™ã€‚ .RE .SS "編集モード" .sp \fIVi 風編集モード\fR㯠vi ã«ä¼¼ãŸã‚­ãƒ¼æ“作ã§ç·¨é›†ã‚’行ã†ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚Vi 風編集モードã§ã¯ã€æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã¨ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã®äºŒã¤ã®ãƒ¢ãƒ¼ãƒ‰ã‚’é©å®œåˆ‡ã‚Šæ›¿ãˆã¦ç·¨é›†ã‚’行ã„ã¾ã™ã€‚編集ãŒå§‹ã¾ã‚‹ã¨ãã¯ãƒ¢ãƒ¼ãƒ‰ã¯å¿…ãšæŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«ãªã£ã¦ã„ã¾ã™ã€‚挿入モードã§ã¯å…¥åŠ›ã—ãŸæ–‡å­—ãŒåŸºæœ¬çš„ã«ãã®ã¾ã¾ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã•れã¾ã™ã€‚コマンドモードã§ã¯å…¥åŠ›ã—ãŸæ–‡å­—ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã—ãŸã‚Šæ–‡å­—を消去ã—ãŸã‚Šã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ .sp \fIEmacs 風編集モード\fR㯠emacs ã«ä¼¼ãŸã‚­ãƒ¼æ“作ã§ç·¨é›†ã‚’行ã†ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚入力ã—ãŸæ–‡å­—ã¯åŸºæœ¬çš„ã«ãã®ã¾ã¾ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã•れã¾ã™ãŒã€ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れる一部ã®ã‚­ãƒ¼æ“作㌠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã¨ç•°ãªã‚Šã¾ã™ã€‚ .sp ã“れらã®ãƒ¢ãƒ¼ãƒ‰ã®ä»–ã«ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®éš›ã«ç”¨ã„る検索モード㌠vi 風㨠emacs 風ã¨ãれãžã‚Œã«ã‚りã¾ã™ã€‚ .SS "行編集コマンド" .sp 行編集中ã«å…¥åŠ›ã•ã‚ŒãŸæ–‡å­—ã¯å…¨ã¦ä»¥ä¸‹ã®è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®ã„ãšã‚Œã‹ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚コマンドã¨ã‚­ãƒ¼ã®å¯¾å¿œã¯ bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¤‰æ›´ã§ãã¾ã™ (検索モードを除ã)。 .sp 以下ã®ä¸€è¦§ã«ã¯å„コマンドã«å¯¾å¿œã™ã‚‹ã‚­ãƒ¼å…¥åŠ›ã®åˆæœŸè¨­å®šã‚‚示ã—ã¦ã‚りã¾ã™ã€‚ãªãŠã€ 『vi\-insert〠㯠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã‚’〠『vi\-command〠㯠vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã‚’〠『vi\-search〠㯠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã‚’〠『emacs〠㯠emacs 風編集モードを〠『emacs\-search〠㯠emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã‚’示ã—ã¾ã™ã€‚ .sp コマンドã®ä¸­ã«ã¯å¼•数を指定ã™ã‚‹ã“ã¨ã§ãã®å‹•作を変更ã§ãã‚‹ã‚‚ã®ãŒã‚りã¾ã™ã€‚例ãˆã° forward\-char コマンドã¯é€šå¸¸ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’一文字分å‰ã«ç§»å‹•ã—ã¾ã™ãŒã€å¼•数を指定ã™ã‚‹ã¨ãã®å¼•æ•°ã®æ–‡å­—数分ã ã‘カーソルを移動ã—ã¾ã™ã€‚引数ã¯ã€ç›®çš„ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å‰ã« digit\-argument コマンドを使ã†ã“ã¨ã§æŒ‡å®šã§ãã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB基本的ãªç·¨é›†ã‚³ãƒžãƒ³ãƒ‰\fR .RS 4 .PP noop .RS 4 何も行ã„ã¾ã›ã‚“。 .PP vi\-command .RS 4 \fB\e^[\fR .RE .RE .PP alert .RS 4 警告音を発ã—ã¾ãŸã¯ç«¯æœ«ã‚’点滅ã•ã›ã¾ã™ã€‚ .RE .PP self\-insert .RS 4 入力ã—ãŸæ–‡å­—ã‚’ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚(エスケープシーケンスã«ã‚ˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã®å¯¾è±¡ã¨ãªã‚‹æ–‡å­—ã¯æŒ¿å…¥ã§ãã¾ã›ã‚“) .PP vi\-insert, emacs .RS 4 \fB\e\e\fR .RE .RE .PP insert\-tab .RS 4 タブをç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[\e^I\fR .RE .RE .PP expect\-verbatim .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã™ã‚‹ä¸€æ–‡å­—ã‚’ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã†ã¨ self\-insert コマンドã§å…¥åŠ›ã§ããªã„文字も入力ã§ãã¾ã™ (ナル文字 \fB\*(Aq\e0\*(Aq\fR を除ã)。 .PP vi\-insert, vi\-search, emacs\-search .RS 4 \fB\e^V\fR .RE .PP emacs .RS 4 \fB\e^Q\fR, \fB\e^V\fR .RE .RE .PP digit\-argument .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ•°å­—ã¾ãŸã¯ãƒã‚¤ãƒ•ンã®å…¥åŠ›ã«å¯¾ã—ã¦ã®ã¿æœ‰åйã§ã™ã€‚入力ã—ãŸæ•°å­—を次ã®ã‚³ãƒžãƒ³ãƒ‰ã¸ã®å¼•æ•°ã¨ã—ã¦å—ã‘付ã‘ã¾ã™ (ãƒã‚¤ãƒ•ンã®å ´åˆã¯ç¬¦å·ã‚’å転ã—ã¾ã™)。 .sp Digit\-argument コマンドを連続ã—ã¦ä½¿ã†ã“ã¨ã§è¤‡æ•°æ¡ã®å¼•数を指定ã§ãã¾ã™ã€‚例ãˆã° vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã§ \fB12l\fR ã¨å…¥åŠ›ã™ã‚‹ã¨ã€forward\-char コマンドã«å¼•æ•° 12 を与ãˆãŸã“ã¨ã«ãªã‚Šã¾ã™ (ã™ãªã‚ã¡ã‚«ãƒ¼ã‚½ãƒ«ãŒå·¦ã« 12 文字分移動ã—ã¾ã™)。 .PP vi\-command .RS 4 \fB1\fR, \fB2\fR, \fB3\fR, \fB4\fR, \fB5\fR, \fB6\fR, \fB7\fR, \fB8\fR, \fB9\fR .RE .PP emacs .RS 4 \fB\e^[0\fR, \fB\e^[1\fR, \fB\e^[2\fR, \fB\e^[3\fR, \fB\e^[4\fR, \fB\e^[5\fR, \fB\e^[6\fR, \fB\e^[7\fR, \fB\e^[8\fR, \fB\e^[9\fR, \fB\e^[\-\fR, .RE .RE .PP bol\-or\-digit .RS 4 引数ãŒãªã„å ´åˆã¯ beginning\-of\-line コマンドã¨åŒã˜ã‚ˆã†ã«ã€å¼•æ•°ãŒã‚ã‚‹å ´åˆã¯ digit\-argument コマンドã¨åŒã˜ã‚ˆã†ã«å‹•作ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB0\fR .RE .RE .PP accept\-line .RS 4 行編集を終了ã—ã€ç¾åœ¨ã®ãƒãƒƒãƒ•ã‚¡ã®å†…容をシェルã¸ã®å…¥åŠ›ã¨ã—ã¦ä¸Žãˆã¾ã™ã€‚è¡Œã®æœ«å°¾ã«ã¯è‡ªå‹•çš„ã«æ”¹è¡ŒãŒä»˜ã‘加ã‚りã¾ã™ã€‚ .PP vi\-insert, vi\-command, emacs, emacs\-search .RS 4 \fB\e^J\fR, \fB\e^M\fR .RE .RE .PP abort\-line .RS 4 行編集を中止ã—ã€ç©ºã®å…¥åŠ›ã‚’ã‚·ã‚§ãƒ«ã«ä¸Žãˆã¾ã™ã€‚ .PP vi\-insert, vi\-command, vi\-search, emacs, emacs\-search .RS 4 \fB\e!\fR, \fB\e^C\fR .RE .RE .PP eof .RS 4 シェルã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。 .RE .PP eof\-if\-empty .RS 4 ãƒãƒƒãƒ•ã‚¡ãŒç©ºãªã‚‰ã°ã€è¡Œç·¨é›†ã‚’終了ã—ã€ã‚·ã‚§ãƒ«ã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。ãƒãƒƒãƒ•ã‚¡ãŒç©ºã§ãªã‘れã°ã€alert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-insert, vi\-command .RS 4 \fB\e#\fR, \fB\e^D\fR .RE .RE .PP eof\-or\-delete .RS 4 ãƒãƒƒãƒ•ã‚¡ãŒç©ºãªã‚‰ã°ã€è¡Œç·¨é›†ã‚’終了ã—ã€ã‚·ã‚§ãƒ«ã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。ãƒãƒƒãƒ•ã‚¡ãŒç©ºã§ãªã‘れã°ã€delete\-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e#\fR, \fB\e^D\fR .RE .RE .PP accept\-with\-hash .RS 4 引数ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã‹ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã®æ–‡å­—㌠\fB#\fR ã§ãªã‘れã°ã€ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã« \fB#\fR を挿入ã—ã¾ã™ã€‚ãã†ã§ãªã‘れã°ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã® \fB#\fR を削除ã—ã¾ã™ã€‚ã„ãšã‚Œã®å ´åˆã‚‚ã€ãã®å¾Œ accept\-line コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB#\fR .RE .PP emacs .RS 4 \fB\e^[#\fR .RE .RE .PP setmode\-viinsert .RS 4 編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBi\fR, \fB\eI\fR .RE .RE .PP setmode\-vicommand .RS 4 編集モードを vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-insert .RS 4 \fB\e^[\fR .RE .RE .PP setmode\-emacs .RS 4 編集モードを emacs 風編集モードã«å¤‰æ›´ã—ã¾ã™ã€‚ .RE .PP expect\-char, abort\-expect\-char .RS 4 ã“れ㯠find\-char コマンドãªã©ã‚’実装ã™ã‚‹ãŸã‚ã« yash 内部ã§ä½¿ã‚れã¦ã„るコマンドã§ã€ç›´æŽ¥ä½¿ç”¨ã—ã¦ã‚‚æ„味ã¯ã‚りã¾ã›ã‚“。 .RE .PP redraw\-all .RS 4 行編集ã®ãƒ—ロンプトやãƒãƒƒãƒ•ァを端末ã«è¡¨ç¤ºã—ãªãŠã—ã¾ã™ã€‚ .PP vi\-insert, vi\-command, vi\-search, emacs, emacs\-search .RS 4 \fB\e^L\fR .RE .RE .PP clear\-and\-redraw\-all .RS 4 端末ã®è¡¨ç¤ºã‚’クリアã—ã€è¡Œç·¨é›†ã®ãƒ—ロンプトやãƒãƒƒãƒ•ァを端末ã«è¡¨ç¤ºã—ãªãŠã—ã¾ã™ã€‚ .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB移動コマンド\fR .RS 4 .sp \fI移動コマンド\fRã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã•ã›ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ã»ã¨ã‚“ã©ã®ç§»å‹•コマンドã¯å¼•数を与ãˆã‚‹ã“ã¨ã§ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’引数ã®å›žæ•°ã ã‘実行ã™ã‚‹ã®ã¨åŒã˜ã‚ˆã†ã«å‹•作ã•ã›ã‚‰ã‚Œã¾ã™ã€‚例ãˆã° forward\-char コマンドã«å¼•æ•° 4 を与ãˆã‚‹ã¨ã€ã‚«ãƒ¼ã‚½ãƒ«ã‚’ 4 文字先ã«é€²ã‚ã¾ã™ã€‚ .sp 以下ã€\fIbigword\fR ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸç©ºç™½ã§ãªã„文字をã„ã„ã€\fIsemiword\fR ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸç©ºç™½ã§ã‚‚å¥èª­ç‚¹ã§ã‚‚ãªã„文字をã„ã„ã€\fIemacsword\fR ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸè‹±æ•°å­—ã‚’ã„ã„ã¾ã™ã€‚ã¾ãŸ \fIviword\fR ã¨ã¯ä»¥ä¸‹ã®ã„ãšã‚Œã‹ã‚’ã„ã„ã¾ã™ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 一文字以上ã®é€£ç¶šã—ãŸè‹±æ•°å­—ã¾ãŸã¯ä¸‹ç·š (\fB_\fR) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 一文字以上ã®é€£ç¶šã—ãŸã€è‹±æ•°å­—ã§ã‚‚下線ã§ã‚‚空白ã§ã‚‚ãªã„文字 .RE .sp 以下ã«ç§»å‹•コマンドã®ä¸€è¦§ã‚’示ã—ã¾ã™ã€‚ .PP forward\-char .RS 4 ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-insert .RS 4 \fB\eR\fR .RE .PP vi\-command .RS 4 \fBl\fR, (space), \fB\eR\fR .RE .PP emacs .RS 4 \fB\eR\fR, \fB\e^F\fR .RE .RE .PP backward\-char .RS 4 カーソルをå‰ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-insert .RS 4 \fB\eL\fR .RE .PP vi\-command .RS 4 \fBh\fR, \fB\eB\fR, \fB\eL\fR, \fB\e?\fR, \fB\e^H\fR .RE .PP emacs .RS 4 \fB\eL\fR, \fB\e^B\fR .RE .RE .PP forward\-bigword .RS 4 カーソルを次㮠bigword ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBW\fR .RE .RE .PP end\-of\-bigword .RS 4 カーソルを bigword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBE\fR .RE .RE .PP backward\-bigword .RS 4 カーソルをå‰ã® bigword ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBB\fR .RE .RE .PP forward\-semiword .RS 4 カーソルを次㮠semiword ã«ç§»å‹•ã—ã¾ã™ã€‚ .RE .PP end\-of\-semiword .RS 4 カーソルを semiword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚ .RE .PP backward\-semiword .RS 4 カーソルをå‰ã® semiword ã«ç§»å‹•ã—ã¾ã™ã€‚ .RE .PP forward\-viword .RS 4 カーソルを次㮠viword ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBw\fR .RE .RE .PP end\-of\-viword .RS 4 カーソルを viword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBe\fR .RE .RE .PP backward\-viword .RS 4 カーソルをå‰ã® viword ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBb\fR .RE .RE .PP forward\-emacsword .RS 4 カーソルを次㮠emacsword ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[f\fR, \fB\e^[F\fR .RE .RE .PP backward\-emacsword .RS 4 カーソルをå‰ã® emacsword ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[b\fR, \fB\e^[B\fR .RE .RE .PP beginning\-of\-line .RS 4 カーソルをãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-insert, vi\-command .RS 4 \fB\eH\fR .RE .PP emacs .RS 4 \fB\eH\fR, \fB\e^A\fR .RE .RE .PP end\-of\-line .RS 4 カーソルをãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-insert .RS 4 \fB\eE\fR .RE .PP vi\-command .RS 4 \fB$\fR, \fB\eE\fR .RE .PP emacs .RS 4 \fB\eE\fR, \fB\e^E\fR .RE .RE .PP go\-to\-column .RS 4 カーソルをãƒãƒƒãƒ•ァ内㮠\fIn\fR 文字目ã«ç§»å‹•ã—ã¾ã™ã€‚ãŸã ã— \fIn\fR ã¯å¼•æ•°ã§ã™ (引数ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ 1)。 .PP vi\-command .RS 4 \fB|\fR .RE .RE .PP first\-nonblank .RS 4 カーソルをãƒãƒƒãƒ•ã‚¡å†…ã®æœ€åˆã®ç©ºç™½ã§ãªã„文字ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB^\fR .RE .RE .PP find\-char .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’進ã‚ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBf\fR .RE .PP emacs .RS 4 \fB\e^]\fR .RE .RE .PP find\-char\-rev .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’戻ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBF\fR .RE .PP emacs .RS 4 \fB\e^[\e^]\fR .RE .RE .PP till\-char .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã®ç›´å‰ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’進ã‚ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBt\fR .RE .RE .PP till\-char\-rev .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã®ç›´å¾Œã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’戻ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBT\fR .RE .RE .PP refind\-char .RS 4 å‰å›žå®Ÿè¡Œã—㟠find\-char, find\-char\-rev, till\-char, till\-char\-rev コマンドをå†å®Ÿè¡Œã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB;\fR .RE .RE .PP refind\-char\-rev .RS 4 å‰å›žå®Ÿè¡Œã—㟠find\-char, find\-char\-rev, till\-char, till\-char\-rev コマンドをã€ã‚«ãƒ¼ã‚½ãƒ«ã®é€²ã‚€å‘ãを逆ã«ã—ã¦å†å®Ÿè¡Œã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB,\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB編集コマンド\fR .RS 4 .sp 編集コマンドã¯ãƒãƒƒãƒ•ã‚¡ã®å†…容を変更ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ã»ã¨ã‚“ã©ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¯å¼•数を与ãˆã‚‹ã“ã¨ã§ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’引数ã®å›žæ•°ã ã‘実行ã™ã‚‹ã®ã¨åŒã˜ã‚ˆã†ã«å‹•作ã•ã›ã‚‰ã‚Œã¾ã™ã€‚ .sp åå‰ã« 『kill〠ãŒä»˜ãコマンドã§å‰Šé™¤ã—ãŸæ–‡å­—列ã¯\fIキルリング\fRã¨ã„ã†å ´æ‰€ã«ä¿ç®¡ã•れã€å¾Œã§ put ãªã©ã®ã‚³ãƒžãƒ³ãƒ‰ã§ãƒãƒƒãƒ•ã‚¡ã«æˆ»ã™ã“ã¨ãŒã§ãã¾ã™ã€‚ .sp 以下ã«ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®ä¸€è¦§ã‚’示ã—ã¾ã™ã€‚ .PP delete\-char .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill\-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-insert, emacs .RS 4 \fB\eX\fR .RE .RE .PP delete\-bigword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ bigword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill\-bigword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP delete\-semiword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ semiword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill\-semiword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP delete\-viword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ viword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill\-viword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP delete\-emacsword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ emacsword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill\-emacsword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP backward\-delete\-char .RS 4 カーソルã®å‰ã«ã‚る文字を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward\-kill\-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-insert, emacs .RS 4 \fB\eB\fR, \fB\e?\fR, \fB\e^H\fR .RE .RE .PP backward\-delete\-bigword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ bigword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward\-kill\-bigword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP backward\-delete\-semiword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ semiword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward\-kill\-semiword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-insert .RS 4 \fB\e^W\fR .RE .RE .PP backward\-delete\-viword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ viword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward\-kill\-viword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP backward\-delete\-emacsword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ emacsword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward\-kill\-emacsword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP delete\-line .RS 4 ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã¾ã™ã€‚ .RE .PP forward\-delete\-line .RS 4 カーソル以é™ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã¾ã™ã€‚ .RE .PP backward\-delete\-line .RS 4 カーソルよりå‰ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã¾ã™ã€‚ .PP vi\-insert .RS 4 \fB\e$\fR, \fB\e^U\fR .RE .RE .PP kill\-char .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBx\fR, \fB\eX\fR .RE .RE .PP kill\-bigword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ bigword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .RE .PP kill\-semiword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ semiword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .RE .PP kill\-viword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ viword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .RE .PP kill\-emacsword .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ emacsword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[d\fR, \fB\e^[D\fR .RE .RE .PP backward\-kill\-char .RS 4 カーソルã®å‰ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBX\fR .RE .RE .PP backward\-kill\-bigword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ bigword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^W\fR .RE .RE .PP backward\-kill\-semiword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ semiword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .RE .PP backward\-kill\-viword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ viword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .RE .PP backward\-kill\-emacsword .RS 4 カーソルã®å‰ã«ã‚ã‚‹ emacsword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[\eB\fR, \fB\e^[\e?\fR, \fB\e^[\e^H\fR .RE .RE .PP kill\-line .RS 4 ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .RE .PP forward\-kill\-line .RS 4 カーソル以é™ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^K\fR .RE .RE .PP backward\-kill\-line .RS 4 カーソルよりå‰ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e$\fR, \fB\e^U\fR, \fB\e^X\eB\fR, \fB\e^X\e?\fR .RE .RE .PP put\-before .RS 4 最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å‰ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—åˆ—ã®æœ€å¾Œã®æ–‡å­—ã®ã¨ã“ã‚ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBP\fR .RE .RE .PP put .RS 4 最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å¾Œã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—åˆ—ã®æœ€å¾Œã®æ–‡å­—ã®ã¨ã“ã‚ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBp\fR .RE .RE .PP put\-left .RS 4 最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å‰ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—列ã®ç›´å¾Œã«ç§»å‹•ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^Y\fR .RE .RE .PP put\-pop .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ put\-before, put, put\-left, put\-pop コマンドã®ç›´å¾Œã«ã ã‘使ãˆã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã‚­ãƒ«ãƒªãƒ³ã‚°ã‹ã‚‰æŒ¿å…¥ã—ãŸæ–‡å­—列を削除ã—ã€ä»£ã‚りã«ãã®æ–‡å­—列ã®å‰ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列を挿入ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[y\fR, \fB\e^[Y\fR .RE .RE .PP undo .RS 4 ç›´å‰ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容をå‰ã®çŠ¶æ…‹ã«æˆ»ã—ã¾ã™ã€‚ .PP vi .RS 4 \fBu\fR .RE .PP emacs .RS 4 \fB\e^_\fR, \fB\e^X\e$\fR, \fB\e^X\e^U\fR .RE .RE .PP undo\-all .RS 4 å…¨ã¦ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…å®¹ã‚’åˆæœŸçŠ¶æ…‹ã«æˆ»ã—ã¾ã™ã€‚ .PP vi .RS 4 \fBU\fR .RE .PP emacs .RS 4 \fB\e^[\e^R\fR, \fB\e^[r\fR, \fB\e^[R\fR .RE .RE .PP cancel\-undo .RS 4 undo, undo\-all ã«ã‚ˆã‚‹ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®å–り消ã—ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を復元ã—ã¾ã™ã€‚ .PP vi .RS 4 \fB\e^R\fR .RE .RE .PP cancel\-undo\-all .RS 4 undo, undo\-all ã«ã‚ˆã‚‹ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®å–り消ã—ã‚’å…¨ã¦å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を復元ã—ã¾ã™ã€‚ .RE .PP redo .RS 4 ç›´å‰ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’繰り返ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB\&.\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB補完コマンド\fR .RS 4 .PP complete .RS 4 ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã¾ã™ã€‚補完候補ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãã®ä¸€è¦§ã‚’表示ã—ã¾ã™ã€‚ .RE .PP complete\-next\-candidate .RS 4 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-insert, emacs .RS 4 \fB\e^I\fR .RE .RE .PP complete\-prev\-candidate .RS 4 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-insert, emacs .RS 4 \fB\ebt\fR .RE .RE .PP complete\-next\-column .RS 4 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®åˆ—ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP complete\-prev\-column .RS 4 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®åˆ—ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP complete\-next\-page .RS 4 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®ãƒšãƒ¼ã‚¸ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP complete\-prev\-page .RS 4 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®ãƒšãƒ¼ã‚¸ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP complete\-list .RS 4 ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã¾ã™ã€‚引数を指定ã—ãªã„å ´åˆã€è£œå®Œå€™è£œã®ä¸€è¦§ã‚’表示ã—ã¾ã™ã€‚引数を指定ã™ã‚‹ã¨ã€ãã®ç•ªå·ã®å€™è£œã§è£œå®Œå†…容を確定ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[?\fR, \fB\e^[=\fR .RE .RE .PP complete\-all .RS 4 ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã€ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã«ã‚ã‚‹å˜èªžã‚’ã™ã¹ã¦ã®è£œå®Œå€™è£œã§ç½®ãæ›ãˆã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[*\fR .RE .RE .PP complete\-max .RS 4 ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã€å„è£œå®Œå€™è£œã®æœ€é•·å…±é€šå…ˆé ­éƒ¨åˆ†ã‚’カーソルä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚ .RE .PP clear\-candidates .RS 4 補完候補ã®ä¸€è¦§ã‚’消去ã—ã¾ã™ã€‚ .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBVi 固有ã®ã‚³ãƒžãƒ³ãƒ‰\fR .RS 4 .PP vi\-replace\-char .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚る文字をã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ã«ç½®ãæ›ãˆã¾ã™ã€‚ .PP vi\-command .RS 4 \fBr\fR .RE .RE .PP vi\-insert\-beginning .RS 4 カーソルをãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode\-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBI\fR .RE .RE .PP vi\-append .RS 4 ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode\-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBI\fR .RE .RE .PP vi\-append\-to\-eol .RS 4 カーソルをãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode\-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBA\fR .RE .RE .PP vi\-replace .RS 4 Setmode\-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ãŒã€åŒæ™‚ã«ä¸Šæ›¸ãモードを有効ã«ã—ã¾ã™ã€‚上書ãモードã§ã¯ã€self\-insert ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—を挿入ã™ã‚‹ä»£ã‚りã«ã‚«ãƒ¼ã‚½ãƒ«ã®ã¨ã“ã‚ã«ã‚ã‚‹æ–‡å­—ã‚’ç½®ãæ›ãˆã¾ã™ã€‚上書ãモードã¯ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’変更ã™ã‚‹ã¾ã§æœ‰åйã§ã™ã€‚ .PP vi\-command .RS 4 \fBR\fR .RE .RE .PP vi\-switch\-case .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字ã®å¤§æ–‡å­—ã¨å°æ–‡å­—を入れ替ãˆã¾ã™ã€‚ .RE .PP vi\-switch\-case\-char .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚る文字ã®å¤§æ–‡å­—ã¨å°æ–‡å­—を入れ替ãˆã¦ã€ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB~\fR .RE .RE .PP vi\-yank .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字をキルリングã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBy\fR .RE .RE .PP vi\-yank\-to\-eol .RS 4 カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字をキルリングã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBY\fR .RE .RE .PP vi\-delete .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBd\fR .RE .RE .PP vi\-delete\-to\-eol .RS 4 カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBD\fR .RE .RE .PP vi\-change .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字を削除ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBc\fR .RE .RE .PP vi\-change\-to\-eol .RS 4 カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字を削除ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ Delete the characters from the current cursor position to the end of the line and switch to the vi insert mode\&. .PP vi\-command .RS 4 \fBC\fR .RE .RE .PP vi\-change\-line .RS 4 ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBS\fR .RE .RE .PP vi\-yank\-and\-change .RS 4 Vi\-change コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚ .RE .PP vi\-yank\-and\-change\-to\-eol .RS 4 Vi\-change\-to\-eol コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚ .RE .PP vi\-yank\-and\-change\-line .RS 4 Vi\-change\-line コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚ .RE .PP vi\-substitute .RS 4 カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—キルリングã«ä¿ç®¡ã—ãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBs\fR .RE .RE .PP vi\-append\-last\-bigword .RS 4 コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ãŠã‘る最後㮠bigword ã‚’ã€ç©ºç™½æ–‡å­—ã«ç¶šã‘ã¦ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã®ç›´å¾Œã«æŒ¿å…¥ã—ã¾ã™ã€‚引数 \fIn\fR を与ãˆãŸã¨ãã¯æœ€å¾Œã® bigword ã®ä»£ã‚り㫠\fIn\fR 番目㮠bigword を挿入ã—ã¾ã™ã€‚ãã®å¾Œã€setmode\-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB_\fR .RE .RE .PP vi\-exec\-alias .RS 4 ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ã‚’ \fIc\fR ã¨ã™ã‚‹ã¨ã€\fB_\fR\fB\fIc\fR\fR ã¨ã„ã†åå‰ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®å†…容をシェルã¸ã®å…¥åŠ›ã¨ã¿ãªã—ã¦è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB@\fR .RE .RE .PP vi\-edit\-and\-accept .RS 4 エディタã¨ã—㦠vi ã‚’èµ·å‹•ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を編集ã•ã›ã¾ã™ã€‚エディタãŒçµ‚了ã™ã‚‹ã¨ç·¨é›†å¾Œã®å†…容をãƒãƒƒãƒ•ã‚¡ã«å映ã—ãŸå¾Œ accept\-line コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ãŸã ã—エディタã®çµ‚了ステータス㌠0 ã§ãªã„ã¨ãã¯ä½•も行ã„ã¾ã›ã‚“。 .PP vi\-command .RS 4 \fBv\fR .RE .RE .PP vi\-complete\-list .RS 4 Complete\-list コマンドã¨åŒæ§˜ã§ã™ãŒã€å€™è£œã‚’確定ã—ãŸã¨ã編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB=\fR .RE .RE .PP vi\-complete\-all .RS 4 Complete\-all コマンドã¨åŒæ§˜ã§ã™ãŒã€å˜èªžã‚’ç½®ãæ›ãˆãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB*\fR .RE .RE .PP vi\-complete\-max .RS 4 Complete\-max コマンドã¨åŒæ§˜ã§ã™ãŒã€å€™è£œã‚’挿入ã—ãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB\e\e\fR .RE .RE .PP vi\-search\-forward .RS 4 順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB?\fR .RE .RE .PP vi\-search\-backward .RS 4 逆方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fB/\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBEmacs 固有ã®ã‚³ãƒžãƒ³ãƒ‰\fR .RS 4 .PP emacs\-transpose\-chars .RS 4 カーソルã®å‰ã«ã‚る文字をå³ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^T\fR .RE .RE .PP emacs\-transpose\-words .RS 4 カーソルã®å‰ã«ã‚ã‚‹ emacsword ã‚’å³ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[t\fR, \fB\e^[T\fR .RE .RE .PP emacs\-downcase\-word .RS 4 カーソルã®å¾Œã«ã‚ã‚‹ emacsword ã‚’å°æ–‡å­—ã«å¤‰æ›ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[l\fR, \fB\e^[L\fR .RE .RE .PP emacs\-upcase\-word .RS 4 カーソルã®å¾Œã«ã‚ã‚‹ emacsword を大文字ã«å¤‰æ›ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[u\fR, \fB\e^[U\fR .RE .RE .PP emacs\-capitalize\-word .RS 4 カーソルã®å¾Œã«ã‚ã‚‹ emacsword をキャピタライズã—ã¾ã™ (å„å˜èªžã®é ­æ–‡å­—ã ã‘大文字ã«ã™ã‚‹)。 .PP emacs .RS 4 \fB\e^[c\fR, \fB\e^[u\fR .RE .RE .PP emacs\-delete\-horizontal\-space .RS 4 カーソルã®å‰å¾Œã«ã‚る空白を削除ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ã‚«ãƒ¼ã‚½ãƒ«ã®å‰ã«ã‚る空白を削除ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[\e\e\fR .RE .RE .PP emacs\-just\-one\-space .RS 4 カーソルã®å‰å¾Œã«ã‚る空白ã®å€‹æ•°ã‚’一ã¤ã«èª¿æ•´ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãã®å¼•æ•°ã®æ•°ã ã‘空白を残ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[\fR (エスケープã®å¾Œã«ç©ºç™½æ–‡å­—) .RE .RE .PP emacs\-search\-forward .RS 4 順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^S\fR .RE .RE .PP emacs\-search\-backward .RS 4 順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^R\fR .RE .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBコマンド履歴関連ã®ã‚³ãƒžãƒ³ãƒ‰\fR .RS 4 .PP oldest\-history .RS 4 コマンド履歴ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 .RE .PP newest\-history .RS 4 コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 .RE .PP return\-history .RS 4 コマンド履歴ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 .RE .PP oldest\-history\-bol .RS 4 コマンド履歴ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBG\fR .RE .RE .PP newest\-history\-bol .RS 4 コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ .RE .PP return\-history\-bol .RS 4 コマンド履歴ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBg\fR .RE .RE .PP oldest\-history\-eol .RS 4 コマンド履歴ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[<\fR .RE .RE .PP newest\-history\-eol .RS 4 コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ .RE .PP return\-history\-eol .RS 4 コマンド履歴ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ .PP emacs .RS 4 \fB\e^[>\fR .RE .RE .PP next\-history .RS 4 コマンド履歴ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 .RE .PP prev\-history .RS 4 コマンド履歴ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 .RE .PP next\-history\-bol .RS 4 コマンド履歴ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ .PP vi\-command .RS 4 \fBj\fR, \fB+\fR, \fB\eD\fR, \fB\e^N\fR .RE .RE .PP prev\-history\-bol .RS 4 コマンド履歴ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ .PP vi\-command .RS 4 \fBk\fR, \fB\-\fR, \fB\eU\fR, \fB\e^P\fR .RE .RE .PP next\-history\-eol .RS 4 コマンド履歴ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ .PP vi\-insert, emacs .RS 4 \fB\eD\fR, \fB\e^N\fR .RE .RE .PP prev\-history\-eol .RS 4 コマンド履歴ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ .PP vi\-insert, emacs .RS 4 \fB\eU\fR, \fB\e^P\fR .RE .RE .PP search\-again .RS 4 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBn\fR .RE .RE .PP search\-again\-rev .RS 4 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’æ–¹å‘を逆ã«ã—ã¦ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ .PP vi\-command .RS 4 \fBN\fR .RE .RE .PP search\-again\-forward .RS 4 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’順方å‘ã«ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ .RE .PP search\-again\-backward .RS 4 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’逆方å‘ã«ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ .RE .PP beginning\-search\-forward .RS 4 コマンド履歴を順方å‘ã«æ¤œç´¢ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã¾ã§ã®é–“ã«ã‚る文字列ãŒåŒã˜æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 .RE .PP beginning\-search\-backward .RS 4 コマンド履歴を逆方å‘ã«æ¤œç´¢ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã¾ã§ã®é–“ã«ã‚る文字列ãŒåŒã˜å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBコマンド履歴検索モードã®ã‚³ãƒžãƒ³ãƒ‰\fR .RS 4 .PP srch\-self\-insert .RS 4 入力ã—ãŸæ–‡å­—を検索用ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã—ã¾ã™ã€‚(エスケープシーケンスã«ã‚ˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã®å¯¾è±¡ã¨ãªã‚‹æ–‡å­—ã¯æŒ¿å…¥ã§ãã¾ã›ã‚“) .PP vi\-search, emacs\-search .RS 4 \fB\e\e\fR .RE .RE .PP srch\-backward\-delete\-char .RS 4 検索用ãƒãƒƒãƒ•ã‚¡ã®æœ€å¾Œã®ä¸€æ–‡å­—を削除ã—ã¾ã™ã€‚検索用ãƒãƒƒãƒ•ã‚¡ãŒç©ºã®å ´åˆã¯: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} vi 風編集モードã§ã¯ srch\-abort\-search コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} emacs 風編集モードã§ã¯ alert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ .RE .PP vi\-search, emacs\-search .RS 4 \fB\eB\fR, \fB\e?\fR, \fB\e^H\fR .RE .RE .PP srch\-backward\-delete\-line .RS 4 検索用ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã¾ã™ã€‚ .PP vi\-search, emacs\-search .RS 4 \fB\e$\fR, \fB\e^U\fR .RE .RE .PP srch\-continue\-forward .RS 4 ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã®æ¬¡ã®çµæžœã‚’順方å‘ã«æŽ¢ã—ã¾ã™ã€‚ .PP emacs\-search .RS 4 \fB\e^S\fR .RE .RE .PP srch\-continue\-backward .RS 4 ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã®æ¬¡ã®çµæžœã‚’逆方å‘ã«æŽ¢ã—ã¾ã™ã€‚ .PP emacs\-search .RS 4 \fB\e^R\fR .RE .RE .PP srch\-accept\-search .RS 4 検索を終了ã—ã€ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã‚’確定ã—ã¾ã™ã€‚æ¤œç´¢çµæžœã«ç§»å‹•ã—ã¾ã™ã€‚ .PP vi\-search .RS 4 \fB\e^J\fR, \fB\e^M\fR .RE .PP emacs\-search .RS 4 \fB\e^J\fR, \fB\e^[\fR .RE .RE .PP srch\-abort\-search .RS 4 検索を中止ã—ã€æ¤œç´¢ã‚’é–‹å§‹ã™ã‚‹å‰ã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚ .PP vi\-search .RS 4 \fB\e^[\fR .RE .PP emacs\-search .RS 4 \fB\e^G\fR .RE .RE .RE .SS "エスケープシーケンス" .sp Bindkey コマンドã§è¡Œç·¨é›†ã®ã‚­ãƒ¼è¨­å®šã‚’表示・設定ã™ã‚‹éš›ã€ãƒ•ァンクションキーãªã©ã®ç‰¹æ®Šãªã‚­ãƒ¼ã¯ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã§è¡¨ã‚ã—ã¾ã™ã€‚エスケープシーケンスã¯å…¨ã¦ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\fB\e\fR) ã§å§‹ã¾ã‚Šã¾ã™ã€‚ã¾ãŸãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãã®ã‚‚ã®ã‚‚エスケープã®å¯¾è±¡ã§ã™ã€‚エスケープシーケンスã«å¯¾ã™ã‚‹ã‚­ãƒ¼ã®å‰²ã‚Šå½“ã¦ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\e\e\fR .RS 4 ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\fB\e\fR) .RE .PP \fB\eB\fR .RS 4 Backspace .RE .PP \fB\eD\fR .RS 4 ↓矢å°ã‚­ãƒ¼ .RE .PP \fB\eE\fR .RS 4 End .RE .PP \fB\eH\fR .RS 4 Home .RE .PP \fB\eI\fR .RS 4 Insert (Insert\-char, Enter\-insert\-mode) .RE .PP \fB\eL\fR .RS 4 â†çŸ¢å°ã‚­ãƒ¼ .RE .PP \fB\eN\fR .RS 4 Page\-down (Next\-page) .RE .PP \fB\eP\fR .RS 4 Page\-up (Previous\-page) .RE .PP \fB\eR\fR .RS 4 →矢å°ã‚­ãƒ¼ .RE .PP \fB\eU\fR .RS 4 ↑矢å°ã‚­ãƒ¼ .RE .PP \fB\eX\fR .RS 4 Delete .RE .PP \fB\e!\fR .RS 4 INTR .RE .PP \fB\e#\fR .RS 4 EOF .RE .PP \fB\e$\fR .RS 4 KILL .RE .PP \fB\e?\fR .RS 4 ERASE .RE .PP \fB\e^@\fR .RS 4 Ctrl + @ .RE .PP \fB\e^A\fR, \fB\e^B\fR, \&..., \fB\e^Z\fR .RS 4 Ctrl + A, Ctrl + B, \&..., Ctrl + Z .sp ※ Ctrl + I 㯠Tabã€Ctrl + J 㯠Newlineã€Ctrl + M 㯠Carriage\-return ã§ã™ã€‚ .RE .PP \fB\e^[\fR .RS 4 Ctrl + [ (Escape) .RE .PP \fB\e^\e\fR .RS 4 Ctrl + \e .RE .PP \fB\e^]\fR .RS 4 Ctrl + ] .RE .PP \fB\e^^\fR .RS 4 Ctrl + ^ .RE .PP \fB\e^_\fR .RS 4 Ctrl + _ .RE .PP \fB\e^?\fR .RS 4 Ctrl + ? (Delete) .RE .PP \fB\eF00\fR, \fB\eF01\fR, \&..., \fB\eF63\fR .RS 4 F0, F1, \&..., F63 .RE .PP \fB\ea1\fR .RS 4 キーパッドã®å·¦ä¸Šã‚­ãƒ¼ .RE .PP \fB\ea3\fR .RS 4 キーパッドã®å³ä¸Šã‚­ãƒ¼ .RE .PP \fB\eb2\fR .RS 4 キーパッドã®ä¸­å¤®ã‚­ãƒ¼ .RE .PP \fB\ebg\fR .RS 4 Beginning .RE .PP \fB\ebt\fR .RS 4 Back\-tab .RE .PP \fB\ec1\fR .RS 4 キーパッドã®å·¦ä¸‹ã‚­ãƒ¼ .RE .PP \fB\ec3\fR .RS 4 キーパッドã®å³ä¸‹ã‚­ãƒ¼ .RE .PP \fB\eca\fR .RS 4 Clear\-all\-tabs .RE .PP \fB\ecl\fR .RS 4 Close .RE .PP \fB\ecn\fR .RS 4 Cancel .RE .PP \fB\eco\fR .RS 4 Command .RE .PP \fB\ecp\fR .RS 4 Copy .RE .PP \fB\ecr\fR .RS 4 Create .RE .PP \fB\ecs\fR .RS 4 Clear\-screen ã¾ãŸã¯ erase .RE .PP \fB\ect\fR .RS 4 Clear\-tab .RE .PP \fB\edl\fR .RS 4 Delete\-line .RE .PP \fB\eei\fR .RS 4 Exit\-insert\-mode .RE .PP \fB\eel\fR .RS 4 Clear\-to\-end\-of\-line .RE .PP \fB\ees\fR .RS 4 Clear\-to\-end\-of\-screen .RE .PP \fB\eet\fR .RS 4 Enter (Send) .RE .PP \fB\eex\fR .RS 4 Exit .RE .PP \fB\efd\fR .RS 4 Find .RE .PP \fB\ehp\fR .RS 4 Help .RE .PP \fB\eil\fR .RS 4 Insert\-line .RE .PP \fB\ell\fR .RS 4 Home\-down .RE .PP \fB\eme\fR .RS 4 Message .RE .PP \fB\emk\fR .RS 4 Mark .RE .PP \fB\ems\fR .RS 4 マウスイベント .RE .PP \fB\emv\fR .RS 4 Move .RE .PP \fB\enx\fR .RS 4 Next\-object .RE .PP \fB\eon\fR .RS 4 Open .RE .PP \fB\eop\fR .RS 4 Options .RE .PP \fB\epr\fR .RS 4 Print (Copy) .RE .PP \fB\epv\fR .RS 4 Previous\-object .RE .PP \fB\erd\fR .RS 4 Redo .RE .PP \fB\ere\fR .RS 4 Resume .RE .PP \fB\erf\fR .RS 4 Ref (Reference) .RE .PP \fB\erh\fR .RS 4 Refresh .RE .PP \fB\erp\fR .RS 4 Replace .RE .PP \fB\ers\fR .RS 4 Restart .RE .PP \fB\esf\fR .RS 4 Scroll\-forward (Scroll\-down) .RE .PP \fB\esl\fR .RS 4 Select .RE .PP \fB\esr\fR .RS 4 Scroll\-backward (Scroll\-up) .RE .PP \fB\est\fR .RS 4 Set\-tab .RE .PP \fB\esu\fR .RS 4 Suspend .RE .PP \fB\esv\fR .RS 4 Save .RE .PP \fB\eud\fR .RS 4 Undo .RE .PP \fB\eSE\fR .RS 4 Shift + End .RE .PP \fB\eSH\fR .RS 4 Shift + Home .RE .PP \fB\eSI\fR .RS 4 Shift + Insert .RE .PP \fB\eSL\fR .RS 4 Shift + â†çŸ¢å°ã‚­ãƒ¼ .RE .PP \fB\eSR\fR .RS 4 Shift + →矢å°ã‚­ãƒ¼ .RE .PP \fB\eSX\fR .RS 4 Shift + Delete .RE .PP \fB\eSbg\fR .RS 4 Shift + Beginning .RE .PP \fB\eScn\fR .RS 4 Shift + Cancel .RE .PP \fB\eSco\fR .RS 4 Shift + Command .RE .PP \fB\eScp\fR .RS 4 Shift + Copy .RE .PP \fB\eScr\fR .RS 4 Shift + Create .RE .PP \fB\eSdl\fR .RS 4 Shift + Delete\-line .RE .PP \fB\eSel\fR .RS 4 Shift + End\-of\-line .RE .PP \fB\eSex\fR .RS 4 Shift + Exit .RE .PP \fB\eSfd\fR .RS 4 Shift + Find .RE .PP \fB\eShp\fR .RS 4 Shift + Help .RE .PP \fB\eSmg\fR .RS 4 Shift + Message .RE .PP \fB\eSmv\fR .RS 4 Shift + Move .RE .PP \fB\eSnx\fR .RS 4 Shift + Next .RE .PP \fB\eSop\fR .RS 4 Shift + Options .RE .PP \fB\eSpr\fR .RS 4 Shift + Print .RE .PP \fB\eSpv\fR .RS 4 Shift + Previous .RE .PP \fB\eSrd\fR .RS 4 Shift + Redo .RE .PP \fB\eSre\fR .RS 4 Shift + Resume .RE .PP \fB\eSrp\fR .RS 4 Shift + Replace .RE .PP \fB\eSsu\fR .RS 4 Shift + Suspend .RE .PP \fB\eSsv\fR .RS 4 Shift + Save .RE .PP \fB\eSud\fR .RS 4 Shift + Undo .RE .sp INTR, EOF, KILL, ERASE ã®å››ã¤ã¯ stty コマンドãªã©ã§è¨­å®šã•れる端末ã®ç‰¹æ®Šæ–‡å­—ã§ã™ã€‚一般的ãªç’°å¢ƒã§ã¯ã€INTR 㯠Ctrl + C ã«ã€EOF 㯠Ctrl + D ã«ã€KILL 㯠Ctrl + U ã«ã€ERASE 㯠Ctrl + H ã¾ãŸã¯ Ctrl + ? ã«è¨­å®šã•れã¦ã„ã¾ã™ã€‚ã“れら四ã¤ã¯ä»–ã®ã‚­ãƒ¼å…¥åŠ›ã‚ˆã‚Šã‚‚å„ªå…ˆã—ã¦èªè­˜ã•れã¾ã™ã€‚ .SS "コマンドライン補完" .sp 行編集ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã—ã¦ã„る途中㧠Tab キーを押ã™ã“ã¨ã§ã€ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã‚„オプションã€å¼•数を補完ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚コマンドåやファイルåを途中ã¾ã§æ‰“ã¡è¾¼ã‚“ã ã¨ã“ã‚ã§ Tab キーを押ã™ã¨ã€ãã®åå‰ã«ä¸€è‡´ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰åやファイルåã®ä¸€è¦§ãŒç¾ã‚Œã¾ã™ã€‚ã•らã«ç¶šã‘㦠Tab キーを押ã™ã¨ã€å…¥åŠ›ã—ãŸã„åå‰ã‚’一覧ã®ä¸­ã‹ã‚‰é¸ã¶ã“ã¨ãŒã§ãã¾ã™ã€‚(一致ã™ã‚‹åå‰ãŒä¸€ã¤ã—ã‹ãªã„å ´åˆã¯ã€ä¸€è¦§ã¯ç¾ã‚Œãšã€ç›´æŽ¥åå‰ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å…¥åŠ›ã•れã¾ã™ã€‚) .sp 補完ã®å¯¾è±¡ã¨ãªã‚‹åå‰ã« \fB*\fR ã‚„ \fB?\fR ãªã©ã®æ–‡å­—ãŒå…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®ãƒ‘ターンã«ä¸€è‡´ã™ã‚‹åå‰å…¨ã¦ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å±•é–‹ã•れã¾ã™ã€‚(一覧ã«ã‚ˆã‚‹é¸æŠžã¯ã§ãã¾ã›ã‚“) .sp 標準状態ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰åを入力ã—ã¦ã„ã‚‹ã¨ãã¯ã‚³ãƒžãƒ³ãƒ‰åãŒã€ã‚³ãƒžãƒ³ãƒ‰ã®å¼•数を入力ã—ã¦ã„ã‚‹ã¨ãã¯ãƒ•ァイルåãŒè£œå®Œã•れã¾ã™ã€‚ã—ã‹ã—補完を行ã†é–¢æ•° (\fI補完関数\fR) を定義ã™ã‚‹ã“ã¨ã§è£œå®Œå†…容を変更ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB補完動作ã®è©³ç´°\fR .RS 4 .sp シェルを起動ã—ã¦ã‹ã‚‰åˆã‚ã¦è£œå®Œã‚’行ãŠã†ã¨ã—ãŸã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ \fB\&.\fR\fB \-AL completion/INIT\fR を実行ã™ã‚‹ã®ã¨åŒæ§˜ã«ã—ã¦ã€ãƒ•ァイル completion/INIT をロードパスã‹ã‚‰èª­ã¿è¾¼ã¿ã¾ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã„å ´åˆã¯ã€ãã®ã¾ã¾è£œå®Œå‹•作を続ã‘ã¾ã™ã€‚(ã“ã®å‡¦ç†ã¯ä¸»ã«ã‚·ã‚§ãƒ«ã«ä»˜å±žã—ã¦ã„る補完関数を読ã¿è¾¼ã‚€ãŸã‚ã®ã‚‚ã®ã§ã™ãŒã€ãƒ­ãƒ¼ãƒ‰ãƒ‘ス内ã«è‡ªåˆ†ã§ç”¨æ„ã—ãŸãƒ•ァイルを置ã„ã¦ãŠãã“ã¨ã§ä»£ã‚りã«ãれを読ã¿è¾¼ã¾ã›ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚) .sp 補完ã¯ã€å¯¾è±¡ã«å¿œã˜ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«è¡Œã„ã¾ã™ã€‚ .PP コマンドå .RS 4 関数 \fBcompletion//command\fR ãŒå®šç¾©ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれを補完関数ã¨ã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚定義ã•れã¦ã„ãªã„å ´åˆã¯ã€å…¥åЛ䏭ã®å˜èªžã‚’コマンドåã¨ã—ã¦è£œå®Œã—ã¾ã™ã€‚ .RE .PP コマンドã®å¼•æ•° .RS 4 関数 \fBcompletion//argument\fR ãŒå®šç¾©ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれを補完関数ã¨ã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚定義ã•れã¦ã„ãªã„å ´åˆã¯ã€å…¥åЛ䏭ã®å˜èªžã‚’ファイルåã¨ã—ã¦è£œå®Œã—ã¾ã™ã€‚ .RE .sp ã“ã®ä»–ã€ãƒãƒ«ãƒ€å±•é–‹ã«ãŠã‘るユーザåやパラメータ展開ã«ãŠã‘るパラメータåを入力ã—ã¦ã„ã‚‹ã¨ãã¯ã€ãƒ¦ãƒ¼ã‚¶åやパラメータåãŒå¸¸ã«è£œå®Œã•れã¾ã™ã€‚(補完ã®ã—ã‹ãŸã‚’変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“) .sp è£œå®Œé–¢æ•°ã¯æ™®é€šã®é–¢æ•°ã¨åŒæ§˜ã« (ä½ç½®ãƒ‘ラメータãªã—ã§) 実行ã•れã¾ã™ã€‚ãŸã ã—ã€è£œå®Œé–¢æ•°ã®å®Ÿè¡Œæ™‚ã«ã¯ä»¥ä¸‹ã®ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒè‡ªå‹•çš„ã«è¨­å®šã•れã¾ã™ã€‚ .PP \fBIFS\fR .RS 4 空白文字・タブ・改行ã®ä¸‰æ–‡å­— (シェル起動時ã®ãƒ‡ãƒ•ォルト) .RE .PP \fBWORDS\fR .RS 4 æ—¢ã«å…¥åŠ›ã•れã¦ã„るコマンドåã¨ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã‚’å«ã‚€é…列ã§ã™ã€‚コマンドåを補完ã—よã†ã¨ã—ã¦ã„ã‚‹ã¨ãã¯ã€ã“ã®é…列ã¯ç©ºã«ãªã‚Šã¾ã™ã€‚ .RE .PP \fBTARGETWORD\fR .RS 4 ç¾åœ¨è£œå®Œã‚’行ãŠã†ã¨ã—ã¦ã„ã‚‹ã€é€”中ã¾ã§å…¥åŠ›ã•れãŸã‚³ãƒžãƒ³ãƒ‰åã¾ãŸã¯ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã§ã™ã€‚ .RE .sp 補完関数ã®ä¸­ã§ complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã§ã€è£œå®Œå€™è£œãŒç”Ÿæˆã•れã¾ã™ã€‚シェルã¯è£œå®Œé–¢æ•°å®Ÿè¡Œä¸­ã«ç”Ÿæˆã•れãŸè£œå®Œå€™è£œã‚’用ã„ã¦è£œå®Œã‚’行ã„ã¾ã™ã€‚ .sp 補完関数ã®å®Ÿè¡Œä¸­ã¯ã€ç«¯æœ«ã«å¯¾ã—ã¦å…¥å‡ºåŠ›ã‚’è¡Œã£ã¦ã¯ãªã‚Šã¾ã›ã‚“ (端末ã®è¡¨ç¤ºãŒä¹±ã‚Œã¦ã—ã¾ã„ã¾ã™)。スムーズãªè£œå®Œã‚’行ã†ãŸã‚ã«ã€è£œå®Œã®å®Ÿè¡Œä¸­ã«é•·ã„時間ã®ã‹ã‹ã‚‹å‡¦ç†ã‚’行ã†ã®ã¯é¿ã‘ã¦ãã ã•ã„。 .sp 補完ã®å®Ÿè¡Œä¸­ã¯ã€POSIX 準拠モードãŒå¼·åˆ¶çš„ã«è§£é™¤ã•れã¾ã™ã€‚ã¾ãŸ errexit オプションã¯ç„¡åйã¨ãªã‚Šã€ãƒˆãƒ©ãƒƒãƒ—ã¯å®Ÿè¡Œã•れã¾ã›ã‚“。 .RE .SH "POSIX 準拠モード" .sp Yash ã¯åŸºæœ¬çš„ã« POSIX\&.1\-2008 ã®ã‚·ã‚§ãƒ«ã®è¦å®šã«å¾“ã£ã¦å‹•作ã—ã¾ã™ãŒã€åˆ©ä¾¿æ€§ã‚„分ã‹ã‚Šã‚„ã™ã•ã®ãŸã‚ã« POSIX ã®è¦å®šã¨ã¯ç•°ãªã‚‹å‹•作をã™ã‚‹ç‚¹ã‚‚ã‚りã¾ã™ã€‚ãã®ãŸã‚標準状態㮠yash 㯠POSIX ã®è¦å®šã™ã‚‹ã‚·ã‚§ãƒ«ã¨ã—ã¦ä¾›ã™ã‚‹ã«ã¯å‘ãã¾ã›ã‚“。\fIPOSIX 準拠モード\fRを有効ã«ã™ã‚‹ã¨ã€yash ã¯ã§ãã‚‹é™ã‚Š POSIX ã®è¦å®šé€šã‚Šã«å‹•作ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚POSIX 準拠シェルã¨ã—ã¦ã®äº’æ›æ€§ãŒå¿…è¦ãªå ´é¢ã§ã¯ã€POSIX 準拠モードを有効ã«ã—ã¦ãã ã•ã„。 .sp シェルã®èµ·å‹•時ã®èµ·å‹•時ã®åå‰ãŒ \fBsh\fR ãªã‚‰ã°ã‚·ã‚§ãƒ«ã¯è‡ªå‹•的㫠POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚ã¾ãŸèµ·å‹•時㫠\fB\-o posixlycorrect\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã‚‚ POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚ã¾ãŸèµ·å‹•後ã¯ã€\fBset\fR\fB \-o posixlycorrect\fR を実行ã™ã‚‹ã“ã¨ã§ POSIX 準拠モードを有効ã«ã§ãã¾ã™ã€‚ .sp POSIX 準拠モードを有効ã«ã™ã‚‹ã¨ã€yash 㯠POSIX ã®è¦å®šã«ã§ãã‚‹ã ã‘従ã†ã‚ˆã†ã«ãªã‚‹ã ã‘ã§ãªãã€POSIX ãŒ\fI未定義\fRã‚„\fI未è¦å®š\fRã¨å®šã‚ã¦ã„ã‚‹å ´åˆã®ã»ã¨ã‚“ã©ã‚’エラーã«ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ã™ãªã‚ã¡ã€yash ç‹¬è‡ªã®æ‹¡å¼µæ©Ÿèƒ½ã®å¤šãã¯ä½¿ãˆãªããªã‚Šã¾ã™ã€‚具体的ã«ã¯ã€POSIX 準拠モードを有効ã«ã™ã‚‹ã¨ä»¥ä¸‹ã®ã‚ˆã†ãªæŒ™å‹•ã®å¤‰åŒ–ãŒã‚りã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シェルã®èµ·å‹•時ã®åˆæœŸåŒ–ã§èª­ã¿è¾¼ã‚€ã‚¹ã‚¯ãƒªãƒ—トファイルãŒç•°ãªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®ç½®æ›ã‚’行ã„ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 複åˆã‚³ãƒžãƒ³ãƒ‰ã®ã‚°ãƒ«ãƒ¼ãƒ”ングや if æ–‡ã®å†…容ãŒç©ºã®å ´åˆã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For ループã§å±•é–‹ã—ãŸå˜èªžã¯ã‚°ãƒ­ãƒ¼ãƒãƒ«å¤‰æ•°ã¨ã—ã¦ä»£å…¥ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Case æ–‡ã®æœ€åˆã®ãƒ‘ターンを \fBesac\fR ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 予約語 \fBfunction\fR を用ã„ã‚‹å½¢å¼ã®é–¢æ•°å®šç¾©æ§‹æ–‡ã¯ä½¿ãˆã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} å˜ç´”コマンドã§ã®é…列ã®ä»£å…¥ã¯ã§ãã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} シェル実行中㫠\fBLC_CTYPE\fR 変数ã®å€¤ãŒå¤‰ã‚ã£ã¦ã‚‚ã€ãれをシェルã®ãƒ­ã‚±ãƒ¼ãƒ«æƒ…å ±ã«å映ã—ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBRANDOM\fR 変数ã¯ä½¿ãˆã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãƒãƒ«ãƒ€å±•é–‹ã§ \fB~\fR 㨠\fB~\fR\fB\fIユーザå\fR\fR 以外ã®å½¢å¼ã®å±•é–‹ãŒä½¿ãˆã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} パラメータ展開ã®å…¥ã‚Œå­ã¯ã§ãã¾ã›ã‚“。ã¾ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æŒ‡å®šã¯ã§ãã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB$(\fR 㨠\fB)\fR ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã«å«ã¾ã‚Œã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒå®Ÿè¡Œã•ã‚Œã‚‹æ™‚ã«æ¯Žå›žè§£æžã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} æ•°å¼å±•é–‹ã§å°æ•°ãªã‚‰ã³ã« \fB++\fR ãŠã‚ˆã³ \fB\-\-\fR 演算å­ãŒä½¿ãˆã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ファイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã€ãƒ‘スå展開ã®çµæžœãŒä¸€ã¤ã§ãªã„å ´åˆã€ã™ãã«ã¯ã‚¨ãƒ©ãƒ¼ã«ã›ãšã€ãƒ‘スå展開を行ã‚ãªã‹ã£ãŸã¨ãã¨åŒæ§˜ã«æ‰±ã„ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ソケットリダイレクト・ヒアストリング・パイプリダイレクト・プロセスリダイレクトã¯ä½¿ç”¨ã§ãã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} å˜ç´”コマンドã®å®Ÿè¡Œæ™‚ã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªãã¦ã‚‚ \fBCOMMAND_NOT_FOUND_HANDLER\fR 変数ã®å€¤ã¯å®Ÿè¡Œã—ã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ãŠã„ã¦é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¯¾å¿œã™ã‚‹å¤–部コマンドãŒãªã„ã¨è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйã§ã‚‚ã€éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã¯ SIGINT 㨠SIGQUIT を無視ã—ã¾ã™ã€‚ã¾ãŸéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力を /dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã™ã‚‹æ¡ä»¶ãŒå¤‰ã‚りã¾ã™ (ジョブ制御ãŒç„¡åйã®ã¨ãã§ã¯ãªãã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒç„¡åйãªã¨ãã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ)。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã„ãã¤ã‹ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç‰¹å®šã®ã‚ªãƒ—ションãŒä½¿ãˆãªããªã‚‹ãªã©æŒ™å‹•ãŒå¤‰ã‚りã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 対話モードã§ãªã„ã¨ãã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ã¾ãŸç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ä»£å…¥ã‚¨ãƒ©ãƒ¼ã‚„リダイレクトエラーãŒç™ºç”Ÿã—ãŸã¨ãã‚‚ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 対話モードã®ãƒ—ロンプトを出ã™å‰ã« \fBPROMPT_COMMAND\fR 変数ã®å€¤ã‚’実行ã—ã¾ã›ã‚“。\fBPS1\fR 変数・\fBPS2\fR 変数・\fBPS4\fR 変数ã®å€¤ã®è§£é‡ˆã®ä»•æ–¹ãŒé•ã„ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} メールãƒã‚§ãƒƒã‚¯ã«ãŠã„ã¦ã€ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ›´æ–°ã•れã¦ã„ã‚‹å ´åˆã¯ãƒ•ァイルãŒç©ºã§ã‚‚æ–°ç€ãƒ¡ãƒ¼ãƒ«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã¾ã™ã€‚ .RE .SH "æ§‹æ–‡ã®å½¢å¼çš„定義" .sp ã“ã“ã« yash ã®æ–‡æ³•ã®å½¢å¼çš„定義を示ã—ã¾ã™ã€‚Yash ã®æ–‡æ³•ã¯è§£æžè¡¨ç¾æ–‡æ³•ã§å®šç¾©ã•れã¾ã™ã€‚ .sp Yash ã®æ–‡æ³•ã«ãŠã‘る終端記å·ã®é›†åˆã¯ã€yash を実行ã™ã‚‹ç’°å¢ƒãŒæ‰±ãˆã‚‹ä»»æ„ã®æ–‡å­—ã®é›†åˆ (実行文字集åˆ) ã§ã™ (ãŸã ã—ナル文字 \fB\*(Aq\e0\*(Aq\fR を除ã)。 .sp 以下ã¯ã€yash ã®æ–‡æ³•ã‚’æ§‹æˆã™ã‚‹éžçµ‚端記å·ã¨ãれã«å¯¾å¿œã™ã‚‹çµ‚端記å·ã®ä¸€è¦§ã§ã™ã€‚ãŸã ã—ã“ã“ã«æŒ™ã’る文法ã®å®šç¾©ã«ã¯ãƒ’アドキュメントã®å†…容ã¨ãã®çµ‚ã‚りを表ã™è¡Œã®è§£æžã®ãŸã‚ã®è¦å‰‡ã¯å«ã¾ã‚Œã¦ã„ã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯æ§‹æ–‡ãŒè‹¥å¹²å¤‰ã‚りã¾ã™ãŒã€ã“ã“ã«ã¯ç¤ºã—ã¾ã›ã‚“。 .PP CompleteCommand .RS 4 SequenceEOF .RE .PP Sequence .RS 4 N* List* .RE .PP List .RS 4 Pipeline ((\fB&&\fR / \fB||\fR) N* Pipeline)* ListSeparator .RE .PP Pipeline .RS 4 Bang? Command (\fB|\fRN* Command)* .RE .PP Command .RS 4 CompoundCommandRedirection* / !RFunctionDefinition / !R SimpleCommand .RE .PP CompoundCommand .RS 4 Subshell / Grouping / IfCommand / ForCommand / WhileCommand / CaseCommand / FunctionCommand .RE .PP Subshell .RS 4 \fB(\fRSequence\fB)\fRS* .RE .PP Grouping .RS 4 LeftBraceSequenceRightBrace .RE .PP IfCommand .RS 4 IfSequenceThen Sequence (Elif Sequence Then Sequence)* (Else Sequence)? Fi .RE .PP ForCommand .RS 4 ForNameS* Separator? (InWord* Separator)? DoSequenceDone .RE .PP WhileCommand .RS 4 (While / Until) SequenceDo Sequence Done .RE .PP CaseCommand .RS 4 CaseWordN* In N* CaseItem* Esac .RE .PP CaseItem .RS 4 !Esac (\fB(\fRS*)? Word (\fB|\fR S* Word)* \fB)\fRSequence (\fB;;\fR / &Esac) .RE .PP FunctionCommand .RS 4 FunctionWord (\fB(\fRS* \fB)\fR)? N* CompoundCommandRedirection* .RE .PP FunctionDefinition .RS 4 NameS* \fB(\fR S* \fB)\fRN* CompoundCommandRedirection* .RE .PP SimpleCommand .RS 4 &(Word / Redirection) (Assignment / Redirection)* (Word / Redirection)* .RE .PP Assignment .RS 4 Name\fB=\fRWord / Name \fB=(\fRN* (Word N*)* \fB)\fR .RE .PP Name .RS 4 ![[:digit:]] [[:alnum:] \fB_\fR]+ .RE .PP PortableName .RS 4 ![\fB0\fR\-\fB9\fR] [\fB0\fR\-\fB9\fR\fBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_\fR]+ .RE .PP Word .RS 4 (WordElement / !SpecialChar \&.)+ S* .RE .PP WordElement .RS 4 \fB\e\fR \&. / \fB\*(Aq\fR (!\fB\*(Aq\fR \&.)* \fB\*(Aq\fR / \fB"\fRQuoteElement* \fB"\fR / Parameter / Arithmetic / CommandSubstitution .RE .PP QuoteElement .RS 4 \fB\e\fR ([\fB$`"\e\fR] / NL) / Parameter / Arithmetic / CommandSubstitution / ![\fB`"\e\fR] \&. .RE .PP Parameter .RS 4 \fB$\fR [\fB@*#?\-$!\fR [:digit:]] / \fB$\fRPortableName / \fB$\fRParameterBody .RE .PP ParameterBody .RS 4 \fB{\fRParameterNumber? (ParameterName / ParameterBody / Parameter) ParameterIndex? ParameterMatch? \fB}\fR .RE .PP ParameterNumber .RS 4 \fB#\fR ![\fB+=:/%\fR] !([\fB\-?#\fR] \fB}\fR) .RE .PP ParameterName .RS 4 [\fB@*#?\-$!\fR] / [[:alnum:] \fB_\fR]+ .RE .PP ParameterIndex .RS 4 \fB[\fRParameterIndexWord (\fB,\fR ParameterIndexWord)? \fB]\fR .RE .PP ParameterIndexWord .RS 4 (WordElement / ![\fB"\*(Aq],\fR] \&.)+ .RE .PP ParameterMatch .RS 4 \fB:\fR? [\fB\-+=?\fR] ParameterMatchWord / (\fB#\fR / \fB##\fR / \fB%\fR / \fB%%\fR) ParameterMatchWord / (\fB:/\fR / \fB/\fR [\fB#%/\fR]?) ParameterMatchWordNoSlash (\fB/\fR ParameterMatchWord)? .RE .PP ParameterMatchWord .RS 4 (WordElement / ![\fB"\*(Aq}\fR] \&.)* .RE .PP ParameterMatchWordNoSlash .RS 4 (WordElement / ![\fB"\*(Aq/}\fR] \&.)* .RE .PP Arithmetic .RS 4 \fB$((\fRArithmeticBody* \fB))\fR .RE .PP ArithmeticBody .RS 4 \fB\e\fR \&. / Parameter / Arithmetic / CommandSubstitution / \fB(\fR ArithmeticBody \fB)\fR / ![\fB`()\fR] \&. .RE .PP CommandSubstitution .RS 4 \fB$(\fRSequence\fB)\fR / \fB`\fRCommandSubstitutionBody* \fB`\fR .RE .PP CommandSubstitutionBody .RS 4 \fB\e\fR [\fB$`\e\fR] / !\fB`\fR \&. .RE .PP Redirection .RS 4 RedirectionFDRedirectionOperatorS* Word / RedirectionFD \fB<(\fRSequence\fB)\fR / RedirectionFD \fB>(\fR Sequence \fB)\fR .RE .PP RedirectionFD .RS 4 [[:digit:]]* .RE .PP RedirectionOperator .RS 4 \fB<\fR / \fB<>\fR / \fB>\fR / \fB>|\fR / \fB>>\fR / \fB>>|\fR / \fB<&\fR / \fB>&\fR / \fB<<\fR / \fB<<\-\fR / \fB<<<\fR .RE .PP ListSeparator .RS 4 Separator / \fB&\fRN* / &\fB)\fR / &\fB;;\fR .RE .PP Separator .RS 4 \fB;\fRN* / N+ / EOF .RE .PP N .RS 4 S* NL .RE .PP S .RS 4 [[:blank:]] / Comment .RE .PP Comment .RS 4 \fB#\fR (!NL \&.)* .RE .PP R .RS 4 Bang / LeftBrace / RightBrace / Case / Do / Done / Elif / Else / Esac / Fi / For / If / In / Then / Until / While .RE .PP Bang .RS 4 \fB!\fRD .RE .PP LeftBrace .RS 4 \fB{\fRD .RE .PP RightBrace .RS 4 \fB}\fRD .RE .PP Case .RS 4 \fBcase\fRD .RE .PP Do .RS 4 \fBdo\fRD .RE .PP Done .RS 4 \fBdone\fRD .RE .PP Elif .RS 4 \fBelif\fRD .RE .PP Else .RS 4 \fBelse\fRD .RE .PP Esac .RS 4 \fBesac\fRD .RE .PP Fi .RS 4 \fBfi\fRD .RE .PP For .RS 4 \fBfor\fRD .RE .PP Function .RS 4 \fBfunction\fRD .RE .PP If .RS 4 \fBif\fRD .RE .PP In .RS 4 \fBin\fRD .RE .PP Then .RS 4 \fBthen\fRD .RE .PP Until .RS 4 \fBuntil\fRD .RE .PP While .RS 4 \fBwhile\fRD .RE .PP D .RS 4 !WordS* .RE .PP SpecialChar .RS 4 [\fB|&;<>()`\e"\*(Aq\fR [:blank:]] / NL .RE .PP NL .RS 4 .RE .PP EOF .RS 4 !\&. .RE .SH "ALIAS 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIAlias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’設定・表示ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBalias [\-gp] [\fR\fB\fIエイリアスå\fR\fR\fB[=\fR\fB\fI値\fR\fR\fB]\&...]\fR .RE .SS "説明" .sp Alias コマンドã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’オペランドã«å¾“ã£ã¦è¨­å®šã¾ãŸã¯è¡¨ç¤ºã—ã¾ã™ã€‚表示ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ (ã®ä¸€éƒ¨) ã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚オペランドを一ã¤ã‚‚与ãˆãªã„å ´åˆã€alias コマンドã¯ç¾åœ¨è¨­å®šã•れã¦ã„ã‚‹å…¨ã¦ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’表示ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-g\fR, \fB\-\-global\fR .RS 4 ã“ã®ã‚ªãƒ—ションを指定ã—ãŸå ´åˆã€è¨­å®šã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ãªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€è¨­å®šã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯é€šå¸¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ãªã‚Šã¾ã™ã€‚ .RE .PP \fB\-p\fR, \fB\-\-prefix\fR .RS 4 ã“ã®ã‚ªãƒ—ションã¯è¡¨ç¤ºã®æ›¸å¼ã‚’é¸æŠžã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãŸå ´åˆã€alias コマンドã¨ãã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°å…¨ã¦ã‚’表示ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€alias ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã ã‘を表示ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIエイリアスå\fR .RS 4 表示ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã§ã™ã€‚ .RE .PP \fIエイリアスå\fR=\fI値\fR .RS 4 設定ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã¨ãã®å†…容ã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š alias コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Yash ã§ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã¨ã—ã¦ä½¿ãˆãªã„文字ã¯ã€ç©ºç™½æ–‡å­—・タブ・改行ã€ãŠã‚ˆã³ \fB=$<>\e\*(Aq"`;&|()#\fR ã®å„文字ã§ã™ã€‚エイリアスã®å†…容ã«ã¯ã™ã¹ã¦ã®æ–‡å­—ãŒä½¿ãˆã¾ã™ã€‚ .sp Alias ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "ARRAY 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIArray 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯é…列ã®è¡¨ç¤ºã‚„æ“作を行ã„ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \fR\fB\fIé…列å\fR\fR\fB [\fR\fB\fI値\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \-d \fR\fB\fIé…列å\fR\fR\fB [\fR\fB\fIインデックス\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \-i \fR\fB\fIé…列å\fR\fR\fB \fR\fB\fIインデックス\fR\fR\fB [\fR\fB\fI値\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBarray \-s \fR\fB\fIé…列å\fR\fR\fB \fR\fB\fIインデックス\fR\fR\fB \fR\fB\fI値\fR\fR .RE .SS "説明" .sp オプションもオペランドも指定ã›ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€array コマンドã¯å…¨ã¦ã®é…列ã®å®šç¾©ã‚’ (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .sp オプションを指定ã›ãšã«\fIé…列å\fRã¨\fI値\fRを与ãˆã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array コマンドã¯ãã®é…列ã®å†…容を指定ã•れãŸå€¤ã«è¨­å®šã—ã¾ã™ã€‚ .sp \fB\-d\fR (\fB\-\-delete\fR) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã‚’削除ã—ã¾ã™ã€‚é…列ã®è¦ç´ æ•°ã¯å‰Šé™¤ã—ãŸè¦ç´ ã®åˆ†ã ã‘å°‘ãªããªã‚Šã¾ã™ã€‚存在ã—ãªã„è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’指定ã—ãŸã¨ãã¯ç„¡è¦–ã—ã¾ã™ã€‚ .sp \fB\-i\fR (\fB\-\-insert\fR) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã®ç›´å¾Œã«æŒ‡å®šã—ãŸå€¤ã‚’è¦ç´ ã¨ã—ã¦è¿½åŠ ã—ã¾ã™ã€‚é…列ã®è¦ç´ æ•°ã¯è¿½åŠ ã—ãŸè¦ç´ ã®åˆ†ã ã‘増ãˆã¾ã™ã€‚\fIインデックス\fR ã¨ã—㦠0 を指定ã™ã‚‹ã¨é…列ã®å…ˆé ­ã«è¦ç´ ã‚’追加ã—ã¾ã™ã€‚\fIインデックス\fRã¨ã—ã¦é…列ã®è¦ç´ æ•°ã‚ˆã‚Šå¤§ããªæ•°ã‚’指定ã™ã‚‹ã¨é…åˆ—ã®æœ«å°¾ã«è¦ç´ ã‚’追加ã—ã¾ã™ã€‚ .sp \fB\-s\fR (\fB\-\-set\fR) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã®å€¤ã‚’指定ã—ãŸå€¤ã«å¤‰æ›´ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-d\fR, \fB\-\-delete\fR .RS 4 é…列ã®è¦ç´ ã‚’削除ã—ã¾ã™ã€‚ .RE .PP \fB\-i\fR, \fB\-\-insert\fR .RS 4 é…列ã«è¦ç´ ã‚’挿入ã—ã¾ã™ã€‚ .RE .PP \fB\-s\fR, \fB\-\-set\fR .RS 4 é…列ã®è¦ç´ ã‚’変更ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIé…列å\fR .RS 4 表示ã¾ãŸã¯æ“作ã™ã‚‹é…列ã®åå‰ã§ã™ã€‚ .RE .PP \fIインデックス\fR .RS 4 é…列ã®è¦ç´ ã‚’指定ã™ã‚‹è‡ªç„¶æ•°ã§ã™ã€‚ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯æœ€åˆã®è¦ç´ ã‹ã‚‰é †ã« 1, 2, 3, \&... ã¨å‰²ã‚ŠæŒ¯ã‚‰ã‚Œã¾ã™ã€‚ .RE .PP \fI値\fR .RS 4 é…列ã®è¦ç´ ã¨ãªã‚‹æ–‡å­—列ã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š array コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ array コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .sp \fBarray \fR\fB\fIé…列å\fR\fR\fB [\fR\fB\fI値\fR\fR\fB\&...]\fR ã®å½¢å¼ã® array コマンドã¯å¤‰æ•°ä»£å…¥ã‚’用ã„㦠\fB\fIé…列å\fR\fR\fB=(\fR\fB\fI値\fR\fR\fB\&...)\fR ã¨æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .SH "BG 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIBg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚¸ãƒ§ãƒ–ã‚’ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbg [\fR\fB\fIジョブ\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Bg コマンドã¯ã‚¸ãƒ§ãƒ–ã‚’ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚ジョブã«ã¯ SIGCONT シグナルãŒé€ã‚‰ã‚Œã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ã¦ã„ã‚‹å ´åˆã¯å†é–‹ã•れã¾ã™ã€‚ .sp ジョブã®å®Ÿè¡Œã‚’å†é–‹ã™ã‚‹å‰ã« bg コマンドã¯ã‚¸ãƒ§ãƒ–ã®åå‰ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .sp Bg コマンドã¯ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã—ã‹ä½¿ãˆã¾ã›ã‚“。 .SS "オペランド" .PP \fIジョブ\fR .RS 4 実行ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID。 .sp ジョブを複数指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を実行ã—ã¾ã™ã€‚ .sp éž POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® \fB%\fR ã¯çœç•¥ã§ãã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š bg コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Bg ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã¯æŒ‡å®šã—ãŸã‚¸ãƒ§ãƒ–ãŒæ—¢ã«å®Ÿè¡Œä¸­ã®å ´åˆã¯ bg コマンドã¯ä½•ã‚‚ã—ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ãŒã€yash ã® bg コマンドã¯ã‚¸ãƒ§ãƒ–ãŒå®Ÿè¡Œä¸­ã‹ã©ã†ã‹ã«ã‹ã‹ã‚ら㚠SIGCONT シグナルをé€ä¿¡ã—ã¾ã™ã€‚ .SH "BINDKEY 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIBindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯\:行編集ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰è¨­å®šã‚’表示・設定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbindkey \-aev [\fR\fB\fIキー\fR\fR\fB [\fR\fB\fIコマンド\fR\fR\fB]]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbindkey \-l\fR .RE .SS "説明" .sp \fB\-l\fR (\fB\-\-list\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€bindkey コマンドã¯ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã§åˆ©ç”¨å¯èƒ½ãª\:行編集コマンドã®ä¸€è¦§ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .sp ä»–ã®ã‚ªãƒ—ションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€bindkey コマンドã¯ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã®è¡¨ç¤ºã¾ãŸã¯è¨­å®šã‚’行ã„ã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} オペランドã¨ã—ã¦\fIキー\fR・\fIコマンド\fRを与ãˆãªã„å ´åˆã€ç¾åœ¨ã®ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã®å†…容を (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIキー\fRã®ã¿ã‚’与ãˆã‚‹ã¨ã€ãã®ã‚­ãƒ¼ã«å¯¾ã™ã‚‹ç¾åœ¨ã®è¨­å®šã ã‘を出力ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIキー\fRã¨\fIコマンド\fRを両方与ãˆã‚‹ã¨ã€ãã®ã‚­ãƒ¼ã‚’入力ã—ãŸã¨ãã«å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã«è¨­å®šã—ã¾ã™ã€‚ .RE .SS "オプション" .PP \fB\-a\fR, \fB\-\-vi\-command\fR .RS 4 Vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚ .RE .PP \fB\-e\fR, \fB\-\-emacs\fR .RS 4 Emacs 風編集モードã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚ .RE .PP \fB\-v\fR, \fB\-\-vi\-insert\fR .RS 4 Vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIキー\fR .RS 4 表示・設定ã™ã‚‹å¯¾è±¡ã®ã‚­ãƒ¼å…¥åŠ›ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã§ã™ã€‚ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å€¤ã«ã¯ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスãŒåˆ©ç”¨ã§ãã¾ã™ã€‚ .RE .PP \fIコマンド\fR .RS 4 設定ã™ã‚‹è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ãƒã‚¤ãƒ•ン一㤠(\fB\-\fR) を指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ\fIキー\fRã«å¯¾ã™ã‚‹è¨­å®šã‚’削除ã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š bindkey コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ bindkey コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "BREAK 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIBreak 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯å®Ÿè¡Œä¸­ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbreak [\fR\fB\fIæ·±ã•\fR\fR\fB]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBbreak \-i\fR .RE .SS "説明" .sp \fB\-i\fR (\fB\-\-iteration\fR) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€break コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã® for ループã¾ãŸã¯ while ループã¾ãŸã¯ until ループを中断ã—ã¾ã™ã€‚多é‡ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§å®Ÿè¡Œã—ãŸå ´åˆã€å†…å´ã‹ã‚‰æ•°ãˆã¦\fIæ·±ã•\fR番目ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚\fIæ·±ã•\fRãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æœ€ã‚‚内å´ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ (\fIæ·±ã•\fR = 1)。指定ã•れãŸ\fIæ·±ã•\fRãŒå®Ÿéš›ã«å®Ÿè¡Œã—ã¦ã„る多é‡ãƒ«ãƒ¼ãƒ—ã®æ·±ã•より大ãã„å ´åˆã¯æœ€ã‚‚外å´ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚ .sp \fB\-i\fR (\fB\-\-iteration\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€break コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®å復実行を中断ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-i\fR, \fB\-\-iteration\fR .RS 4 ループã§ã¯ãªãå復実行を中断ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fInest\fR .RS 4 内å´ã‹ã‚‰ä½•番目ã®ãƒ«ãƒ¼ãƒ—を中断ã™ã‚‹ã®ã‹ã‚’指定ã™ã‚‹ 1 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ .RE .SS "終了ステータス" .sp ループã®ä¸­æ–­ã«æˆåŠŸã™ã‚‹ã¨çµ‚了ステータス㯠0 ã§ã™ã€‚å復実行ã®ä¸­æ–­ã«æˆåŠŸã™ã‚‹ã¨ break コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠break コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .SS "補足" .sp Break コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ \fB\-i\fR (\fB\-\-interact\fR) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "CD 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fICd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcd [\-L|\-P] [\fR\fB\fIディレクトリ\fR\fR\fB]\fR .RE .SS "説明" .sp Cd コマンドã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚æ–°ã—ã„作業ディレクトリã«å¿œã˜ã¦ \fBPWD\fR 変数ã®å€¤ãŒå†è¨­å®šã•れるã¨ã¨ã‚‚ã«ã€å‰ã® \fBPWD\fR 変数ã®å€¤ãŒ \fBOLDPWD\fR 変数ã«è¨­å®šã•れã¾ã™ã€‚ .sp 指定ã—ãŸ\fIディレクトリ\fRãŒç›¸å¯¾ãƒ‘スã®å ´åˆ (最åˆãŒ \fB\&.\fR ã¾ãŸã¯ \fB\&.\&.\fR ã§å§‹ã¾ã‚‹ã‚‚ã®ã‚’除ã)ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ãŠã‘ã‚‹ \fBPATH\fR å¤‰æ•°ã®æ¤œç´¢ã¨åŒæ§˜ã«ã—ã¦ã€\fBCDPATH\fR 変数ã®å€¤ã«ã‚るコロンã§åŒºåˆ‡ã£ãŸå„ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªå†…ã«æŒ‡å®šã—ãŸ\fIディレクトリ\fRãŒã‚ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ã€‚ディレクトリãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¯ã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæ–°ã—ã„作業ディレクトリã«ãªã‚Šã¾ã™ã€‚見ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€\fIディレクトリ\fRã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘スã¨ãªã‚Šã¾ã™ã€‚ .sp \fBCDPATH\fR å¤‰æ•°ã®æ¤œç´¢ã§æ–°ã—ã„作業ディレクトリãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¾ãŸã¯\fIディレクトリ\fRã¨ã—㦠\fB\-\fR ãŒæŒ‡å®šã•れãŸå ´åˆã¯æ–°ã—ã„作業ディレクトリã®ãƒ‘スを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .sp 作業ディレクトリã®å¤‰æ›´ã«æˆåŠŸã—ãŸå ´åˆã€\fBYASH_AFTER_CD\fR 変数ãŒè¨­å®šã•れã¦ã„れã°ãã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ (éž POSIX 準拠モード時)。 .SS "オプション" .PP \fB\-L\fR, \fB\-\-logical\fR .RS 4 ディレクトリパスã«å«ã¾ã‚Œã‚‹ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’解決ã›ãšã«æ–°ã—ã„作業ディレクトリを決定ã—ã¾ã™ã€‚æ–°ã—ã„ \fBPWD\fR 変数ã®å€¤ã«ã¯ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã«ãªã£ã¦ã„るパスåコンãƒãƒ¼ãƒãƒ³ãƒˆãŒãã®ã¾ã¾æ®‹ã‚Šã¾ã™ã€‚ .RE .PP \fB\-P\fR, \fB\-\-physical\fR .RS 4 ディレクトリパスã«å«ã¾ã‚Œã‚‹ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’解決ã—ã¾ã™ã€‚æ–°ã—ã„ \fBPWD\fR 変数ã®å€¤ã¯ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’å«ã¿ã¾ã›ã‚“。 .RE .PP \fB\-\-default\-directory=\fR\fB\fIディレクトリ\fR\fR .RS 4 \fIディレクトリ\fRオペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€ä»£ã‚りã«ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸ\fIディレクトリ\fRã‚’æ–°ã—ã„作業ディレクトリã¨ã—ã¾ã™ã€‚ .RE .sp \fB\-L\fR (\fB\-\-logical\fR) オプション㨠\fB\-P\fR (\fB\-\-physical\fR) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€\fB\-L\fR を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .SS "オペランド" .PP \fIディレクトリ\fR .RS 4 æ–°ã—ã„作業ディレクトリã®ãƒ‘スåã§ã™ã€‚絶対パスã¾ãŸã¯å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘ã‚¹ã§æŒ‡å®šã—ã¾ã™ã€‚ .sp ã“ã®å€¤ãŒãƒã‚¤ãƒ•ン一㤠(「\-ã€) ã®å ´åˆã€\fBOLDPWD\fR 変数ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€\fBHOME\fR 変数ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (\fB\-\-default\-directory\fR オプションを指定ã—ãŸå ´åˆã‚’除ã)。 .RE .SS "終了ステータス" .sp 作業ディレクトリを正ã—ã変更ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp Cd ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ \fBYASH_AFTER_CD\fR 変数ãŠã‚ˆã³ \fB\-\-default\-directory=\&...\fR オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。POSIX ã¯\fIディレクトリ\fRã¨ã—ã¦ãƒã‚¤ãƒ•ン一ã¤ã‚’指定ã—ãŸã¨ãã« \fB\-L\fR ã¾ãŸã¯ \fB\-P\fR オプションを併用ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 .sp \fBYASH_AFTER_CD\fR 変数ã®å®Ÿè¡Œçµæžœã¯ cd コマンドã®çµ‚了ステータスã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。 .SH "コロン組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIコロン組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ä½•も行ã‚ãªã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB: [\fR\fB\fI引数\fR\fR\fB\&...]\fR .RE .SS "説明" .sp コロンコマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚ .SS "終了ステータス" .sp コロンコマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp コロンコマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp 引数ã®å±•é–‹ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«è¡Œã„ã¾ã™ã€‚ .sp True コマンドã¯ã‚³ãƒ­ãƒ³ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«ä½•も行ã„ã¾ã›ã‚“ãŒã€ã‚³ãƒ­ãƒ³ã‚³ãƒžãƒ³ãƒ‰ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ã‚‹ã®ã«å¯¾ã— true ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .SH "COMMAND 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fICommand 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ã¾ãŸã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã‚’特定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcommand [\-befp] \fR\fB\fIコマンド\fR\fR\fB [\fR\fB\fI引数\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcommand \-v|\-V [\-abefkp] \fR\fB\fIコマンド\fR\fR\fB\&...\fR .RE .SS "説明" .sp \fB\-v\fR (\fB\-\-identify\fR) オプションãªã‚‰ã³ã« \fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€command コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸ\fIコマンド\fRを与ãˆã‚‰ã‚ŒãŸ\fI引数\fRã§å®Ÿè¡Œã—ã¾ã™ã€‚コマンドã®å®Ÿè¡Œã®ä»•æ–¹ã¯å˜ç´”コマンドã®å®Ÿè¡Œã®æœ€å¾Œã®ã‚¹ãƒ†ãƒƒãƒ—ã«æº–ã˜ã¾ã™ãŒã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã§ã¯å¤–部コマンド・組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»é–¢æ•°ã®å†…ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸã‚‚ã®ã—ã‹æ¤œç´¢ã—ã¾ã›ã‚“。ã¾ãŸã‚³ãƒžãƒ³ãƒ‰ãŒç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ãŸã‚Šãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã‚„代入エラーãŒèµ·ããŸã‚Šã—ã¦ã‚‚シェルã¯çµ‚了ã—ã¾ã›ã‚“。 .sp \fB\-v\fR (\fB\-\-identify\fR) オプションã¾ãŸã¯ \fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€command コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸ\fIコマンド\fRã®ç¨®é¡žã¨ãƒ‘スを特定ã—ãれを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚\fIコマンド\fRã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚„関数ã§ã‚ã£ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 .sp \fB\-v\fR (\fB\-\-identify\fR) オプションを付ã‘ã¦å®Ÿè¡Œã—ãŸã¨ãã®å‡ºåŠ›ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®çµæžœè¦‹ã¤ã‹ã£ãŸã‚³ãƒžãƒ³ãƒ‰ãŠã‚ˆã³ãã®ä»–ã®å¤–部コマンドã¯ã€ãã®çµ¶å¯¾ãƒ‘スを出力ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ã‚ˆã‚‰ãšå®Ÿè¡Œã•れる組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„関数ã¯ã€å˜ã«ãã®åå‰ã‚’出力ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 予約語ã¯ã€å˜ã«ãã®åå‰ã‚’出力ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} エイリアスã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œå¯èƒ½ãªå½¢å¼ã§ãã®åå‰ã¨å€¤ã‚’出力ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€ä½•も出力ã—ã¾ã›ã‚“。(終了ステータスãŒéž 0 ã«ãªã‚Šã¾ã™) .RE .sp \fB\-V\fR (\fB\-\-verbose\-identify\fR) オプション使用時ã¯ã€å‡ºåŠ›ã®å½¢å¼ãŒäººé–“ã«ã¨ã£ã¦ã‚ˆã‚Šèª­ã¿ã‚„ã™ããªã‚Šã¾ã™ã€‚ .SS "オプション" .PP \fB\-a\fR, \fB\-\-alias\fR .RS 4 \fIコマンド\fRã¨ã—ã¦ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ \fB\-v\fR (\fB\-\-identify\fR) ã¾ãŸã¯ \fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションã¨ä¸€ç·’ã«ä½¿ã†å¿…è¦ãŒã‚りã¾ã™ã€‚ .RE .PP \fB\-b\fR, \fB\-\-builtin\-command\fR .RS 4 \fIコマンド\fRã¨ã—ã¦çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ .RE .PP \fB\-e\fR, \fB\-\-external\-command\fR .RS 4 \fIコマンド\fRã¨ã—ã¦å¤–部コマンドを検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ .RE .PP \fB\-f\fR, \fB\-\-function\fR .RS 4 \fIコマンド\fRã¨ã—ã¦é–¢æ•°ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ .RE .PP \fB\-k\fR, \fB\-\-keyword\fR .RS 4 \fIコマンド\fRã¨ã—ã¦äºˆç´„語を検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ \fB\-v\fR (\fB\-\-identify\fR) ã¾ãŸã¯ \fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションã¨ä¸€ç·’ã«ä½¿ã†å¿…è¦ãŒã‚りã¾ã™ã€‚ .RE .PP \fB\-p\fR, \fB\-\-standard\-path\fR .RS 4 ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ãŠã„ã¦ã€\fBPATH\fR 変数ã®ä»£ã‚りã«ã€æ¨™æº–ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’ã™ã¹ã¦å«ã‚€ã‚ˆã†ãªã‚·ã‚¹ãƒ†ãƒ å›ºæœ‰ã®ãƒ‡ãƒ•ォルトパスを用ã„ã¦å¤–部コマンドを検索ã—ã¾ã™ã€‚ .RE .PP \fB\-v\fR, \fB\-\-identify\fR .RS 4 与ãˆã‚‰ã‚ŒãŸ\fIコマンド\fRã®ç¨®é¡žã¨ãƒ‘スを特定ã—ã€ç°¡å˜ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB\-V\fR, \fB\-\-verbose\-identify\fR .RS 4 与ãˆã‚‰ã‚ŒãŸ\fIコマンド\fRã®ç¨®é¡žã¨ãƒ‘スを特定ã—ã€äººé–“ã«ã¨ã£ã¦èª­ã¿ã‚„ã™ã„å½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .sp \fB\-a\fR (\fB\-\-alias\fR), \fB\-b\fR (\fB\-\-builtin\-command\fR), \fB\-e\fR (\fB\-\-external\-command\fR), \fB\-f\fR (\fB\-\-function\fR), \fB\-k\fR (\fB\-\-keyword\fR) オプションã®ã©ã‚Œã‚‚指定ã—ãªã‹ã£ãŸå ´åˆã¯ã€ä»¥ä¸‹ã®ã‚ªãƒ—ションを指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .PP \fB\-v\fR (\fB\-\-identify\fR) ã‚ã‚‹ã„㯠\fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションを指定ã—ã¦ã„ãªã„ã¨ã .RS 4 \fB\-b \-e\fR .RE .PP \fB\-v\fR (\fB\-\-identify\fR) ã¾ãŸã¯ \fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションを指定ã—ã¦ã„ã‚‹ã¨ã .RS 4 \fB\-a \-b \-e \-f \-k\fR .RE .SS "オペランド" .PP \fIコマンド\fR .RS 4 実行ã™ã‚‹ã¾ãŸã¯ç¨®é¡žã‚’特定ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã§ã™ã€‚ .RE .PP \fI引数\fR\&... .RS 4 実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚ .RE .SS "終了ステータス" .PP \fB\-v\fR (\fB\-\-identify\fR) ã‚ã‚‹ã„㯠\fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションを指定ã—ã¦ã„ãªã„ã¨ã .RS 4 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス .RE .PP \fB\-v\fR (\fB\-\-identify\fR) ã¾ãŸã¯ \fB\-V\fR (\fB\-\-verbose\-identify\fR) オプションを指定ã—ã¦ã„ã‚‹ã¨ã .RS 4 エラーãŒãªã„é™ã‚Š 0 .RE .SS "補足" .sp Command ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«è¦å®šã®ã‚るオプション㯠\fB\-p\fR, \fB\-v\fR, \fB\-V\fR ã ã‘ã§ã™ã€‚ã“れ以外ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯ \fB\-v\fR ã¾ãŸã¯ \fB\-V\fR オプションを使用ã™ã‚‹ã¨ã\fIコマンド\fRã¯ã¡ã‚‡ã†ã©ä¸€ã¤ã—ã‹æŒ‡å®šã§ãã¾ã›ã‚“。 .sp POSIX 㯠\fB\-v\fR オプション㨠\fB\-V\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«æŒ‡å®šã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。Yash ã§ã¯ã“れら二ã¤ã®ã‚ªãƒ—ションを両方指定ã™ã‚‹ã¨æœ€å¾Œã«æŒ‡å®šã—ãŸã‚‚ã®ãŒæœ‰åйã«ãªã‚Šã¾ã™ã€‚ .SH "COMPLETE 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIComplete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³è£œå®Œã«ãŠã„ã¦è£œå®Œå€™è£œã‚’生æˆã—ã¾ã™ã€‚ã“ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯è£œå®Œé–¢æ•°ã®å®Ÿè¡Œä¸­ã«ã ã‘使ãˆã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcomplete [\-A \fR\fB\fIパターン\fR\fR\fB] [\-R \fR\fB\fIパターン\fR\fR\fB] [\-T] [\-P \fR\fB\fI接頭辞\fR\fR\fB] [\-S \fR\fB\fI接尾辞\fR\fR\fB] [\-abcdfghjkuv] [[\-O] [\-D \fR\fB\fI説明\fR\fR\fB] \fR\fB\fIå˜èªž\fR\fR\fB\&...]\fR .RE .SS "説明" .sp 補完関数ã®ä¸­ã§ã“ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã¨ã€complete ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸå¼•æ•°ã«å¾“ã£ã¦è£œå®Œå€™è£œã‚’生æˆã—ã¾ã™ã€‚ã©ã®ã‚ªãƒ—ション・オペランドã§å€™è£œã‚’生æˆã™ã‚‹ã«ã›ã‚ˆã€å®Ÿéš›ã«ç”Ÿæˆã•れる候補ã¯ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹ (コマンドライン上ã«é€”中ã¾ã§å…¥åŠ›ã•れãŸ) å˜èªžã«ä¸€è‡´ã™ã‚‹ã‚‚ã®ã«é™ã‚‰ã‚Œã¾ã™ã€‚ .SS "オプション" .PP \fB\-A \fR\fB\fIパターン\fR\fR, \fB\-\-accept=\fR\fB\fIパターン\fR\fR .RS 4 ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ\fIパターン\fRã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã ã‘を生æˆã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯è¤‡æ•°å›žæŒ‡å®šã§ãã¾ã™ (指定ã—ãŸå…¨ã¦ã®\fIパターン\fRã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã ã‘を生æˆã—ã¾ã™)。 .RE .PP \fB\-D \fR\fB\fI説明\fR\fR, \fB\-\-description=\fR\fB\fI説明\fR\fR .RS 4 ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸ\fI説明\fRãŒè£œå®Œã®éš›ã«å€™è£œã®èª¬æ˜Žã¨ã—ã¦è¡¨ç¤ºã•れã¾ã™ã€‚ .RE .PP \fB\-O\fR, \fB\-\-option\fR .RS 4 生æˆã™ã‚‹å€™è£œã‚’コマンドã®ã‚ªãƒ—ションã¨ã¿ãªã™ã‚ˆã†ã«ã—ã¾ã™ã€‚候補を画é¢ä¸Šã«ä¸€è¦§è¡¨ç¤ºã™ã‚‹éš›ã«è‡ªå‹•çš„ã«å…ˆé ­ã«ãƒã‚¤ãƒ•ンを付加ã—ã¾ã™ã€‚ .RE .PP \fB\-P \fR\fB\fI接頭辞\fR\fR, \fB\-\-prefix=\fR\fB\fI接頭辞\fR\fR .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã™ã‚‹\fI接頭辞\fRã¯ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžã®æŽ¥é ­è¾žã«ãªã£ã¦ã„ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€å€™è£œç”Ÿæˆã®éš›ã«ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸ\fI接頭辞\fRを無視ã—ã¦ãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ã€‚例ãˆã°è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžãŒ \fBfile:///home/user/docume\fR ã§ã‚りã€ã“ã® URL をファイルåã¨ã—ã¦è£œå®Œã—ãŸã„ã¨ã—ã¾ã—ょã†ã€‚ã“ã®å ´åˆã¯ã€\fBcomplete \-P file:// \-f\fR ã¨ã™ã‚‹ã¨ URL ã‹ã‚‰ \fBfile://\fR を除ã„ãŸæ®‹ã‚Šã® \fB/home/user/docume\fR ã®éƒ¨åˆ†ã«å¯¾ã—ã¦ãƒ•ァイルåã¨ã—ã¦ã®è£œå®Œå€™è£œãŒç”Ÿæˆã•れã¾ã™ã€‚ .RE .PP \fB\-R \fR\fB\fIパターン\fR\fR, \fB\-\-reject=\fR\fB\fIパターン\fR\fR .RS 4 ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ\fIパターン\fRã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã‚’生æˆã—ã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションã¯è¤‡æ•°å›žæŒ‡å®šã§ãã¾ã™ (指定ã—ãŸ\fIパターン\fRã®å°‘ãªãã¨ã‚‚一ã¤ã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã‚’å…¨ã¦é™¤å¤–ã—ã¾ã™)。 .RE .PP \fB\-S \fR\fB\fI接尾辞\fR\fR, \fB\-\-suffix=\fR\fB\fI接尾辞\fR\fR .RS 4 生æˆã—ãŸå„å€™è£œã®æœ«å°¾ã«\fI接尾辞\fRを付加ã—ã¾ã™ã€‚ .RE .PP \fB\-T\fR, \fB\-\-no\-termination\fR .RS 4 通常ã¯ã€è£œå®ŒãŒçµ‚ã‚ã£ãŸå¾Œã«æ¬¡ã®å˜èªžã‚’ã™ã入力ã§ãるよã†ã«ã€è£œå®Œã—ãŸå˜èªžã®ç›´å¾Œã«ç©ºç™½ã‚’è‡ªå‹•çš„ã«æŒ¿å…¥ã—ã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ションを指定ã—ãŸã¨ãã¯ç©ºç™½ã‚’挿入ã—ã¾ã›ã‚“。 .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB補完方å¼è¨­å®šã®ãŸã‚ã®ã‚ªãƒ—ション\fR .RS 4 .PP \fB\-a\fR, \fB\-\-alias\fR .RS 4 エイリアス (\fB\-\-normal\-alias \-\-global\-alias\fR ã«åŒã˜) .RE .PP \fB\-\-array\-variable\fR .RS 4 é…列 .RE .PP \fB\-\-bindkey\fR .RS 4 Bindkey コマンドã§åˆ©ç”¨å¯èƒ½ãª\:行編集コマンド .RE .PP \fB\-b\fR, \fB\-\-builtin\-command\fR .RS 4 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ (\fB\-\-special\-builtin \-\-semi\-special\-builtin \-\-regular\-builtin\fR ã«åŒã˜) .RE .PP \fB\-c\fR, \fB\-\-command\fR .RS 4 コマンド (\fB\-\-builtin\-command \-\-external\-command \-\-function\fR ã«åŒã˜) .RE .PP \fB\-d\fR, \fB\-\-directory\fR .RS 4 ディレクトリ .RE .PP \fB\-\-dirstack\-index\fR .RS 4 ディレクトリスタックã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ .RE .PP \fB\-\-executable\-file\fR .RS 4 実行å¯èƒ½ãƒ•ァイル .RE .PP \fB\-\-external\-command\fR .RS 4 外部コマンド .RE .PP \fB\-f\fR, \fB\-\-file\fR .RS 4 ファイル (ディレクトリå«ã‚€) .RE .PP \fB\-\-finished\-job\fR .RS 4 終了ã—ãŸã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID .RE .PP \fB\-\-function\fR .RS 4 関数 .RE .PP \fB\-\-global\-alias\fR .RS 4 グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ .RE .PP \fB\-g\fR, \fB\-\-group\fR .RS 4 (ファイルã®ãƒ‘ーミッションãªã©ã«ãŠã‘ã‚‹) グループ .RE .PP \fB\-h\fR, \fB\-\-hostname\fR .RS 4 ホストå .RE .PP \fB\-j\fR, \fB\-\-job\fR .RS 4 ジョブ ID .RE .PP \fB\-k\fR, \fB\-\-keyword\fR .RS 4 シェルã®äºˆç´„語 .RE .PP \fB\-\-normal\-alias\fR .RS 4 通常㮠(グローãƒãƒ«ã§ãªã„) エイリアス .RE .PP \fB\-\-regular\-builtin\fR .RS 4 通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ .RE .PP \fB\-\-running\-job\fR .RS 4 実行中ã®ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID .RE .PP \fB\-\-scalar\-variable\fR .RS 4 (é…列を除ã„ãŸé€šå¸¸ã®) 変数 .RE .PP \fB\-\-semi\-special\-builtin\fR .RS 4 準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ .RE .PP \fB\-\-signal\fR .RS 4 シグナル .RE .PP \fB\-\-special\-builtin\fR .RS 4 特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ .RE .PP \fB\-\-stopped\-job\fR .RS 4 åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID .RE .PP \fB\-u\fR, \fB\-\-username\fR .RS 4 ユーザã®ãƒ­ã‚°ã‚¤ãƒ³å .RE .PP \fB\-v\fR, \fB\-\-variable\fR .RS 4 変数 .RE .sp \fB\-d\fR (\fB\-\-directory\fR) オプションを指定ã›ãšã« \fB\-f\fR (\fB\-\-file\fR) オプションを指定ã—ãŸå ´åˆã€\fB\-S \&...\fR (\fB\-\-suffix=\&...\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šã®æœ‰ç„¡ã«ã‹ã‹ã‚らãšã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを表ã™è£œå®Œå€™è£œã«ã¯æŽ¥å°¾è¾žã¨ã—ã¦ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒä»˜ãã€å€™è£œã®ç›´å¾Œã«ã¯ç©ºç™½ãŒå…¥ã‚Šã¾ã›ã‚“ (\fB\-S / \-T\fR を指定ã—ãŸã¨ãã¨åŒã˜å‹•作)。 .sp ジョブ ID ã®è£œå®Œã¯å…ˆé ­ã® \fB%\fR を除ã„ãŸéƒ¨åˆ†ã«å¯¾ã—ã¦è¡Œã‚れるã®ã§ã€è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžãŒæ—¢ã« \fB%\fR ã‚’å«ã‚“ã§ã„ã‚‹å ´åˆã¯ \fB%\fR を接頭辞ã¨ã—ã¦æŒ‡å®šã—ã¦ãã ã•ã„。 .RE .SS "オペランド" .sp Complete コマンドã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€å„オペランドãŒãれãžã‚Œè£œå®Œå€™è£œã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚指定ã—ãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®ã†ã¡ã€ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžã«åˆã†ã‚‚ã®ãŒè£œå®Œå€™è£œã¨ãªã‚Šã¾ã™ã€‚ .SS "終了ステータス" .sp 候補ãŒå°‘ãªãã¨ã‚‚一ã¤ç”Ÿæˆã§ããŸå ´åˆã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚æ–°ãŸãªå€™è£œãŒä¸€ã¤ã‚‚生æˆã§ããªã‹ã£ãŸã¨ãã¯ã€çµ‚了ステータス㯠1 ã§ã™ã€‚ãã®ä»–ã®ã‚¨ãƒ©ãƒ¼ã®å ´åˆã¯ 2 以上ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ complete コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "CONTINUE 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIContinue 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯å®Ÿè¡Œä¸­ã®ãƒ«ãƒ¼ãƒ—ã®æ¬¡ã®ç¹°ã‚Šè¿”ã—ã«å‡¦ç†ã‚’ç§»ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcontinue [\fR\fB\fIæ·±ã•\fR\fR\fB]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBcontinue \-i\fR .RE .SS "説明" .sp \fB\-i\fR (\fB\-\-iteration\fR) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€continue コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã® for ループã¾ãŸã¯ while ループã¾ãŸã¯ until ループã®ç¹°ã‚Šè¿”ã—を中断ã—ã€ç›´ã¡ã«æ¬¡ã®ç¹°ã‚Šè¿”ã—ã‚’é–‹å§‹ã—ã¾ã™ (while/until ループã«ã¤ã„ã¦ã¯ã€ãƒ«ãƒ¼ãƒ—ã®å®Ÿè¡Œæ¡ä»¶ã®åˆ¤å®šã‹ã‚‰ã‚„り直ã—ã¾ã™)。多é‡ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§å®Ÿè¡Œã—ãŸå ´åˆã€å†…å´ã‹ã‚‰æ•°ãˆã¦\fIæ·±ã•\fR番目ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ã€‚\fIæ·±ã•\fRãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æœ€ã‚‚内å´ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ (\fIæ·±ã•\fR = 1)。指定ã•れãŸ\fIæ·±ã•\fRãŒå®Ÿéš›ã«å®Ÿè¡Œã—ã¦ã„る多é‡ãƒ«ãƒ¼ãƒ—ã®æ·±ã•より大ãã„å ´åˆã¯æœ€ã‚‚外å´ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ã€‚ .sp \fB\-i\fR (\fB\-\-iteration\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€continue コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®å復実行ã®ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’中断ã—ã€ç›´ã¡ã«æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’é–‹å§‹ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-i\fR, \fB\-\-iteration\fR .RS 4 ループã§ã¯ãªãå復実行ã«å¯¾ã—ã¦ä½œç”¨ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIæ·±ã•\fR .RS 4 内å´ã‹ã‚‰ä½•番目ã®ãƒ«ãƒ¼ãƒ—ã«ä½œç”¨ã™ã‚‹ã®ã‹ã‚’指定ã™ã‚‹ 1 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ .RE .SS "終了ステータス" .sp \fB\-i\fR (\fB\-\-iteration\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã€continue コマンドã®å‡¦ç†ãŒæˆåŠŸã™ã‚‹ã¨çµ‚了ステータス㯠0 ã§ã™ã€‚\fB\-i\fR (\fB\-\-iteration\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã€continue コマンドã®å‡¦ç†ãŒæˆåŠŸã™ã‚‹ã¨ continue コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠continue コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .SS "補足" .sp Continue コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ \fB\-i\fR (\fB\-\-interact\fR) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "DIRS 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIDirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を表示ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBdirs [\-cv] [\fR\fB\fIインデックス\fR\fR\fB\&.\&.]\fR .RE .SS "説明" .sp \fIディレクトリスタック\fRã¨ã¯ã€ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å¤‰æ›´ã®å±¥æ­´ã‚’ã¨ã‚‹ä»•組ã¿ã§ã™ã€‚Pushd コマンドã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã™ã‚‹ã¨ã€å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«è¿½åŠ ã•れã¾ã™ã€‚Popd コマンドを使ã†ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«ä¿å­˜ã—ã¦ã‚ã‚‹å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«æˆ»ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚Dirs コマンドを使ã†ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を表示ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ディレクトリスタックã®å†…容㯠\fBDIRSTACK\fR é…列㨠\fBPWD\fR 変数ã«ä¿å­˜ã•れã¾ã™ã€‚ã“れらã®å€¤ã‚’変更ã™ã‚‹ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚ .sp ディレクトリスタックã«ä¿å­˜ã—ã¦ã‚るディレクトリã¯\fIインデックス\fRã§åŒºåˆ¥ã—ã¾ã™ã€‚インデックス㯠\fB\-v\fR (\fB\-\-verbose\fR) オプションを付ã‘㦠dirs コマンドを実行ã™ã‚‹ã“ã¨ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯æ­£å· (\fB+\fR) ã¾ãŸã¯è² å· (\fB\-\fR) ã®ä»˜ã„ãŸæ•´æ•°ã®å½¢ã§è¡¨ã‚ã—ã¾ã™ã€‚整数㯠pushd コマンドã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«è¿½åŠ ã—ãŸé †ã«æŒ¯ã‚‰ã‚Œã¾ã™ã€‚例ãˆã°ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB+0\fR ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚インデックス \fB+1\fR ã¯æœ€å¾Œã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã§ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB+2\fR ã¯ãã®ä¸€ã¤å‰ã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚インデックス \fB\-0\fR ã¯æœ€åˆã« 追加ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB\-1\fR ã¯ãã®æ¬¡ã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚ .sp \fB\-c\fR (\fB\-\-clear\fR) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€dirs コマンドã¯ç¾åœ¨ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã‚’一ã¤ãšã¤æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ \fB\-c\fR (\fB\-\-clear\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€dirs コマンドã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB+0\fR 以外ã®è¦ç´ ã‚’ã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-c\fR, \fB\-\-clear\fR .RS 4 ディレクトリスタックã®è¦ç´ ã‚’ (ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã™ã‚‹ã‚‚ã®ã‚’除ã„ã¦) ã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚ .RE .PP \fB\-v\fR, \fB\-\-verbose\fR .RS 4 ディレクトリスタックã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚‚出力ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIインデックス\fR .RS 4 表示ã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã™ã€‚インデックスを一ã¤ã‚‚指定ã—ãªã„ã¨ãã¯ã€å…¨ã¦ã®è¦ç´ ã‚’インデックス \fB+0\fR ã®ã‚‚ã®ã‹ã‚‰é †ã«è¡¨ç¤ºã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š dirs コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ dirs コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "DISOWN 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIDisown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBdisown [\-a] [\fR\fB\fIジョブ\fR\fR\fB\&...}\fR .RE .SS "説明" .sp Disown コマンドã¯ã‚·ã‚§ãƒ«ãŒç®¡ç†ã—ã¦ã„るジョブを削除ã—ã¾ã™ã€‚削除ã—ãŸã‚¸ãƒ§ãƒ–ã¯ã‚¸ãƒ§ãƒ–制御ã®å¯¾è±¡ã‹ã‚‰å¤–れã¾ã™ãŒã€ã‚¸ãƒ§ãƒ–ã‚’æ§‹æˆã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã¯ç¶™ç¶šã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 å…¨ã¦ã®ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIジョブ\fR .RS 4 削除ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID。 .sp 複数指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚éž POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® \fB%\fR ã¯çœç•¥ã§ãã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š disown コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ disown コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ãƒ†ã‚­ã‚¹ãƒˆãƒ•ァイルを開ã„ã¦ã€ãã®å†…容をコマンドã¨ã—ã¦è§£é‡ˆã—実行ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\&. [\-AL] \fR\fB\fIファイルå\fR\fR\fB [\fR\fB\fI引数\fR\fR\fB\&...]\fR .RE .SS "説明" .sp ドットコマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸ\fIファイルå\fRã®ãƒ•ァイルを開ãã€ãã®å†…容をコマンドã¨ã—ã¦è§£é‡ˆã—ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã§å®Ÿè¡Œã—ã¾ã™ã€‚ .sp \fIファイルå\fRã«ç¶šã‘ã¦\fI引数\fRãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€é–¢æ•°ã®å®Ÿè¡Œã®æ™‚ã¨åŒæ§˜ã«ã€ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œå‰ã«\fI引数\fRãŒä½ç½®ãƒ‘ラメータã«è¨­å®šã•れã€å®Ÿè¡Œå¾Œã«å…ƒã®ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã«æˆ»ã‚Šã¾ã™ã€‚ .sp \fIファイルå\fRã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\fB/\fR) ãŒä¸€ã¤ã‚‚å…¥ã£ã¦ã„ãªã„å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®ã¨ãã¨åŒæ§˜ã« \fBPATH\fR å¤‰æ•°ã®æ¤œç´¢ã‚’行ã„ã€é–‹ãã¹ãファイルを探ã—ã¾ã™ã€‚ãŸã ã—ファイルã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ã•ãˆã‚れã°å®Ÿè¡Œå¯èƒ½ã§ã‚ã‚‹å¿…è¦ã¯ã‚りã¾ã›ã‚“。検索ã®çµæžœãƒ•ァイルãŒè¦‹ã¤ã‹ã‚Œã°ã€ãã®ãƒ•ァイルã®å†…容を解釈・実行ã—ã¾ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã€POSIX 準拠モードã§ã¯ç›´ã¡ã«ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚POSIX 準拠モードã§ãªã„ã¨ãã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ•ァイルを開ãã“ã¨ã‚’試ã¿ã¾ã™ã€‚ .SS "オプション" .PP \fB\-A\fR, \fB\-\-no\-alias\fR .RS 4 ファイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã™ã‚‹éš›ã€ã‚¨ã‚¤ãƒªã‚¢ã‚¹å±•開を行ã„ã¾ã›ã‚“。 .RE .PP \fB\-L\fR, \fB\-\-autoload\fR .RS 4 \fIファイルå\fRãŒã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’å«ã‚“ã§ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€\fBPATH\fR 変数ã®ä»£ã‚り㫠\fBYASH_LOADPATH\fR 変数を検索ã—ã¦é–‹ãã¹ãファイルを探ã—ã¾ã™ã€‚\fIファイルå\fRã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘スåã¨ã¯ã¿ãªã—ã¾ã›ã‚“。 .RE .sp ドットコマンドã§ã¯ã€æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ .SS "オペランド" .PP \fIファイルå\fR .RS 4 読ã¿è¾¼ã‚€ãƒ•ァイルã®ãƒ‘スåã§ã™ã€‚ .RE .PP \fI引数\fR\&... .RS 4 ファイルã®å†…容を実行ã—ã¦ã„ã‚‹é–“ã«ä½ç½®ãƒ‘ラメータã«è¨­å®šã™ã‚‹æ–‡å­—列ã§ã™ã€‚ .RE .SS "終了ステータス" .sp ドットコマンドã®çµ‚了ステータスã¯ã€ãƒ•ァイルã‹ã‚‰èª­ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ãŸæœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚ファイルã®å†…容ã«ä¸€ã¤ã‚‚コマンドãŒå…¥ã£ã¦ã„ãªã‹ã£ãŸã¨ãã¯çµ‚了ステータス㯠0 ã§ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚Šé–‹ã‘ãªã‹ã£ãŸã‚Šã—ãŸã¨ãã¯çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp ドットコマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp シェル㌠POSIX 準拠モードã§ã€ã‹ã¤å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ãªã„ã¨ãã€èª­ã¿è¾¼ã‚€ã¹ãファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚Šé–‹ã‘ãªã‹ã£ãŸã‚Šã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ .sp POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .sp POSIX ã«ã¯\fI引数\fRオペランドã«ã‚ˆã£ã¦ä½ç½®ãƒ‘ラメータを変更ã§ãã‚‹ã“ã¨ã«ã¤ã„ã¦ã®è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ POSIX 準拠モードã§ã¯\fI引数\fRオペランドを与ãˆã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ .SH "ECHO 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIEcho 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBecho [\fR\fB\fI文字列\fR\fR\fB\&...]\fR .RE .sp Echo コマンドã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã‚’å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚オプションã¯ã€ä»¥ä¸‹ã«è¿°ã¹ã‚‹ä¾‹å¤–を除ã„ã¦ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。オプションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«ç½®ãå¿…è¦ãŒã‚りã¾ã™ã€‚Echo コマンドã§ã¯æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã¯çµ¶å¯¾ã«èµ·ãã¾ã›ã‚“。 .SS "説明" .sp Echo コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨æ”¹è¡Œã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚引数ãŒãªã„å ´åˆã¯æ”¹è¡Œã ã‘を出力ã—ã¾ã™ã€‚引数ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãれãžã‚Œã‚’空白文字ã§åŒºåˆ‡ã£ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBエスケープシーケンス\fR .RS 4 .sp Echo コマンドã«ä¸Žãˆã‚‹å¼•æ•°ã§ã¯ã€å¾Œè¿°ã® \fBECHO_STYLE\fR 変数㨠\fB\-e\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .PP \fB\ea\fR .RS 4 ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7) .RE .PP \fB\eb\fR .RS 4 ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 8) .RE .PP \fB\ec\fR .RS 4 ã“れ以é™ä½•も出力ã—ãªã„。 .RE .PP \fB\ee\fR .RS 4 エスケープ文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 27) .RE .PP \fB\ef\fR .RS 4 フォームフィード (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 12) .RE .PP \fB\en\fR .RS 4 改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10) .RE .PP \fB\er\fR .RS 4 復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13) .RE .PP \fB\et\fR .RS 4 水平タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 9) .RE .PP \fB\ev\fR .RS 4 垂直タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 11) .RE .PP \fB\e\e\fR .RS 4 ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ .RE .PP \fB\e0\fR\fB\fIxxx\fR\fR .RS 4 八進数 \fIxxx\fR (最大三æ¡) ã§è¡¨ã‚ã•れるコード番å·ã®æ–‡å­— .RE .sp エスケープシーケンスãŒç„¡åŠ¹ã®æ™‚ã¯ã€ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¯è§£é‡ˆã›ãšã«ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBECHO_STYLE 変数\fR .RS 4 .sp Echo コマンドãŒã‚ªãƒ—ションやエスケープシーケンスを解釈ã™ã‚‹ã‹ã©ã†ã‹ã¯ \fBECHO_STYLE\fR 変数ã®å€¤ã«ã‚ˆã‚Šã¾ã™ã€‚以下ã«ã€ã“ã®å¤‰æ•°ã®å€¤ã¨ echo コマンドã®å‹•作ã¨ã®å¯¾å¿œã‚’示ã—ã¾ã™ã€‚ .PP \fBSYSV\fR, \fBXSI\fR .RS 4 オプションã¯ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。常ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ã¾ã™ã€‚ .RE .PP \fBBSD\fR .RS 4 \fB\-n\fR オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンスã¯ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。 .RE .PP \fBGNU\fR .RS 4 \fB\-n\fR, \fB\-e\fR, \fB\-E\fR オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンス㯠\fB\-e\fR オプションを指定ã—ãŸã¨ãã ã‘解釈ã—ã¾ã™ã€‚ .RE .PP \fBZSH\fR .RS 4 \fB\-n\fR, \fB\-e\fR, \fB\-E\fR オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンス㯠\fB\-E\fR オプションを指定ã—ãªã„ã‹ãŽã‚Šè§£é‡ˆã—ã¾ã™ã€‚ .RE .PP \fBDASH\fR .RS 4 \fB\-n\fR オプションを解釈ã—ã¾ã™ã€‚常ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ã¾ã™ã€‚ .RE .PP \fBRAW\fR .RS 4 オプションもエスケープシーケンスも一切解釈ã—ã¾ã›ã‚“。 .RE .sp \fBECHO_STYLE\fR 変数ãŒè¨­å®šã•れã¦ã„ãªã„ã¨ãã¯ã€å€¤ãŒ \fBSYSV\fR ã¾ãŸã¯ \fBXSI\fR ã®å ´åˆã®å‹•作をã—ã¾ã™ã€‚ .RE .SS "オプション" .PP \fB\-n\fR .RS 4 æœ€å¾Œã«æ”¹è¡Œã‚’出力ã—ãªã„よã†ã«ã™ã‚‹ã€‚ .RE .PP \fB\-e\fR .RS 4 エスケープシーケンスを解釈ã™ã‚‹ã‚ˆã†ã«ã™ã‚‹ã€‚ .RE .PP \fB\-E\fR .RS 4 エスケープシーケンスを解釈ã›ãšã€å…¨ã¦ã®æ–‡å­—ã‚’ãã®ã¾ã¾å‡ºåŠ›ã™ã‚‹ã‚ˆã†ã«ã™ã‚‹ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š echo コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ \fBECHO_STYLE\fR 変数ãŠã‚ˆã³ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。POSIX ã§ã¯ã€\fB\-n\fR ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れãŸã¨ãã¾ãŸã¯å¼•æ•°ã«ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã®å‹•作をè¦å®šã—ã¦ã„ã¾ã›ã‚“ã€‚å¯æ¬æ€§ã®ã‚るシェルスクリプトを書ãã«ã¯ã€echo コマンドよりも printf コマンドã®ä½¿ç”¨ã‚’推奨ã—ã¾ã™ã€‚ .SH "EVAL 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIEval 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã—ã¦è§£é‡ˆã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBeval [\-i] [\fR\fB\fIコマンド\fR\fR\fB\&...]\fR .RE .sp Eval コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ .SS "説明" .sp Eval コマンドã¯ã€ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’シェルã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã€ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã§å®Ÿè¡Œã—ã¾ã™ã€‚ .sp \fB\-i\fR (\fB\-\-iteration\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’ã¾ã¨ã‚ã¦ä¸€åº¦ã«è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚複数ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ãれらを順ã«é€£çµã—ã¦ä¸€ã¤ã«ã—ã¦ã‹ã‚‰è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ (連çµã®éš›ã€å„オペランド間ã«ç©ºç™½æ–‡å­—を一ã¤ãšã¤åŒºåˆ‡ã‚Šã¨ã—ã¦æŒ¿å…¥ã—ã¾ã™)。 .sp \fB\-i\fR (\fB\-\-iteration\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’é †ã«ä¸€ã¤ãšã¤è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚ã“れを\fIå復実行\fRã¨ã„ã„ã¾ã™ã€‚å復実行ã®é€”中㧠continue コマンドを \fB\-i\fR オプション付ãã§å®Ÿè¡Œã—ãŸå ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã¯ä¸­æ–­ã•れã€eval コマンドã«ä¸Žãˆã‚‰ã‚ŒãŸæ¬¡ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®è§£é‡ˆãƒ»å®Ÿè¡Œã«ç§»ã‚Šã¾ã™ã€‚å復実行ã®é€”中㧠break コマンドを \fB\-i\fR オプション付ãã§å®Ÿè¡Œã—ãŸå ´åˆã€å復実行ã¯ä¸­æ–­ã•れã€ã“ã® eval コマンドã®å®Ÿè¡Œã¯çµ‚了ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-i\fR, \fB\-\-iteration\fR .RS 4 与ãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ã‚’é †ã«å復実行ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIコマンド\fR .RS 4 コマンドã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã™ã‚‹æ–‡å­—列ã§ã™ã€‚ .RE .SS "終了ステータス" .sp オペランドãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¾ãŸã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®ä¸­ã«ã‚³ãƒžãƒ³ãƒ‰ãŒä¸€ã¤ã‚‚å«ã¾ã‚Œã¦ã„ãªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚コマンドãŒä¸€ã¤ä»¥ä¸Šè§£é‡ˆãƒ»å®Ÿè¡Œã•れãŸå ´åˆã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠eval コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .SS "補足" .sp Eval コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "EXEC 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIExec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ã®ãƒ—ロセスを別ã®å¤–部コマンドã«ç½®ãæ›ãˆã¾ã™ã€‚ã¾ãŸã‚·ã‚§ãƒ«ã®ãƒ—ロセスã«å¯¾ã—ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚’実行ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBexec [\-cf] [\-a \fR\fB\fIコマンドå\fR\fR\fB] [\fR\fB\fIコマンド\fR\fR\fB [\fR\fB\fI引数\fR\fR\fB\&...]]\fR .RE .sp Exec コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“れ㯠exec コマンドã«å¯¾ã™ã‚‹ã‚ªãƒ—ションã¨\fIコマンド\fRã«å¯¾ã™ã‚‹ã‚ªãƒ—ションを区別ã™ã‚‹ãŸã‚ã«é‡è¦ã§ã™ã€‚\fIコマンド\fRより後ã«ã‚る引数ã¯ã™ã¹ã¦\fI引数\fRã¨ã¿ãªã•れã¾ã™ã€‚ .SS "説明" .sp Exec コマンドを\fIコマンド\fRを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯å˜ç´”コマンドã®å®Ÿè¡Œã®æœ€å¾Œã®ã‚¹ãƒ†ãƒƒãƒ—ã¨åŒæ§˜ã«ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã¯å¿…ãšå¤–部コマンドã¨ã—ã¦ã¿ãªã•れã€é–¢æ•°ã‚„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç„¡è¦–ã—ã¾ã™ã€‚ãã—ã¦ãã®å¤–部コマンドã¯ã‚µãƒ–シェルã§ã¯ãªãç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã§ exec システムコールを呼ã³å‡ºã™ã“ã¨ã§å®Ÿè¡Œã—ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚·ã‚§ãƒ«ã®ãƒ—ãƒ­ã‚»ã‚¹ã¯æ–°ã—ãèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«ç½®ãæ›ã‚りã¾ã™ã€‚ .sp シェル㌠POSIX 準拠モードã®ã¨ãã¾ãŸã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ãªã„ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ã®èµ·å‹•ã«å¤±æ•—ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ .sp シェル㌠POSIX 準拠モードã§ã¯ãªãã‹ã¤å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã¨ãã€åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã—ã¾ã›ã‚“。一度 exec ãŒå®Ÿè¡Œã•れるã¨ã€ã‚·ã‚§ãƒ«ãŒæŒã£ã¦ã„ã‚‹ã‚¸ãƒ§ãƒ–ã®æƒ…å ±ã¯å¤±ã‚れるãŸã‚ã€æ‰‹å‹•ã§ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã£ã¦ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã¾ãŸã¯çµ‚了ã•ã›ãªã‘れã°ãªã‚‰ãªããªã‚Šã¾ã™ã€‚警告を無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã™ã‚‹ã«ã¯ \fB\-f\fR (\fB\-\-force\fR) オプションを付ã‘ã¦ãã ã•ã„。 .sp \fIコマンド\fRãªã—ã§å®Ÿè¡Œã—ãŸå ´åˆ exec コマンドã¯ä½•も行ã„ã¾ã›ã‚“ãŒã€ã“ã® exec コマンドを実行ã™ã‚‹éš›ã«è¡Œã£ãŸãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®åŠ¹æžœã¯ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã«æ®‹ã‚Šã¾ã™ã€‚ .SS "オプション" .PP \fB\-a \fR\fB\fIコマンドå\fR\fR, \fB\-\-as=\fR\fB\fIコマンドå\fR\fR .RS 4 \fIコマンド\fRã®ä»£ã‚りã«\fIコマンドå\fRをコマンドåã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã—ã¾ã™ã€‚ .RE .PP \fB\-c\fR, \fB\-\-clear\fR .RS 4 既存ã®ç’°å¢ƒå¤‰æ•°ã‚’ã™ã¹ã¦å‰Šé™¤ã—ãŸçŠ¶æ…‹ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ãŸã ã—ã“ã® exec コマンドを実行ã™ã‚‹éš›ã«è¡Œã£ãŸå¤‰æ•°ä»£å…¥ã®çµæžœã¯ç’°å¢ƒå¤‰æ•°ã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã—ã¾ã™ã€‚ .RE .PP \fB\-f\fR, \fB\-\-force\fR .RS 4 警告を無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIコマンド\fR .RS 4 実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .RE .PP \fI引数\fR\&... .RS 4 実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚ .RE .SS "終了ステータス" .sp 指定ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®èµ·å‹•ã«æˆåŠŸã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã¯ãã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセスã«ç½®ãæ›ã‚ã£ã¦ã—ã¾ã†ã®ã§ã€çµ‚了ステータスã¯ã‚りã¾ã›ã‚“。 .sp 実行ã—よã†ã¨ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠127 ã§ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã£ãŸãŒå®Ÿè¡Œã§ããªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠126 ã§ã™ã€‚\fIコマンド\fRを指定ã›ãšã« exec コマンドを実行ã—ãŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Exec コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "EXIT 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIExit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRコマンドã¯ã‚·ã‚§ãƒ«ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBexit [\-f] [\fR\fB\fI終了ステータス\fR\fR\fB]\fR .RE .SS "説明" .sp Exit コマンドã¯ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã‚·ã‚§ãƒ« (ã¾ãŸã¯ã‚µãƒ–シェル) を終了ã—ã¾ã™ã€‚ .sp åœæ­¢ã—ã¦ã„るジョブã®ã‚る対話モードã®ã‚·ã‚§ãƒ«ã‚’終了ã—よã†ã¨ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€çµ‚了ã—ã¾ã›ã‚“。\fB\-f\fR (\fB\-\-force\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã‹ exit コマンドを二連続ã§å®Ÿè¡Œã™ã‚‹ã¨è­¦å‘Šã‚’無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’終了ã—ã¾ã™ã€‚ .sp シェル終了時ã®ãƒˆãƒ©ãƒƒãƒ—ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ãŒçµ‚了ã™ã‚‹å‰ã«ãれãŒå®Ÿè¡Œã•れã¾ã™ã€‚ .SS "オプション" .PP \fB\-f\fR, \fB\-\-force\fR .RS 4 警告を無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’終了ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fI終了ステータス\fR .RS 4 終了ã™ã‚‹ã‚·ã‚§ãƒ«ã®çµ‚了ステータスを指定ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ .sp ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€exit コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを用ã„ã¾ã™ (ãŸã ã—トラップを実行中ã®å ´åˆã¯ãƒˆãƒ©ãƒƒãƒ—ã«å…¥ã‚‹ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス)。 .sp 終了ã™ã‚‹ã‚·ã‚§ãƒ«ã®å®Ÿéš›ã®çµ‚了ステータスã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸæ•°ã‚’ 256 ã§å‰²ã£ãŸä½™ã‚Šã«ãªã‚Šã¾ã™ã€‚ .RE .SS "終了ステータス" .sp Exit コマンドã¯ã‚·ã‚§ãƒ«ã‚’終了ã™ã‚‹ã®ã§ã€exit コマンドãã®ã‚‚ã®ã®çµ‚了ステータスã¯ã‚りã¾ã›ã‚“。 .sp 例外ã¨ã—ã¦ã€exit コマンドãŒè­¦å‘Šã‚’表示ã—ã¦ã€ã‚·ã‚§ãƒ«ã‚’終了ã—ãªã‹ã£ãŸå ´åˆã€exit コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp Exit コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã§ã¯ã€\fI終了ステータス\fRã®å€¤ã¯ 0 以上 256 未満ã§ãªã‘れã°ãªã‚‰ãªã„ã¨ã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯æ‹¡å¼µã¨ã—㦠256 以上ã®å€¤ã‚‚å—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ .sp POSIX ã«ã¯ \fB\-f\fR (\fB\-\-force\fR) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .sp シェル終了時ã®ãƒˆãƒ©ãƒƒãƒ—ã®å®Ÿè¡Œä¸­ã« exit コマンドを実行ã™ã‚‹ã¨ã€å†ã³ãƒˆãƒ©ãƒƒãƒ—ãŒå®Ÿè¡Œã•れるã“ã¨ã¯ãªããã®ã¾ã¾ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚ã“ã®ã¨ã exit コマンドã«\fI終了ステータス\fRãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€ã‚‚ã—終了時ã®ãƒˆãƒ©ãƒƒãƒ—ãŒè¨­å®šã•れã¦ã„ãªã‹ã£ãŸå ´åˆã«ã‚·ã‚§ãƒ«ãŒè¿”ã—ãŸã‚ã†çµ‚了ステータスã§ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚(シェルã®çµ‚了もå‚ç…§) .SH "EXPORT 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIExport 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã®å¤‰æ•°ã‚’表示・設定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBexport [\-prX] [\fR\fB\fI変数\fR\fR\fB[=\fR\fB\fI値\fR\fR\fB]\&...]\fR .RE .SS "説明" .sp Export コマンド㯠typeset コマンド㫠\fB\-gx\fR オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠typeset コマンドã¨åŒæ§˜ã§ã™ã€‚ .SS "補足" .sp Export コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ export コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã™ãŒã€ã‚ªãƒ—ション㯠\fB\-p\fR ã—ã‹è¦å®šãŒã‚りã¾ã›ã‚“。ãã®ä»–ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠\fB\-p\fR オプションをオペランドã¨ã¨ã‚‚ã«ä½¿ã†ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 .SH "FALSE 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIFalse 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ä½•も行ã‚ãšã«éž 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfalse\fR .RE .SS "説明" .sp False コマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚ .SS "終了ステータス" .sp False コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp False ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .SH "FC 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIFc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«è¨˜éŒ²ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œãƒ»è¡¨ç¤ºã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc [\-qr] [\-e \fR\fB\fIエディタ\fR\fR\fB] [\fR\fB\fI始点\fR\fR\fB [\fR\fB\fI終点\fR\fR\fB]]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-s[q] [\fR\fB\fIå‰\fR\fR\fB=\fR\fB\fI後\fR\fR\fB] [\fR\fB\fI始点\fR\fR\fB]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfc \-l[nrv] [\fR\fB\fI始点\fR\fR\fB [\fR\fB\fI終点\fR\fR\fB]]\fR .RE .SS "説明" .sp \fB\-l\fR (\fB\-\-list\fR) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€fc コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ã¾ã™ã€‚\fB\-s\fR (\fB\-\-silent\fR) オプションを付ã‘ã¦ã„ãªã„å ´åˆã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã™ã‚‹å‰ã«ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã§ãるよã†ã«ã—ã¾ã™ã€‚エディタãŒçµ‚了ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç·¨é›†å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚\fB\-s\fR (\fB\-\-silent\fR) オプションを付ã‘ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã›ãšç›´æŽ¥ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ã¾ã™ã€‚ã„ãšã‚Œã®å ´åˆã‚‚ã€å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯æ¨™æº–出力ã«å‡ºåŠ›ã—コマンド履歴ã«è¿½åŠ ã•れã¾ã™ã€‚ .sp \fB\-l\fR (\fB\-\-list\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€fc コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸç¯„囲ã®ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚標準ã§ã¯å±¥æ­´å†…ã®ã‚³ãƒžãƒ³ãƒ‰ã®å†…容を履歴番å·ã¨ã¨ã‚‚ã«è¡¨ç¤ºã—ã¾ã™ãŒã€\fB\-n\fR (\fB\-\-no\-numbers\fR) ãŠã‚ˆã³ \fB\-v\fR (\fB\-\-verbose\fR) オプションã«ã‚ˆã‚Šå‡ºåЛ形å¼ã‚’変更ã§ãã¾ã™ã€‚ .SS "オプション" .PP \fB\-e \fR\fB\fIエディタ\fR\fR, \fB\-\-editor=\fR\fB\fIエディタ\fR\fR .RS 4 コマンドã®ç·¨é›†ã«ç”¨ã„るエディタ。 .sp ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€\fBFCEDIT\fR 変数ã®å€¤ã‚’エディタã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚\fBFCEDIT\fR 変数も設定ã•れã¦ã„ãªã„å ´åˆã¯ã€vi をエディタã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚ .RE .PP \fB\-l\fR, \fB\-\-list\fR .RS 4 コマンド履歴ã®å†…容を表示ã—ã¾ã™ã€‚ .RE .PP \fB\-n\fR, \fB\-\-no\-numbers\fR .RS 4 コマンド履歴ã®å†…容を表示ã™ã‚‹éš›ã€å±¥æ­´ç•ªå·ã‚’çœã„ã¦ã‚³ãƒžãƒ³ãƒ‰ã®ã¿è¡¨ç¤ºã—ã¾ã™ã€‚ .RE .PP \fB\-q\fR, \fB\-\-quiet\fR .RS 4 コマンドを実行ã™ã‚‹å‰ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’出力ã—ãªã„よã†ã«ã—ã¾ã™ã€‚ .RE .PP \fB\-r\fR, \fB\-\-reverse\fR .RS 4 \fI始点\fRã¨\fI終点\fRを入れ替ãˆã¾ã™ã€‚ .RE .PP \fB\-s\fR, \fB\-\-silent\fR .RS 4 コマンドを編集ã›ãšã«ç›´æŽ¥å†å®Ÿè¡Œã—ã¾ã™ã€‚ .RE .PP \fB\-v\fR, \fB\-\-verbose\fR .RS 4 コマンド履歴ã®å†…容を表示ã™ã‚‹éš›ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ™‚刻も表示ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fI始点\fRã¨\fI終点\fR .RS 4 \fI始点\fRã¨\fI終点\fRã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€å†å®Ÿè¡Œã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ç¯„囲を指定ã—ã¾ã™ã€‚\fI始点\fRã‚ã‚‹ã„ã¯\fI終点\fRã«æ•´æ•°ã‚’指定ã™ã‚‹ã¨ã€ãれã¯å±¥æ­´ç•ªå·ã¨ã¿ãªã—ã¾ã™ã€‚è² ã®æ•´æ•°ã¯æœ€æ–°ã®å±¥æ­´ã‹ã‚‰æ•°ãˆãŸç•ªå·ã¨ãªã‚Šã¾ã™ã€‚例ãˆã° \fB\-2\fR ã¯æœ€å¾Œã‹ã‚‰äºŒç•ªç›®ã«å±¥æ­´ã«ç™»éŒ²ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’表ã—ã¾ã™ã€‚æ•´æ•°ä»¥å¤–ã®æ–‡å­—列を\fI始点\fRã‚ã‚‹ã„ã¯\fI終点\fRã«æŒ‡å®šã™ã‚‹ã¨ã€ãã®æ–‡å­—列ã§å§‹ã¾ã‚‹æœ€æ–°ã®å±¥æ­´ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .sp Fc コマンドãŒå†å®Ÿè¡Œã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã€\fI始点\fRã¨\fI終点\fRã§æŒ‡å®šã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¨ãã®é–“ã«ã‚る履歴ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚\fI始点\fRãŒ\fI終点\fRより後ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’指ã—ã¦ã„ã‚‹å ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®é †åºã¯é€†ã«ãªã‚Šã¾ã™ã€‚ .sp \fI始点\fRã¾ãŸã¯\fI終点\fRãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã®ãƒ‡ãƒ•ォルト値ã¯ä»¥ä¸‹ã®è¡¨ã®ã¨ãŠã‚Šã§ã™ã€‚ .TS allbox tab(:); ltB ltB ltB. T{ T}:T{ \fB\-l\fR ã‚り T}:T{ \fB\-l\fR ãªã— T} .T& lt lt lt lt lt lt. T{ \fI始点\fR T}:T{ \-16 T}:T{ \-1 T} T{ \fI終点\fR T}:T{ \-16 T}:T{ \fI始点\fRã«åŒã˜ T} .TE .sp 1 .RE .PP \fIå‰\fR=\fI後\fR .RS 4 \fIå‰\fR=\fI後\fRã®å½¢å¼ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®ä¸€éƒ¨ã‚’æ›¸ãæ›ãˆã‚‹ã“ã¨ã‚’指示ã—ã¾ã™ã€‚å†å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ä¸­ã«\fIå‰\fRã¨åŒã˜æ–‡å­—列ãŒã‚ã‚‹å ´åˆã¯ã€ãã®éƒ¨åˆ†ã‚’\fI後\fRã«ç½®ãæ›ãˆã¦å®Ÿè¡Œã—ã¾ã™ã€‚該当部分ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ã€æœ€åˆã®ã‚‚ã®ã ã‘ã‚’ç½®ãæ›ãˆã¾ã™ã€‚ .RE .SS "終了ステータス" .sp コマンドを正ã—ãå†å®Ÿè¡Œã§ããŸå ´åˆã€fc コマンドã®çµ‚了ステータスã¯å†å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚\fB\-l\fR (\fB\-\-list\fR) オプションを指定ã—ãŸå ´åˆã¯ã€å±¥æ­´ãŒæ­£ã—ã出力ã§ãれã°çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Fc ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ \fB\-q\fR (\fB\-\-quiet\fR) ãŠã‚ˆã³ \fB\-v\fR (\fB\-\-verbose\fR) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“れらã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .sp 行編集ã®å‹•作中ã¯å±¥æ­´ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .SH "FG 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIFg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚¸ãƒ§ãƒ–をフォアグラウンドã§å®Ÿè¡Œã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBfg [\fR\fB\fIジョブ\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Fg コマンドã¯ã‚¸ãƒ§ãƒ–をフォアグラウンドã«ç§»å‹•ã— SIGCONT シグナルをé€ã‚Šã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ã¦ã„ãŸå ´åˆã¯ãƒ•ォアグラウンドã§å®Ÿè¡ŒãŒå†é–‹ã•れã¾ã™ã€‚Fg コマンドã¯ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã¾ã§å¾…機ã—ã€ã‚¸ãƒ§ãƒ–ã®çµ‚了ステータスを返ã—ã¾ã™ã€‚ .sp ジョブã®å®Ÿè¡Œã‚’å†é–‹ã™ã‚‹å‰ã« fg コマンドã¯ã‚¸ãƒ§ãƒ–ã®åå‰ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .sp Fg コマンドã¯ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã—ã‹ä½¿ãˆã¾ã›ã‚“。 .SS "オペランド" .PP \fIジョブ\fR .RS 4 実行ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID。 .sp 複数指定ã™ã‚‹ã¨æŒ‡å®šã—ãŸé †ã«ä¸€ã¤ãšã¤ã‚¸ãƒ§ãƒ–をフォアグラウンドã§å®Ÿè¡Œã—ã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を実行ã—ã¾ã™ã€‚ .sp éž POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® \fB%\fR ã¯çœç•¥ã§ãã¾ã™ã€‚ .RE .SS "終了ステータス" .sp ジョブを正ã—ã実行ã§ããŸå ´åˆã€fg コマンドã®çµ‚了ステータス㯠(最後ã«) 実行ã—ãŸã‚¸ãƒ§ãƒ–ã®çµ‚了ステータスã§ã™ã€‚エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp Fg ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX 準拠モードã§ã¯\fIジョブ\fRã¯ä¸€ã¤ã¾ã§ã—ã‹æŒ‡å®šã§ãã¾ã›ã‚“。 .SH "GETOPTS 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIGetopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBgetopts \fR\fB\fIオプションリスト\fR\fR\fB \fR\fB\fI変数å\fR\fR\fB [\fR\fB\fI引数\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Getopts コマンドã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«å«ã¾ã‚Œã¦ã„る一文字ã®ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚Getopts コマンドを一回呼ã³å‡ºã™ãŸã³ã«ã‚ªãƒ—ションãŒä¸€ã¤è§£æžã•れã€ãã®ã‚ªãƒ—ションを表ã™ä¸€æ–‡å­—ãŒ\fI変数å\fRã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ä»£å…¥ã•れã¾ã™ã€‚ .sp è§£æžã®å¯¾è±¡ã¨ãªã‚‹ã‚ªãƒ—ションã®ç¨®é¡žã‚‚ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ã¾ã™ã€‚\fIオプションリスト\fRã«ã¯å—ã‘付ã‘ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—を並ã¹ã¦æŒ‡å®šã—ã¾ã™ã€‚文字ã®å¾Œã«ã‚³ãƒ­ãƒ³ (\fB:\fR) を付ã‘ã‚‹ã¨ãã®ã‚ªãƒ—ションã¯å¼•æ•°ã‚’ã¨ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚例ãˆã°ã€\fB\-a\fR, \fB\-b\fR, \fB\-c\fR ã®ä¸‰ç¨®é¡žã®ã‚ªãƒ—ションをå—ã‘付ã‘ã€ã•らã«ã“れらã®ã†ã¡ \fB\-b\fR ãŒå¼•æ•°ã‚’ã¨ã‚‹å ´åˆã€\fIオプションリスト\fRã«ã¯ \fBab:c\fR を指定ã—ã¾ã™ã€‚ .sp 引数をã¨ã‚‹ã‚ªãƒ—ションを解æžã—ãŸã¨ãã€ãã®å¼•æ•°ã®å€¤ãŒ \fBOPTARG\fR 変数ã«ä»£å…¥ã•れã¾ã™ã€‚ .sp \fIオプションリスト\fRã§ä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„オプションã«å‡ºãã‚ã—ãŸã¨ãã¾ãŸã¯å¼•æ•°ã‚’ã¨ã‚‹ã‚ªãƒ—ションã«å¼•æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã®å‹•作ã¯ã€\fIオプションリスト\fRã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ (\fB:\fR) ã§ã‚ã‚‹ã‹ã©ã†ã‹ã§æ±ºã¾ã‚Šã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIオプションリスト\fRã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ã®å ´åˆã€ãã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—㌠\fBOPTARG\fR 変数ã«ä»£å…¥ã•れã€\fI変数å\fRã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ã¯ \fB?\fR (\fIオプションリスト\fRã§ä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„オプションã«å‡ºãã‚ã—ãŸã¨ã) ã¾ãŸã¯ \fB:\fR (引数をã¨ã‚‹ã‚ªãƒ—ションã«å¼•æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ã) ãŒä»£å…¥ã•れã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIオプションリスト\fRã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ã§ãªã„å ´åˆã€\fBOPTARG\fR 変数ã¯å‰Šé™¤ã•れã€\fI変数å\fRã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ã¯ \fB?\fR ãŒä»£å…¥ã•れã¾ã™ã€‚ã¾ãŸã“ã®ã¨ã標準エラーã«ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒå‡ºåŠ›ã•れã¾ã™ãŒã€ãれã§ã‚‚ getopts コマンドã®çµ‚了ステータス㯠0 ã«ãªã‚Šã¾ã™ã€‚ .RE .sp Getopts コマンドã¯ã€å®Ÿè¡Œã™ã‚‹ãŸã³ã«ä¸€ã¤ãšã¤ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã™ã‚‹ã«ã¯ã€æ¯Žå›žåŒã˜\fI引数\fRã§ getopts コマンドを繰り返ã—実行ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚シェルã¯ã€ã‚ªãƒ—ションをã©ã“ã¾ã§è§£æžã—ãŸã‹ã‚’覚ãˆã¦ãŠããŸã‚ã«ã€\fBOPTIND\fR 変数を用ã„ã¾ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã‚‹ã¾ã§ã«ã“ã®å¤‰æ•°ã‚’変更ã—ã¦ã¯ã„ã‘ã¾ã›ã‚“。全ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã‚‹ã¨ã€\fBOPTIND\fR 変数ã«ã¯\fI引数\fR (ã¾ãŸã¯ä½ç½®ãƒ‘ラメータ) ã®ä¸­ã§æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã«å½“ãŸã‚‹ã‚‚ã®ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒä»£å…¥ã•れã¾ã™ (オペランドãŒãªã„å ´åˆã¯\fI引数\fRã¾ãŸã¯ä½ç½®ãƒ‘ラメータã®å€‹æ•° + 1 ã«ãªã‚Šã¾ã™)。 .sp ç•°ãªã‚‹\fI引数\fRã‚’è§£æžã•ã›ãŸã„å ´åˆã¯ã€getopts ã‚³ãƒžãƒ³ãƒ‰ã«æ–°ã—ã„\fI引数\fRを与ãˆã‚‹å‰ã« \fBOPTIND\fR 変数㫠\fB1\fR を代入ã—ã¦ãã ã•ã„。 .SS "オペランド" .PP \fIオプションリスト\fR .RS 4 è§£æžã®å¯¾è±¡ã¨ãªã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—ã®ç¾…列ã§ã™ã€‚ .RE .PP \fI変数å\fR .RS 4 è§£æžçµæžœã®å€¤ã‚’代入ã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚ .RE .PP \fI引数\fRs .RS 4 è§£æžã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚ .sp ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’指定ã—ãªã„å ´åˆã¯ã€ä½ç½®ãƒ‘ラメータを解æžã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp \fI引数\fRã®ä¸­ã«ã‚ªãƒ—ションãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¯ã€(ãれãŒ\fIオプションリスト\fRã«å«ã¾ã‚Œã¦ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãš) 終了ステータス㯠0 ã§ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã£ãŸæ™‚ã¯ã€çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "使用例" .sp .if n \{\ .RS 4 .\} .nf aopt=false bopt= copt=false while getopts ab:c opt do case $opt in a) aopt=true ;; b) bopt=$OPTARG ;; c) copt=true ;; \e?) return 2 ;; esac done if $aopt; then echo オプション \-a ãŒæŒ‡å®šã•れã¾ã—ãŸ; fi if [ \-n "$bopt" ]; then echo オプション \-b $bopt ãŒæŒ‡å®šã•れã¾ã—ãŸ; fi if $copt; then echo オプション \-c ãŒæŒ‡å®šã•れã¾ã—ãŸ; fi shift $((OPTIND \- 1)) echo オペランド㯠$* .fi .if n \{\ .RE .\} .SS "補足" .sp Getopts コマンドãŒè§£æžã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã¯ã€ã‚ªãƒ—ションã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«æŒ‡å®šã—ã¦ã‚ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚最åˆã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒç¾ã‚ŒãŸæ™‚点ã§ã€getopts コマンドã¯è§£æžã‚’終了ã—ã¾ã™ã€‚ .sp Getopts ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã¯ã€\fBOPTIND\fR 変数㫠\fB1\fR 以外ã®å€¤ã‚’代入ã—ãŸå ´åˆã®å‹•作をè¦å®šã—ã¦ã„ã¾ã›ã‚“。 .SH "HASH 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIHash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯å¤–部コマンドã®ãƒ‘スを検索・表示ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \fR\fB\fIコマンド\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-r [\fR\fB\fIコマンド\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash [\-a]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-d \fR\fB\fIユーザå\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-dr [\fR\fB\fIユーザå\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhash \-d\fR .RE .SS "説明" .sp オプションを指定ã—ãªã„å ´åˆã€hash コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤–部コマンドã®ãƒ‘スを検索ã—ã€çµæžœã‚’記憶ã—ã¾ã™ (æ—¢ã«è¨˜æ†¶ã—ã¦ã„ã‚‹å ´åˆã¯å†åº¦æ¤œç´¢ãƒ»è¨˜æ†¶ã—ã¾ã™)。 .sp \fB\-r\fR (\fB\-\-remove\fR) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€hash コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤–部コマンドã®ãƒ‘スã«é–¢ã™ã‚‹è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚\fB\-r\fR (\fB\-\-remove\fR) オプションを指定ã—ã‹ã¤\fIコマンド\fRを指定ã—ãªã„å ´åˆã€å…¨ã¦ã®è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚ .sp \fB\-r\fR (\fB\-\-remove\fR) オプションを指定ã›ãš\fIコマンド\fRも指定ã—ãªã„å ´åˆã€è¨˜æ†¶ã—ã¦ã„るパスã®ä¸€è¦§ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .sp \fB\-d\fR (\fB\-\-directory\fR) オプションを指定ã—ãŸå ´åˆã€hash コマンドã¯å¤–部コマンドã®ãƒ‘スã®ä»£ã‚りã«ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを検索・記憶ã¾ãŸã¯è¡¨ç¤ºã—ã¾ã™ã€‚記憶ã—ãŸãƒ‘スã¯ãƒãƒ«ãƒ€å±•é–‹ã§ä½¿ç”¨ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 シェルãŒè¨˜æ†¶ã—ã¦ã„ã‚‹å…¨ã¦ã®ãƒ‘スを出力ã—ã¾ã™ã€‚ .sp ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€ã‚·ã‚§ãƒ«ãŒè¨˜æ†¶ã—ã¦ã„るパスã®ã†ã¡çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã™ã‚‹ã‚‚ã®ã¯å‡ºåŠ›ã—ã¾ã›ã‚“。 .RE .PP \fB\-d\fR, \fB\-\-directory\fR .RS 4 外部コマンドã®ãƒ‘スã®ä»£ã‚りã«ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを扱ã„ã¾ã™ã€‚ .RE .PP \fB\-r\fR, \fB\-\-remove\fR .RS 4 指定ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¾ãŸã¯ãƒ¦ãƒ¼ã‚¶åã«å¯¾ã™ã‚‹ãƒ‘スã®è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIコマンド\fR .RS 4 パスを記憶・消去ã™ã‚‹å¤–部コマンドã®åå‰ã§ã™ã€‚スラッシュをå«ã‚€ãƒ‘スを指定ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .PP \fIユーザå\fR .RS 4 ホームディレクトリã®ãƒ‘スを記憶・消去ã™ã‚‹ãƒ¦ãƒ¼ã‚¶åã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š hash コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp シェルã¯ã€å¤–部コマンド (ã¾ãŸã¯ãƒãƒ«ãƒ€å±•é–‹) を実行ã™ã‚‹éš›ã«è‡ªå‹•çš„ã«ã‚³ãƒžãƒ³ãƒ‰ (ã¾ãŸã¯ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒª) ã®ãƒ‘スを記憶ã™ã‚‹ã®ã§ã€é€šå¸¸ã¯ã‚ã–ã‚ã– hash コマンドを使ã£ã¦ãƒ‘スを記憶ã•ã›ã‚‹å¿…è¦ã¯ã‚りã¾ã›ã‚“。 .sp \fBPATH\fR 変数ã®å€¤ãŒå¤‰ã‚ã£ãŸæ™‚ã¯ã€è¨˜æ†¶ã—ãŸå¤–部コマンドã®ãƒ‘スã¯è‡ªå‹•çš„ã«ã™ã¹ã¦æ¶ˆåŽ»ã•れã¾ã™ã€‚ .sp POSIX ãŒè¦å®šã—ã¦ã„るオプション㯠\fB\-r\fR ã ã‘ã§ã™ã€‚よã£ã¦ä»–ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "HELP 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIHelp 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«é–¢ã™ã‚‹èª¬æ˜Žã‚’表示ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhelp [\fR\fB\fIコマンド\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«é–¢ã™ã‚‹èª¬æ˜Žã‚’出力ã—ã¾ã™ã€‚ .sp ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€\fBman yash\fR ã®å‡ºåŠ›ã®ä¸€éƒ¨ã‚’抜ã出ã—ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚従ã£ã¦ã€ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ãƒšãƒ¼ã‚¸ãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•れã¦ã„ãªã‘ã‚Œã°æ­£ã—ã動作ã—ã¾ã›ã‚“。ã¾ãŸã€man コマンドã®å‡ºåŠ›ã®å½¢å¼ã«ã‚ˆã£ã¦ã¯æ­£ã—ã説明を抜ã出ã›ãªã„ã“ã¨ãŒã‚りã¾ã™ã€‚ .SS "オペランド" .PP \fIコマンド\fR .RS 4 説明を表示ã™ã‚‹çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š help コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ The exit status of the help built\-in is zero unless there is any error\&. .SS "補足" .sp POSIX ã«ã¯ help コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .sp Yash ã®å¤šãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã€\fB\-\-help\fR オプションを与ãˆã‚‹ã“ã¨ã§ help コマンドã®å‡ºåŠ›ã¨åŒæ§˜ã®èª¬æ˜Žã‚’表示ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .SH "HISTORY 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIHistory 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚’編集ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBhistory [\-cF] [\-d \fR\fB\fIé …ç›®\fR\fR\fB] [\-s \fR\fB\fIコマンド\fR\fR\fB] [\-r \fR\fB\fIファイル\fR\fR\fB] [\-w \fR\fB\fIファイル\fR\fR\fB] [\fR\fB\fI個数\fR\fR\fB]\fR .RE .SS "説明" .sp History コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容を編集・表示ã—ã¾ã™ã€‚ .sp ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã—ã¦ã‚ã‚‹å ´åˆã€history コマンドã¯ãã®ã‚ªãƒ—ションã«å¾“ã£ã¦ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容を編集ã—ã¾ã™ã€‚複数ã®ã‚ªãƒ—ションãŒã‚ã‚‹å ´åˆã¯æŒ‡å®šã—ãŸé †ã«å‡¦ç†ã—ã¾ã™ã€‚ .sp オペランドã§\fI個数\fRãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã€history コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容をãã®å€‹æ•°ã ã‘標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚出力ã®å½¢å¼ã¯ fc ã‚³ãƒžãƒ³ãƒ‰ã«æº–ã˜ã¾ã™ã€‚ .sp オプションもオペランドも与ãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€history コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…å®¹ã‚’å…¨ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-c\fR, \fB\-\-clear\fR .RS 4 コマンド履歴をã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚ .RE .PP \fB\-d \fR\fB\fIé …ç›®\fR\fR, \fB\-\-delete=\fR\fB\fIé …ç›®\fR\fR .RS 4 指定ã—ãŸ\fIé …ç›®\fRをコマンド履歴ã‹ã‚‰å‰Šé™¤ã—ã¾ã™ã€‚\fIé …ç›®\fRã®æŒ‡å®šã®ä»•方㯠fc コマンドã®\fI始点\fR・\fI終点\fRオペランドã¨åŒã˜ã§ã™ã€‚ .RE .PP \fB\-F\fR, \fB\-\-flush\-file\fR .RS 4 å±¥æ­´ãƒ•ã‚¡ã‚¤ãƒ«ã‚’å†æ§‹ç¯‰ã—ã¾ã™ã€‚ .RE .PP \fB\-r \fR\fB\fIファイル\fR\fR, \fB\-\-read=\fR\fB\fIファイル\fR\fR .RS 4 指定ã—ãŸ\fIファイル\fRã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã¿å±¥æ­´ã«è¿½åŠ ã—ã¾ã™ã€‚ファイルã®å†…容ã¯å˜ãªã‚‹ãƒ†ã‚­ã‚¹ãƒˆãƒ•ァイルã¨ã—ã¦è§£é‡ˆã•れã€ãれãžã‚Œã®è¡Œã®å†…容ãŒä¸€ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è¿½åŠ ã•れã¾ã™ã€‚ .RE .PP \fB\-s \fR\fB\fIコマンド\fR\fR, \fB\-\-set=\fR\fB\fIコマンド\fR\fR .RS 4 ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®æœ€å¾Œã®é …目を削除ã—ã€ä»£ã‚ã‚Šã«æŒ‡å®šã—ãŸ\fIコマンド\fRを追加ã—ã¾ã™ã€‚ .RE .PP \fB\-w \fR\fB\fIファイル\fR\fR, \fB\-\-write=\fR\fB\fIファイル\fR\fR .RS 4 指定ã—ãŸ\fIファイル\fRã«ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…å®¹ã‚’å…¨ã¦æ›¸ã出ã—ã¾ã™ã€‚æ—¢ã«ã‚るファイルã®å†…å®¹ã¯æ¶ˆåŽ»ã—ã¾ã™ã€‚履歴ã¯å˜ãªã‚‹ãƒ†ã‚­ã‚¹ãƒˆã¨ã—ã¦ä¸€è¡Œãšã¤æ›¸ã出ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fI個数\fR .RS 4 表示ã™ã‚‹å±¥æ­´ã®å€‹æ•°ã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š history コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ history コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .sp 行編集ã®å‹•作中ã¯å±¥æ­´ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .SH "JOBS 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIJobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ãŒæœ‰ã—ã¦ã„るジョブを表示ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBjobs [\-lnprs] [\fR\fB\fIジョブ\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Jobs コマンドã¯ã‚·ã‚§ãƒ«ãŒç¾åœ¨æœ‰ã—ã¦ã„るジョブã®åå‰ã‚„状態を表示ã—ã¾ã™ã€‚ .sp 標準ã§ã¯å„ジョブã«ã¤ã„ã¦ä»¥ä¸‹ã®æƒ…報を一行ãšã¤è¡¨ç¤ºã—ã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã‚¸ãƒ§ãƒ–ç•ªå· .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–を示ã™è¨˜å· (\fB+\fR ã¾ãŸã¯ \fB\-\fR) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 状態 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} コマンドå .RE .SS "オプション" .PP \fB\-l\fR, \fB\-\-verbose\fR .RS 4 ジョブを構æˆã—ã¦ã„るパイプラインã®è¦ç´ ã”ã¨ã«ãƒ—ロセス ID ã¨çŠ¶æ…‹ã¨ã‚³ãƒžãƒ³ãƒ‰åを表示ã—ã¾ã™ã€‚ .RE .PP \fB\-n\fR, \fB\-\-new\fR .RS 4 状態ãŒå¤‰åŒ–ã—ã¦ã‹ã‚‰ã¾ã ä¸€åº¦ã‚‚表示ã—ã¦ã„ãªã„ジョブã ã‘を表示ã—ã¾ã™ã€‚ .RE .PP \fB\-p\fR, \fB\-\-pgid\-only\fR .RS 4 ジョブã®ãƒ—ロセスグループ ID ã ã‘を表示ã—ã¾ã™ã€‚ .RE .PP \fB\-r\fR, \fB\-\-running\-only\fR .RS 4 実行中ã®ã‚¸ãƒ§ãƒ–ã ã‘を表示ã—ã¾ã™ã€‚ .RE .PP \fB\-s\fR, \fB\-\-stopped\-only\fR .RS 4 åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ã ã‘を表示ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIジョブ\fR .RS 4 表示ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID ã§ã™ã€‚一ã¤ã‚‚指定ã—ãªã„å ´åˆã¯å…¨ã¦ã®ã‚¸ãƒ§ãƒ–を表示ã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š jobs コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Jobs ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã§è¦å®šã•れã¦ã„るオプション㯠\fB\-l\fR 㨠\fB\-p\fR ã ã‘ã§ã™ã€‚従ã£ã¦ POSIX 準拠モードã§ã¯ã“れ以外ã®ã‚ªãƒ—ションã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯ã€\fB\-l\fR オプション指定時ã€ãƒ—ロセスã”ã¨ã§ã¯ãªãジョブã”ã¨ã«çŠ¶æ…‹ã‚’è¡¨ç¤ºã—ã¾ã™ã€‚ .sp Yash ã§ã¯ã€ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスグループ ID ã¯ã‚¸ãƒ§ãƒ–ã‚’æ§‹æˆã™ã‚‹ãƒ‘ã‚¤ãƒ—ãƒ©ã‚¤ãƒ³ã®æœ€åˆã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã«ä¸€è‡´ã—ã¾ã™ã€‚ .SH "KILL 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIKill 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Šã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBkill [\-\fR\fB\fIシグナル\fR\fR\fB|\-s \fR\fB\fIシグナル\fR\fR\fB|\-n \fR\fB\fIシグナル\fR\fR\fB] \fR\fB\fIプロセス\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBkill \-l [\-v] [\fR\fB\fIシグナル\fR\fR\fB\&...]\fR .RE .sp Kill コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ .SS "説明" .sp \fB\-l\fR オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€kill ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸ\fIプロセス\fRã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã™ã€‚é€ä¿¡ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã®ç¨®é¡žã¯\fIシグナル指定オプション\fRã§æŒ‡å®šã—ã¾ã™ã€‚シグナルã®ç¨®é¡žã‚’指定ã—ãªã„å ´åˆã¯ SIGTERM シグナルをé€ä¿¡ã—ã¾ã™ã€‚ .sp \fB\-l\fR オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€kill ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸ\fIシグナル\fRã«é–¢ã™ã‚‹æƒ…報を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚\fIシグナル\fRを指定ã—ãªã„å ´åˆã¯å…¨ã¦ã®ã‚·ã‚°ãƒŠãƒ«ã«é–¢ã™ã‚‹æƒ…報を表示ã—ã¾ã™ã€‚ .SS "オプション" .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBシグナル指定オプション\fR .RS 4 .PP \fB\-\fR\fB\fIシグナル\fR\fR, \fB\-s \fR\fB\fIシグナル\fR\fR, \fB\-n \fR\fB\fIシグナル\fR\fR .RS 4 é€ä¿¡ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã‚’指定ã—ã¾ã™ã€‚\fIシグナル\fRã«ã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã¨ã‚·ã‚°ãƒŠãƒ«åã®ã©ã¡ã‚‰ã‹ã‚’指定ã—ã¾ã™ã€‚シグナル番å·ã¨ã—㦠0 を指定ã™ã‚‹ã¨ã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹ã“ã¨ãŒã§ãã‚‹ã‹ã©ã†ã‹ã®åˆ¤å®šã ã‘を行ã„ã€å®Ÿéš›ã«ã¯ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã›ã‚“。シグナルをåå‰ã§æŒ‡å®šã™ã‚‹éš›ã¯ã€å¤§æ–‡å­—ã¨å°æ–‡å­—ã®åŒºåˆ¥ã¯ã‚りã¾ã›ã‚“。 .RE .sp シグナル指定オプションã¯ä¸€åº¦ã«ä¸€ã¤ã¾ã§ã—ã‹ä½¿ãˆã¾ã›ã‚“。 .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBä»–ã®ã‚ªãƒ—ション\fR .RS 4 .PP \fB\-l\fR .RS 4 シグナルã«é–¢ã™ã‚‹æƒ…報を表示ã—ã¾ã™ã€‚ .RE .PP \fB\-v\fR .RS 4 シグナルã«é–¢ã™ã‚‹æƒ…報をより詳ã—ã表示ã—ã¾ã™ã€‚\fB\-v\fR オプションを指定ã—ã¦ã„ãªã„å ´åˆã¯å˜ã«ã‚·ã‚°ãƒŠãƒ«åを出力ã—ã¾ã™ãŒã€æŒ‡å®šã—ã¦ã„ã‚‹å ´åˆã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ãƒ»ã‚·ã‚°ãƒŠãƒ«å・シグナルã®ç°¡å˜ãªèª¬æ˜Žã‚’出力ã—ã¾ã™ã€‚ .sp ã“ã®ã‚ªãƒ—ションを指定ã—ãŸã¨ãã¯åŒæ™‚ã« \fB\-l\fR も指定ã—ã¦ã‚ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚ .RE .RE .SS "オペランド" .PP \fIプロセス\fR .RS 4 シグナルをé€ä¿¡ã™ã‚‹ãƒ—ロセスをプロセス ID・プロセスグループ ID・ジョブ ID ã®ã„ãšã‚Œã‹ã§æŒ‡å®šã—ã¾ã™ã€‚プロセスグループ ID を指定ã™ã‚‹ã¨ãã¯ã€å…ˆé ­ã«è² å· (\fB\-\fR) を付ã‘ã¾ã™ã€‚プロセスã¨ã—㦠\fB0\fR を指定ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ãƒ—ロセスãŒå±žã™ã‚‹ãƒ—ロセスグループを指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚プロセスã¨ã—㦠\fB\-1\fR を指定ã™ã‚‹ã¨ã€å…¨ã¦ã®ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã™ã€‚ .RE .PP \fIシグナル\fR .RS 4 情報を表示ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã®åå‰ã¾ãŸã¯ç•ªå·ã§ã™ã€‚シグナルã«ã‚ˆã£ã¦ä¸­æ–­ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š kill コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚一ã¤ä»¥ä¸Šã®ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹ã“ã¨ãŒã§ããŸå ´åˆã€ä»–ã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Œãªã‹ã£ãŸãƒ—ロセスãŒã‚ã£ãŸã¨ã—ã¦ã‚‚終了ステータス㯠0 ã«ãªã‚Šã¾ã™ã€‚ .SS "補足" .sp Kill ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp è² æ•°ã«è¦‹ãˆã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®æ‰±ã„ã«ã¯æ³¨æ„ãŒå¿…è¦ã§ã™ã€‚例ãˆã° \fBkill \-1 \-2\fR ã§ã¯ \fB\-1\fR ãŒã‚·ã‚°ãƒŠãƒ«æŒ‡å®šã‚ªãƒ—ションã€\fB\-2\fR ãŒã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ãªã‚‹ã®ã§ã€ç•ªå· 1 ã®ã‚·ã‚°ãƒŠãƒ«ã‚’プロセスグループ 2 ã«é€ä¿¡ã—ã¾ã™ã€‚\fBkill \(em \-1 \-2\fR ã‚„ \fBkill \-TERM \-1 \-2\fR ã§ã¯ \fB\-1\fR 㨠\fB\-2\fR ã¯ã©ã¡ã‚‰ã‚‚オペランドã«ãªã‚Šã¾ã™ã€‚ .sp POSIX ã«ã¯ \fB\-v\fR ãŠã‚ˆã³ \fB\-n\fR オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“れらã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠\fB\-s\fR オプションã®å¼•æ•°ã¨ã—ã¦ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã‚’指定ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。POSIX ã¯\fIシグナル\fRã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦ã‚·ã‚°ãƒŠãƒ«ã®åå‰ã‚’指定ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 .sp POSIX ã¯ã€ã‚·ã‚°ãƒŠãƒ«å㯠\fBINT\fR ã‚„ \fBQUIT\fR ã®ã‚ˆã†ã«æœ€åˆã® SIG を除ã„ãŸå½¢ã§æŒ‡å®šã—ãªã‘れã°ãªã‚‰ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚éž POSIX 準拠モード㮠yash ã§ã¯ã€æ‹¡å¼µã¨ã—㦠SIG を付ã‘ãŸå½¢ã§ã‚‚指定ã§ãã¾ã™ã€‚ .SH "POPD 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIPopd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’削除ã—ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’戻ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBpopd [\fR\fB\fIインデックス\fR\fR\fB]\fR .RE .SS "説明" .sp Popd コマンドã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®è¦ç´ ã‚’削除ã—ã¾ã™ã€‚インデックス \fB+0\fR ã®è¦ç´ ã‚’削除ã—ãŸå ´åˆã¯ã€æ–°ãŸã«ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB+0\fR ã®è¦ç´ ã¨ãªã£ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .SS "オペランド" .PP \fIインデックス\fR .RS 4 削除ã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã™ã€‚çœç•¥ã™ã‚‹ã¨ \fB+0\fR を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp ディレクトリスタックã®è¦ç´ ã‚’æ­£ã—ã削除ã—作業ディレクトリを変更ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp ディレクトリスタックã«è¦ç´ ãŒä¸€ã¤ã—ã‹ãªã„å ´åˆã¯ãれ以上è¦ç´ ã‚’削除ã§ããªã„ã®ã§ã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ .sp POSIX ã«ã¯ popd コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "PRINTF 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIPrintf 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’æ•´å½¢ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBprintf \fR\fB\fI書å¼\fR\fR\fB [\fR\fB\fI値\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Printf コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸ\fI書å¼\fRã«å¾“ã£ã¦\fI値\fRã‚’æ•´å½¢ã—ã€æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚Echo コマンドã¨ã¯ç•°ãªã‚Šã€å‡ºåŠ›ã®æœ€å¾Œã«ã¯è‡ªå‹•çš„ã«æ”¹è¡Œã¯ä»˜ãã¾ã›ã‚“。 .sp 書å¼ã®æŒ‡å®šã®ä»•方㯠C 言語㮠printf 関数ã¨ã‚ˆãä¼¼ã¦ã„ã¾ã™ã€‚書å¼ã®ä¸­ã§ã¯ \fB%\fR ã§å§‹ã¾ã‚‹å¤‰æ›æŒ‡å®šã¨ \fB\e\fR ã§å§‹ã¾ã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを使用ã§ãã¾ã™ã€‚書å¼ã«å«ã¾ã‚Œã‚‹å¤‰æ›æŒ‡å®šã¨ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ä»¥å¤–ã®æ–‡å­—ã¯ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBå¤‰æ›æŒ‡å®š\fR .RS 4 .sp å¤‰æ›æŒ‡å®šã¯ãƒ‘ãƒ¼ã‚»ãƒ³ãƒˆè¨˜å· (\fB%\fR) ã‹ã‚‰å§‹ã¾ã‚Šã¾ã™ã€‚ .sp \fB%%\fR 以外ã®å¤‰æ›æŒ‡å®šã¯ã€å¯¾å¿œã™ã‚‹å€¤ã‚’ã¨ã‚Šã¾ã™ã€‚å¤‰æ›æŒ‡å®šã¯ã€å€¤ã‚’特定ã®å½¢å¼ã«æ•´å½¢ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚å¤‰æ›æŒ‡å®šã¨å€¤ã¯ä¸Žãˆã‚‰ã‚ŒãŸé †ç•ªã«å¯¾å¿œä»˜ã‘られã¾ã™ã€‚値ãŒä½™ã£ãŸå ´åˆã¯ã€å…¨ã¦ã®å€¤ã‚’処ç†ã—終ã‚ã‚‹ã¾ã§æ›¸å¼ã®æ•´å½¢ãƒ»å‡ºåŠ›ã‚’ç¹°ã‚Šè¿”ã—ã¾ã™ã€‚値ãŒè¶³ã‚Šãªã„å ´åˆã¯ã€ç©ºæ–‡å­—列 (文字列ã«é–¢ã™ã‚‹å¤‰æ›æŒ‡å®šã®å ´åˆ) ã¾ãŸã¯ 0 (数値ã«é–¢ã™ã‚‹å¤‰æ›æŒ‡å®šã®å ´åˆ) を仮定ã—ã¾ã™ã€‚値ãŒä¸€ã¤ã‚‚与ãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€æ›¸å¼ã¯ä¸€åº¦ã ã‘出力ã•れã¾ã™ã€‚ .sp 利用å¯èƒ½ãªå¤‰æ›æŒ‡å®šã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB%d\fR, \fB%i\fR .RS 4 æ•´æ•°ã®å€¤ã‚’ (符å·ä»˜ã) å進整数ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%u\fR .RS 4 æ•´æ•°ã®å€¤ã‚’ (符å·ãªã—) å進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%o\fR .RS 4 æ•´æ•°ã®å€¤ã‚’ (符å·ãªã—) 八進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%x\fR .RS 4 æ•´æ•°ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ãªã—) å六進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%X\fR .RS 4 æ•´æ•°ã®å€¤ã‚’大文字㮠(符å·ãªã—) å六進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%f\fR .RS 4 実数ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ä»˜ã) å°æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%F\fR .RS 4 実数ã®å€¤ã‚’大文字㮠(符å·ä»˜ã) å°æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%e\fR .RS 4 実数ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ä»˜ã) æŒ‡æ•°è¡¨è¨˜å°æ•°ã§å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%E\fR .RS 4 実数ã®å€¤ã‚’大文字㮠(符å·ä»˜ã) æŒ‡æ•°è¡¨è¨˜å°æ•°ã§å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%g\fR .RS 4 値ã®å¤§ãã•や精度ã«å¿œã˜ã¦ \fB%f\fR 㨠\fB%e\fR ã®ã©ã¡ã‚‰ã‹ã®å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%G\fR .RS 4 値ã®å¤§ãã•や精度ã«å¿œã˜ã¦ \fB%F\fR 㨠\fB%E\fR ã®ã©ã¡ã‚‰ã‹ã®å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%c\fR .RS 4 文字列ã®å€¤ã®æœ€åˆã®æ–‡å­—を出力ã—ã¾ã™ã€‚ .RE .PP \fB%s\fR .RS 4 文字列ã®å€¤ã‚’ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB%b\fR .RS 4 文字列ã®å€¤ã‚’ã€ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ãªãŒã‚‰å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã“ã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンス㯠echo コマンドã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¨åŒã˜ã§ã™ã€‚ .RE .PP \fB%%\fR .RS 4 ãƒ‘ãƒ¼ã‚»ãƒ³ãƒˆè¨˜å· (\fB%\fR) を出力ã—ã¾ã™ã€‚ .RE .sp \fB%g\fR 㨠\fB%G\fR ã§ã¯ã€å°æ•°ã®æŒ‡æ•°éƒ¨ãŒ \-5 ä»¥ä¸Šç²¾åº¦ä»¥ä¸‹ã®æ™‚ã« \fB%f\fR ã¾ãŸã¯ \fB%F\fR ã‚’ã€ãã‚Œä»¥å¤–ã®æ™‚ã« \fB%e\fR ã¾ãŸã¯ \fB%E\fR を使用ã—ã¾ã™ã€‚ .sp \fB%%\fR 以外ã®å¤‰æ›æŒ‡å®šã§ã¯ã€æœ€åˆã® \fB%\fR ã®ç›´å¾Œã«å¤‰æ›æŒ‡å®šãƒ•ラグ・フィールド幅・精度をã“ã®é †ã§æŒ‡å®šã§ãã¾ã™ã€‚ã“れらを指定ã™ã‚‹ã“ã¨ã§å‡ºåŠ›ã®å½¢å¼ã‚’ç´°ã‹ã調整ã§ãã¾ã™ã€‚ .sp 指定ã§ãã‚‹å¤‰æ›æŒ‡å®šãƒ•ラグã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚フラグを複数指定ã—ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 .PP マイナス (\fB\-\fR) .RS 4 ã“ã®ãƒ•ラグを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸãƒ•ィールド幅ã®ä¸­ã§å€¤ã‚’å·¦ã«å¯„ã›ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã®ãƒ•ラグを指定ã—ãªã„å ´åˆã€å€¤ã¯å³ã«å¯„りã¾ã™ã€‚ .RE .PP プラス (\fB+\fR) .RS 4 数値ã®ç¬¦å· (æ­£å·ã¾ãŸã¯è² å·) ã‚’å¿…ãšå‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP 空白文字 (\fB \fR) .RS 4 出力ã™ã‚‹æ•°å€¤ã«ç¬¦å· (æ­£å·ã¾ãŸã¯è² å·) ãŒä»˜ã‹ãªã„å ´åˆã¯ã€ç¬¦å·ã®ä»£ã‚りã«ç©ºç™½æ–‡å­—を出力ã—ã¾ã™ã€‚ .RE .PP \fB#\fR .RS 4 値を別形å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ \fB%o\fR ã®å ´åˆã€å‡ºåŠ›ã™ã‚‹å…«é€²æ•°ã®å…ˆé ­ã«å¿…ãšä¸€æ¡ä»¥ä¸Šã® 0 ãŒä»˜ãよã†ã«ã€å¿…è¦ã«å¿œã˜ã¦ 0 を付加ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ \fB%x\fR (ã¾ãŸã¯ \fB%X\fR) ã®å ´åˆã€å€¤ãŒ 0 ã§ãªã‘ã‚Œã°æ•°å€¤ã®å…ˆé ­ã« \fB0x\fR (ã¾ãŸã¯ \fB0X\fR) を付加ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ \fB%e\fR, \fB%E\fR, \fB%f\fR, \fB%F\fR, \fB%g\fR, \fB%G\fR ã®å ´åˆã€å°æ•°ç‚¹ã®å¾Œã«æ•°å­—ãŒãªã„å ´åˆã§ã‚‚å°æ•°ç‚¹ã‚’çœç•¥ã—ãªã„よã†ã«ã—ã¾ã™ã€‚ã¾ãŸå¤‰æ›æŒ‡å®šãŒ \fB%g\fR, \fB%G\fR ã®å ´åˆã€å°æ•°ç‚¹ã®å¾Œã« 0 ä»¥å¤–ã®æ•°å­—ãŒãªã„å ´åˆã§ã‚‚ 0 ã‚’çœç•¥ã—ãªã„よã†ã«ã—ã¾ã™ã€‚ .RE .PP ゼロ (\fB0\fR) .RS 4 å¤‰æ›æŒ‡å®šãŒ \fB%d\fR, \fB%i\fR, \fB%u\fR, \fB%o\fR, \fB%x\fR, \fB%X\fR, \fB%e\fR, \fB%E\fR, \fB%f\fR, \fB%F\fR, \fB%g\fR, \fB%G\fR ã®å ´åˆã€å‡ºåŠ›ãŒæŒ‡å®šã—ãŸãƒ•ィールド幅ã„ã£ã±ã„ã«ãªã‚‹ã¾ã§æ•°å€¤ã®å…ˆé ­ã« 0 を付加ã—ã¾ã™ã€‚ .sp ãƒžã‚¤ãƒŠã‚¹ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã“ã®ãƒ•ラグã¯ç„¡è¦–ã•れã¾ã™ã€‚ .sp å¤‰æ›æŒ‡å®šãŒ \fB%d\fR, \fB%i\fR, \fB%u\fR, \fB%o\fR, \fB%x\fR, \fB%X\fR ã§ã€ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã“ã®ãƒ•ラグã¯ç„¡è¦–ã•れã¾ã™ã€‚ .RE .sp フィールド幅ã¯ã€å…ˆé ­ã« 0 ã®ä»˜ã‹ãªã„å進整数ã®å½¢ã§æŒ‡å®šã—ã¾ã™ã€‚ .sp フィールド幅ã¯å‡ºåŠ›ã®æœ€ä½Žãƒã‚¤ãƒˆæ•°ã‚’指示ã—ã¾ã™ã€‚出力ã®ãƒã‚¤ãƒˆæ•°ãŒãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰å¹…ã«æº€ãŸãªã„ã¨ãã¯ã€ãƒã‚¤ãƒˆæ•°ãŒãƒ•ィールド幅ã«ä¸€è‡´ã™ã‚‹ã¾ã§ç©ºç™½æ–‡å­—を付加ã—ã¾ã™ã€‚ .sp 精度ã¯ã€ãƒ”リオド (\fB\&.\fR) ã®ç›´å¾Œã«å進整数を置ã„ãŸã‚‚ã®ã®å½¢ã§æŒ‡å®šã—ã¾ã™ã€‚ピリオドã®å¾Œã«æ•´æ•°ãŒãªã‘れã°ã€0 ãŒæŒ‡å®šã—ã¦ã‚ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .sp å¤‰æ›æŒ‡å®šãŒ \fB%d\fR, \fB%i\fR, \fB%u\fR, \fB%o\fR, \fB%x\fR, \fB%X\fR ã®å ´åˆã€ç²¾åº¦ã¯å‡ºåŠ›ã®æœ€ä½Žæ¡æ•°ã‚’指示ã—ã¾ã™ã€‚æ•°å€¤ãŒæœ€ä½Žæ¡æ•°ã«æº€ãŸãªã„å ´åˆã¯æœ€ä½Žæ¡æ•°ã«é”ã™ã‚‹ã¾ã§å…ˆé ­ã« 0 を付加ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 1 ã¨ã¿ãªã—ã¾ã™ã€‚ .sp å¤‰æ›æŒ‡å®šãŒ \fB%e\fR, \fB%E\fR, \fB%f\fR, \fB%F\fR ã®å ´åˆã€ç²¾åº¦ã¯å°æ•°ç‚¹ä»¥é™ã®æ¡æ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 6 ã¨ã¿ãªã—ã¾ã™ã€‚ .sp å¤‰æ›æŒ‡å®šãŒ \fB%g\fR, \fB%G\fR ã®å ´åˆã€ç²¾åº¦ã¯æ•°å€¤ã®æœ€å¤§æœ‰åŠ¹æ¡æ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 6 ã¨ã¿ãªã—ã¾ã™ã€‚ .sp å¤‰æ›æŒ‡å®šãŒ \fB%s\fR, \fB%b\fR ã®å ´åˆã€ç²¾åº¦ã¯å‡ºåŠ›ã™ã‚‹æ–‡å­—åˆ—ã®æœ€å¤§ãƒã‚¤ãƒˆæ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ç„¡é™å¤§ã¨ã¿ãªã—ã¾ã™ã€‚ .sp å¤‰æ›æŒ‡å®š \fB%f\fR ã«ã‚¼ãƒ­ãƒ•ラグを指定ã—ã€ãƒ•ィールド幅㫠8ã€ç²¾åº¦ã« 3 を指定ã™ã‚‹å ´åˆã€æœ€çµ‚çš„ãªå¤‰æ›æŒ‡å®šã¯ \fB%08\&.3f\fR ã¨ãªã‚Šã¾ã™ã€‚ã“ã®å¤‰æ›æŒ‡å®šã«å¯¾ã—ã¦å€¤ 12\&.34 を与ãˆã‚‹ã¨ã€å‡ºåŠ›ã¯ \fB0012\&.340\fR ã¨ãªã‚Šã¾ã™ã€‚ .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBエスケープシーケンス\fR .RS 4 .sp 書å¼ã®ä¸­ã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\ea\fR .RS 4 ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7) .RE .PP \fB\eb\fR .RS 4 ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 8) .RE .PP \fB\ef\fR .RS 4 フォームフィード (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 12) .RE .PP \fB\en\fR .RS 4 改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10) .RE .PP \fB\er\fR .RS 4 復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13) .RE .PP \fB\et\fR .RS 4 水平タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 9) .RE .PP \fB\ev\fR .RS 4 垂直タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 11) .RE .PP \fB\e\e\fR .RS 4 ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ .RE .PP \fB\e"\fR .RS 4 二é‡å¼•用符 .RE .PP \fB\e\*(Aq\fR .RS 4 一é‡å¼•用符 (ã‚¢ãƒã‚¹ãƒˆãƒ­ãƒ•ィー) .RE .PP \fB\e\fR\fB\fIxxx\fR\fR .RS 4 八進数 \fIxxx\fR (最大三æ¡) ã§è¡¨ã‚ã•れるコード番å·ã®æ–‡å­— .RE .RE .SS "オペランド" .PP \fI書å¼\fR .RS 4 出力ã™ã‚‹æ–‡å­—åˆ—ã®æ›¸å¼ã§ã™ã€‚ .RE .PP \fI値\fR .RS 4 å¤‰æ›æŒ‡å®šãŒå‡ºåŠ›ã™ã‚‹å€¤ (数値ã¾ãŸã¯æ–‡å­—列) ã§ã™ã€‚ .sp 数値を値ã¨ã—ã¦æŒ‡å®šã™ã‚‹éš›ã€ä¸€é‡ã¾ãŸã¯äºŒé‡å¼•用符ã®å¾Œã«ä½•ã‹æ–‡å­—ã‚’ç½®ã„ãŸã‚‚ã®ã‚’指定ã™ã‚‹ã“ã¨ã§ã€ãã®æ–‡å­—ã®ã‚³ãƒ¼ãƒ‰ç•ªå·ã‚’数値ã¨ã—ã¦æŒ‡å®šã§ãã¾ã™ã€‚例ãˆã° \fB3\fR ã¨ã„ã†æ–‡å­—ã®ã‚³ãƒ¼ãƒ‰ç•ªå·ãŒ 51 ãªã‚‰ã°ã€ \fBprintf \*(Aq%d\*(Aq \*(Aq"3\*(Aq\fR 㯠\fB51\fR を出力ã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š printf コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã§ã¯ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã®æ‰±ã„ã«ã¤ã„ã¦å޳坆ã«å®šç¾©ã—ã¦ã„ã¾ã›ã‚“。\fB%s\fR å¤‰æ›æŒ‡å®šã§ç²¾åº¦ã‚’指定ã—ãŸå ´åˆã‚„ã€\fB%c\fR å¤‰æ›æŒ‡å®šã‚’使用ã™ã‚‹å ´åˆã€å€¤ã«ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ãŒå«ã¾ã‚Œã¦ã„ã‚‹ã¨é©åˆ‡ãªå‡ºåŠ›ãŒå¾—られãªã„ã‹ã‚‚ã—れã¾ã›ã‚“。Yash ã§ã¯ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã¯å…¨ã¦ãƒ¯ã‚¤ãƒ‰æ–‡å­—ã«å¤‰æ›ã—ã¦ã‹ã‚‰å‡¦ç†ã™ã‚‹ã®ã§ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã®ä¸€éƒ¨ã®ãƒã‚¤ãƒˆã ã‘ãŒå‡ºåŠ›ã•れるよã†ãªã“ã¨ã¯ã‚りã¾ã›ã‚“。 .SH "PUSHD 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIPushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’追加ã—ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBpushd [\-L|\-P] [\fR\fB\fIディレクトリ\fR\fR\fB]\fR .RE .SS "説明" .sp Pushd コマンド㯠cd コマンドã¨åŒæ§˜ã«ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚作業ディレクトリã®å¤‰æ›´ã«æˆåŠŸã™ã‚‹ã¨ã€æ–°ã—ã„作業ディレクトリをディレクトリスタックã«è¿½åŠ ã—ã¾ã™ã€‚ .SS "オプション" .sp Cd コマンドã§ä½¿ãˆã‚‹ã‚ªãƒ—ションã«åŠ ãˆã¦ä»¥ä¸‹ã®ã‚ªãƒ—ション㌠pushd コマンドã§ä½¿ãˆã¾ã™ã€‚ .PP \fB\-\-remove\-duplicates\fR .RS 4 æ–°ã—ã„ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæ—¢ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«å…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€å…ƒã€…å…¥ã£ã¦ã„ãŸè¦ç´ ã‚’削除ã—ã¦é‡è¤‡ã‚’ãªãã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIディレクトリ\fR .RS 4 æ–°ã—ã„作業ディレクトリã®ãƒ‘スåã§ã™ã€‚絶対パスã¾ãŸã¯å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘ã‚¹ã§æŒ‡å®šã—ã¾ã™ã€‚ .sp ã“ã®å€¤ãŒãƒã‚¤ãƒ•ン一㤠(\fB\-\fR) ã®å ´åˆã€\fBOLDPWD\fR 変数ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .sp ã“ã®å€¤ãŒç¬¦å·ä»˜ãæ•´æ•°ã®å ´åˆã€ãã®æ•´æ•°ã‚’ディレクトリスタックã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¨ã¿ãªã—ã¦ã€ãã®è¦ç´ ãŒè¡¨ã™ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (指定ã•れãŸè¦ç´ ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰å‰Šé™¤ã•れã¾ã™)。 .sp ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ \fB+1\fR ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (\fB\-\-default\-directory\fR オプションを指定ã—ãŸå ´åˆã‚’除ã)。 .RE .SS "終了ステータス" .sp 作業ディレクトリを正ã—ã変更ã—ディレクトリスタックã«è¿½åŠ ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ pushd コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "PWD 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIPwd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ã®ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表示ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBpwd [\-L|\-P]\fR .RE .SS "説明" .sp Pwd コマンドã¯ã‚·ã‚§ãƒ«ã®ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’çµ¶å¯¾ãƒ‘ã‚¹ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-L\fR, \fB\-\-logical\fR .RS 4 \fBPWD\fR 変数ã®å€¤ãŒç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スã§ã€ä¸­ã« \fB\&.\fR ã‚„ \fB\&.\&.\fR ã‚’å«ã‚“ã§ã„ãªã‘れã°ã€ãれを出力ã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ \fB\-P\fR を指定ã—ãŸå ´åˆã¨åŒæ§˜ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP \fB\-P\fR, \fB\-\-physical\fR .RS 4 ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スをã€ä¸­ã«ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’å«ã¾ãªã„ã‹ãŸã¡ã§å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .sp \fB\-L\fR (\fB\-\-logical\fR) オプション㨠\fB\-P\fR (\fB\-\-physical\fR) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€\fB\-L\fR を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š pwd コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Pwd ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .SH "READ 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIRead 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯æ¨™æº–入力ã‹ã‚‰è¡Œã‚’読ã¿è¾¼ã¿å¤‰æ•°ã«ä»£å…¥ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBread [\-Ar] \fR\fB\fI変数å\fR\fR\fB\&...\fR .RE .SS "説明" .sp Read ã‚³ãƒžãƒ³ãƒ‰ã¯æ¨™æº–入力ã‹ã‚‰ä¸€è¡Œã®æ–‡å­—列を読ã¿è¾¼ã¿ã€ãれを変数ã«ä»£å…¥ã—ã¾ã™ã€‚シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ã€è¡Œç·¨é›†ã‚’利用ã™ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã‚‰ã°ã€èª­ã¿è¾¼ã¿ã«è¡Œç·¨é›†ã‚’使用ã—ã¾ã™ã€‚ .sp \fB\-r\fR (\fB\-\-raw\-mode\fR) オプションを付ã‘ã‚‹ã¨ã€è¡Œå†…ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒæ§˜ã«æ‰±ã‚れã¾ã™ã€‚ .sp \fB\-r\fR (\fB\-\-raw\-mode\fR) オプションを付ã‘ãªã„å ´åˆã€èª­ã¿è¾¼ã‚“ã æ–‡å­—列ã®ä¸­ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\fB\e\fR) ã¯å¼•用符ã¨ã—ã¦åƒãã¾ã™ã€‚ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒè¡Œæœ«ã«ã‚ã‚‹ã¨ãã¯è¡Œã®é€£çµã‚’行ã„ã¾ã™ã€‚対話モードã®ã‚·ã‚§ãƒ«ãŒ 2 行目以é™ã‚’読ã¿è¾¼ã‚€ã¨ãã€æ¨™æº–入力ãŒç«¯æœ«ãªã‚‰ã° \fBPS2\fR 変数ã®å€¤ãŒãƒ—ロンプトã¨ã—ã¦å‡ºåŠ›ã•れã¾ã™ã€‚ .sp 読ã¿è¾¼ã‚“ã æ–‡å­—列ã¯ã€å˜èªžåˆ†å‰²ã«ã‚ˆã£ã¦åˆ†å‰²ã—ã¾ã™ã€‚分割後ã®å„文字列ãŒã€ãれãžã‚Œã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã•れãŸå¤‰æ•°ã®å€¤ã«é †ã«è¨­å®šã•れã¾ã™ã€‚指定ã•れãŸå¤‰æ•°ã®æ•°ã‚ˆã‚Šåˆ†å‰²çµæžœã®ã»ã†ãŒå¤šã„å ´åˆã¯ã€æœ€å¾Œã®å¤‰æ•°ã«æ®‹ã‚Šã®åˆ†å‰²çµæžœã®å…¨ã¦ãŒå…¥ã‚Šã¾ã™ã€‚åˆ†å‰²çµæžœã®æ•°ã‚ˆã‚ŠæŒ‡å®šã•れãŸå¤‰æ•°ã®ã»ã†ãŒå¤šã„å ´åˆã¯ã€ä½™ã£ãŸå¤‰æ•°ã«ã¯ç©ºæ–‡å­—列ãŒå…¥ã‚Šã¾ã™ã€‚ .SS "オプション" .PP \fB\-A\fR, \fB\-\-array\fR .RS 4 æœ€å¾Œã«æŒ‡å®šã—ãŸå¤‰æ•°ã‚’é…列ã«ã—ã¾ã™ã€‚分割後ã®å„文字列ãŒé…列ã®è¦ç´ ã¨ã—ã¦è¨­å®šã•れã¾ã™ã€‚ .RE .PP \fB\-r\fR, \fB\-\-raw\-mode\fR .RS 4 読ã¿è¾¼ã‚“ã æ–‡å­—列ã®ä¸­ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’引用符ã¨ã—ã¦æ‰±ã‚ãªã„よã†ã«ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fI変数å\fR .RS 4 読ã¿è¾¼ã‚“ã æ–‡å­—列を格ç´ã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š read コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Read ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ \fB\-A\fR (\fB\-\-array\fR) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "READONLY 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIReadonly 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯èª­ã¿å–り専用ã®å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’表示・設定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBreadonly [\-pxX] [\fR\fB\fI変数\fR\fR\fB[=\fR\fB\fI値\fR\fR\fB]\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBreadonly \-f[p] [\fR\fB\fI変数\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Readonly コマンド㯠typeset コマンド㫠\fB\-gr\fR オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠typeset コマンドã¨åŒæ§˜ã§ã™ã€‚ .SS "補足" .sp readonly コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã«ã¯ readonly コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã™ãŒã€ã‚ªãƒ—ション㯠\fB\-p\fR ã—ã‹è¦å®šãŒã‚りã¾ã›ã‚“。ãã®ä»–ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠\fB\-p\fR オプションをオペランドã¨ã¨ã‚‚ã«ä½¿ã†ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 .SH "RETURN 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIReturn 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®é–¢æ•°ã¾ãŸã¯ã‚¹ã‚¯ãƒªãƒ—トã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBreturn [\-n] [\fR\fB\fI終了ステータス\fR\fR\fB]\fR .RE .SS "説明" .sp \fB\-n\fR (\fB\-\-no\-return\fR) オプションを付ã‘ãšã« return コマンドを実行ã™ã‚‹ã¨ã€ä»¥ä¸‹ã®ã†ã¡å½“ã¦ã¯ã¾ã‚‹å‹•作を行ã„ã¾ã™: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 関数ã®å®Ÿè¡Œä¸­ã®å ´åˆã¯ã€ãã®é–¢æ•°ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ドットコマンドã§ãƒ•ァイルを開ã„ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã„る途中ã®å ´åˆã¯ã€ãã®ãƒ•ァイルã®èª­ã¿è¾¼ã¿ãƒ»å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Eval コマンドã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã„る途中ã®å ´åˆã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ã“れ以外ã®å ´åˆã¯ã€(対話モードã®ã¨ãを除ã„ã¦) シェルã¯çµ‚了ã—ã¾ã™ã€‚ .RE .sp \fB\-n\fR (\fB\-\-no\-return\fR) オプションを付ã‘㦠return コマンドを実行ã™ã‚‹ã¨ã€return コマンドã¯ãŸã å˜ã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã•れã¦ã„る終了ステータスを返ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-n\fR, \fB\-\-no\-return\fR .RS 4 コマンドã®å®Ÿè¡Œã‚’中断ã—ã¾ã›ã‚“。 .RE .SS "オペランド" .PP \fI終了ステータス\fR .RS 4 Return コマンドã®çµ‚了ステータスを指定ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ .sp ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€return コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを用ã„ã¾ã™ (ãŸã ã—トラップを実行中ã®å ´åˆã¯ãƒˆãƒ©ãƒƒãƒ—ã«å…¥ã‚‹ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス)。 .RE .SS "終了ステータス" .sp Return コマンドã®çµ‚了ステータスã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸå€¤ã§ã™ã€‚Return コマンドã®çµ‚了ステータス㯠return コマンドãŒçµ‚了ã™ã‚‹é–¢æ•°ãƒ»ãƒ‰ãƒƒãƒˆã‚³ãƒžãƒ³ãƒ‰ãƒ»eval コマンド・シェル自身ã®çµ‚了ステータスã«ã‚‚ãªã‚Šã¾ã™ã€‚ .SS "補足" .sp Return コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã§ã¯ã€\fI終了ステータス\fRã®å€¤ã¯ 0 以上 256 未満ã§ãªã‘れã°ãªã‚‰ãªã„ã¨ã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯æ‹¡å¼µã¨ã—㦠256 以上ã®å€¤ã‚‚å—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ .sp POSIX ã§ã¯é–¢æ•°ã‚ã‚‹ã„ã¯ãƒ‰ãƒƒãƒˆã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œä¸­ä»¥å¤–ã«ãŠã‘ã‚‹ return コマンドã®å‹•作を定ã‚ã¦ã„ã¾ã›ã‚“。 .sp POSIX ã«ã¯ \fB\-n\fR (\fB\-\-no\-return\fR) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 .SH "SET 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fISet 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ションã®è¨­å®šã¨ä½ç½®ãƒ‘ラメータã®å¤‰æ›´ã‚’行ã„ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset [\fR\fB\fIオプション\fR\fR\fB\&...] [\fR\fB\fIオペランド\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset \-o\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBset +o\fR .RE .sp Set コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ .SS "説明" .sp コマンドライン引数を一切与ãˆãšã« set コマンドを実行ã™ã‚‹ã¨ã€ç¾åœ¨ã‚·ã‚§ãƒ«ã«è¨­å®šã•れã¦ã„ã‚‹å…¨ã¦ã®å¤‰æ•°ã®ä¸€è¦§ã‚’アルファベット順㧠(コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ .sp \fB\-o\fR を唯一ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸ŽãˆãŸå ´åˆã¯ç¾åœ¨ã®ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ション設定を一覧ã«ã—ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚\fB+o\fR を唯一ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸ŽãˆãŸå ´åˆã‚‚åŒæ§˜ã§ã™ãŒã€ã“ã®å ´åˆã¯ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ .sp ã“れ以外ã®å ´åˆã¯ã€set コマンドã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ションã®è¨­å®šã¨ä½ç½®ãƒ‘ラメータã®å¤‰æ›´ã®ã©ã¡ã‚‰ã‹ã¾ãŸã¯ä¸¡æ–¹ã®å‹•作を行ã„ã¾ã™ã€‚ .SS "オプション" .sp オプションãŒä¸€ã¤ä»¥ä¸Šä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã€set コマンドã¯ãã‚Œã‚‰ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’åˆ‡ã‚Šæ›¿ãˆã¾ã™ã€‚通常ã®å½¢å¼ã§ã‚ªãƒ—ションを与ãˆã‚‹ã¨ã€ãã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã¯æœ‰åйã«ãªã‚Šã¾ã™ã€‚オプションã®å…ˆé ­ã®ãƒã‚¤ãƒ•ン (\fB\-\fR) ã®ä»£ã‚りã«ãƒ—ラス (\fB+\fR) を付ã‘ã¦æŒ‡å®šã™ã‚‹ã¨ã€ãã®ã‚ªãƒ—ションã¯ç„¡åйã«ãªã‚Šã¾ã™ã€‚例ãˆã° \fB\-m\fR ã‚„ \fB\-o monitor\fR ã‚„ \fB\-\-monitor\fR ã¯ã‚·ã‚§ãƒ«ã®ã‚¸ãƒ§ãƒ–制御を有効ã«ã—ã€é€†ã« \fB+m\fR ã‚„ \fB+o monitor\fR ã‚„ \fB++monitor\fR ã¯ã‚¸ãƒ§ãƒ–制御を無効ã«ã—ã¾ã™ã€‚ .sp é•·ã„オプションã®åå‰ã«å«ã¾ã‚Œã‚‹è‹±æ•°å­—ä»¥å¤–ã®æ–‡å­—ã¯ç„¡è¦–ã•れã€å¤§æ–‡å­—ã¨å°æ–‡å­—ã®åŒºåˆ¥ã¯ã‚りã¾ã›ã‚“。例ãˆã° \fB\-\-Le\-Comp\-Debug\fR 㯠\fB\-\-lecompdebug\fR ã«åŒã˜ã§ã™ã€‚ã¾ãŸé•·ã„オプションã®åå‰ã®å…ˆé ­ã« \fBno\fR を付ã‘ã‚‹ã“ã¨ã§ã€ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’é€†è»¢ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚例ãˆã° \fB\-\-noallexport\fR 㯠\fB++allexport\fR ã«åŒã˜ãã€ã¾ãŸ \fB++nonotify\fR 㯠\fB\-\-notify\fR ã«åŒã˜ã§ã™ã€‚ .sp オプションã¯ä»¥ä¸‹ã«æŒ™ã’ã‚‹å½¢å¼ã§æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} é•·ã„オプション (例: \fB\-\-allexport\fR) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 引数ã¨ã—ã¦ã‚ªãƒ—ションåを指定ã—㟠\fB\-o\fR オプション (例: \fB\-o allexport\fR) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 一文字ã®ã‚ªãƒ—ション (例: \fB\-a\fR) .RE .sp ãŸã ã—å…¨ã¦ã®ã‚ªãƒ—ションãŒä¸€æ–‡å­—ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã§ãã‚‹ã‚ã‘ã§ã¯ã‚りã¾ã›ã‚“。 .sp 利用å¯èƒ½ãªã‚ªãƒ—ションã¯ä»¥ä¸‹ã®ã¨ãŠã‚Šã§ã™: .PP all\-export (\fB\-a\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å¤‰æ•°ã«ä»£å…¥ã‚’ã™ã‚‹ã¨ãã®å¤‰æ•°ã¯è‡ªå‹•çš„ã«ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚ .RE .PP brace\-expand .RS 4 ã“ã®ã‚ªãƒ—ションã¯ãƒ–レース展開を有効ã«ã—ã¾ã™ã€‚ .RE .PP case\-glob .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã«ãŠã‘るパターンマッãƒãƒ³ã‚°ã¯å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¦è¡Œã„ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ .RE .PP clobber (\fB+C\fR) .RS 4 ã“ã®ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã¨ã€ \fB>\fR 演算å­ã«ã‚ˆã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§æ—¢å­˜ã®ãƒ•ァイルを上書ãã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ .RE .PP cur\-async, cur\-bg, cur\-stop .RS 4 ã“れらã®ã‚ªãƒ—ションã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã®é¸æŠžã®ä»•æ–¹ã«å½±éŸ¿ã—ã¾ã™ã€‚(ジョブ ID å‚ç…§)。ã“れらã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ .RE .PP dot\-glob .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã«ãŠã„ã¦ãƒ•ァイルåã®å…ˆé ­ã®ãƒ”ãƒªã‚ªãƒ‰ã‚’ç‰¹åˆ¥ã«æ‰±ã„ã¾ã›ã‚“。 .RE .PP emacs .RS 4 ã“ã®ã‚ªãƒ—ション㯠emacs 風行編集を有効ã«ã—ã¾ã™ã€‚ .RE .PP err\-exit (\fB\-e\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å®Ÿè¡Œã—ãŸãƒ‘イプラインã®çµ‚了ステータス㌠0 ã§ãªã‘れã°ã€ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ãŸã ã—ã€ä»¥ä¸‹ã®å ´åˆã‚’除ãã¾ã™ã€‚ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} ãã®ã‚³ãƒžãƒ³ãƒ‰ãŒ if æ–‡ã®åˆ†å²ã‚„ while/until æ–‡ã®ãƒ«ãƒ¼ãƒ—æ¡ä»¶ã®åˆ¤å®šã«ä½¿ã‚ã‚Œã‚‹å ´åˆ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} パイプラインã®å…ˆé ­ã« \fB!\fR ãŒä»˜ã„ã¦ã„ã‚‹å ´åˆ .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} パイプラインãŒã‚µãƒ–シェルグルーピング以外ã®å˜ç‹¬ã®è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã‹ã‚‰æ§‹æˆã•ã‚Œã‚‹å ´åˆ .RE .RE .PP exec (\fB+n\fR) .RS 4 ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®è§£é‡ˆã ã‘を行ã„ã€å®Ÿéš›ã«ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã‚¹ã‚¯ãƒªãƒ—ãƒˆã®æ–‡æ³•ãƒã‚§ãƒƒã‚¯ã‚’ã™ã‚‹ã®ã«ä¾¿åˆ©ã§ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚対話モードã§ã¯ã€ã“ã®ã‚ªãƒ—ションã«é–¢ã‚らãšã‚³ãƒžãƒ³ãƒ‰ã¯å¸¸ã«å®Ÿè¡Œã•れã¾ã™ã€‚ .RE .PP extended\-glob .RS 4 ã“ã®ã‚ªãƒ—ションã¯ãƒ‘スå展開ã«ãŠã‘る拡張機能を有効ã«ã—ã¾ã™ã€‚ .RE .PP glob (\fB+f\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãã¯ã‚·ã‚§ãƒ«ã¯ãƒ‘スå展開を行ã„ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ .RE .PP hash\-on\-def (\fB\-h\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ã関数を定義ã™ã‚‹ã¨ã€ç›´ã¡ã«ãã®é–¢æ•°å†…ã§ä½¿ã‚れるå„コマンド㮠PATH 検索を行ã„コマンドã®ãƒ‘スåを記憶ã—ã¾ã™ã€‚ .RE .PP hist\-space .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ç©ºç™½ã§å§‹ã¾ã‚‹è¡Œã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«è‡ªå‹•çš„ã«è¿½åŠ ã—ã¾ã›ã‚“。 .RE .PP ignore\-eof .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ã« EOF (入力ã®çµ‚ã‚り) ãŒå…¥åŠ›ã•れã¦ã‚‚シェルã¯ãれを無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã®èª­ã¿è¾¼ã¿ã‚’ç¶šã‘ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€èª¤ã£ã¦ Ctrl\-D を押ã—ã¦ã—ã¾ã£ã¦ã‚‚シェルã¯çµ‚了ã—ãªããªã‚Šã¾ã™ã€‚ .RE .PP le\-always\-rp, le\-comp\-debug, le\-conv\-meta, le\-no\-conv\-meta, le\-prompt\-sp, le\-visible\-bell .RS 4 ã“れらã®ã‚ªãƒ—ションã¯è¡Œç·¨é›†ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚行編集ã®ã‚ªãƒ—ションをå‚ç…§ã—ã¦ãã ã•ã„。 .RE .PP mark\-dirs .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã®å±•é–‹çµæžœã«ãŠã„ã¦ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表ã™ã‚‚ã®ã®æœ«å°¾ã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’付ã‘ã¾ã™ã€‚ .RE .PP monitor (\fB\-m\fR) .RS 4 ã“ã®ã‚ªãƒ—ションã¯ã‚¸ãƒ§ãƒ–制御を有効ã«ã—ã¾ã™ã€‚シェルを対話モードã§èµ·å‹•ã—ãŸã¨ãã“ã®ã‚ªãƒ—ションã¯è‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚ .RE .PP notify (\fB\-b\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã®ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡ŒçŠ¶æ…‹ãŒå¤‰åŒ–ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«ãれを標準エラーã«å ±å‘Šã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ション㯠notifyle オプションより優先ã—ã¾ã™ã€‚ .RE .PP notify\-le .RS 4 ã“ã®ã‚ªãƒ—ション㯠notify オプションã¨ã»ã¼åŒã˜ã§ã™ãŒã€è¡Œç·¨é›†ã‚’行ã£ã¦ã„る最中ã®ã¿ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚ .RE .PP null\-glob .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã§ãƒžãƒƒãƒã™ã‚‹ãƒ‘スåãŒãªã„ã¨ãå…ƒã®ãƒ‘ã‚¿ãƒ¼ãƒ³ã¯æ®‹ã‚Šã¾ã›ã‚“。 .RE .PP posixly\-correct .RS 4 ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードを有効ã«ã—ã¾ã™ã€‚ .RE .PP trace\-all .RS 4 ã“ã®ã‚ªãƒ—ションã¯ã€è£œåŠ©ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œä¸­ã‚‚ x-trace オプションを機能ã•ã›ã‚‹ã‹ã©ã†ã‹ã‚’指定ã—ã¾ã™ã€‚補助コマンドã¨ã¯ã€ \fBCOMMAND_NOT_FOUND_HANDLER\fR〠\fBPROMPT_COMMAND\fRã€ãŠã‚ˆã³ \fBYASH_AFTER_CD\fR 変数ã®å€¤ã¨ã—ã¦å®šç¾©ã•れã€ç‰¹å®šã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§è§£é‡ˆãƒ»å®Ÿè¡Œã•れるコマンドã§ã™ã€‚ ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ .RE .PP unset (\fB+u\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘ラメータ展開ã§å­˜åœ¨ã—ãªã„変数を展開ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ã¯ãªã‚‰ãšç©ºæ–‡å­—列ã«å±•é–‹ã•れã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ .RE .PP verbose (\fB\-v\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯èª­ã¿è¾¼ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ã‚’ãã®ã¾ã¾æ¨™æº–エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .PP vi .RS 4 ã“ã®ã‚ªãƒ—ション㯠vi 風行編集を有効ã«ã—ã¾ã™ã€‚å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åŠ¹ã§æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ãªã‚‰ã°ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«è‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚ .RE .PP x\-trace (\fB\-x\fR) .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹å‰ã«å±•é–‹ã®çµæžœã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã®å‡ºåŠ›ã¯ã€å„行頭㫠\fBPS4\fR 変数ã®å€¤ã‚’展開ã—ãŸçµæžœã‚’付ã‘ã¦ç¤ºã•れã¾ã™ã€‚ Trace-all オプションもå‚ç…§ã—ã¦ãã ã•ã„。 .RE .SS "オペランド" .sp Set コマンドã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã¾ãŸã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’区切るãƒã‚¤ãƒ•ン二㤠(\fB\-\-\fR, コマンドã®å¼•æ•°ã®æ§‹æ–‡å‚ç…§) ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«å…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€ç¾åœ¨ã®ä½ç½®ãƒ‘ラメータã¯å‰Šé™¤ã•れã€ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒãれãžã‚Œæ–°ã—ãä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚ãƒã‚¤ãƒ•ン二ã¤ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã¦ã‹ã¤ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒãªã„å ´åˆã¯ä½ç½®ãƒ‘ラメータã¯ãªããªã‚Šã¾ã™ã€‚ .SS "終了ステータス" .sp ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šãŒé–“é•ã£ã¦ã„ã‚‹å ´åˆã‚’除ãã€set コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Set コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX è¦æ ¼ã«å®šç¾©ã•れã¦ã„るオプションã¯é™ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚è¦æ ¼ã®å®šç¾©ã§ã¯ã€ .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-\-allexport\fR ãªã©ã®é•·ã„オプションã¯ä½¿ãˆã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} オプションåã« \fBno\fR を付ã‘ã¦ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} オプションåã«å¤§æ–‡å­—や英字ã§ãªã„記å·ã¯ä½¿ãˆã¾ã›ã‚“。 .RE .sp è¦æ ¼ã«å®šç¾©ã•れã¦ã„るオプションã¯ä»¥ä¸‹ã®ã¨ãŠã‚Šã§ã™: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-a\fR, \fB\-o allexport\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-e\fR, \fB\-o errexit\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-m\fR, \fB\-o monitor\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-C\fR, \fB\-o noclobber\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-n\fR, \fB\-o noexec\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-f\fR, \fB\-o noglob\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-b\fR, \fB\-o notify\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-u\fR, \fB\-o nounset\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-v\fR, \fB\-o verbose\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-x\fR, \fB\-o xtrace\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-h\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-o ignoreeof\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-o nolog\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB\-o vi\fR .RE .sp POSIX ã§ã¯ã“ã®ã»ã‹ã«ã€é–¢æ•°å®šç¾©ã‚’コマンド履歴ã«ç™»éŒ²ã—ãªã„よã†ã«ã™ã‚‹ \fB\-o nolog\fR オプションをè¦å®šã—ã¦ã„ã¾ã™ãŒã€yash ã¯ã“れをサãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã›ã‚“。 .SH "SHIFT 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIShift 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ä½ç½®ãƒ‘ラメータã®ã„ãã¤ã‹ã‚’削除ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBshift [\fR\fB\fI個数\fR\fR\fB]\fR .RE .SS "説明" .sp Shift コマンドã¯ä½ç½®ãƒ‘ラメータã®ã†ã¡æœ€åˆã®ã„ãã¤ã‹ã‚’削除ã—ã¾ã™ã€‚削除ã™ã‚‹ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã®æ•°ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ã¾ã™ã€‚ .SS "オペランド" .PP \fI個数\fR .RS 4 削除ã™ã‚‹ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’指示ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ .sp 実際ã®ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚ˆã‚Šå¤§ãã„æ•°ã‚’指定ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚çœç•¥ã™ã‚‹ã¨ 1 を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š shift コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Shift コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã¯ç‰¹æ®Šãƒ‘ラメータ \fB#\fR ã«ã‚ˆã£ã¦çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ .SH "SUSPEND 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fISuspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ã‚’åœæ­¢ (サスペンド) ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBsuspend [\-f]\fR .RE .SS "説明" .sp Suspend コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスãŒå±žã™ã‚‹ãƒ—ロセスグループ内ã®ã™ã¹ã¦ã®ãƒ—ロセスã«å¯¾ã—㦠SIGSTOP シグナルをé€ä¿¡ã—ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‰ã‚ŒãŸå„プロセス (シェル自身をå«ã‚€) ã¯åœæ­¢ (サスペンド) 状態ã«ãªã‚Šã¾ã™ã€‚åœæ­¢çŠ¶æ…‹ã«ãªã£ãŸãƒ—ロセス㯠SIGCONT シグナルをå—ä¿¡ã™ã‚‹ã¨å®Ÿè¡Œã‚’å†é–‹ã—ã¾ã™ã€‚ .sp シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ã€ã•らã«ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ—ロセスグループ ID ãŒã‚»ãƒƒã‚·ãƒ§ãƒ³ãƒªãƒ¼ãƒ€ãƒ¼ã®ãƒ—ロセス ID ã«ç­‰ã—ã„ã¨ãã¯ã€\fB\-f\fR (\fB\-\-force\fR) オプションを付ã‘ãªã„é™ã‚Šã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã›ã‚“。ã“れã¯ã‚·ã‚§ãƒ«ãŒåœæ­¢ã—ãŸå¾Œå®Ÿè¡Œã‚’å†é–‹ã•ã›ã‚‹ã“ã¨ãŒã§ããªããªã£ã¦ã—ã¾ã†ã®ã‚’未然ã«é˜²ããŸã‚ã§ã™ã€‚ .SS "オプション" .PP \fB\-f\fR, \fB\-\-force\fR .RS 4 警告を無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’åœæ­¢ã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp Suspend コマンドã®çµ‚了ステータスã¯ã€SIGSTOP ã‚·ã‚°ãƒŠãƒ«ã‚’ã‚·ã‚§ãƒ«ã«æ­£ã—ãé€ä¿¡ã§ããŸã¨ã㯠0ã€ãれ以外ãªã‚‰éž 0 ã§ã™ã€‚ .SS "補足" .sp POSIX ã«ã¯ suspend コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "TEST 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fITest 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯å¼•æ•°ã§æŒ‡å®šã—ãŸå†…容ã®åˆ¤å®šã‚’行ã„ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtest \fR\fB\fI判定å¼\fR\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fB[ \fR\fB\fI判定å¼\fR\fR\fB ]\fR .RE .sp Test コマンドã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã‚’区別ã—ã¾ã›ã‚“。コマンドライン引数ã¯å…¨ã¦\fI判定å¼\fRã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚コマンド㌠\fB[\fR ã®åå‰ã§å®Ÿè¡Œã•ã‚ŒãŸæ™‚ã¯ã€åˆ¤å®šå¼ã®å¾Œã« \fB]\fR ãŒå¿…è¦ã§ã™ã€‚ .SS "説明" .sp Test コマンドã¯å¼•æ•°ã§ä¸Žãˆã‚‰ã‚ŒãŸ\fI判定å¼\fRを評価ã—ã€çµæžœãŒçœŸãªã‚‰ã° 0 ã®çµ‚了ステータスをã€å½ãªã‚‰ã° 1 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚判定å¼ã¯ä½•種類ã‹ã®æ¼”ç®—å­ã¨ãれã«å¯¾ã™ã‚‹è¢«æ¼”ç®—å­ã¨ã‹ã‚‰ãªã‚Šã¾ã™ã€‚ .sp ファイルã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚指定ã—ãŸãƒ•ァイルãŒã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã®å ´åˆã€ãã®ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ãŒæŒ‡ã—ã¦ã„ã‚‹å…ˆã®ãƒ•ァイルã«ã¤ã„ã¦åˆ¤å®šã‚’行ã„ã¾ã™ (\fB\-h\fR, \fB\-L\fR 演算å­ã‚’除ã)。 .PP \fB\-b \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒãƒ–ロックスペシャルファイルã‹ã©ã†ã‹ .RE .PP \fB\-c \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒã‚­ãƒ£ãƒ©ã‚¯ã‚¿ã‚¹ãƒšã‚·ãƒ£ãƒ«ãƒ•ァイルã‹ã©ã†ã‹ .RE .PP \fB\-d \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã©ã†ã‹ .RE .PP \fB\-e \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒå­˜åœ¨ã™ã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\-f \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒé€šå¸¸ã®ãƒ•ァイルã‹ã©ã†ã‹ .RE .PP \fB\-G \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRã®ã‚°ãƒ«ãƒ¼ãƒ— ID ãŒã‚·ã‚§ãƒ«ã®å®ŸåŠ¹ã‚°ãƒ«ãƒ¼ãƒ— ID ã«ç­‰ã—ã„ã‹ã©ã†ã‹ .RE .PP \fB\-g \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRã® set\-group\-ID ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\-h \fR\fB\fIファイル\fR\fR .RS 4 \fB\-L \fR\fB\fIファイル\fR\fR ã«åŒã˜ .RE .PP \fB\-k \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRã® sticky ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\-L \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‹ã©ã†ã‹ .RE .PP \fB\-N \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRã®æœ€çµ‚å¤‰æ›´æ—¥æ™‚ãŒæœ€çµ‚アクセス日時より後ã‹ã©ã†ã‹ .RE .PP \fB\-O \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRã®ãƒ¦ãƒ¼ã‚¶ ID ãŒã‚·ã‚§ãƒ«ã®å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ã«ç­‰ã—ã„ã‹ã©ã†ã‹ .RE .PP \fB\-p \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fR㌠FIFO (åå‰ä»˜ãパイプ) ã‹ã©ã†ã‹ .RE .PP \fB\-r \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒèª­ã¿è¾¼ã¿å¯èƒ½ã‹ã©ã†ã‹ .RE .PP \fB\-S \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒã‚½ã‚±ãƒƒãƒˆã‹ã©ã†ã‹ .RE .PP \fB\-s \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRサイズãŒç©ºã§ãªã„ã‹ã©ã†ã‹ .RE .PP \fB\-u \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRã® set\-user\-ID ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\-w \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒæ›¸ãè¾¼ã¿å¯èƒ½ã‹ã©ã†ã‹ .RE .PP \fB\-x \fR\fB\fIファイル\fR\fR .RS 4 \fIファイル\fRãŒå®Ÿè¡Œå¯èƒ½ã‹ã©ã†ã‹ .RE .sp ファイル記述å­ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\-t \fR\fB\fIファイル記述å­\fR\fR .RS 4 \fIファイル記述å­\fRãŒç«¯æœ«ã‹ã©ã†ã‹ (ファイル記述å­ã¯ 0 以上ã®è‡ªç„¶æ•°ã§æŒ‡å®šã—ã¾ã™) .RE .sp 文字列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\-n \fR\fB\fI文字列\fR\fR .RS 4 文字列ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹ .RE .PP \fB\-z \fR\fB\fI文字列\fR\fR .RS 4 文字列ãŒç©ºæ–‡å­—列ã‹ã©ã†ã‹ .RE .sp シェルã®ã‚ªãƒ—ションã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\-o ?\fR\fB\fIオプション\fR\fR .RS 4 \fIオプション\fRãŒæ­£ã—ã„オプションåã§ã‚ã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\-o \fR\fB\fIオプション\fR\fR .RS 4 \fIオプション\fRãŒæ­£ã—ã„オプションåã§ã‚りã€ã‹ã¤ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйã«è¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ .RE .sp ファイルã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ (存在ã—ãªã„ファイルã¯ä»–ã®ãƒ•ァイルよりå¤ã„ã¨ã¿ãªã—ã¾ã™)。 .PP \fB\fIファイル1\fR\fR\fB \-nt \fR\fB\fIファイル2\fR\fR .RS 4 \fIファイル1\fRã®æ›´æ–°æ™‚刻ãŒ\fIファイル2\fRより新ã—ã„ã‹ã©ã†ã‹ .RE .PP \fB\fIファイル1\fR\fR\fB \-ot \fR\fB\fIファイル2\fR\fR .RS 4 \fIファイル1\fRã®æ›´æ–°æ™‚刻ãŒ\fIファイル2\fRよりå¤ã„ã‹ã©ã†ã‹ .RE .PP \fB\fIファイル1\fR\fR\fB \-ef \fR\fB\fIファイル2\fR\fR .RS 4 二ã¤ã®ãƒ•ァイルãŒäº’ã„ã®ãƒãƒ¼ãƒ‰ãƒªãƒ³ã‚¯ã§ã‚ã‚‹ã‹ã©ã†ã‹ .RE .sp 文字列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\fI文字列1\fR\fR\fB = \fR\fB\fI文字列2\fR\fR .RS 4 二ã¤ã®æ–‡å­—列ãŒåŒã˜ã‹ã©ã†ã‹ .RE .PP \fB\fI文字列1\fR\fR\fB != \fR\fB\fI文字列2\fR\fR .RS 4 二ã¤ã®æ–‡å­—列ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ .RE .sp 以下ã®äºŒé …演算å­ã¯ç¾åœ¨ã®ãƒ­ã‚±ãƒ¼ãƒ«ã®è¾žæ›¸å¼é †åºã«å¾“ã£ã¦æ–‡å­—列を比較ã—ã¾ã™ã€‚ .PP \fB\fI文字列1\fR\fR\fB === \fR\fB\fI文字列2\fR\fR .RS 4 二ã¤ã®æ–‡å­—列ãŒåŒã˜ã‹ã©ã†ã‹ .RE .PP \fB\fI文字列1\fR\fR\fB !== \fR\fB\fI文字列2\fR\fR .RS 4 二ã¤ã®æ–‡å­—列ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\fI文字列1\fR\fR\fB < \fR\fB\fI文字列2\fR\fR .RS 4 \fI文字列1\fR ㌠\fI文字列2\fR よりも順åºãŒæ‰‹å‰ã‹ã©ã†ã‹ .RE .PP \fB\fI文字列1\fR\fR\fB <= \fR\fB\fI文字列2\fR\fR .RS 4 \fI文字列1\fR ㌠\fI文字列2\fR よりも順åºãŒæ‰‹å‰ã¾ãŸã¯åŒã˜ã‹ã©ã†ã‹ .RE .PP \fB\fI文字列1\fR\fR\fB > \fR\fB\fI文字列2\fR\fR .RS 4 \fI文字列1\fR ㌠\fI文字列2\fR よりも順åºãŒå¾Œã‹ã©ã†ã‹ .RE .PP \fB\fI文字列1\fR\fR\fB >= \fR\fB\fI文字列2\fR\fR .RS 4 \fI文字列1\fR ㌠\fI文字列2\fR よりも順åºãŒå¾Œã¾ãŸã¯åŒã˜ã‹ã©ã†ã‹ .RE .sp パターンマッãƒãƒ³ã‚°ã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\fI文字列\fR\fR\fB =~ \fR\fB\fIパターン\fR\fR .RS 4 拡張正è¦è¡¨ç¾\fIパターン\fRãŒ\fI文字列\fRã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹ .RE .sp æ•´æ•°ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB\fIv1\fR\fR\fB \-eq \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR 㨠\fIv2\fR ãŒç­‰ã—ã„ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-ne \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR 㨠\fIv2\fR ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-gt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR よりも大ãã„ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-ge \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR 以上ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-lt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR よりもå°ã•ã„ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-le \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR 以下ã‹ã©ã†ã‹ .RE .sp ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã‚’è¡¨ã™æ–‡å­—列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚文字列ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã¨ã—ã¦ã®æ¯”較ã®ã—ã‹ãŸã¯å¾Œè¿°ã—ã¾ã™ã€‚ .PP \fB\fIv1\fR\fR\fB \-veq \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR 㨠\fIv2\fR ãŒç­‰ã—ã„ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-vne \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR 㨠\fIv2\fR ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-vgt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR よりも大ãã„ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-vge \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR 以上ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-vlt \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR よりもå°ã•ã„ã‹ã©ã†ã‹ .RE .PP \fB\fIv1\fR\fR\fB \-vle \fR\fB\fIv2\fR\fR .RS 4 \fIv1\fR ㌠\fIv2\fR 以下ã‹ã©ã†ã‹ .RE .sp ä»–ã®åˆ¤å®šå¼ã‚’組ã¿åˆã‚ã›ã¦ã‚ˆã‚Šè¤‡é›‘ãªåˆ¤å®šå¼ã‚’作る演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ .PP \fB! \fR\fB\fI判定å¼\fR\fR .RS 4 \fI判定å¼\fRãŒå½ã‹ã©ã†ã‹ (判定å¼ã®çœŸå½ã‚’逆転ã—ã¾ã™) .RE .PP \fB( \fR\fB\fI判定å¼\fR\fR\fB )\fR .RS 4 \fI判定å¼\fRãŒçœŸã‹ã©ã†ã‹ (判定å¼ã®æ§‹æ–‡ä¸Šã®å„ªå…ˆé †ä½ã‚’高ãã—ã¾ã™) .RE .PP \fB\fI判定å¼1\fR\fR\fB \-a \fR\fB\fI判定å¼2\fR\fR .RS 4 二ã¤ã®åˆ¤å®šå¼ãŒä¸¡æ–¹ã¨ã‚‚真ã‹ã©ã†ã‹ .RE .PP \fB\fI判定å¼1\fR\fR\fB \-o \fR\fB\fI判定å¼2\fR\fR .RS 4 二ã¤ã®åˆ¤å®šå¼ã®å°‘ãªãã¨ã‚‚片方ãŒçœŸã‹ã©ã†ã‹ .RE .sp 判定å¼ãŒç©ºã®å ´åˆã€çµæžœã¯å½ã¨ã¿ãªã—ã¾ã™ã€‚判定å¼ãŒ (演算å­ã®ä»˜ã„ã¦ã„ãªã„) 文字列一ã¤ã®å ´åˆã€ãã®æ–‡å­—列ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹ã‚’判定ã—ã¾ã™ã€‚ .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã®æ¯”較\fR .RS 4 .sp 文字列ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã¨ã—ã¦ã®æ¯”較ã¯ã€åŸºæœ¬çš„ã«ã¯ç¾åœ¨ã®ãƒ­ã‚±ãƒ¼ãƒ«æƒ…å ±ã«å¾“ã£ãŸè¾žæ›¸å¼é †åºã§è¡Œã„ã¾ã™ã€‚ãŸã ã—ã€é€£ç¶šã™ã‚‹æ•°å­—ã¯ä¸€ã¤ã®è‡ªç„¶æ•°ã¨ã—ã¦æ¯”較ã—ã¾ã™ã€‚ã¾ãŸæ•°å­—ã¨ãã‚Œä»¥å¤–ã®æ–‡å­—ã¨ã®æ¯”較ã§ã¯å¸¸ã«æ•°å­—ã®æ–¹ãŒå¤§ãã„ã¨ã¿ãªã—ã¾ã™ã€‚ .sp 例ãˆã°ã€\fB0\&.1\&.2\-3\fR 㨠\fB00\&.001\&.02\-3\fR ã¯ç­‰ã—ãã€\fB0\&.2\&.1\fR 㨠\fB0\&.10\&.0\fR ã¨ã§ã¯å¾Œè€…ã®æ–¹ãŒå¤§ãã„ã¨åˆ¤å®šã•れã¾ã™ã€‚ .RE .SS "終了ステータス" .sp Test コマンドã®çµ‚了ステータスã¯ã€\fI判定å¼\fRã®è©•ä¾¡çµæžœãŒçœŸãªã‚‰ã° 0ã€å½ãªã‚‰ã° 1 ã§ã™ã€‚\fI判定å¼\fRã®æ§‹æ–‡ã«èª¤ã‚ŠãŒã‚ã‚‹å ´åˆãã®ä»–ã®ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸã¨ãã¯ã€çµ‚了ステータス㯠2 ã§ã™ã€‚ .SS "補足" .sp 複雑ãªåˆ¤å®šå¼ã¯èª¤ã£ã¦è§£é‡ˆã•れるã“ã¨ãŒã‚ã‚‹ã®ã§é¿ã‘ã‚‹ã“ã¨ã‚’ãŠå‹§ã‚ã—ã¾ã™ã€‚例ãˆã° \fB[ 1 \-eq 1 \-a \-t = 1 \-a ! foo ]\fR 㯠\fB[ 1 \-eq 1 ] && [ \-t = 1 ] && ! [ foo ]\fR ã®ã‚ˆã†ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’分ã‘ã‚‹ã¨å¼ãŒã‚ˆã‚Šæ˜Žç¢ºã«ãªã‚Šã¾ã™ã€‚ .sp POSIX ã¯ã€ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã®çµ‚了ステータスを 『2 以上〠ã¨å®šã‚ã¦ã„ã¾ã™ã€‚ã¾ãŸ POSIX ã«ã¯ä»¥ä¸‹ã®æ¼”ç®—å­ã®è¦å®šã¯ã‚りã¾ã›ã‚“: \fB\-nt\fR, \fB\-ot\fR, \fB\-ef\fR, \fB==\fR, \fB===\fR, \fB!==\fR, \fB<\fR, \fB<=\fR, \fB>\fR, \fB>=\fR, \fB=~\fR, \fB\-veq\fR, \fB\-vne\fR, \fB\-vgt\fR, \fB\-vge\fR, \fB\-vlt\fR, \fB\-vle\fR。 POSIX ã« \fB\-o\fR ã®å˜é …演算å­ã¨ã—ã¦ã®è¦å®šã¯ã‚りã¾ã›ã‚“。 .SH "TIMES 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fITimes 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ã¨ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒæ¶ˆè²»ã—㟠CPU 時間を表示ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtimes\fR .RE .SS "説明" .sp Times コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã¨ãã®å­ãƒ—ãƒ­ã‚»ã‚¹ãŒæ¶ˆè²»ã—㟠CPU 時間を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚一行目ã«ã‚·ã‚§ãƒ«ãƒ—ロセス自身ãŒãƒ¦ãƒ¼ã‚¶ãƒ¢ãƒ¼ãƒ‰ãŠã‚ˆã³ã‚·ã‚¹ãƒ†ãƒ ãƒ¢ãƒ¼ãƒ‰ã§æ¶ˆè²»ã—㟠CPU 時間をãれãžã‚Œè¡¨ç¤ºã—ã¾ã™ã€‚二行目ã«ã‚·ã‚§ãƒ«ã®å…¨ã¦ã®å­å­«ãƒ—ロセス (親プロセス㌠wait ã—ã¦ã„ãªã„ã‚‚ã®ã‚’除ã) ãŒãƒ¦ãƒ¼ã‚¶ãƒ¢ãƒ¼ãƒ‰ãŠã‚ˆã³ã‚·ã‚¹ãƒ†ãƒ ãƒ¢ãƒ¼ãƒ‰ã§æ¶ˆè²»ã—㟠CPU 時間をãれãžã‚Œè¡¨ç¤ºã—ã¾ã™ã€‚ .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š times コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Times コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .SH "TRAP 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fITrap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作を設定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap \fR\fB\fI動作\fR\fR\fB \fR\fB\fIシグナル\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap \fR\fB\fIシグナル番å·\fR\fR\fB [\fR\fB\fIシグナル\fR\fR\fB\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrap \-p [\fR\fB\fIシグナル\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Trap コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作 (\fIトラップ\fR) を表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ .sp オペランドã«\fI動作\fRã¨\fIシグナル\fRを指定ã—㦠trap コマンドを実行ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ãŒ\fIシグナル\fRã‚’å—ä¿¡ã—ãŸéš›ã«æŒ‡å®šã—ãŸ\fI動作\fRを行ã†ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ\fIシグナル番å·\fRã®å ´åˆã€ãã‚Œã¨æ®‹ã‚Šã®\fIシグナル\fRã«å¯¾ã™ã‚‹å‹•作ã¯ã€å‹•作ã¨ã—㦠\fB\-\fR ãŒæŒ‡å®šã•れãŸã¨ãã¨åŒæ§˜ã«æ¨™æº–ã®å‹•作ã«è¨­å®šã•れã¾ã™ã€‚ .sp \fB\-p\fR (\fB\-\-print\fR) オプションを指定ã—ãŸå ´åˆã¾ãŸã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’一ã¤ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€trap コマンドã¯ç¾åœ¨ã®ãƒˆãƒ©ãƒƒãƒ—ã®è¨­å®šçжæ³ã‚’コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚\fIシグナル\fRãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã«é–¢ã™ã‚‹è¨­å®šã‚’ã€ä¸Žãˆã‚‰ã‚Œã¦ãªã„ã¨ãã¯å…¨ã¦ã®è¨­å®šã‚’出力ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-p\fR, \fB\-\-print\fR .RS 4 ç¾åœ¨ã®ãƒˆãƒ©ãƒƒãƒ—ã®è¨­å®šã‚’表示ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fI動作\fR .RS 4 シグナルをå—ä¿¡ã—ãŸéš›ã®å‹•作を指定ã—ã¾ã™ã€‚\fI動作\fRãŒãƒã‚¤ãƒ•ン一㤠(\fB\-\fR) ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ã‚·ã‚¹ãƒ†ãƒ ã§è¦å®šã•ã‚ŒãŸæ¨™æº–ã®å‹•作を行ã„ã¾ã™ã€‚\fI動作\fRãŒç©ºæ–‡å­—列ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ã‚·ã‚°ãƒŠãƒ«ã‚’無視ã—ã¾ã™ã€‚ãれ以外ã®å€¤ã‚’指定ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã¿ãªã—ã¦ã€ã‚·ã‚°ãƒŠãƒ«å—信時ã«ã“れを解釈・実行ã—ã¾ã™ (コマンドã®å®Ÿè¡Œä¸­ã«ã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã¯ã€ã‚³ãƒžãƒ³ãƒ‰ãŒçµ‚了ã—ãŸå¾Œã«ãƒˆãƒ©ãƒƒãƒ—を実行ã—ã¾ã™)。 .RE .PP \fIシグナル\fR .RS 4 動作ã®å¯¾è±¡ã¨ãªã‚‹ã‚·ã‚°ãƒŠãƒ«ã§ã™ã€‚シグナルã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã¨ã‚·ã‚°ãƒŠãƒ«åã®ã©ã¡ã‚‰ã‹ã§æŒ‡å®šã—ã¾ã™ã€‚ .sp \fIシグナル\fRã¨ã—㦠\fB0\fR ã¾ãŸã¯ \fBEXIT\fR を指定ã™ã‚‹ã¨ã€ã“れã¯ã‚·ã‚§ãƒ«ã®çµ‚了時ã«ç™ºç”Ÿã™ã‚‹ä»®æƒ³ã®ã‚·ã‚°ãƒŠãƒ«ã‚’指定ã—ã¦ã„ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚ã“ã®ä»®æƒ³ã®ã‚·ã‚°ãƒŠãƒ«ã«å¯¾ã—ã¦è¨­å®šã•れãŸ\fI動作\fRã¯ã€ã‚·ã‚§ãƒ«ãŒæ­£å¸¸çµ‚了ã™ã‚‹ç›´å‰ã«å®Ÿè¡Œã•れã¾ã™ã€‚ .RE .PP \fIシグナル番å·\fR .RS 4 \fIシグナル\fRã¨åŒæ§˜ã§ã™ãŒã€ã‚·ã‚°ãƒŠãƒ«ã‚’番å·ã§æŒ‡å®šã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp ãƒˆãƒ©ãƒƒãƒ—ãŒæ­£ã—ã設定ã¾ãŸã¯è¡¨ç¤ºã•れãŸã¨ãã¯çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp Trap コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã¯ã€ã‚·ã‚°ãƒŠãƒ«å㯠\fBINT\fR ã‚„ \fBQUIT\fR ã®ã‚ˆã†ã«æœ€åˆã® SIG を除ã„ãŸå½¢ã§æŒ‡å®šã—ãªã‘れã°ãªã‚‰ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯ã€æ‹¡å¼µã¨ã—㦠SIG を付ã‘ãŸå½¢ã§ã‚‚指定ã§ãã¾ã™ã—ã€ã‚·ã‚°ãƒŠãƒ«åã®å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¾ã›ã‚“ (ã“ã®ã‚ˆã†ãªæ‹¡å¼µã¯ POSIX ã§ã‚‚èªã‚られã¦ã„ã¾ã™)。 .SH "TRUE 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fITrue 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ä½•も行ã‚ãšã« 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtrue\fR .RE .SS "説明" .sp True コマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚ .SS "終了ステータス" .sp True コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp True ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp コロンコマンド㯠true コマンドã¨åŒæ§˜ã«ä½•も行ã„ã¾ã›ã‚“ãŒã€true ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ã‚‹ã®ã«å¯¾ã—コロンコマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .SH "TYPE 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIType 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã‚’特定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtype [\-abefkp] [\fR\fB\fIコマンド\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Type コマンド㯠command コマンド㫠\fB\-V\fR オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠command コマンドã¨åŒã˜ã§ã™ã€‚ .SS "補足" .sp POSIX ã§ã¯ã€type コマンド㨠command コマンドã¨ã®é–¢ä¿‚ã«ã¤ã„ã¦è¦å®šã—ã¦ã„ã¾ã›ã‚“。従ã£ã¦ä»–ã®ã‚·ã‚§ãƒ«ã® type コマンド㯠command コマンド㫠\fB\-V\fR オプションを付ã‘ãŸã‚‚ã®ã¨ã¯ç•°ãªã‚‹å‹•作をã™ã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ã¾ãŸ POSIX 㯠type コマンドã®ã‚ªãƒ—ションをè¦å®šã—ã¦ã„ã¾ã›ã‚“。 .sp POSIX 準拠モードã§ã¯å°‘ãªãã¨ã‚‚一ã¤\fIコマンド\fRを指定ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ .SH "TYPESET 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fITypeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’表示・設定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtypeset [\-gprxX] [\fR\fB\fI変数\fR\fR\fB[=\fR\fB\fI値\fR\fR\fB]\&...]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBtypeset \-f[pr] [\fR\fB\fI関数\fR\fR\fB\&...]\fR .RE .SS "説明" .sp \fB\-f\fR (\fB\-\-functions\fR) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯å¤‰æ•°ã‚’出力ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚\fB\-f\fR (\fB\-\-functions\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯é–¢æ•°ã‚’出力ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ .sp \fB\-p\fR (\fB\-\-print\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚\fB\-p\fR (\fB\-\-print\fR) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’設定ã—ã¾ã™ã€‚オペランドを一ã¤ã‚‚与ãˆãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€\fB\-p\fR (\fB\-\-print\fR) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æœ‰ç„¡ã«ã‹ã‹ã‚ら㚠typeset コマンドã¯å…¨ã¦ã®å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’出力ã—ã¾ã™ (ã“ã®ã¨ã \fB\-g\fR (\fB\-\-global\fR) オプションãŒã‚ã‚Œã°æœ¬å½“ã«ã™ã¹ã¦ã®å¤‰æ•°ã‚’ã€ãã†ã§ãªã„ã¨ãã¯ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã ã‘を出力ã—ã¾ã™)。 .SS "オプション" .PP \fB\-f\fR, \fB\-\-functions\fR .RS 4 変数ã§ã¯ãªã関数を表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ .RE .PP \fB\-g\fR, \fB\-\-global\fR .RS 4 ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æ–°ã—ã変数を作æˆã™ã‚‹å ´åˆãã®å¤‰æ•°ã‚’グローãƒãƒ«å¤‰æ•°ã¨ã—ã¾ã™ã€‚ã™ãªã‚ã¡å¤‰æ•°ã¯é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ã¦ã‚‚残りã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€è¨­å®šã™ã‚‹å¤‰æ•°ã¯ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚ .sp オペランドãŒãªã„å ´åˆã¯ã€ã“ã®ã‚ªãƒ—ションを指定ã—ã¦ã„ã‚‹ã¨å…¨ã¦ã®å¤‰æ•°ã‚’出力ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ã¦ã„ãªã„ã¨ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã ã‘出力ã—ã¾ã™ã€‚ .RE .PP \fB\-p\fR, \fB\-\-print\fR .RS 4 変数ã¾ãŸã¯é–¢æ•°ã®å®šç¾©ã‚’ (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 出力ã—ã¾ã™ã€‚ .RE .PP \fB\-r\fR, \fB\-\-readonly\fR .RS 4 設定ã™ã‚‹å¤‰æ•°ãƒ»é–¢æ•°ã‚’\fI読ã¿å–り専用\fRã«ã—ã¾ã™ã€‚読ã¿å–り専用ã®å¤‰æ•°ãƒ»é–¢æ•°ã¯ã€å€¤ã‚’変更ã—ãŸã‚Šå‰Šé™¤ã—ãŸã‚Šã§ããªããªã‚Šã¾ã™ã€‚ .sp 変数・関数を出力ã™ã‚‹éš›ã¯ã€èª­ã¿å–り専用ã®å¤‰æ•°ãƒ»é–¢æ•°ã ã‘出力ã—ã¾ã™ã€‚ .RE .PP \fB\-x\fR, \fB\-\-export\fR .RS 4 設定ã™ã‚‹å¤‰æ•°ã‚’エクスãƒãƒ¼ãƒˆå¯¾è±¡ã«ã—ã¾ã™ã€‚ .sp 変数を出力ã™ã‚‹éš›ã¯ã€ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã®å¤‰æ•°ã ã‘出力ã—ã¾ã™ã€‚ .RE .PP \fB\-X\fR, \fB\-\-unexport\fR .RS 4 設定ã™ã‚‹å¤‰æ•°ã‚’エクスãƒãƒ¼ãƒˆå¯¾è±¡ã‹ã‚‰å¤–ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fI変数\fR .RS 4 出力ã¾ãŸã¯è¨­å®šã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚ .sp å¤‰æ•°ãŒæ—¢ã«å­˜åœ¨ã™ã‚‹å ´åˆã€å¤‰æ•°ã®å€¤ã¯å¤‰ã‚りã¾ã›ã‚“。存在ã—ãªã„変数を指定ã—ãŸå ´åˆã€å¤‰æ•°ã¯å­˜åœ¨ã™ã‚‹ãŒãã®å€¤ã¯å­˜åœ¨ã—ãªã„状態ã«ãªã‚Šã¾ã™ (ã“ã®ã‚ˆã†ãªå¤‰æ•°ã¯ãƒ‘ラメータ展開ã§ã¯å­˜åœ¨ã—ãªã„変数ã¨ã—ã¦æ‰±ã„ã¾ã™)。 .RE .PP \fI変数\fR=\fI値\fR .RS 4 設定ã™ã‚‹å¤‰æ•°ã®åå‰ã¨ãã®å€¤ã§ã™ã€‚ .sp 指定ã—ãŸ\fI値\fRãŒå¤‰æ•°ã®å€¤ã¨ã—ã¦è¨­å®šã•れã¾ã™ã€‚ã“ã®å½¢å¼ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ã¯ã€\fB\-p\fR (\fB\-\-print\fR) オプションを指定ã—ãŸã¨ãã§ã‚‚ã“ã®å¤‰æ•°ã¯å‡ºåŠ›ã§ã¯ãªã設定ã•れã¾ã™ã€‚ .RE .PP \fI関数\fR .RS 4 出力ã¾ãŸã¯è¨­å®šã™ã‚‹é–¢æ•°ã®åå‰ã§ã™ã€‚存在ã—ãªã„関数を指定ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š typeset コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp æ—¢ã«ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒå­˜åœ¨ã™ã‚‹å ´åˆã€ãれを無視ã—ã¦ã‚°ãƒ­ãƒ¼ãƒãƒ«å¤‰æ•°ã‚’æ–°ã—ã作るã“ã¨ã¯ã§ãã¾ã›ã‚“ (\fB\-g\fR (\fB\-\-global\fR) オプションを指定ã—ã¦ã„ã¦ã‚‚既存ã®ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒå†è¨­å®šã•れã¾ã™)。 .sp POSIX ã«ã¯ typeset コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

.sp Export コマンド㯠typeset コマンド㫠\fB\-gx\fR オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚Readonly コマンド㯠typeset コマンド㫠\fB\-gr\fR オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ .SH "ULIMIT 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIUlimit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™ã‚’表示・設定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBulimit \-a [\-H|\-S]\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBulimit [\-H|\-S] [\-efilnqrstuvx] [\fR\fB\fI値\fR\fR\fB]\fR .RE .SS "説明" .sp Ulimit コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ .sp \fB\-a\fR (\fB\-\-all\fR) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€ulimit コマンドã¯å…¨ã¦ã®ç¨®é¡žã®ãƒªã‚½ãƒ¼ã‚¹ã«ã¤ã„ã¦ç¾åœ¨ã®åˆ¶é™å€¤ã‚’一覧形å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚\fB\-a\fR (\fB\-\-all\fR) オプションを付ã‘ãªã„ã§å®Ÿè¡Œã™ã‚‹ã¨ã€ä¸€ç¨®é¡žã®ãƒªã‚½ãƒ¼ã‚¹ã«ã¤ã„ã¦åˆ¶é™å€¤ã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚オペランドã§\fI値\fRを指定ã—ã¦ã„ã‚‹å ´åˆã€ãã®å€¤ã«åˆ¶é™å€¤ã‚’設定ã—ã¾ã™ã€‚\fI値\fRを指定ã—ã¦ã„ãªã„å ´åˆã¯ç¾åœ¨ã®åˆ¶é™å€¤ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚表示・設定ã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã¯ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ã¾ã™ã€‚設定ã—ãŸãƒªã‚½ãƒ¼ã‚¹ã®åˆ¶é™å€¤ã¯ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å„コマンドã«å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚ .sp リソースã®å„種類ã«ã¤ã„ã¦ã€\fIãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆ\fRã¨\fIソフトリミット\fRã®äºŒç¨®é¡žã®åˆ¶é™å€¤ãŒã‚りã¾ã™ã€‚ソフトリミットãŒãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’è¶…ãˆã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。ã¾ãŸãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’ç·©ã‚ã‚‹ã«ã¯å°‚ç”¨ã®æ¨©é™ãŒå¿…è¦ã§ã™ã€‚ .sp \fB\-H\fR (\fB\-\-hard\fR) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€ulimit コマンドã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚\fB\-S\fR (\fB\-\-soft\fR) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€ulimit コマンドã¯ã‚½ãƒ•トリミットを表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ã©ã¡ã‚‰ã®ã‚ªãƒ—ションも指定ã—ã¦ãªã„å ´åˆã€ulimit コマンドã¯ã‚½ãƒ•トリミットã®ã¿ã‚’表示ã™ã‚‹ã‹ã¾ãŸã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã¨ã‚½ãƒ•トリミットã®ä¸¡æ–¹ã‚’設定ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-H\fR, \fB\-\-hard\fR .RS 4 ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ .RE .PP \fB\-S\fR, \fB\-\-soft\fR .RS 4 ソフトリミットを表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ .RE .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 全種類ã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã‚’表示ã—ã¾ã™ã€‚ .RE .sp 以下ã®ã‚ªãƒ—ションã¯è¡¨ç¤ºãƒ»è¨­å®šã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã‚’指定ã—ã¾ã™ã€‚ã“れらã®ã‚ªãƒ—ションãŒã©ã‚Œã‚‚与ãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã¯ã€\fB\-f\fR ãŒä¸Žãˆã‚‰ã‚ŒãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚(表示・設定å¯èƒ½ãªãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã¯ã‚·ã‚¹ãƒ†ãƒ ã«ã‚ˆã£ã¦ç•°ãªã‚Šã¾ã™) .PP \fB\-c\fR, \fB\-\-core\fR .RS 4 プロセスãŒå¼·åˆ¶çµ‚了ã•ã›ã‚‰ã‚ŒãŸã¨ãã«ã§ãるコアファイルã®ã‚µã‚¤ã‚ºã®é™ç•Œ (512 ãƒã‚¤ãƒˆå˜ä½) .RE .PP \fB\-d\fR, \fB\-\-data\fR .RS 4 プロセスãŒä½¿ç”¨ã§ãるデータセグメント領域ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) .RE .PP \fB\-e\fR, \fB\-\-nice\fR .RS 4 スケジューリング優先度 (nice 値) ã®é™ç•Œ .RE .PP \fB\-f\fR, \fB\-\-fsize\fR .RS 4 プロセスãŒä½œæˆã§ãるファイルã®ã‚µã‚¤ã‚ºã®é™ç•Œ (512 ãƒã‚¤ãƒˆå˜ä½) .RE .PP \fB\-i\fR, \fB\-\-sigpending\fR .RS 4 プロセスã®å‡¦ç†å¾…ã¡ã‚·ã‚°ãƒŠãƒ«ã®å€‹æ•°ã®é™ç•Œ .RE .PP \fB\-l\fR, \fB\-\-memlock\fR .RS 4 RAM 上ã«ãƒ­ãƒƒã‚¯å¯èƒ½ãªãƒ¡ãƒ¢ãƒªã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) .RE .PP \fB\-m\fR, \fB\-\-rss\fR .RS 4 プロセス㮠resident set (RAM 上ã«å­˜åœ¨ã™ã‚‹ä»®æƒ³ãƒšãƒ¼ã‚¸) ã®æ•°ã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) .RE .PP \fB\-n\fR, \fB\-\-nofile\fR .RS 4 プロセスãŒä½¿ç”¨ã§ãるファイル記述å­ã®æœ€å¤§å€¤ + 1 .RE .PP \fB\-q\fR, \fB\-\-msgqueue\fR .RS 4 POSIX メッセージキューã®ã‚µã‚¤ã‚ºã®é™ç•Œ .RE .PP \fB\-r\fR, \fB\-\-rtprio\fR .RS 4 リアルタイムスケジューリングã®å„ªå…ˆåº¦ã®é™ç•Œ .RE .PP \fB\-s\fR, \fB\-\-stack\fR .RS 4 プロセスãŒä½¿ç”¨ã§ãるスタック領域ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) .RE .PP \fB\-t\fR, \fB\-\-cpu\fR .RS 4 プロセスãŒä½¿ç”¨ã§ãã‚‹ CPU 時間ã®é™ç•Œ (ç§’å˜ä½) .RE .PP \fB\-u\fR, \fB\-\-nproc\fR .RS 4 プロセスãŒèµ·å‹•ã§ãã‚‹å­ãƒ—ロセスã®å€‹æ•°ã®é™ç•Œ .RE .PP \fB\-v\fR, \fB\-\-as\fR .RS 4 プロセスãŒä½¿ç”¨ã§ãるメモリ領域全体ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) .RE .PP \fB\-x\fR, \fB\-\-locks\fR .RS 4 プロセスãŒãƒ­ãƒƒã‚¯ã§ãるファイルã®å€‹æ•°ã®é™ç•Œ .RE .SS "オペランド" .PP \fI値\fR .RS 4 設定ã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã§ã™ã€‚ .sp 値ã¯åŸºæœ¬çš„ã« 0 以上ã®è‡ªç„¶æ•°ã§æŒ‡å®šã—ã¾ã™ãŒã€è‡ªç„¶æ•°ã®ä»£ã‚り㫠\fBhard\fRã€\fBsoft\fRã€\fBunlimited\fR ã®ã„ãšã‚Œã‹ã®æ–‡å­—列を指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“ã‚Œã‚‰ã®æ–‡å­—列ã¯ãれãžã‚Œç¾åœ¨ã®ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã®å€¤ã€ç¾åœ¨ã®ã‚½ãƒ•トリミットã®å€¤ã€ç„¡åˆ¶é™ã‚’表ã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp リソース制é™å€¤ãŒæ­£ã—ã出力ã¾ãŸã¯è¨­å®šã§ããŸã¨ãã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp POSIX ãŒè¦å®šã—ã¦ã„るオプション㯠\fB\-f\fR ã ã‘ã§ã™ã€‚ã¾ãŸ POSIX ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®\fI値\fRã¨ã—ã¦è‡ªç„¶æ•°ã—ã‹è¦å®šã—ã¦ã„ã¾ã›ã‚“。 .SH "UMASK 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIUmask 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’表示・設定ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBumask \fR\fB\fIマスク\fR\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBumask [\-S]\fR .RE .SS "説明" .sp オペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã€umask コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ç¾åœ¨ã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚\fB\-S\fR (\fB\-\-symbolic\fR) オプションã§å‡ºåŠ›ã®å½¢å¼ã‚’指定ã§ãã¾ã™ã€‚出力ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦å†åˆ©ç”¨å¯èƒ½ãªå½¢å¼ã«ãªã£ã¦ã„ã¾ã™ã€‚ .sp オペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã€umask コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’与ãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å€¤ã«è¨­å®šã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-S\fR, \fB\-\-symbolic\fR .RS 4 ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã¯ã€è¨˜å·å½¢å¼ã§ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’出力ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æ•°å€¤å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIマスク\fR .RS 4 ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€umask コマンドã¯ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’ã“ã®å€¤ã«è¨­å®šã—ã¾ã™ã€‚値ã¯ä»¥ä¸‹ã«è¿°ã¹ã‚‹æ•°å€¤å½¢å¼ã¨è¨˜å·å½¢å¼ã®ã©ã¡ã‚‰ã‹ã§ä¸Žãˆã¾ã™ã€‚ .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB数値形å¼\fR .RS 4 .sp 数値形å¼ã¯ 0 以上ã®å…«é€²æ•´æ•°ã§ãƒžã‚¹ã‚¯ã‚’指定ã—ã¾ã™ã€‚ã“れã¯ä»¥ä¸‹ã®å„モードを表ã™è‡ªç„¶æ•°ã®ã„ãã¤ã‹ã®å’Œã§ã™ã€‚ .PP 0400 .RS 4 ユーザã®èª­ã¿å–ã‚Šæ¨©é™ .RE .PP 0200 .RS 4 ãƒ¦ãƒ¼ã‚¶ã®æ›¸ãè¾¼ã¿æ¨©é™ .RE .PP 0100 .RS 4 ユーザã®å®Ÿè¡Œæ¨©é™ .RE .PP 0040 .RS 4 グループã®èª­ã¿å–ã‚Šæ¨©é™ .RE .PP 0020 .RS 4 ã‚°ãƒ«ãƒ¼ãƒ—ã®æ›¸ãè¾¼ã¿æ¨©é™ .RE .PP 0010 .RS 4 グループã®å®Ÿè¡Œæ¨©é™ .RE .PP 0004 .RS 4 ãã®ä»–ã®èª­ã¿å–ã‚Šæ¨©é™ .RE .PP 0002 .RS 4 ãã®ä»–ã®æ›¸ãè¾¼ã¿æ¨©é™ .RE .PP 0001 .RS 4 ãã®ä»–ã®å®Ÿè¡Œæ¨©é™ .RE .RE .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fB記å·å½¢å¼\fR .RS 4 .sp 記å·å½¢å¼ã¯ä»¥ä¸‹ã®ã‚ˆã†ãªæ›¸å¼ã®è¨˜å·åˆ—ã§ãƒžã‚¹ã‚¯\fBã—ãªã„\fR権é™ã‚’指定ã—ã¾ã™ã€‚ .sp 記å·åˆ—ã¯ä¸€ã¤ä»¥ä¸Šã®\fI節\fRをカンマ (\fB,\fR) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚ \fI節\fRã¯\fI対象\fRã®åˆ—ã¨ä¸€ã¤ä»¥ä¸Šã®\fI動作\fRã‹ã‚‰ãªã‚Šã¾ã™ã€‚ .sp \fI対象\fRã«ã¯ä»¥ä¸‹ã®è¨˜å·ã‚’ã„ãã¤ã§ã‚‚指定ã§ãã¾ã™ã€‚ .PP \fBu\fR .RS 4 ユーザ .RE .PP \fBg\fR .RS 4 グループ .RE .PP \fBo\fR .RS 4 ãã®ä»– .RE .PP \fBa\fR .RS 4 ユーザ・グループ・ãã®ä»–ã®å…¨ã¦ .RE .sp \fI対象\fRãŒä¸€ã¤ã‚‚指定ã•れã¦ã„ãªã„å ´åˆã¯ \fBa\fR ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .sp \fI動作\fRã¯ä»¥ä¸‹ã®\fI演算å­\fRã¨\fI権é™\fRã®çµ„ã¿åˆã‚ã›ã§ã™ã€‚ \fI演算å­\fRã¯ä»¥ä¸‹ã®ã©ã‚Œã‹ã§ã™ã€‚ .PP \fB=\fR .RS 4 \fI対象\fRã«å¯¾ã™ã‚‹è¨­å®šã‚’\fI権é™\fRã«ã—ã¾ã™ã€‚ .RE .PP \fB+\fR .RS 4 \fI対象\fRã«å¯¾ã™ã‚‹è¨­å®šã«\fI権é™\fRを加ãˆã¾ã™ã€‚ .RE .PP \fB\-\fR .RS 4 \fI対象\fRã«å¯¾ã™ã‚‹è¨­å®šã‹ã‚‰\fI権é™\fRを除ãã¾ã™ã€‚ .RE .sp \fI権é™\fRã¯ä»¥ä¸‹ã®ã©ã‚Œã‹ã§ã™ã€‚ .PP \fBr\fR .RS 4 読ã¿å–ã‚Šæ¨©é™ .RE .PP \fBw\fR .RS 4 書ãè¾¼ã¿æ¨©é™ .RE .PP \fBx\fR .RS 4 å®Ÿè¡Œæ¨©é™ .RE .PP \fBX\fR .RS 4 å®Ÿè¡Œæ¨©é™ (元々実行権é™ãŒè¨­å®šã•れã¦ã„ãŸå ´åˆã®ã¿) .RE .PP \fBs\fR .RS 4 Set\-user\-ID, Set\-group\-ID .RE .PP \fBu\fR .RS 4 ç¾åœ¨ã®ãƒ¦ãƒ¼ã‚¶ã®å€¤ .RE .PP \fBg\fR .RS 4 ç¾åœ¨ã®ã‚°ãƒ«ãƒ¼ãƒ—ã®å€¤ .RE .PP \fBo\fR .RS 4 ç¾åœ¨ã®ãã®ä»–ã®å€¤ .RE .sp \fBr\fR, \fBw\fR, \fBx\fR, \fBX\fR, \fBs\fR ã®è¨˜å·åŒå£«ã¯ä¸€åº¦ã«çµ„ã¿åˆã‚ã›ã¦æŒ‡å®šã§ãã¾ã™ã€‚ .sp 例ãˆã° \fBumask u=rwx,go+r\-w\fR を実行ã™ã‚‹ã¨ã€ãƒ¦ãƒ¼ã‚¶ã®èª­ã¿å–り権é™ã¨æ›¸ãè¾¼ã¿æ¨©é™ã¨å®Ÿè¡Œæ¨©é™ã‚’マスクã—ãªã„よã†ã«ã—ã€ã‚°ãƒ«ãƒ¼ãƒ—ã¨ãã®ä»–ã®èª­ã¿å–り権é™ã‚’マスクã—ãªã„よã†ã«ã—ã€ã‚°ãƒ«ãƒ¼ãƒ—ã¨ãã®ä»–ã®æ›¸ãè¾¼ã¿æ¨©é™ã‚’マスクã™ã‚‹ã‚ˆã†ã«ã—ã¾ã™ã€‚ .RE .SS "終了ステータス" .sp ファイルモード作æˆãƒžã‚¹ã‚¯ãŒæ­£ã—ã出力ã¾ãŸã¯è¨­å®šã§ããŸã¨ãã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ .SS "補足" .sp Ulimit ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX 㯠\fB\-S\fR オプションを指定ã—ãªã‹ã£ãŸå ´åˆã®å‡ºåЛ形å¼ãŒå¿…ãšã—も数値形å¼ã§ã‚ã‚‹ã¨ã¯è¦å®šã—ã¦ã„ã¾ã›ã‚“。 .SH "UNALIAS 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIUnalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’削除ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBunalias \fR\fB\fIエイリアスå\fR\fR\fB\&...\fR .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBunalias \-a\fR .RE .SS "説明" .sp Unalias コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’削除ã—ã¾ã™ã€‚ .SS "オプション" .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 å…¨ã¦ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’削除ã—ã¾ã™ã€‚ .RE .SS "オペランド" .PP \fIエイリアスå\fR .RS 4 削除ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š unalias コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚存在ã—ãªã„ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå ´åˆã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ .SS "補足" .sp Unalias ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .SH "UNSET 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIUnset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’削除ã—ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBunset [\-fv] [\fR\fB\fIåå‰\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Unset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸåå‰ã®å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’削除ã—ã¾ã™ã€‚ .sp 元々存在ã—ãªã„変数・関数を削除ã—よã†ã¨ã—ã¦ã‚‚ã€ä½•ã‚‚èµ·ã“りã¾ã›ã‚“ (エラーã«ã¯ãªã‚Šã¾ã›ã‚“)。 .SS "オプション" .PP \fB\-f\fR, \fB\-\-functions\fR .RS 4 関数を削除ã—ã¾ã™ã€‚ .RE .PP \fB\-v\fR, \fB\-\-variables\fR .RS 4 変数を削除ã—ã¾ã™ã€‚ .RE .sp \fB\-f\fR (\fB\-\-functions\fR) オプション㨠\fB\-v\fR (\fB\-\-variables\fR) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€\fB\-v\fR を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ .SS "オペランド" .PP \fIåå‰\fR .RS 4 削除ã™ã‚‹å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã®åå‰ã§ã™ã€‚ .RE .SS "終了ステータス" .sp エラーãŒãªã„é™ã‚Š unset コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ .SS "補足" .sp Unset コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp POSIX ã§ã¯ã€\fB\-f\fR 㨠\fB\-v\fR ã®ã©ã¡ã‚‰ã®ã‚ªãƒ—ションも指定ã•れã¦ã„ãªã„å ´åˆã€æŒ‡å®šã—ãŸåå‰ã®å¤‰æ•°ãŒãªã„å ´åˆã¯ã‹ã‚りã«ãã®åå‰ã®é–¢æ•°ã‚’削除ã—ã¦ã‚ˆã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚ .sp POSIX 準拠モードã§ã¯å°‘ãªãã¨ã‚‚一ã¤\fIåå‰\fRを指定ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ .SH "WAIT 組込ã¿ã‚³ãƒžãƒ³ãƒ‰" .sp \fIWait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰\fRã¯ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã®ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã¡ã¾ã™ã€‚ .SS "æ§‹æ–‡" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fBwait [\fR\fB\fIジョブ\fR\fR\fB\&...]\fR .RE .SS "説明" .sp Wait コマンドã¯å®Ÿè¡Œä¸­ã®ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã¡ã¾ã™ã€‚ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãも終了ã—ãŸã¨ã¿ãªã—ã¾ã™ã€‚ .sp Wait コマンドã¯ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйã§ãªã„ã¨ãã§ã‚‚éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を待ã¤ã®ã«ä½¿ãˆã¾ã™ã€‚ .sp Wait コマンドã®å®Ÿè¡Œä¸­ã«ã‚·ã‚§ãƒ«ãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸå ´åˆã€ãã®ã‚·ã‚°ãƒŠãƒ«ã«å¯¾ã—トラップãŒè¨­å®šã—ã¦ã‚れã°ãã®ãƒˆãƒ©ãƒƒãƒ—ã‚’ç›´ã¡ã«å®Ÿè¡Œã— wait コマンドã¯ãã®ã¾ã¾çµ‚了ã—ã¾ã™ã€‚ã¾ãŸã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйãªå ´åˆã€ã‚·ã‚§ãƒ«ãŒ SIGINT シグナルをå—ä¿¡ã™ã‚‹ã¨ wait コマンドã¯ä¸­æ–­ã•れã¾ã™ã€‚ .SS "オペランド" .PP \fIジョブ\fR .RS 4 終了を待ã¤ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ã‚¸ãƒ§ãƒ– ID ã¾ãŸã¯ãƒ—ロセス ID ã§ã™ã€‚ .RE .sp \fIジョブ\fRを何も指定ã—ãªã„ã¨ã‚·ã‚§ãƒ«ãŒæœ‰ã™ã‚‹å…¨ã¦ã®ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を待ã¡ã¾ã™ã€‚ .sp 存在ã—ãªã„ジョブ・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã™ã‚‹ã¨ã€çµ‚了ステータス 127 ã§æ—¢ã«çµ‚了ã—ãŸã‚¸ãƒ§ãƒ–ã‚’ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã€ã‚¨ãƒ©ãƒ¼ã«ã¯ã—ã¾ã›ã‚“。 .SS "終了ステータス" .sp \fIジョブ\fRãŒä¸€ã¤ã‚‚与ãˆã‚‰ã‚Œã¦ãŠã‚‰ãšã€ã‚·ã‚§ãƒ«ãŒå…¨ã¦ã®ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を正ã—ãå¾…ã¤ã“ã¨ãŒã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚\fIジョブ\fRãŒä¸€ã¤ä»¥ä¸Šä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€æœ€å¾Œã®\fIジョブ\fRã®çµ‚了ステータス㌠wait コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ .sp Wait コマンドãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã€çµ‚了ステータスã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã‚’表㙠128 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚ãã®ä»–ã®ç†ç”±ã§ wait コマンドãŒã‚¸ãƒ§ãƒ–ã®çµ‚了を正ã—ãå¾…ã¤ã“ã¨ãŒã§ããªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠1 以上 126 以下ã§ã™ã€‚ .SS "補足" .sp Wait ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ .sp éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã¯éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸç›´å¾Œã«ç‰¹æ®Šãƒ‘ラメータ \fB!\fR ã®å€¤ã‚’見るã“ã¨ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйãªã¨ã㯠jobs コマンドã§ãƒ—ロセス ID を調ã¹ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .SH "著者" .PP \fB渡邊 裕貴[FAMILY Given]\fR <\&magicant@users\&.sourceforge\&.jp\&> .RS 4 著者. .RE yash-2.35/doc/ja/_jobs.txt0000644000175000017500000000414112154557026015542 0ustar magicantmagicant= Jobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Jobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Jobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ãŒæœ‰ã—ã¦ã„ã‚‹link:job.html[ジョブ]を表示ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +jobs [-lnprs] [{{ジョブ}}...]+ [[description]] == 説明 Jobs コマンドã¯ã‚·ã‚§ãƒ«ãŒç¾åœ¨æœ‰ã—ã¦ã„ã‚‹link:job.html[ジョブ]ã®åå‰ã‚„状態を表示ã—ã¾ã™ã€‚ 標準ã§ã¯å„ジョブã«ã¤ã„ã¦ä»¥ä¸‹ã®æƒ…報を一行ãšã¤è¡¨ç¤ºã—ã¾ã™ã€‚ - ã‚¸ãƒ§ãƒ–ç•ªå· - ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–を示ã™è¨˜å· (+++ ã¾ãŸã¯ +-+) - 状態 - コマンドå [[options]] == オプション +-l+:: +--verbose+:: ジョブを構æˆã—ã¦ã„るパイプラインã®è¦ç´ ã”ã¨ã«ãƒ—ロセス ID ã¨çŠ¶æ…‹ã¨ã‚³ãƒžãƒ³ãƒ‰åを表示ã—ã¾ã™ã€‚ +-n+:: +--new+:: 状態ãŒå¤‰åŒ–ã—ã¦ã‹ã‚‰ã¾ã ä¸€åº¦ã‚‚表示ã—ã¦ã„ãªã„ジョブã ã‘を表示ã—ã¾ã™ã€‚ +-p+:: +--pgid-only+:: ジョブã®ãƒ—ロセスグループ ID ã ã‘を表示ã—ã¾ã™ã€‚ +-r+:: +--running-only+:: 実行中ã®ã‚¸ãƒ§ãƒ–ã ã‘を表示ã—ã¾ã™ã€‚ +-s+:: +--stopped-only+:: åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ã ã‘を表示ã—ã¾ã™ã€‚ [[operands]] == オペランド {{ジョブ}}:: 表示ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®link:job.html#jobid[ジョブ ID] ã§ã™ã€‚一ã¤ã‚‚指定ã—ãªã„å ´åˆã¯å…¨ã¦ã®ã‚¸ãƒ§ãƒ–を表示ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š jobs コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Jobs コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã§è¦å®šã•れã¦ã„るオプション㯠+-l+ 㨠+-p+ ã ã‘ã§ã™ã€‚従ã£ã¦ link:posix.html[POSIX 準拠モード]ã§ã¯ã“れ以外ã®ã‚ªãƒ—ションã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯ã€+-l+ オプション指定時ã€ãƒ—ロセスã”ã¨ã§ã¯ãªãジョブã”ã¨ã«çŠ¶æ…‹ã‚’è¡¨ç¤ºã—ã¾ã™ã€‚ Yash ã§ã¯ã€ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスグループ ID ã¯ã‚¸ãƒ§ãƒ–ã‚’æ§‹æˆã™ã‚‹ãƒ‘ã‚¤ãƒ—ãƒ©ã‚¤ãƒ³ã®æœ€åˆã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã«ä¸€è‡´ã—ã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_getopts.html0000644000175000017500000001643212154557026016425 0ustar magicantmagicant Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚

æ§‹æ–‡

  • getopts オプションリスト 変数å [引数…]

説明

Getopts コマンドã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«å«ã¾ã‚Œã¦ã„る一文字ã®ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚Getopts コマンドを一回呼ã³å‡ºã™ãŸã³ã«ã‚ªãƒ—ションãŒä¸€ã¤è§£æžã•れã€ãã®ã‚ªãƒ—ションを表ã™ä¸€æ–‡å­—ãŒå¤‰æ•°åã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ä»£å…¥ã•れã¾ã™ã€‚

è§£æžã®å¯¾è±¡ã¨ãªã‚‹ã‚ªãƒ—ションã®ç¨®é¡žã‚‚ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ã¾ã™ã€‚オプションリストã«ã¯å—ã‘付ã‘ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—を並ã¹ã¦æŒ‡å®šã—ã¾ã™ã€‚文字ã®å¾Œã«ã‚³ãƒ­ãƒ³ (:) を付ã‘ã‚‹ã¨ãã®ã‚ªãƒ—ションã¯å¼•æ•°ã‚’ã¨ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚例ãˆã°ã€-a, -b, -c ã®ä¸‰ç¨®é¡žã®ã‚ªãƒ—ションをå—ã‘付ã‘ã€ã•らã«ã“れらã®ã†ã¡ -b ãŒå¼•æ•°ã‚’ã¨ã‚‹å ´åˆã€ã‚ªãƒ—ションリストã«ã¯ ab:c を指定ã—ã¾ã™ã€‚

引数をã¨ã‚‹ã‚ªãƒ—ションを解æžã—ãŸã¨ãã€ãã®å¼•æ•°ã®å€¤ãŒ OPTARG 変数ã«ä»£å…¥ã•れã¾ã™ã€‚

オプションリストã§ä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„オプションã«å‡ºãã‚ã—ãŸã¨ãã¾ãŸã¯å¼•æ•°ã‚’ã¨ã‚‹ã‚ªãƒ—ションã«å¼•æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã®å‹•作ã¯ã€ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãƒªã‚¹ãƒˆã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ (:) ã§ã‚ã‚‹ã‹ã©ã†ã‹ã§æ±ºã¾ã‚Šã¾ã™ã€‚

  • ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãƒªã‚¹ãƒˆã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ã®å ´åˆã€ãã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—㌠OPTARG 変数ã«ä»£å…¥ã•れã€å¤‰æ•°åã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ã¯ ? (オプションリストã§ä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„オプションã«å‡ºãã‚ã—ãŸã¨ã) ã¾ãŸã¯ : (引数をã¨ã‚‹ã‚ªãƒ—ションã«å¼•æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ã) ãŒä»£å…¥ã•れã¾ã™ã€‚

  • ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãƒªã‚¹ãƒˆã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ã§ãªã„å ´åˆã€OPTARG 変数ã¯å‰Šé™¤ã•れã€å¤‰æ•°åã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ã¯ ? ãŒä»£å…¥ã•れã¾ã™ã€‚ã¾ãŸã“ã®ã¨ã標準エラーã«ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒå‡ºåŠ›ã•れã¾ã™ãŒã€ãれã§ã‚‚ getopts コマンドã®çµ‚了ステータス㯠0 ã«ãªã‚Šã¾ã™ã€‚

Getopts コマンドã¯ã€å®Ÿè¡Œã™ã‚‹ãŸã³ã«ä¸€ã¤ãšã¤ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã™ã‚‹ã«ã¯ã€æ¯Žå›žåŒã˜å¼•æ•°ã§ getopts コマンドを繰り返ã—実行ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚シェルã¯ã€ã‚ªãƒ—ションをã©ã“ã¾ã§è§£æžã—ãŸã‹ã‚’覚ãˆã¦ãŠããŸã‚ã«ã€OPTIND 変数を用ã„ã¾ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã‚‹ã¾ã§ã«ã“ã®å¤‰æ•°ã‚’変更ã—ã¦ã¯ã„ã‘ã¾ã›ã‚“。全ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã‚‹ã¨ã€OPTIND 変数ã«ã¯å¼•æ•° (ã¾ãŸã¯ä½ç½®ãƒ‘ラメータ) ã®ä¸­ã§æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã«å½“ãŸã‚‹ã‚‚ã®ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒä»£å…¥ã•れã¾ã™ (オペランドãŒãªã„å ´åˆã¯å¼•æ•°ã¾ãŸã¯ä½ç½®ãƒ‘ラメータã®å€‹æ•° + 1 ã«ãªã‚Šã¾ã™)。

ç•°ãªã‚‹å¼•æ•°ã‚’è§£æžã•ã›ãŸã„å ´åˆã¯ã€getopts ã‚³ãƒžãƒ³ãƒ‰ã«æ–°ã—ã„引数を与ãˆã‚‹å‰ã« OPTIND 変数㫠1 を代入ã—ã¦ãã ã•ã„。

オペランド

オプションリスト

è§£æžã®å¯¾è±¡ã¨ãªã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—ã®ç¾…列ã§ã™ã€‚

変数å

è§£æžçµæžœã®å€¤ã‚’代入ã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚

引数s

è§£æžã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚

ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’指定ã—ãªã„å ´åˆã¯ã€ä½ç½®ãƒ‘ラメータを解æžã—ã¾ã™ã€‚

終了ステータス

引数ã®ä¸­ã«ã‚ªãƒ—ションãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¯ã€(ãれãŒã‚ªãƒ—ションリストã«å«ã¾ã‚Œã¦ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãš) 終了ステータス㯠0 ã§ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã£ãŸæ™‚ã¯ã€çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

使用例

aopt=false bopt= copt=false
while getopts ab:c opt
do
  case $opt in
  a) aopt=true ;;
  b) bopt=$OPTARG ;;
  c) copt=true ;;
  \?) return 2 ;;
  esac
done
if $aopt;          then echo オプション -a ãŒæŒ‡å®šã•れã¾ã—ãŸ;       fi
if [ -n "$bopt" ]; then echo オプション -b $bopt ãŒæŒ‡å®šã•れã¾ã—ãŸ; fi
if $copt;          then echo オプション -c ãŒæŒ‡å®šã•れã¾ã—ãŸ;       fi
shift $((OPTIND - 1))
echo オペランド㯠$*

補足

Getopts コマンドãŒè§£æžã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã¯ã€ã‚ªãƒ—ションã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«æŒ‡å®šã—ã¦ã‚ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚最åˆã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒç¾ã‚ŒãŸæ™‚点ã§ã€getopts コマンドã¯è§£æžã‚’終了ã—ã¾ã™ã€‚

Getopts ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã¯ã€OPTIND 変数㫠1 以外ã®å€¤ã‚’代入ã—ãŸå ´åˆã®å‹•作をè¦å®šã—ã¦ã„ã¾ã›ã‚“。

yash-2.35/doc/ja/_kill.txt0000644000175000017500000001115112154557026015537 0ustar magicantmagicant= Kill 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Kill 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Kill 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Šã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +kill [-{{シグナル}}|-s {{シグナル}}|-n {{シグナル}}] {{プロセス}}...+ - +kill -l [-v] [{{シグナル}}...]+ Kill コマンドã§ã¯ã€link:posix.html[POSIX 準拠モード]ã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ [[description]] == 説明 +-l+ オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€kill ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸ{{プロセス}}ã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã™ã€‚é€ä¿¡ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã®ç¨®é¡žã¯{{シグナル指定オプション}}ã§æŒ‡å®šã—ã¾ã™ã€‚シグナルã®ç¨®é¡žã‚’指定ã—ãªã„å ´åˆã¯ SIGTERM シグナルをé€ä¿¡ã—ã¾ã™ã€‚ +-l+ オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€kill ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸ{{シグナル}}ã«é–¢ã™ã‚‹æƒ…報を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚{{シグナル}}を指定ã—ãªã„å ´åˆã¯å…¨ã¦ã®ã‚·ã‚°ãƒŠãƒ«ã«é–¢ã™ã‚‹æƒ…報を表示ã—ã¾ã™ã€‚ [[options]] == オプション === シグナル指定オプション +-{{シグナル}}+:: +-s {{シグナル}}+:: +-n {{シグナル}}+:: é€ä¿¡ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã‚’指定ã—ã¾ã™ã€‚{{シグナル}}ã«ã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã¨ã‚·ã‚°ãƒŠãƒ«åã®ã©ã¡ã‚‰ã‹ã‚’指定ã—ã¾ã™ã€‚シグナル番å·ã¨ã—㦠0 を指定ã™ã‚‹ã¨ã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹ã“ã¨ãŒã§ãã‚‹ã‹ã©ã†ã‹ã®åˆ¤å®šã ã‘を行ã„ã€å®Ÿéš›ã«ã¯ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã›ã‚“。シグナルをåå‰ã§æŒ‡å®šã™ã‚‹éš›ã¯ã€å¤§æ–‡å­—ã¨å°æ–‡å­—ã®åŒºåˆ¥ã¯ã‚りã¾ã›ã‚“。 シグナル指定オプションã¯ä¸€åº¦ã«ä¸€ã¤ã¾ã§ã—ã‹ä½¿ãˆã¾ã›ã‚“。 === ä»–ã®ã‚ªãƒ—ション +-l+:: シグナルã«é–¢ã™ã‚‹æƒ…報を表示ã—ã¾ã™ã€‚ +-v+:: シグナルã«é–¢ã™ã‚‹æƒ…報をより詳ã—ã表示ã—ã¾ã™ã€‚+-v+ オプションを指定ã—ã¦ã„ãªã„å ´åˆã¯å˜ã«ã‚·ã‚°ãƒŠãƒ«åを出力ã—ã¾ã™ãŒã€æŒ‡å®šã—ã¦ã„ã‚‹å ´åˆã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ãƒ»ã‚·ã‚°ãƒŠãƒ«å・シグナルã®ç°¡å˜ãªèª¬æ˜Žã‚’出力ã—ã¾ã™ã€‚ + ã“ã®ã‚ªãƒ—ションを指定ã—ãŸã¨ãã¯åŒæ™‚ã« +-l+ も指定ã—ã¦ã‚ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚ [[operands]] == オペランド {{プロセス}}:: シグナルをé€ä¿¡ã™ã‚‹ãƒ—ロセスをプロセス ID・プロセスグループ ID・link:job.html#jobid[ジョブ ID] ã®ã„ãšã‚Œã‹ã§æŒ‡å®šã—ã¾ã™ã€‚プロセスグループ ID を指定ã™ã‚‹ã¨ãã¯ã€å…ˆé ­ã«è² å· (+-+) を付ã‘ã¾ã™ã€‚プロセスã¨ã—㦠+0+ を指定ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ãƒ—ロセスãŒå±žã™ã‚‹ãƒ—ロセスグループを指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚プロセスã¨ã—㦠+-1+ を指定ã™ã‚‹ã¨ã€å…¨ã¦ã®ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã™ã€‚ {{シグナル}}:: 情報を表示ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã®åå‰ã¾ãŸã¯ç•ªå·ã§ã™ã€‚シグナルã«ã‚ˆã£ã¦ä¸­æ–­ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š kill コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚一ã¤ä»¥ä¸Šã®ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹ã“ã¨ãŒã§ããŸå ´åˆã€ä»–ã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Œãªã‹ã£ãŸãƒ—ロセスãŒã‚ã£ãŸã¨ã—ã¦ã‚‚終了ステータス㯠0 ã«ãªã‚Šã¾ã™ã€‚ [[notes]] == 補足 Kill コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ è² æ•°ã«è¦‹ãˆã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®æ‰±ã„ã«ã¯æ³¨æ„ãŒå¿…è¦ã§ã™ã€‚例ãˆã° +kill -1 -2+ ã§ã¯ +-1+ ãŒã‚·ã‚°ãƒŠãƒ«æŒ‡å®šã‚ªãƒ—ションã€+-2+ ãŒã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ãªã‚‹ã®ã§ã€ç•ªå· 1 ã®ã‚·ã‚°ãƒŠãƒ«ã‚’プロセスグループ 2 ã«é€ä¿¡ã—ã¾ã™ã€‚+kill -- -1 -2+ ã‚„ +kill -TERM -1 -2+ ã§ã¯ +-1+ 㨠+-2+ ã¯ã©ã¡ã‚‰ã‚‚オペランドã«ãªã‚Šã¾ã™ã€‚ POSIX ã«ã¯ +-v+ ãŠã‚ˆã³ +-n+ オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“れらã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠+-s+ オプションã®å¼•æ•°ã¨ã—ã¦ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã‚’指定ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。POSIX ã¯{{シグナル}}ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦ã‚·ã‚°ãƒŠãƒ«ã®åå‰ã‚’指定ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 POSIX ã¯ã€ã‚·ã‚°ãƒŠãƒ«å㯠+INT+ ã‚„ +QUIT+ ã®ã‚ˆã†ã«æœ€åˆã® SIG を除ã„ãŸå½¢ã§æŒ‡å®šã—ãªã‘れã°ãªã‚‰ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚éž link:posix.html[POSIX 準拠モード]ã® yash ã§ã¯ã€æ‹¡å¼µã¨ã—㦠SIG を付ã‘ãŸå½¢ã§ã‚‚指定ã§ãã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_unalias.txt0000644000175000017500000000177712154557026016255 0ustar magicantmagicant= Unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:syntax.html#aliases[エイリアス]を削除ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +unalias {{エイリアスå}}...+ - +unalias -a+ [[description]] == 説明 Unalias コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸlink:syntax.html#aliases[エイリアス]を削除ã—ã¾ã™ã€‚ [[options]] == オプション +-a+:: +--all+:: å…¨ã¦ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’削除ã—ã¾ã™ã€‚ [[operands]] == オペランド {{エイリアスå}}:: 削除ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š unalias コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚存在ã—ãªã„ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå ´åˆã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ [[notes]] == 補足 Unalias コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/params.txt0000644000175000017500000005167612154557026015750 0ustar magicantmagicant= パラメータã¨å¤‰æ•° :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - パラメータã¨å¤‰æ•° :description: Yash ãŒæ‰±ã†ãƒ‘ラメータã®ç¨®é¡žã‚„ç‰¹åˆ¥ãªæ„味をæŒã¤å¤‰æ•°ã«ã¤ã„㦠dfn:[パラメータ]ã¨ã¯ã€link:expand.html[パラメータ展開]ã§å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã‚‹ãƒ‡ãƒ¼ã‚¿ã‚’言ã„ã¾ã™ã€‚パラメータã«ã¯<>・<>・<>ã®ä¸‰ç¨®é¡žãŒã‚りã¾ã™ã€‚ [[positional]] == ä½ç½®ãƒ‘ラメータ dfn:[ä½ç½®ãƒ‘ラメータ]㯠1 以上ã®è‡ªç„¶æ•°ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるパラメータã§ã™ã€‚例ãˆã°ä½ç½®ãƒ‘ラメータãŒä¸‰ã¤ã‚ã‚‹å ´åˆã€ãれらã¯é †ã« +1+, +2+, +3+ ã¨ã„ã†åç§°ã§è­˜åˆ¥ã•れã¾ã™ã€‚ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã¯<> ã§å–å¾—ã§ãã¾ã™ã€‚ã¾ãŸå…¨ã¦ã®ä½ç½®ãƒ‘ラメータを表ã™ç‰¹æ®Šãƒ‘ラメータã¨ã—㦠+*+ 㨠+@+ ãŒã‚りã¾ã™ã€‚ ä½ç½®ãƒ‘ラメータã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã€ã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã‚’å…ƒã«åˆæœŸåŒ–ã•れã¾ã™ (link:invoke.html#arguments[起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°]å‚ç…§)。引数ã®ã†ã¡ã€ä½ç½®ãƒ‘ラメータã®å€¤ã¨ã—ã¦ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒé †ã«ä¸€ã¤ãšã¤ä½ç½®ãƒ‘ラメータã¨ãªã‚Šã¾ã™ã€‚ シェルã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œä¸­ã«link:exec.html#function[関数]ãŒå‘¼ã³å‡ºã•れるã¨ãã€ä½ç½®ãƒ‘ラメータã¯ãã®é–¢æ•°ã®å‘¼ã³å‡ºã—ã«å¯¾ã™ã‚‹å¼•æ•°ã«å¤‰æ›´ã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€é–¢æ•°ã®å®Ÿè¡Œä¸­ã¯ä½ç½®ãƒ‘ラメータã«ã‚ˆã£ã¦é–¢æ•°ã®å¼•æ•°ã‚’å‚ç…§ã§ãã¾ã™ã€‚関数呼ã³å‡ºã—ã®ç›´å‰ã®ä½ç½®ãƒ‘ラメータã®å€¤ã¯ä¿å­˜ã•れã¦ãŠã‚Šã€é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹éš›ã«å…ƒã®å€¤ã«æˆ»ã‚Šã¾ã™ã€‚ ä½ç½®ãƒ‘ラメータã¯ã€link:_set.html[set] ã‚„ link:_shift.html[shift] ãªã©ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ã‚ˆã£ã¦å¤‰æ›´ã§ãã¾ã™ã€‚ +0+ ã¯ä½ç½®ãƒ‘ラメータã¨ã¯è¦‹ãªã•れã¾ã›ã‚“ (特殊パラメータã®ä¸€ã¤ã§ã™)。 [[special]] == 特殊パラメータ dfn:[特殊パラメータ]ã¯ä¸€æ–‡å­—ã®è¨˜å·ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるパラメータã§ã™ã€‚特殊パラメータã«ã¯ãƒ¦ãƒ¼ã‚¶ãŒæ˜Žç¤ºçš„ã«å€¤ã‚’代入ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 Yash ã§ã¯ä»¥ä¸‹ã®ç‰¹æ®Šãƒ‘ラメータãŒåˆ©ç”¨å¯èƒ½ã§ã™ã€‚ [[sp-zero]]+0+:: ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ä¸Žãˆã‚‰ã‚ŒãŸã‚·ã‚§ãƒ«ã®å®Ÿè¡Œãƒ•ァイルã®åç§°ã¾ãŸã¯ã‚¹ã‚¯ãƒªãƒ—トファイルã®åç§°ã§ã™ã€‚(link:invoke.html#arguments[起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°]å‚ç…§) [[sp-hash]]+#+:: ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã®ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’表㙠0 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚ [[sp-dollar]]+$+:: ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ã‚·ã‚§ãƒ«è‡ªèº«ã®ãƒ—ロセス ID ã‚’è¡¨ã™æ­£ã®æ•´æ•°ã§ã™ã€‚ã“ã®å€¤ã¯ã‚µãƒ–シェルã«ãŠã„ã¦ã‚‚変ã‚りã¾ã›ã‚“。 [[sp-hyphen]]+-+:: ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã‚·ã‚§ãƒ«ã§æœ‰åŠŸã«ãªã£ã¦ã„ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—ã‚’ã¤ãªã’ãŸã‚‚ã®ã§ã™ã€‚ã“ã®å€¤ã«ã¯ã€link:invoke.html[シェルã®èµ·å‹•]時ã«ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§æŒ‡å®šã§ãる一文字ã®ã‚ªãƒ—ションã®ã†ã¡ç¾åœ¨æœ‰åйã«ãªã£ã¦ã„ã‚‹ã‚‚ã®ãŒå…¨ã¦å«ã¾ã‚Œã¾ã™ã€‚link:_set.html[set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚ªãƒ—ションを変更ã—ãŸå ´åˆã¯ã€ãã®å¤‰æ›´ãŒã“ã®ãƒ‘ラメータã®å€¤ã«ã‚‚åæ˜ ã•れã¾ã™ã€‚ [[sp-question]]+?+:: ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€æœ€å¾Œã«çµ‚了ã—ãŸlink:syntax.html#pipelines[パイプライン]ã®çµ‚了ステータスを表㙠0 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚ [[sp-exclamation]]+!+:: ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸlink:syntax.html#async[éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰]ã®ãƒ—ロセス ID ã§ã™ã€‚ [[sp-asterisk]]+*+:: ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã®<>ã®å€¤ã§ã™ã€‚ä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã“ã®ãƒ‘ラメータã®å€¤ã¯ç©ºæ–‡å­—列ã§ã™ã€‚ä½ç½®ãƒ‘ラメータãŒè¤‡æ•°ã‚ã‚‹å ´åˆã€ã“ã®ãƒ‘ラメータã®å€¤ã¯å…¨ã¦ã®ä½ç½®ãƒ‘ラメータã®å€¤ã‚’連çµã—ãŸã‚‚ã®ã§ã™ã€‚å„ä½ç½®ãƒ‘ラメータã®å€¤ã®é–“ã¯ä»¥ä¸‹ã«å¾“ã£ã¦åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ + - 変数 <> ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºã§ãªã„å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯å¤‰æ•° +IFS+ ã®å€¤ã®æœ€åˆã®æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ - 変数 +IFS+ ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºã®å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯é–“ã«ä½•ã‚‚ç½®ã‹ãšã«é€£çµã•れã¾ã™ã€‚ - 変数 +IFS+ ãŒå­˜åœ¨ã—ãªã„å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯ç©ºç™½æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ [[sp-at]]+@+:: ã“ã®ãƒ‘ラメータã¯ã€ãƒ‘ラメータ +*+ ã¨åŒæ§˜ã«ç¾åœ¨ã®å…¨ã¦ã®<>を表ã—ã¾ã™ã€‚ãŸã ã—ã€ã“ã®ãƒ‘ラメータãŒäºŒé‡å¼•用符ã«ã‚ˆã‚‹link:syntax.html#quotes[クォート]ã®ä¸­ã§link:expand.html#params[展開]ã•れる場åˆã®æ‰±ã„ãŒãƒ‘ラメータ +*+ ã¨ç•°ãªã‚Šã¾ã™ã€‚ã“ã®å ´åˆã€å„ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã¯æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã‚‹ã®ã§ã¯ãªãã€(クォートã®å†…部ã§ã‚ã‚‹ã«ã‚‚ã‹ã‹ã‚らãš) link:expand.html#split[å˜èªžåˆ†å‰²]ã•れã¾ã™ã€‚ã¾ãŸä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã“ã®ãƒ‘ラメータã¯å±•開後ã®å˜èªžã«ã¯æ®‹ã‚Šã¾ã›ã‚“。 + 例ãˆã°ä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ +echo 1 "$@" 2+ 㯠++echo++ã€++1++ã€++2++ ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚ä½ç½®ãƒ‘ラメータ㌠++1++ã€++2 2++ã€++3++ ã®ä¸‰ã¤ã®ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ +echo "$@"+ 㯠++echo++ã€++1++ã€++2 2++ã€++3++ ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ +echo "a$@b"+ 㯠++echo++ã€++a1++ã€++2 2++ã€++3b++ ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚ [[variables]] == 変数 dfn:[変数]ã¨ã¯ãƒ¦ãƒ¼ã‚¶ãŒè‡ªç”±ã«ä»£å…¥å¯èƒ½ãªãƒ‘ラメータã§ã™ã€‚å„変数ã¯åå‰ã§åŒºåˆ¥ã•れã€ãれãžã‚ŒãŒæ–‡å­—列ã®å€¤ã‚’æŒã¡ã¾ã™ã€‚ 変数ã®åå‰ã¯ã€è‹±æ•°å­—ã¨ä¸‹ç·š (+_+) ã‹ã‚‰æ§‹æˆã•れã¾ã™ã€‚ãŸã ã—変数åã®é ­æ–‡å­—ã‚’æ•°å­—ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。環境ã«ã‚ˆã£ã¦ã¯ã“ã‚Œä»¥å¤–ã®æ–‡å­—も変数åã«ä½¿ç”¨ã§ãã¾ã™ã€‚ ã‚·ã‚§ãƒ«ãŒæ‰±ã†å¤‰æ•°ã®ã†ã¡ã€ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã®å¯¾è±¡ã¨ãªã£ã¦ã„ã‚‹ã‚‚ã®ã¯dfn:[環境変数]ã¨ã„ã„ã¾ã™ã€‚ã“れらã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ãŒå¤–部コマンドを起動ã™ã‚‹éš›ã«å¤–éƒ¨ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚シェルãŒèµ·å‹•ã•れãŸã¨ãã«ã‚·ã‚§ãƒ«ã‚’èµ·å‹•ã—ãŸãƒ—ログラムã‹ã‚‰æ¸¡ã•れãŸå¤‰æ•°ã¯è‡ªå‹•çš„ã«ç’°å¢ƒå¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚ 変数ã¯ã€link:syntax.html#simple[å˜ç´”コマンド]ã«ã‚ˆã£ã¦ä»£å…¥ã§ãã¾ã™ã€‚ã¾ãŸ link:_typeset.html[typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã©ã§ã‚‚変数ã«ä»£å…¥ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚変数を削除ã™ã‚‹ã«ã¯ link:_unset.html[unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を使ã„ã¾ã™ã€‚ [[shellvars]] === シェルãŒä½¿ç”¨ã™ã‚‹å¤‰æ•° 以下ã®åå‰ã®å¤‰æ•°ã¯ã€yash ã®å®Ÿè¡Œã«ãŠã„ã¦ç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚ [[sv-cdpath]]+CDPATH+:: ã“ã®å¤‰æ•°ã¯ link:_cd.html[cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ç§»å‹•先ディレクトリを検索ã™ã‚‹ãŸã‚ã«ä½¿ã‚れã¾ã™ã€‚ [[sv-columns]]+COLUMNS+:: ã“ã®å¤‰æ•°ã¯ç«¯æœ«ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®æ¨ªå¹… (文字数) を指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã€ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã®æ¨ªå¹…ã§ã¯ãªãã“ã®å¤‰æ•°ã®å€¤ã§æŒ‡å®šã•ã‚ŒãŸæ¨ªå¹…ãŒlink:lineedit.html[行編集]ã§ä½¿ã‚れã¾ã™ã€‚ [[sv-command_not_found_handler]]+COMMAND_NOT_FOUND_HANDLER+:: シェルãŒå®Ÿè¡Œã—よã†ã¨ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œã•れã¾ã™ã€‚䏿˜Žãªã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ãã«ä½•ã‹åˆ¥ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã•ã›ãŸã„時ã«ä¾¿åˆ©ã§ã™ã€‚link:exec.html#simple[å˜ç´”コマンドã®å®Ÿè¡Œ]ã‚’å‚照。 + ã“ã®æ©Ÿèƒ½ã¯ link:posix.html[POSIX 準拠モード]ã§ã¯åƒãã¾ã›ã‚“。 [[sv-dirstack]]+DIRSTACK+:: ã“ã®é…列変数ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å®Ÿè£…ã«ä½¿ã‚れã¦ã„ã¾ã™ã€‚link:_pushd.html[pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’移動ã—ãŸã¨ãã€å‰ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’覚ãˆã¦ãŠããŸã‚ã«ãã®ãƒ‘スåãŒã“ã®é…列ã«å…¥ã‚Œã‚‰ã‚Œã¾ã™ã€‚ã“ã®é…列ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を直接変更ã™ã‚‹ã“ã¨ã«ãªã‚Šã¾ã™ã€‚ [[sv-echo_style]]+ECHO_STYLE+:: ã“ã®å¤‰æ•°ã¯ link:_echo.html[echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã®æŒ™å‹•を指定ã—ã¾ã™ã€‚ [[sv-env]]+ENV+:: link:posix.html[POSIX 準拠モード]ã§å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ã§ç¤ºã•れるパスã®ãƒ•ァイルãŒåˆæœŸåŒ–スクリプトã¨ã—ã¦èª­ã¿è¾¼ã¾ã‚Œã¾ã™ (link:invoke.html#init[シェルã®åˆæœŸåŒ–処ç†]å‚ç…§)。 [[sv-fcedit]]+FCEDIT+:: link:_fc.html[Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã™ã‚‹éš›ã€ã“ã®å¤‰æ•°ã®å€¤ã§ç¤ºã•れãŸã‚¨ãƒ‡ã‚£ã‚¿ãŒã‚³ãƒžãƒ³ãƒ‰ã®ç·¨é›†ã«ä½¿ã‚れã¾ã™ã€‚ [[sv-handled]]+HANDLED+:: ã“ã®å¤‰æ•°ã¯ +COMMAND_NOT_FOUND_HANDLER+ 変数ã®å€¤ãŒå®Ÿè¡Œã•れãŸå¾Œã«ã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã“ã¨ã‚’エラーã¨ã™ã‚‹ã‹ã©ã†ã‹ã‚’指示ã—ã¾ã™ã€‚link:exec.html#simple[å˜ç´”コマンドã®å®Ÿè¡Œ]ã‚’å‚照。 [[sv-histfile]]+HISTFILE+:: link:interact.html#history[コマンド履歴]ã‚’ä¿å­˜ã™ã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚ [[sv-histrmdup]]+HISTRMDUP+:: link:interact.html#history[コマンド履歴]ã®é‡è¤‡ã‚’ãƒã‚§ãƒƒã‚¯ã™ã‚‹å€‹æ•°ã‚’指定ã—ã¾ã™ã€‚履歴ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’追加ã™ã‚‹éš›ã€æ—¢ã«å±¥æ­´ã«ã‚るコマンドã®ã†ã¡ã“ã“ã§æŒ‡å®šã—ãŸå€‹æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ãŒæ–°ã—ã追加ã•れるコマンドã¨åŒã˜ã‹ã©ã†ã‹ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚åŒã˜ã‚³ãƒžãƒ³ãƒ‰ãŒæ—¢ã«å±¥æ­´ã«ã‚れã°ã€ãれã¯å±¥æ­´ã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚ + 例ãˆã°ã“ã®å¤‰æ•°ã®å€¤ãŒ +1+ ã®ã¨ãã¯ã€å±¥æ­´ã«è¿½åŠ ã•れるコマンドãŒä¸€ã¤å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒã˜ãªã‚‰ã°ãれã¯å‰Šé™¤ã•れã¾ã™ã€‚ãれよりå¤ã„履歴ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€(履歴ã«è¿½åŠ ã•れるコマンドã¨åŒã˜ã§ã‚‚) 削除ã•れã¾ã›ã‚“。もã—ã“ã®å¤‰æ•°ã®å€¤ãŒ +HISTSIZE+ 変数ã®å€¤ã¨åŒã˜ãªã‚‰ã€å±¥æ­´ã®ä¸­ã§é‡è¤‡ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã™ã¹ã¦å‰Šé™¤ã•れã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã‚‚ã—ã“ã®å¤‰æ•°ã®å€¤ãŒ +0+ ãªã‚‰ã€é‡è¤‡ã™ã‚‹å±¥æ­´ã¯ä¸€åˆ‡å‰Šé™¤ã•れã¾ã›ã‚“。 [[sv-histsize]]+HISTSIZE+:: link:interact.html#history[コマンド履歴]ã«ä¿å­˜ã•れる履歴項目ã®å€‹æ•°ã‚’指定ã—ã¾ã™ã€‚ [[sv-home]]+HOME+:: ユーザã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを指定ã—ã¾ã™ã€‚link:expand.html#tilde[ãƒãƒ«ãƒ€å±•é–‹]ã‚„ link:_cd.html[cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚ [[sv-ifs]]+IFS+:: ã“ã®å¤‰æ•°ã¯link:expand.html#split[å˜èªžåˆ†å‰²]ã®åŒºåˆ‡ã‚Šã‚’指定ã—ã¾ã™ã€‚シェルã®èµ·å‹•時ã«ã“ã®å¤‰æ•°ã®å€¤ã¯ç©ºç™½æ–‡å­—・タブ・改行ã®ä¸‰æ–‡å­—ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ [[sv-lang]]+LANG+:: [[sv-lc_all]]+LC_ALL+:: [[sv-lc_collate]]+LC_COLLATE+:: [[sv-lc_ctype]]+LC_CTYPE+:: [[sv-lc_messages]]+LC_MESSAGES+:: [[sv-lc_monetary]]+LC_MONETARY+:: [[sv-lc_numeric]]+LC_NUMERIC+:: [[sv-lc_time]]+LC_TIME+:: ã“れらã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ãŒå‹•作ã™ã‚‹ãƒ­ã‚±ãƒ¼ãƒ«ã‚’指定ã—ã¾ã™ã€‚シェルãŒèª­ã¿æ›¸ãã™ã‚‹ãƒ•ァイルã®ã‚¨ãƒ³ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°ã‚„エラーメッセージã®å†…容ãªã©ã¯ã“ã®å¤‰æ•°ã§æŒ‡å®šã•れãŸãƒ­ã‚±ãƒ¼ãƒ«ã«å¾“ã„ã¾ã™ã€‚ + +LC_CTYPE+ 変数ã®å€¤ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã®ã¿å映ã•れã¾ã™ã€‚シェルã®å®Ÿè¡Œä¸­ã«ã“ã®å¤‰æ•°ã‚’変更ã—ã¦ã‚‚シェルã®ãƒ­ã‚±ãƒ¼ãƒ«ã¯å¤‰ã‚りã¾ã›ã‚“ (シェルãŒéž link:posix.html[POSIX 準拠モード]ã§link:interact.html[対話モード]ã®å ´åˆã‚’除ã)。 [[sv-lineno]]+LINENO+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€ç¾åœ¨ã‚·ã‚§ãƒ«ãŒèª­ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¦ã„るファイルã«ãŠã‘ã‚‹ã€ç¾åœ¨å®Ÿè¡Œä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã®ã‚る行番å·ã‚’示ã—ã¾ã™ã€‚(link:interact.html[対話モード]ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã—ã¦å®Ÿè¡Œã™ã‚‹ãŸã³ã«è¡Œç•ªå·ã¯ 1 ã«æˆ»ã‚Šã¾ã™) + 一度ã“ã®å¤‰æ•°ã«ä»£å…¥ã—ãŸã‚Šå¤‰æ•°ã‚’削除ã—ãŸã‚Šã™ã‚‹ã¨ã€ã“ã®å¤‰æ•°ã‚’用ã„ã¦è¡Œç•ªå·ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ [[sv-lines]]+LINES+:: ã“ã®å¤‰æ•°ã¯ç«¯æœ«ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®è¡Œæ•°ã‚’指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã€ãƒ‡ãƒ•ォルトã®è¡Œæ•°ã§ã¯ãªãã“ã®å¤‰æ•°ã®å€¤ã§æŒ‡å®šã•れãŸè¡Œæ•°ãŒlink:lineedit.html[行編集]ã§ä½¿ã‚れã¾ã™ã€‚ [[sv-mail]]+MAIL+:: ã“ã®å¤‰æ•°ã¯link:interact.html#mailcheck[メールãƒã‚§ãƒƒã‚¯]ã®å¯¾è±¡ã¨ãªã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚ [[sv-mailcheck]]+MAILCHECK+:: ã“ã®å¤‰æ•°ã¯link:interact.html#mailcheck[メールãƒã‚§ãƒƒã‚¯]を行ã†é–“隔を秒å˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠+600+ ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ [[sv-mailpath]]+MAILPATH+:: ã“ã®å¤‰æ•°ã¯link:interact.html#mailcheck[メールãƒã‚§ãƒƒã‚¯]ã®å¯¾è±¡ã¨ãªã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚ [[sv-nlspath]]+NLSPATH+:: POSIX ã«ã‚ˆã‚‹ã¨ã“ã®å¤‰æ•°ã®å€¤ã¯ãƒ­ã‚±ãƒ¼ãƒ«ä¾å­˜ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒ‡ãƒ¼ã‚¿ãƒ•ァイルã®ãƒ‘スを指示ã™ã‚‹ã“ã¨ã«ãªã£ã¦ã„ã¾ã™ãŒã€yash ã§ã¯ä½¿ç”¨ã—ã¦ã„ã¾ã›ã‚“。 [[sv-oldpwd]]+OLDPWD+:: link:_cd.html[Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã©ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ãŸã¨ãã«ã€å¤‰æ›´å‰ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ‘スãŒã“ã®å¤‰æ•°ã«è¨­å®šã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ãƒ‡ãƒ•ォルトã§ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚ [[sv-optarg]]+OPTARG+:: link:_getopts.html[Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§å¼•数付ãã®ã‚ªãƒ—ションを読ã¿è¾¼ã‚“ã ã¨ãã€ãã®å¼•æ•°ã®å€¤ãŒã“ã®å¤‰æ•°ã«è¨­å®šã•れã¾ã™ã€‚ [[sv-optind]]+OPTIND+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€link:_getopts.html[getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§æ¬¡ã«èª­ã¿è¾¼ã‚€ã‚ªãƒ—ションã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’表ã—ã¾ã™ã€‚シェルã®èµ·å‹•時ã«ã“ã®å¤‰æ•°ã¯ +1+ ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ [[sv-path]]+PATH+:: ã“ã®å¤‰æ•°ã¯ã€link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢æ™‚]ã«ã‚³ãƒžãƒ³ãƒ‰ã®ã‚りã‹ã‚’示ã™ãƒ‘スを指定ã—ã¾ã™ã€‚ [[sv-ppid]]+PPID+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€ã‚·ã‚§ãƒ«ã®è¦ªãƒ—ロセスã®ãƒ—ロセス ID ã‚’è¡¨ã™æ­£ã®æ•´æ•°ã§ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯link:exec.html#subshell[サブシェル]ã«ãŠã„ã¦ã‚‚変ã‚りã¾ã›ã‚“。 [[sv-prompt_command]]+PROMPT_COMMAND+:: link:posix.html[POSIX 準拠モード]ã§ãªã„link:interact.html[対話モード]ã®ã‚·ã‚§ãƒ«ã«ãŠã„ã¦ã€ã‚·ã‚§ãƒ«ãŒå„コマンドã®ãƒ—ロンプトを出ã™ç›´å‰ã«ã€ã“ã®å¤‰æ•°ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ã€‚ã“れã¯ã€ãƒ—ロンプトを出ã™ç›´å‰ã«æ¯Žå›ž ifdef::basebackend-html[] pass:[eval -i -- "${PROMPT_COMMAND-}"] endif::basebackend-html[] ifndef::basebackend-html[`eval -i -- "${PROMPT_COMMAND-}"`] ã¨ã„ã†ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã®ã¨åŒã˜ã§ã™ãŒã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œçµæžœã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã® +?+ 特殊パラメータã®å€¤ã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。 [[sv-ps1]]+PS1+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‡ºåŠ›ã™ã‚‹æ¨™æº–ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ—ロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯link:interact.html#prompt[プロンプト]ã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 + ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠+\$ + ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚(link:posix.html[POSIX 準拠モード] ãªã‚‰å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ㌠0 ã‹ã©ã†ã‹ã«ã‚ˆã£ã¦ +$ + 㨠+# + ã®ã©ã¡ã‚‰ã‹) [[sv-ps1r]]+PS1R+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€éš›ã«ã€å…¥åŠ›ã•れるコマンドã®å³å´ã«è¡¨ç¤ºã•れるプロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯link:interact.html#prompt[プロンプト]ã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 [[sv-ps1s]]+PS1S+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€éš›ã«ã€å…¥åŠ›ã•れるコマンドを表示ã™ã‚‹ãƒ•ã‚©ãƒ³ãƒˆã®æ›¸å¼ã‚’指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯link:interact.html#prompt[プロンプト]ã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 [[sv-ps2]]+PS2+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‡ºåŠ›ã™ã‚‹è£œåŠ©çš„ãªã‚³ãƒžãƒ³ãƒ‰ãƒ—ロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯link:interact.html#prompt[プロンプト]ã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠+> + ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ [[sv-ps2r]]+PS2R+:: ã“ã®å¤‰æ•°ã¯ <> 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠<> 変数ã§ã¯ãªã <> 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚ [[sv-ps2s]]+PS2S+:: ã“ã®å¤‰æ•°ã¯ <> 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠<> 変数ã§ã¯ãªã <> 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚ [[sv-ps4]]+PS4+:: link:_set.html#options[Xtrace オプション]ãŒæœ‰åйãªã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ãŒå„トレース出力ã®å‰ã«å‡ºåŠ›ã•れã¾ã™ã€‚ãŸã ã—出力ã®å‰ã«ã“ã®å¤‰æ•°ã®å€¤ã«å¯¾ã—ã¦link:expand.html#params[パラメータ展開]ã€link:expand.html#cmdsub[コマンド置æ›]ã€link:expand.html#arith[æ•°å¼å±•é–‹]を行ã„ã¾ã™ã€‚ã¾ãŸ link:posix.html[POSIX 準拠モード]ã§ãªã‘れã°ã€<> 変数ã¨åŒæ§˜ã«ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ç‰¹æ®Šãªè¨˜æ³•ãŒåˆ©ç”¨ã§ãã¾ã™ã€‚ + ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠++ + ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ [[sv-ps4s]]+PS4S+:: ã“ã®å¤‰æ•°ã¯ <> 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠<> 変数ãŒä½¿ç”¨ã•れるã¨ãã§ã¯ãªãã€ãƒˆãƒ¬ãƒ¼ã‚¹å‡ºåŠ›ã®éš›ã« <> 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã‚’使ã†ã¨ãƒˆãƒ¬ãƒ¼ã‚¹å‡ºåŠ›ã®ãƒ•ã‚©ãƒ³ãƒˆã®æ›¸å¼ã‚’変更ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ [[sv-pwd]]+PWD+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スを表ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æ­£ã—ã„パスã«åˆæœŸåŒ–ã•れã€link:_cd.html[cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã©ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã™ã‚‹åº¦ã«å†è¨­å®šã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ãƒ‡ãƒ•ォルトã§ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚ [[sv-random]]+RANDOM+:: ã“ã®å¤‰æ•°ã¯ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ 0 以上 32768 未満ã®ä¸€æ§˜åˆ†å¸ƒä¹±æ•°ã«ãªã£ã¦ã„ã¾ã™ã€‚ + ã“ã®å¤‰æ•°ã«éžè² æ•´æ•°ã‚’代入ã™ã‚‹ã¨ä¹±æ•°ã‚’生æˆã™ã‚‹__種__ã‚’å†è¨­å®šã§ãã¾ã™ã€‚ + 一度ã“ã®å¤‰æ•°ã‚’削除ã™ã‚‹ã¨ã€ã“ã®å¤‰æ•°ã‚’用ã„ã¦ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ã¾ãŸã‚·ã‚§ãƒ«ãŒ link:posix.html[POSIX 準拠モード]ã§èµ·å‹•ã•れãŸå ´åˆã€ã“ã®å¤‰æ•°ã§ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 [[sv-term]]+TERM+:: ã“ã®å¤‰æ•°ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‹•作ã—ã¦ã„る端末ã®ç¨®é¡žã‚’指定ã—ã¾ã™ã€‚ã“ã“ã§æŒ‡å®šã•れãŸç«¯æœ«ã®ç¨®é¡žã«å¾“ã£ã¦link:lineedit.html[行編集]機能ã¯ç«¯æœ«ã‚’制御ã—ã¾ã™ã€‚ [[sv-yash_after_cd]]+YASH_AFTER_CD+:: ã“ã®å¤‰æ•°ã®å€¤ã¯ã€link:_cd.html[cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã‚„ link:_pushd.html[pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒå¤‰æ›´ã•れãŸå¾Œã«ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ã€‚ã“れã¯ã€ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒå¤‰ã‚ã£ãŸå¾Œã«æ¯Žå›ž ifdef::basebackend-html[] pass:[eval -i -- "${YASH_AFTER_CD-}"] endif::basebackend-html[] ifndef::basebackend-html[`eval -i -- "${YASH_AFTER_CD-}"`] ã¨ã„ã†ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã®ã¨åŒã˜ã§ã™ã€‚ [[sv-yash_loadpath]]+YASH_LOADPATH+:: link:_dot.html[ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§èª­ã¿è¾¼ã‚€ã‚¹ã‚¯ãƒªãƒ—トファイルã®ã‚るディレクトリを指定ã—ã¾ã™ã€‚<> 変数ã¨åŒæ§˜ã«ã€ã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦è¤‡æ•°ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’指定ã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã€yash ã«ä»˜å±žã—ã¦ã„る共通スクリプトã®ã‚るディレクトリåã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ [[sv-yash_le_timeout]]+YASH_LE_TIMEOUT+:: ã“ã®å¤‰æ•°ã¯link:lineedit.html[行編集]æ©Ÿèƒ½ã§æ›–æ˜§ãªæ–‡å­—シーケンスãŒå…¥åŠ›ã•れãŸã¨ãã«ã€å…¥åŠ›æ–‡å­—ã‚’ç¢ºå®šã•ã›ã‚‹ãŸã‚ã«ã‚·ã‚§ãƒ«ãŒå¾…ã¤æ™‚間をミリ秒å˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚行編集を行ã†éš›ã«ã“ã®å¤‰æ•°ãŒå­˜åœ¨ã—ãªã‘れã°ã€ãƒ‡ãƒ•ォルトã¨ã—㦠100 ãƒŸãƒªç§’ãŒæŒ‡å®šã•れã¾ã™ã€‚ [[sv-yash_version]]+YASH_VERSION+:: ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã‚·ã‚§ãƒ«ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ [[arrays]] === é…列 dfn:[é…列]ã¨ã¯ã€ä¸€ã¤ã®å¤‰æ•°ã«è¤‡æ•°ã®å€¤ (文字列) ã‚’æŒãŸã›ãŸã‚‚ã®ã§ã™ã€‚一ã¤ã®é…列ã®è¤‡æ•°ã®å€¤ã¯<>ã¨åŒæ§˜ã« 1 以上ã®è‡ªç„¶æ•°ã§è­˜åˆ¥ã•れã¾ã™ã€‚ é…列ã¯ã€link:syntax.html#simple[å˜ç´”コマンド]ã«ã‚ˆã£ã¦ä»£å…¥ã§ãã¾ã™ã€‚ã¾ãŸ link:_array.html[array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã©ã§ã‚‚é…列ã«ä»£å…¥ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚é…列を削除ã™ã‚‹ã«ã¯å¤‰æ•°ã¨åŒæ§˜ã« link:_unset.html[unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を使ã„ã¾ã™ã€‚ é…列をé…列ã®ã¾ã¾ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。é…列をエクスãƒãƒ¼ãƒˆã—よã†ã¨ã™ã‚‹ã¨ã€é…列ã®å„値をコロンã§åŒºåˆ‡ã£ã¦ç¹‹ã„ã ä¸€ã¤ã®æ–‡å­—列ã®å€¤ã‚’æŒã¤å¤‰æ•°ã¨ã—ã¦ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã•れã¾ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ã¯é…列ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_false.txt0000644000175000017500000000117712154557026015705 0ustar magicantmagicant= False 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - False 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[False 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ä½•も行ã‚ãšã«éž 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +false+ [[description]] == 説明 False コマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス False コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 False コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_return.txt0000644000175000017500000000537412154557026016135 0ustar magicantmagicant= Return 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Return 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Return 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®link:exec.html#function[関数]ã¾ãŸã¯ã‚¹ã‚¯ãƒªãƒ—トã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +return [-n] [{{終了ステータス}}]+ [[description]] == 説明 +-n+ (+--no-return+) オプションを付ã‘ãšã« return コマンドを実行ã™ã‚‹ã¨ã€ä»¥ä¸‹ã®ã†ã¡å½“ã¦ã¯ã¾ã‚‹å‹•作を行ã„ã¾ã™: - link:exec.html#function[関数]ã®å®Ÿè¡Œä¸­ã®å ´åˆã¯ã€ãã®é–¢æ•°ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ - link:_dot.html[ドットコマンド]ã§ãƒ•ァイルを開ã„ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã„る途中ã®å ´åˆã¯ã€ãã®ãƒ•ァイルã®èª­ã¿è¾¼ã¿ãƒ»å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ - link:_eval.html[Eval コマンド]ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã„る途中ã®å ´åˆã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ - ã“れ以外ã®å ´åˆã¯ã€(link:interact.html[対話モード]ã®ã¨ãを除ã„ã¦) シェルã¯çµ‚了ã—ã¾ã™ã€‚ +-n+ (+--no-return+) オプションを付ã‘㦠return コマンドを実行ã™ã‚‹ã¨ã€return コマンドã¯ãŸã å˜ã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã•れã¦ã„る終了ステータスを返ã—ã¾ã™ã€‚ [[options]] == オプション +-n+:: +--no-return+:: コマンドã®å®Ÿè¡Œã‚’中断ã—ã¾ã›ã‚“。 [[operands]] == オペランド {{終了ステータス}}:: Return コマンドã®çµ‚了ステータスを指定ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ + ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€return コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを用ã„ã¾ã™ (ãŸã ã—link:_trap.html[トラップ]を実行中ã®å ´åˆã¯ãƒˆãƒ©ãƒƒãƒ—ã«å…¥ã‚‹ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス)。 [[exitstatus]] == 終了ステータス Return コマンドã®çµ‚了ステータスã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸå€¤ã§ã™ã€‚Return コマンドã®çµ‚了ステータス㯠return コマンドãŒçµ‚了ã™ã‚‹é–¢æ•°ãƒ»ãƒ‰ãƒƒãƒˆã‚³ãƒžãƒ³ãƒ‰ãƒ»eval コマンド・シェル自身ã®çµ‚了ステータスã«ã‚‚ãªã‚Šã¾ã™ã€‚ [[notes]] == 補足 Return コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã§ã¯ã€{{終了ステータス}}ã®å€¤ã¯ 0 以上 256 未満ã§ãªã‘れã°ãªã‚‰ãªã„ã¨ã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯æ‹¡å¼µã¨ã—㦠256 以上ã®å€¤ã‚‚å—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ POSIX ã§ã¯é–¢æ•°ã‚ã‚‹ã„ã¯ãƒ‰ãƒƒãƒˆã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œä¸­ä»¥å¤–ã«ãŠã‘ã‚‹ return コマンドã®å‹•作を定ã‚ã¦ã„ã¾ã›ã‚“。 POSIX ã«ã¯ +-n+ (+--no-return+) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_cd.txt0000644000175000017500000001006612154557026015176 0ustar magicantmagicant= Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +cd [-L|-P] [{{ディレクトリ}}]+ [[description]] == 説明 Cd コマンドã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚æ–°ã—ã„作業ディレクトリã«å¿œã˜ã¦ link:params.html#sv-pwd[+PWD+ 変数]ã®å€¤ãŒå†è¨­å®šã•れるã¨ã¨ã‚‚ã«ã€å‰ã® +PWD+ 変数ã®å€¤ãŒ link:params.html#sv-oldpwd[+OLDPWD+ 変数]ã«è¨­å®šã•れã¾ã™ã€‚ 指定ã—ãŸ{{ディレクトリ}}ãŒç›¸å¯¾ãƒ‘スã®å ´åˆ (最åˆãŒ +.+ ã¾ãŸã¯ +..+ ã§å§‹ã¾ã‚‹ã‚‚ã®ã‚’除ã)ã€link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢]ã«ãŠã‘ã‚‹ link:params.html#sv-path[+PATH+ 変数]ã®æ¤œç´¢ã¨åŒæ§˜ã«ã—ã¦ã€link:params.html#sv-cdpath[+CDPATH+ 変数]ã®å€¤ã«ã‚るコロンã§åŒºåˆ‡ã£ãŸå„ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªå†…ã«æŒ‡å®šã—ãŸ{{ディレクトリ}}ãŒã‚ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ã€‚ディレクトリãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¯ã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæ–°ã—ã„作業ディレクトリã«ãªã‚Šã¾ã™ã€‚見ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€{{ディレクトリ}}ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘スã¨ãªã‚Šã¾ã™ã€‚ +CDPATH+ å¤‰æ•°ã®æ¤œç´¢ã§æ–°ã—ã„作業ディレクトリãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¾ãŸã¯{{ディレクトリ}}ã¨ã—㦠+-+ ãŒæŒ‡å®šã•れãŸå ´åˆã¯æ–°ã—ã„作業ディレクトリã®ãƒ‘スを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ 作業ディレクトリã®å¤‰æ›´ã«æˆåŠŸã—ãŸå ´åˆã€link:params.html#sv-yash_after_cd[+YASH_AFTER_CD+ 変数]ãŒè¨­å®šã•れã¦ã„れã°ãã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ (éž link:posix.html[POSIX 準拠モード]時)。 [[options]] == オプション +-L+:: +--logical+:: ディレクトリパスã«å«ã¾ã‚Œã‚‹ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’解決ã›ãšã«æ–°ã—ã„作業ディレクトリを決定ã—ã¾ã™ã€‚æ–°ã—ã„ +PWD+ 変数ã®å€¤ã«ã¯ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã«ãªã£ã¦ã„るパスåコンãƒãƒ¼ãƒãƒ³ãƒˆãŒãã®ã¾ã¾æ®‹ã‚Šã¾ã™ã€‚ +-P+:: +--physical+:: ディレクトリパスã«å«ã¾ã‚Œã‚‹ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’解決ã—ã¾ã™ã€‚æ–°ã—ã„ +PWD+ 変数ã®å€¤ã¯ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’å«ã¿ã¾ã›ã‚“。 +--default-directory={{ディレクトリ}}+:: {{ディレクトリ}}オペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€ä»£ã‚りã«ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸ{{ディレクトリ}}ã‚’æ–°ã—ã„作業ディレクトリã¨ã—ã¾ã™ã€‚ +-L+ (+--logical+) オプション㨠+-P+ (+--physical+) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€+-L+ を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ [[operands]] == オペランド {{ディレクトリ}}:: æ–°ã—ã„作業ディレクトリã®ãƒ‘スåã§ã™ã€‚絶対パスã¾ãŸã¯å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘ã‚¹ã§æŒ‡å®šã—ã¾ã™ã€‚ + ã“ã®å€¤ãŒãƒã‚¤ãƒ•ン一㤠(`-') ã®å ´åˆã€link:params.html#sv-oldpwd[+OLDPWD+ 変数]ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€link:params.html#sv-home[+HOME+ 変数]ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (+--default-directory+ オプションを指定ã—ãŸå ´åˆã‚’除ã)。 [[exitstatus]] == 終了ステータス 作業ディレクトリを正ã—ã変更ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 Cd コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ +YASH_AFTER_CD+ 変数ãŠã‚ˆã³ +--default-directory=...+ オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。POSIX ã¯{{ディレクトリ}}ã¨ã—ã¦ãƒã‚¤ãƒ•ン一ã¤ã‚’指定ã—ãŸã¨ãã« +-L+ ã¾ãŸã¯ +-P+ オプションを併用ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 +YASH_AFTER_CD+ 変数ã®å®Ÿè¡Œçµæžœã¯ cd コマンドã®çµ‚了ステータスã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_command.txt0000644000175000017500000001264512154557026016233 0ustar magicantmagicant= Command 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Command 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Command 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ã¾ãŸã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã‚’特定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +command [-befp] {{コマンド}} [{{引数}}...]+ - +command -v|-V [-abefkp] {{コマンド}}...+ [[description]] == 説明 +-v+ (+--identify+) オプションãªã‚‰ã³ã« +-V+ (+--verbose-identify+) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€command コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸ{{コマンド}}を与ãˆã‚‰ã‚ŒãŸ{{引数}}ã§å®Ÿè¡Œã—ã¾ã™ã€‚コマンドã®å®Ÿè¡Œã®ä»•æ–¹ã¯link:exec.html#simple[å˜ç´”コマンドã®å®Ÿè¡Œ]ã®æœ€å¾Œã®ã‚¹ãƒ†ãƒƒãƒ—ã«æº–ã˜ã¾ã™ãŒã€link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢]ã§ã¯å¤–部コマンド・組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»é–¢æ•°ã®å†…ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸã‚‚ã®ã—ã‹æ¤œç´¢ã—ã¾ã›ã‚“。ã¾ãŸã‚³ãƒžãƒ³ãƒ‰ãŒlink:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã®å ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ãŸã‚Šãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã‚„代入エラーãŒèµ·ããŸã‚Šã—ã¦ã‚‚シェルã¯çµ‚了ã—ã¾ã›ã‚“。 +-v+ (+--identify+) オプションã¾ãŸã¯ +-V+ (+--verbose-identify+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€command コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸ{{コマンド}}ã®ç¨®é¡žã¨ãƒ‘スを特定ã—ãれを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚{{コマンド}}ã¯link:syntax.html#aliases[エイリアス]ã‚„link:exec.html#function[関数]ã§ã‚ã£ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 +-v+ (+--identify+) オプションを付ã‘ã¦å®Ÿè¡Œã—ãŸã¨ãã®å‡ºåŠ›ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ - link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢]ã®çµæžœè¦‹ã¤ã‹ã£ãŸã‚³ãƒžãƒ³ãƒ‰ãŠã‚ˆã³ãã®ä»–ã®å¤–部コマンドã¯ã€ãã®çµ¶å¯¾ãƒ‘スを出力ã—ã¾ã™ã€‚ - ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ã‚ˆã‚‰ãšå®Ÿè¡Œã•れる組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„関数ã¯ã€å˜ã«ãã®åå‰ã‚’出力ã—ã¾ã™ã€‚ - link:syntax.html#tokens[予約語]ã¯ã€å˜ã«ãã®åå‰ã‚’出力ã—ã¾ã™ã€‚ - エイリアスã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œå¯èƒ½ãªå½¢å¼ã§ãã®åå‰ã¨å€¤ã‚’出力ã—ã¾ã™ã€‚ - コマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€ä½•も出力ã—ã¾ã›ã‚“。(終了ステータスãŒéž 0 ã«ãªã‚Šã¾ã™) +-V+ (+--verbose-identify+) オプション使用時ã¯ã€å‡ºåŠ›ã®å½¢å¼ãŒäººé–“ã«ã¨ã£ã¦ã‚ˆã‚Šèª­ã¿ã‚„ã™ããªã‚Šã¾ã™ã€‚ [[options]] == オプション +-a+:: +--alias+:: {{コマンド}}ã¨ã—ã¦link:syntax.html#aliases[エイリアス]を検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ +-v+ (+--identify+) ã¾ãŸã¯ +-V+ (+--verbose-identify+) オプションã¨ä¸€ç·’ã«ä½¿ã†å¿…è¦ãŒã‚りã¾ã™ã€‚ +-b+:: +--builtin-command+:: {{コマンド}}ã¨ã—ã¦çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ +-e+:: +--external-command+:: {{コマンド}}ã¨ã—ã¦å¤–部コマンドを検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ +-f+:: +--function+:: {{コマンド}}ã¨ã—ã¦é–¢æ•°ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ +-k+:: +--keyword+:: {{コマンド}}ã¨ã—ã¦äºˆç´„語を検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ +-v+ (+--identify+) ã¾ãŸã¯ +-V+ (+--verbose-identify+) オプションã¨ä¸€ç·’ã«ä½¿ã†å¿…è¦ãŒã‚りã¾ã™ã€‚ +-p+:: +--standard-path+:: link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢]ã«ãŠã„ã¦ã€link:params.html#sv-path[+PATH+ 変数]ã®ä»£ã‚りã«ã€æ¨™æº–ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’ã™ã¹ã¦å«ã‚€ã‚ˆã†ãªã‚·ã‚¹ãƒ†ãƒ å›ºæœ‰ã®ãƒ‡ãƒ•ォルトパスを用ã„ã¦å¤–部コマンドを検索ã—ã¾ã™ã€‚ +-v+:: +--identify+:: 与ãˆã‚‰ã‚ŒãŸ{{コマンド}}ã®ç¨®é¡žã¨ãƒ‘スを特定ã—ã€ç°¡å˜ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ +-V+:: +--verbose-identify+:: 与ãˆã‚‰ã‚ŒãŸ{{コマンド}}ã®ç¨®é¡žã¨ãƒ‘スを特定ã—ã€äººé–“ã«ã¨ã£ã¦èª­ã¿ã‚„ã™ã„å½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ +-a+ (+--alias+), +-b+ (+--builtin-command+), +-e+ (+--external-command+), +-f+ (+--function+), +-k+ (+--keyword+) オプションã®ã©ã‚Œã‚‚指定ã—ãªã‹ã£ãŸå ´åˆã¯ã€ä»¥ä¸‹ã®ã‚ªãƒ—ションを指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ +-v+ (+--identify+) ã‚ã‚‹ã„㯠+-V+ (+--verbose-identify+) オプションを指定ã—ã¦ã„ãªã„ã¨ã:: +-b -e+ +-v+ (+--identify+) ã¾ãŸã¯ +-V+ (+--verbose-identify+) オプションを指定ã—ã¦ã„ã‚‹ã¨ã:: +-a -b -e -f -k+ [[operands]] == オペランド {{コマンド}}:: 実行ã™ã‚‹ã¾ãŸã¯ç¨®é¡žã‚’特定ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã§ã™ã€‚ {{引数}}...:: 実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚ [[exitstatus]] == 終了ステータス +-v+ (+--identify+) ã‚ã‚‹ã„㯠+-V+ (+--verbose-identify+) オプションを指定ã—ã¦ã„ãªã„ã¨ã:: 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス +-v+ (+--identify+) ã¾ãŸã¯ +-V+ (+--verbose-identify+) オプションを指定ã—ã¦ã„ã‚‹ã¨ã:: エラーãŒãªã„é™ã‚Š 0 [[notes]] == 補足 Command コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«è¦å®šã®ã‚るオプション㯠+-p+, +-v+, +-V+ ã ã‘ã§ã™ã€‚ã“れ以外ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯ +-v+ ã¾ãŸã¯ +-V+ オプションを使用ã™ã‚‹ã¨ã{{コマンド}}ã¯ã¡ã‚‡ã†ã©ä¸€ã¤ã—ã‹æŒ‡å®šã§ãã¾ã›ã‚“。 POSIX 㯠+-v+ オプション㨠+-V+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«æŒ‡å®šã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。Yash ã§ã¯ã“れら二ã¤ã®ã‚ªãƒ—ションを両方指定ã™ã‚‹ã¨æœ€å¾Œã«æŒ‡å®šã—ãŸã‚‚ã®ãŒæœ‰åйã«ãªã‚Šã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/builtin.html0000644000175000017500000002343612154557026016251 0ustar magicantmagicant 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨ã¯ã‚·ã‚§ãƒ«ã«å†…蔵ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¤–部ã®ãƒ—ログラムを起動ã™ã‚‹ã“ã¨ãªãシェル自身ã«ã‚ˆã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚

組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡ž

Yash ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ä¸‰ç¨®é¡žã«åˆ†ã‘られã¾ã™ã€‚

特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ä»–ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚ˆã‚Šã‚‚特ã«é‡è¦ãªã‚³ãƒžãƒ³ãƒ‰ã§ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã¯ç•°ãªã‚‹æ€§è³ªã‚’ã„ãã¤ã‹æŒã£ã¦ã„ã¾ã™ã€‚ã¾ãšã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¯¾å¿œã™ã‚‹å¤–部コマンドã®å­˜åœ¨ã«é–¢ä¿‚ãªã常ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã¾ãŸç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã‘る変数代入ã®çµæžœã¯ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã‚‚残りã¾ã™ã€‚ã•ら㫠POSIX 準拠モードã§ã¯ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã¾ãŸã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã‚ã‚‹ã„ã¯ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ãªã‘れã°ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«éž 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚

準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«æ¬¡ã„ã§é‡è¦ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã€å¯¾å¿œã™ã‚‹å¤–部コマンドã®å­˜åœ¨ã«é–¢ä¿‚ãªã常ã«å®Ÿè¡Œã•れã¾ã™ã€‚ãã®ä»–ã®ç‚¹ã§ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨åŒã˜ã§ã™ã€‚

外部コマンドã¨ã—ã¦å®Ÿè£…å¯èƒ½ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„ POSIX ã«è¦å®šã•れã¦ã„ãªã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’å«ã‚€ã€é‡è¦åº¦ã®ä½Žã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚POSIX 準拠モードã§ã¯ã€é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¯¾å¿œã™ã‚‹å¤–部コマンド㌠PATH å¤‰æ•°ã®æ¤œç´¢ã§è¦‹ã¤ã‹ã£ãŸå ´åˆã®ã¿å®Ÿè¡Œã•れã¾ã™ã€‚

コマンドã®å¼•æ•°ã®æ§‹æ–‡

ã“ã“ã§ã¯çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã«é–¢ã™ã‚‹ä¸€èˆ¬çš„ãªè¦å‰‡ã«ã¤ã„ã¦èª¬æ˜Žã—ã¾ã™ã€‚Yash ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã®æŒ‡å®šãƒ»è§£é‡ˆã®ä»•æ–¹ã¯ã€ä»–ã«æ–­ã‚ŠãŒãªã„é™ã‚Šã“ã®è¦å‰‡ã«å¾“ã„ã¾ã™ã€‚

コマンドã®å¼•æ•°ã¯ã€ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®äºŒç¨®é¡žã«åˆ†ã‘られã¾ã™ã€‚オプションã¯ãƒã‚¤ãƒ•ン (-) ã§å§‹ã¾ã‚‹å¼•æ•°ã§ã€ä¸»ã«ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作を変更ã™ã‚‹ã®ã«ä½¿ã‚れã¾ã™ã€‚オプションã®ä¸­ã«ã¯ãれã«å¯¾å¿œã™ã‚‹å¼•æ•°ã‚’ã¨ã‚‹ã‚‚ã®ã‚‚ã‚りã¾ã™ã€‚オペランドã¯ã‚ªãƒ—ション以外ã®å¼•æ•°ã§ã€ä¸»ã«ã‚³ãƒžãƒ³ãƒ‰ãŒå‡¦ç†ã‚’行ã†å¯¾è±¡ã‚’指定ã™ã‚‹ã®ã«ä½¿ã‚れã¾ã™ã€‚

一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ã‚ªãƒ—ションを与ãˆã‚‹å ´åˆã€åŽŸå‰‡ã¨ã—ã¦ãれらã®ã‚ªãƒ—ションã®é †åºã¯ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作ã«å½±éŸ¿ã—ã¾ã›ã‚“。ã—ã‹ã—オペランドã®é †åºã«ã¯æ„味ãŒã‚りã¾ã™ã€‚

オプションã«ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã¨é•·ã„オプションã¨ãŒã‚りã¾ã™ã€‚一文字ã®ã‚ªãƒ—ションã¯è‹±æ•°å­—一文字ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるオプションã§ã™ã€‚é•·ã„オプションã¯ã‚‚ã£ã¨é•·ã„文字列ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるオプションã§ã™ã€‚POSIX è¦æ ¼ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã«ã¤ã„ã¦ã—ã‹è¦å®šã—ã¦ã„ãªã„ãŸã‚ã€POSIX 準拠モードã§ã¯é•·ã„オプションã¯ä½¿ãˆã¾ã›ã‚“。

一文字ã®ã‚ªãƒ—ションã¯ã€ä¸€ã¤ã®ãƒã‚¤ãƒ•ンã¨ä¸€æ–‡å­—ã®è‹±æ•°å­—ã‹ã‚‰ãªã‚Šã¾ã™ã€‚例ãˆã° -a ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã§ã™ã€‚引数をã¨ã‚‹ã‚ªãƒ—ションã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã«ä¸Žãˆã‚‰ã‚ŒãŸå¼•æ•°ã®ä¸¦ã³ã®ä¸­ã§ãã®ã‚ªãƒ—ションã®ç›´å¾Œã«ä½ç½®ã—ã¦ã„る引数ãŒãã®ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ã¿ãªã•れã¾ã™ã€‚

例 1. Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨ä¸€æ–‡å­—ã®ã‚ªãƒ—ション

Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ã€-m ã¯å¼•æ•°ã‚’ã¨ã‚‰ãªã„一文字ã®ã‚ªãƒ—ションã€-o ã¯å¼•æ•°ã‚’ã¨ã‚‹ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã§ã™ã€‚

  • set -o errexit -m

  • set -oerrexit -m

ã“ã®äºŒã¤ã®ä¾‹ã§ã¯ã€errexit ㌠-o オプションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ãªã‚Šã¾ã™ã€‚

上ã®äºŒã¤ç›®ã®ä¾‹ã§ã¯ã€-o オプションã¨ãれã«å¯¾ã™ã‚‹å¼•æ•°ãŒä¸€ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«ãªã£ã¦ã„ã¾ã™ã€‚POSIX ã¯ã“ã®ã‚ˆã†ãªæ›¸ãæ–¹ã¯é¿ã‘ãªã‘れã°ãªã‚‰ãªã„ã¨å®šã‚ã¦ãŠã‚Šã€POSIX ã«å¾“ã†ã‚¢ãƒ—リケーションã¯å¿…ãšä¸€ã¤ç›®ã®ä¾‹ã®ã‚ˆã†ã«ã‚ªãƒ—ションã¨ãれã«å¯¾ã™ã‚‹å¼•数を別々ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸Žãˆãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã—ã‹ã— yash ã¯ã©ã¡ã‚‰ã®æŒ‡å®šã®ä»•方もå—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚

引数をã¨ã‚‰ãªã„複数ã®ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã¯ã€ä¸€ã¤ã«ã¾ã¨ã‚ã¦æ›¸ãã“ã¨ãŒã§ãã¾ã™ã€‚例ãˆã° -a, -b, -c ã¨ã„ã†ä¸‰ã¤ã®ã‚ªãƒ—ション㯠-abc ã¨æ›¸ã‘ã¾ã™ã€‚

é•·ã„オプションã¯ã€äºŒã¤ã®ãƒã‚¤ãƒ•ンã¨ã‚ªãƒ—ションåã‚’è¡¨ã™æ–‡å­—列ã‹ã‚‰ãªã‚Šã¾ã™ã€‚例ãˆã° --long-option ã¯é•·ã„オプションã§ã™ã€‚オプションåã¯ä»–ã¨ç´›ã‚‰ã‚ã—ããªã„é™ã‚Šæœ«å°¾ã‚’çœç•¥ã§ãã¾ã™ã€‚例ãˆã°ä»–ã« --long ã§å§‹ã¾ã‚‹é•·ã„オプションãŒãªã‘れã°ã€--long-option 㯠--long ã¨çœç•¥ã§ãã¾ã™ã€‚引数をã¨ã‚‹ã‚ªãƒ—ションã§ã¯ã€ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã®å ´åˆã¨åŒæ§˜ã«ã€ã‚ªãƒ—ションã®ç›´å¾Œã«ã‚るコマンドライン引数ãŒãã®ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ã¿ãªã•れã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã€ã‚ªãƒ—ションåã®å¾Œã«ç­‰å· (=) ã§åŒºåˆ‡ã£ã¦ç›´æŽ¥å¼•数を与ãˆã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚

例 2. Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨é•·ã„オプション

Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ã€--quiet ã¯å¼•æ•°ã‚’ã¨ã‚‰ãªã„é•·ã„オプションã€--editor ã¯å¼•æ•°ã‚’ã¨ã‚‹é•·ã„オプションã§ã™ã€‚

  • fc --editor vi --quiet

  • fc --editor=vi --quiet

ã“ã®äºŒã¤ã®ä¾‹ã§ã¯ã€vi ㌠--editor オプションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ãªã‚Šã¾ã™ã€‚

オプション (ãŠã‚ˆã³ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°) 以外ã®å¼•æ•°ã¯ã€å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã¿ãªã•れã¾ã™ã€‚POSIX ã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯å…¨ã¦ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚ˆã‚Šå¾Œã«æ›¸ã‹ãªã‘れã°ãªã‚‰ãªã„ã¨å®šã‚ã¦ã„ã¾ã™ã€‚ãã®ãŸã‚ POSIX 準拠モードã§ã¯ã€æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚る引数㯠(ãŸã¨ãˆãれãŒã‚ªãƒ—ションã§ã‚るよã†ã«è¦‹ãˆã¦ã‚‚) å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å¾Œã«ã‚ªãƒ—ションを書ã„ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。

POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€ãƒã‚¤ãƒ•ン二ã¤ã‹ã‚‰ãªã‚‹å¼•æ•° (--) ã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã®åŒºåˆ‡ã‚Šã¨ã—ã¦ä½¿ãˆã¾ã™ã€‚ã“ã®åŒºåˆ‡ã‚Šä»¥é™ã®å…¨ã¦ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れるãŸã‚ã€ãƒã‚¤ãƒ•ンã§å§‹ã¾ã‚‹ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’æ­£ã—ãæŒ‡å®šã§ãã¾ã™ã€‚

例 3. Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰
  • set -a -b -- -c -d

ã“ã®ä¾‹ã§ã¯ã€-a 㨠-b ãŒã‚ªãƒ—ションã§ã€-c 㨠-d ãŒã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ãªã‚Šã¾ã™ã€‚区切り (--) 自体ã¯ã‚ªãƒ—ションã§ã‚‚オペランドã§ã‚‚ã‚りã¾ã›ã‚“。

POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€ãƒã‚¤ãƒ•ン一ã¤ã‹ã‚‰ãªã‚‹å¼•æ•° (-) ã¯å¸¸ã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã¿ãªã•れã¾ã™ã€‚

yash-2.35/doc/ja/_typeset.txt0000644000175000017500000001045112154557026016303 0ustar magicantmagicant= Typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:params.html#variables[変数]ã¾ãŸã¯link:exec.html#function[関数]を表示・設定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +typeset [-gprxX] [{{変数}}[={{値}}]...]+ - +typeset -f[pr] [{{関数}}...]+ [[description]] == 説明 +-f+ (+--functions+) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯link:params.html#variables[変数]を出力ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚+-f+ (+--functions+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯link:exec.html#function[関数]を出力ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ +-p+ (+--print+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚+-p+ (+--print+) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’設定ã—ã¾ã™ã€‚オペランドを一ã¤ã‚‚与ãˆãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€+-p+ (+--print+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æœ‰ç„¡ã«ã‹ã‹ã‚ら㚠typeset コマンドã¯å…¨ã¦ã®å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’出力ã—ã¾ã™ (ã“ã®ã¨ã +-g+ (+--global+) オプションãŒã‚ã‚Œã°æœ¬å½“ã«ã™ã¹ã¦ã®å¤‰æ•°ã‚’ã€ãã†ã§ãªã„ã¨ãã¯ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã ã‘を出力ã—ã¾ã™)。 [[options]] == オプション +-f+:: +--functions+:: 変数ã§ã¯ãªã関数を表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ +-g+:: +--global+:: ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æ–°ã—ã変数を作æˆã™ã‚‹å ´åˆãã®å¤‰æ•°ã‚’グローãƒãƒ«å¤‰æ•°ã¨ã—ã¾ã™ã€‚ã™ãªã‚ã¡å¤‰æ•°ã¯é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ã¦ã‚‚残りã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€è¨­å®šã™ã‚‹å¤‰æ•°ã¯link:exec.html#localvar[ローカル変数]ã«ãªã‚Šã¾ã™ã€‚ + オペランドãŒãªã„å ´åˆã¯ã€ã“ã®ã‚ªãƒ—ションを指定ã—ã¦ã„ã‚‹ã¨å…¨ã¦ã®å¤‰æ•°ã‚’出力ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ã¦ã„ãªã„ã¨ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã ã‘出力ã—ã¾ã™ã€‚ +-p+:: +--print+:: 変数ã¾ãŸã¯é–¢æ•°ã®å®šç¾©ã‚’ (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 出力ã—ã¾ã™ã€‚ +-r+:: +--readonly+:: 設定ã™ã‚‹å¤‰æ•°ãƒ»é–¢æ•°ã‚’dfn:[読ã¿å–り専用]ã«ã—ã¾ã™ã€‚読ã¿å–り専用ã®å¤‰æ•°ãƒ»é–¢æ•°ã¯ã€å€¤ã‚’変更ã—ãŸã‚Šå‰Šé™¤ã—ãŸã‚Šã§ããªããªã‚Šã¾ã™ã€‚ + 変数・関数を出力ã™ã‚‹éš›ã¯ã€èª­ã¿å–り専用ã®å¤‰æ•°ãƒ»é–¢æ•°ã ã‘出力ã—ã¾ã™ã€‚ +-x+:: +--export+:: 設定ã™ã‚‹å¤‰æ•°ã‚’link:params.html#variables[エクスãƒãƒ¼ãƒˆå¯¾è±¡]ã«ã—ã¾ã™ã€‚ + 変数を出力ã™ã‚‹éš›ã¯ã€ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã®å¤‰æ•°ã ã‘出力ã—ã¾ã™ã€‚ +-X+:: +--unexport+:: 設定ã™ã‚‹å¤‰æ•°ã‚’エクスãƒãƒ¼ãƒˆå¯¾è±¡ã‹ã‚‰å¤–ã—ã¾ã™ã€‚ [[operands]] == オペランド {{変数}}:: 出力ã¾ãŸã¯è¨­å®šã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚ + å¤‰æ•°ãŒæ—¢ã«å­˜åœ¨ã™ã‚‹å ´åˆã€å¤‰æ•°ã®å€¤ã¯å¤‰ã‚りã¾ã›ã‚“。存在ã—ãªã„変数を指定ã—ãŸå ´åˆã€å¤‰æ•°ã¯å­˜åœ¨ã™ã‚‹ãŒãã®å€¤ã¯å­˜åœ¨ã—ãªã„状態ã«ãªã‚Šã¾ã™ (ã“ã®ã‚ˆã†ãªå¤‰æ•°ã¯link:expand.html#params[パラメータ展開]ã§ã¯å­˜åœ¨ã—ãªã„変数ã¨ã—ã¦æ‰±ã„ã¾ã™)。 {{変数}}={{値}}:: 設定ã™ã‚‹å¤‰æ•°ã®åå‰ã¨ãã®å€¤ã§ã™ã€‚ + 指定ã—ãŸ{{値}}ãŒå¤‰æ•°ã®å€¤ã¨ã—ã¦è¨­å®šã•れã¾ã™ã€‚ã“ã®å½¢å¼ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ã¯ã€+-p+ (+--print+) オプションを指定ã—ãŸã¨ãã§ã‚‚ã“ã®å¤‰æ•°ã¯å‡ºåŠ›ã§ã¯ãªã設定ã•れã¾ã™ã€‚ {{関数}}:: 出力ã¾ãŸã¯è¨­å®šã™ã‚‹é–¢æ•°ã®åå‰ã§ã™ã€‚存在ã—ãªã„関数を指定ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š typeset コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 æ—¢ã«ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒå­˜åœ¨ã™ã‚‹å ´åˆã€ãれを無視ã—ã¦ã‚°ãƒ­ãƒ¼ãƒãƒ«å¤‰æ•°ã‚’æ–°ã—ã作るã“ã¨ã¯ã§ãã¾ã›ã‚“ (+-g+ (+--global+) オプションを指定ã—ã¦ã„ã¦ã‚‚既存ã®ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒå†è¨­å®šã•れã¾ã™)。 POSIX ã«ã¯ typeset コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

link:_export.html[Export コマンド]㯠typeset コマンド㫠+-gx+ オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚link:_readonly.html[Readonly コマンド]㯠typeset コマンド㫠+-gr+ オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/job.html0000644000175000017500000002417512154557026015356 0ustar magicantmagicant ジョブ制御

ジョブ制御ã¨ã¯ã€è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’åŒæ™‚ã«å®Ÿè¡Œã—ã€å¿…è¦ã«å¿œã˜ã¦ãれらを中断・å†é–‹ã•ã›ã‚‹æ©Ÿèƒ½ã§ã™ã€‚シェルã¯ã€ã‚ªãƒšãƒ¬ãƒ¼ãƒ†ã‚£ãƒ³ã‚°ã‚·ã‚¹ãƒ†ãƒ ãŒæä¾›ã™ã‚‹ç«¯æœ«ã®æ©Ÿèƒ½ã‚„ãƒ—ãƒ­ã‚»ã‚¹ã‚°ãƒ«ãƒ¼ãƒ—ç®¡ç†æ©Ÿæ§‹ãªã©ã‚’用ã„ã¦ã€ã‚¸ãƒ§ãƒ–制御を実ç¾ã—ã¾ã™ã€‚

ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚……

  • シェルãŒèµ·å‹•ã™ã‚‹å„プロセスã¯ã€ãƒ‘イプラインã”ã¨ã«å…±é€šã®ä¸€æ„ãªãƒ—ロセスグループã«å±žã—ã¾ã™ã€‚ã™ãªã‚ã¡ã€ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ãれãžã‚Œãƒ‘イプラインã”ã¨ã«ã‚¸ãƒ§ãƒ–ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚

  • シェルãŒã‚¸ãƒ§ãƒ–ã‚’èµ·å‹•ã—ãã®ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã£ã¦ã„ã‚‹é–“ã«ãã®ãƒ—ロセスãŒåœæ­¢ã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ (プロセスãŒå®Ÿéš›ã«çµ‚了ã—ãŸã¨ãã¨åŒæ§˜ã«) 次ã®ã‚³ãƒžãƒ³ãƒ‰ã®å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ã“ã®ã¨ãシェルã¯ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã“ã¨ã‚’覚ãˆã¦ã„ã‚‹ã®ã§ã€å¾Œã§ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

  • ジョブãŒåŒæœŸçš„ã«å®Ÿè¡Œã•れる場åˆã€ãã®ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡Œä¸­ã¯ãã®ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスグループãŒç«¯æœ«ã®ãƒ•ォアグラウンドプロセスグループã«ãªã‚Šã¾ã™ã€‚ジョブã®å®Ÿè¡ŒãŒçµ‚了 (ã¾ãŸã¯åœæ­¢) ã™ã‚‹ã¨ã€å†ã³ã‚·ã‚§ãƒ«ãŒãƒ•ォアグラウンドã«ãªã‚Šã¾ã™ã€‚

  • コマンド置æ›ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã‚µãƒ–シェルもã¾ãŸç‹¬ç«‹ã—ãŸãƒ—ロセスグループã«å±žã—ã¾ã™ã€‚ã—ã‹ã—シェルã¯ã“れをジョブã¨ã—ã¦ã¯æ‰±ã‚ãªã„ãŸã‚ã€åœæ­¢ãƒ»å†é–‹ã•ã›ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

  • シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®å ´åˆã€ãƒ—ロンプトを出ã™å‰ã«æ¯Žå›žã‚³ãƒžãƒ³ãƒ‰ jobs -n を実行ã™ã‚‹ã®ã¨åŒæ§˜ã«ã—ã¦ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚

  • éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れã¾ã›ã‚“。(POSIX 準拠モードã®ã¨ãを除ã)

  • SIGTSTP シグナルをå—ã‘ã¦ã‚‚ã€ã‚·ã‚§ãƒ«ã¯åœæ­¢ã—ã¾ã›ã‚“。

  • 特殊パラメータ - ã®å€¤ã« m ãŒå«ã¾ã‚Œã¾ã™ã€‚

  • Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¾…ã£ã¦ã„るジョブãŒçµ‚了ã—ãŸã¨ãã€ãã®ã“ã¨ã‚’示ã™ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã¾ã™ã€‚(å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®æ™‚ã®ã¿ã€‚POSIX 準拠モードを除ã)

ジョブ制御ãŒç„¡åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å„プロセスã¯ã‚·ã‚§ãƒ«ã¨åŒã˜ãƒ—ロセスグループã«å±žã—ã¾ã™ãŒã€å®Ÿè¡Œã—ãŸéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã¯ãれãžã‚Œã‚¸ãƒ§ãƒ–制御ã®å¯¾è±¡ã¨ãªã£ã¦ã„ãªã„ジョブã¨ã—ã¦æ‰±ã„ã¾ã™ã€‚

ã“ã“ã§ã‚¸ãƒ§ãƒ–制御ã«é–¢é€£ã™ã‚‹çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’ç°¡å˜ã«ç´¹ä»‹ã—ã¾ã™ã€‚

jobs

ç¾åœ¨ã‚·ã‚§ãƒ«ãŒç®¡ç†ã—ã¦ã„るジョブを表示ã—ã¾ã™ã€‚

fg ãŠã‚ˆã³ bg

ジョブをフォアグラウンドã¾ãŸã¯ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚主ã«åœæ­¢ã—ãŸã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã•ã›ã‚‹ã®ã«ä½¿ã„ã¾ã™ã€‚

wait

ジョブãŒçµ‚了 (ã¾ãŸã¯åœæ­¢) ã™ã‚‹ã¾ã§å¾…ã¡ã¾ã™ã€‚

disown

ジョブã®å­˜åœ¨ã‚’忘れã¾ã™ã€‚

kill

プロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Šã¾ã™ã€‚

対話モードã§ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出ã™ç›´å‰ã«ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚ã“れ以外ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¦ã»ã—ã„å ´åˆã¯ã€ä»¥ä¸‹ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

notify

タイミングã«ã‹ã‹ã‚らãšã€ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹ãŒå¤‰åŒ–ã—ãŸã‚‰ç›´ã¡ã«ãれを報告ã—ã¾ã™ã€‚

notify-le

行編集を行ã£ã¦ã„る最中ã«ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹ãŒå¤‰åŒ–ã—ãŸã‚‰ç›´ã¡ã«ãれを報告ã—ã¾ã™ã€‚

シェルãŒç®¡ç†ã—ã¦ã„るジョブã¯ä»¥ä¸‹ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§å‰Šé™¤ã•れã¾ã™ã€‚

ジョブ ID

ã„ãã¤ã‹ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã€æ“作対象ã®ã‚¸ãƒ§ãƒ–を指定ã™ã‚‹ãŸã‚ã«ã‚¸ãƒ§ãƒ– ID ã¨ã„ã†ä»¥ä¸‹ã®ã‚ˆã†ãªè¨˜æ³•を用ã„ã¾ã™ã€‚

%
%%
%+

ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–

%-

å‰ã®ã‚¸ãƒ§ãƒ–

%n

ジョブ番å·ãŒ n ã®ã‚¸ãƒ§ãƒ– (n ã¯è‡ªç„¶æ•°)

%string

ジョブåãŒæ–‡å­—列ã§å§‹ã¾ã‚‹ã‚¸ãƒ§ãƒ–

%?string

ジョブåãŒæ–‡å­—列をå«ã‚€ã‚¸ãƒ§ãƒ–

ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–åŠã³å‰ã®ã‚¸ãƒ§ãƒ–ã¨ã¯ã€ã‚·ã‚§ãƒ«ãŒç‰¹å®šã®æ–¹æ³•ã§é¸ã‚“ã ã‚¸ãƒ§ãƒ–ã®ã“ã¨ã§ã€fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ã‚¸ãƒ§ãƒ–ã‚’é¸æŠžã—ã‚„ã™ãã™ã‚‹ãŸã‚ã«ç”¨æ„ã•れã¦ã„ã¾ã™ã€‚ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¨å‰ã®ã‚¸ãƒ§ãƒ–ã¯ä»¥ä¸‹ã®è¦å‰‡ã‚’満ãŸã™ã‚ˆã†ã«é¸ã°ã‚Œã¾ã™ã€‚

  • åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹å ´åˆã¯ã€ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯ãã®ä¸­ã‹ã‚‰é¸ã°ã‚Œã¾ã™ã€‚

  • ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–以外ã«åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹å ´åˆã¯ã€å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãã®ä¸­ã‹ã‚‰é¸ã°ã‚Œã¾ã™ã€‚

  • ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¨å‰ã®ã‚¸ãƒ§ãƒ–ã¯ç•°ãªã‚‹ã‚¸ãƒ§ãƒ–ã«ãªã‚‹ã‚ˆã†ã«é¸ã°ã‚Œã¾ã™ã€‚ジョブãŒä¸€ã¤ã—ã‹ãªã„ã¨ãã¯ãれãŒç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã€å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãªããªã‚Šã¾ã™ã€‚

  • ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã—ãŸã¨ãã¯ã€å‰ã®ã‚¸ãƒ§ãƒ–ãŒç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ã“れ以外ã«ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ãŒå¤‰æ›´ã•れる場åˆã¯ã€å…ƒã®ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯å‰ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚

  • フォアグラウンドã§å®Ÿè¡Œã—ã¦ã„ãŸã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãã¯ã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚

Yash ã«ã¯ã€ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã‚’é¸æŠžã™ã‚‹æ–¹é‡ã‚’指示ã™ã‚‹ãŸã‚ã«ã„ãã¤ã‹ã®ã‚ªãƒ—ションãŒç”¨æ„ã•れã¦ã„ã¾ã™ã€‚ãŸã ã—ã“れらã®ã‚ªãƒ—ションよりも上記ã®è¦å‰‡ã®ã»ã†ãŒå„ªå…ˆã—ã¾ã™ã€‚

cur-async

æ–°ã—ãéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã—ãŸã¨ãã€ãれã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚

cur-bg

Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã—ãŸã¨ãã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚

cur-stop

実行中ã®ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚

ã“れらã®è¦å‰‡ãƒ»ã‚ªãƒ—ションã«åã—ãªã„é™ã‚Šã€ä¸€åº¦é¸ã°ã‚ŒãŸç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãšã£ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã®ã¾ã¾ã§ã™ã€‚

POSIX ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã®é¸æŠžæ–¹æ³•ã‚’ç´°ã‹ã定ã‚ã¦ã„ãªã„ãŸã‚ã€ä»–ã®ã‚·ã‚§ãƒ«ã§ã¯é¸ã³æ–¹ãŒç•°ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚

yash-2.35/doc/ja/redir.txt0000644000175000017500000003062412154557026015560 0ustar magicantmagicant= リダイレクト :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - リダイレクト :description: Yash ãŒã‚µãƒãƒ¼ãƒˆã™ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ©Ÿèƒ½ã®èª¬æ˜Ž dfn:[リダイレクト]ã¯ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ァイル記述å­ã‚’変更ã™ã‚‹æ©Ÿèƒ½ã§ã™ã€‚リダイレクトを使用ã™ã‚‹ã¨ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力や標準出力を通常ã¨ã¯ç•°ãªã‚‹ãƒ•ァイルã«ç¹‹ãŽæ›ãˆãŸçŠ¶æ…‹ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ リダイレクトã¯ã‚³ãƒžãƒ³ãƒ‰ (link:syntax.html#simple[å˜ç´”コマンド]ã¾ãŸã¯link:syntax.html#compound[複åˆã‚³ãƒžãƒ³ãƒ‰]) ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’付ã™ã‚‹ã“ã¨ã§è¡Œã„ã¾ã™ã€‚å˜ç´”コマンドã§ã¯ (ä»–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‹ãªã„é™ã‚Š) ã©ã“ã§ã‚‚リダイレクト演算å­ã‚’ç½®ãã“ã¨ãŒã§ãã¾ã™ã€‚複åˆã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ã®æœ€å¾Œã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’付ã‘ã¾ã™ã€‚ リダイレクトã¯ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒå§‹ã¾ã‚‹å‰ã«å‡¦ç†ã•れã¾ã™ã€‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆãŒã‚ã‚‹å ´åˆã¯ã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ãŒæ›¸ã„ã¦ã‚ã‚‹é †åºã§å‡¦ç†ã•れã¾ã™ã€‚オペランドãªã—ã® link:_exec.html[exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を実行ã™ã‚‹å ´åˆã‚’除ãã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯å¯¾è±¡ã¨ãªã£ã¦ã„るコマンドã«å¯¾ã—ã¦ã®ã¿åƒãã¾ã™ã€‚ã™ãªã‚ã¡ã€å¯¾è±¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã‚‹ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã«ã‚ˆã£ã¦å¤‰æ›´ã•れãŸãƒ•ァイル記述å­ã¯å…ƒã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚ リダイレクト演算å­ã¯ã€+<+ ã¾ãŸã¯ +>+ ã§å§‹ã¾ã‚Šã¾ã™ã€‚+<+ ã§å§‹ã¾ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã¯ãƒ‡ãƒ•ォルトã§ã¯æ¨™æº–入力 (ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ 0) ã«ä½œç”¨ã—ã¾ã™ã€‚+>+ ã§å§‹ã¾ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã¯ãƒ‡ãƒ•ォルトã§ã¯æ¨™æº–出力 (ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ 1) ã«ä½œç”¨ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã®ç¨®é¡žã®æ¼”ç®—å­ã§ã‚‚ã€æ¼”ç®—å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ãƒ‡ãƒ•ォルト以外ã®ãƒ•ァイル記述å­ã«ä½œç”¨ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ (ã“ã®ã¨ãæ•´æ•°ã¨æ¼”ç®—å­ã¨ã®é–“ã«ä¸€åˆ‡ç©ºç™½ãªã©ã‚’入れã¦ã¯ã„ã‘ã¾ã›ã‚“。ã¾ãŸæ•´æ•°ã‚’link:syntax.html#quotes[クォート]ã—ã¦ã‚‚ã„ã‘ã¾ã›ã‚“)。 [[file]] == ファイルã¸ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ 最もよã使ã‚れるリダイレクトã¯ã€ãƒ•ァイルã¸ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã™ã€‚ 入力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ:: +< {{トークン}}+ 出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ:: +> {{トークン}}+ + +>| {{トークン}}+ + +>> {{トークン}}+ 入出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ:: +<> {{トークン}}+ リダイレクトã«å«ã¾ã‚Œã‚‹{{トークン}}ã¯link:expand.html[四種展開]ã•れã¾ã™ã€‚link:interact.html[対話シェル]ã§ã¯ã•らã«link:expand.html#glob[パスå展開]も行ã‚れã¾ã™ (パスå展開ã®çµæžœãŒä¸€ã¤ã®ãƒ•ァイルã§ãªã‘れã°ã‚¨ãƒ©ãƒ¼ã§ã™)。{{トークン}}ã®å±•é–‹çµæžœãŒãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆå¯¾è±¡ã®ãƒ•ァイルåã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚ 入力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–入力ãŒå¯¾è±¡ãƒ•ァイルã‹ã‚‰ã®èª­ã¿è¾¼ã¿å°‚用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルを開ãã“ã¨ãŒã§ããªã‘れã°ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ 出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–出力ãŒå¯¾è±¡ãƒ•ァイルã¸ã®æ›¸ãè¾¼ã¿å°‚用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルãŒå­˜åœ¨ã—ãªã‘れã°ç©ºã®é€šå¸¸ãƒ•ァイルãŒä½œæˆã•れã¾ã™ã€‚å¯¾è±¡ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ—¢ã«ã‚ã‚‹å ´åˆã¯ãã®ãƒ•ァイルãŒé–‹ã‹ã‚Œã¾ã™ã€‚ãŸã ã—演算å­ã®ç¨®é¡žã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«æŒ™å‹•ãŒç•°ãªã‚Šã¾ã™ã€‚ - æ¼”ç®—å­ +>|+ ã§ã¯ã€å¯¾è±¡ãƒ•ァイルãŒå­˜åœ¨ã—ãれãŒé€šå¸¸ã®ãƒ•ァイルã®å ´åˆã€ãƒ•ァイルを開ãéš›ã«ãƒ•ァイルã®å†…容を空ã«ã—ã¾ã™ã€‚ - æ¼”ç®—å­ +>+ ã¯ã€link:_set.html#so-clobber[clobber オプション]ãŒæœ‰åйãªã‚‰ã°æ¼”ç®—å­ +>|+ ã¨åŒã˜ã§ã™ã€‚ã—ã‹ã— clobber オプションãŒç„¡åйãªã‚‰ã°ã€å¯¾è±¡ãƒ•ァイルãŒå­˜åœ¨ã—ãれãŒé€šå¸¸ã®ãƒ•ァイルã®å ´åˆã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ - æ¼”ç®—å­ +>>+ ã§ã¯ã€ãƒ•ァイルを追記モードã§é–‹ãã¾ã™ã€‚ファイルã¸ã®æ›¸ãè¾¼ã¿ã¯å¸¸ã«ãƒ•ã‚¡ã‚¤ãƒ«ã®æœ«å°¾ã¸è¿½è¨˜ã™ã‚‹å½¢ã§è¡Œã‚れã¾ã™ã€‚ 入出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–入力ãŒå¯¾è±¡ãƒ•ァイルã¸ã®èª­ã¿æ›¸ã両用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルãŒå­˜åœ¨ã—ãªã‘れã°ç©ºã®é€šå¸¸ãƒ•ァイルãŒä½œæˆã•れã¾ã™ã€‚ [[socket]] === ソケットリダイレクト ファイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã«ãŠã„ã¦ã€å¯¾è±¡ãƒ•ァイルå㌠+/dev/tcp/{{ホストå}}/{{ãƒãƒ¼ãƒˆ}}+ ã¾ãŸã¯ +/dev/udp/{{ホストå}}/{{ãƒãƒ¼ãƒˆ}}+ ã®å½¢å¼ã‚’ã—ã¦ã„ã¦ã€ãã®ãƒ•ァイルを開ãã“ã¨ãŒã§ããªã„å ´åˆã€ãƒ•ァイルåã«å«ã¾ã‚Œã‚‹{{ホストå}}ã¨{{ãƒãƒ¼ãƒˆ}}ã«å¯¾ã—ã¦é€šä¿¡ã‚’行ã†ãŸã‚ã®ã‚½ã‚±ãƒƒãƒˆãŒé–‹ã‹ã‚Œã¾ã™ã€‚ +/dev/tcp/{{ホストå}}/{{ãƒãƒ¼ãƒˆ}}+ ãŒå¯¾è±¡ã®å ´åˆã¯ã‚¹ãƒˆãƒªãƒ¼ãƒ é€šä¿¡ã‚½ã‚±ãƒƒãƒˆã‚’ã€++/dev/udp/{{ホストå}}/{{ãƒãƒ¼ãƒˆ}}++ ãŒå¯¾è±¡ã®å ´åˆã¯ãƒ‡ãƒ¼ã‚¿ã‚°ãƒ©ãƒ é€šä¿¡ã‚½ã‚±ãƒƒãƒˆã‚’é–‹ãã¾ã™ã€‚典型的ã«ã¯ã€å‰è€…㯠TCP ã‚’ã€å¾Œè€…㯠UDP をプロトコルã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚ ソケットリダイレクトã¯ã©ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’使ã£ã¦ã„ã‚‹ã‹ã«ã‹ã‹ã‚らãšå¸¸ã«èª­ã¿æ›¸ã両用ã®ãƒ•ァイル記述å­ã‚’é–‹ãã¾ã™ã€‚ ソケットリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚ãŸã ã—ã€bash ã«ã‚‚åŒæ§˜ã®æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚ [[dup]] == ファイル記述å­ã®è¤‡è£½ ファイル記述å­ã®è¤‡è£½ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯ã€æ—¢å­˜ã®ãƒ•ァイル記述å­ã‚’コピーã—ãŸã‚Šé–‰ã˜ãŸã‚Šã§ãã¾ã™ã€‚ ファイル記述å­ã®è¤‡è£½:: +<& {{トークン}}+ + +>& {{トークン}}+ {{トークン}}ã¯<>ã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ãŒã€ã“れã¯ãƒ•ァイルåã§ã¯ãªãファイル記述å­ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€{{トークン}}ã®å±•é–‹çµæžœã¯ãƒ•ァイル記述å­ã‚’表ã™éžè² æ•´æ•°ã¨ãªã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ æ¼”ç®—å­ +<&+ ã¯{{トークン}}ã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ã‚’標準入力ã«è¤‡è£½ã—ã¾ã™ã€‚æ¼”ç®—å­ +>&+ ã¯{{トークン}}ã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ã‚’標準出力ã«è¤‡è£½ã—ã¾ã™ã€‚演算å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ã€è¤‡è£½å…ˆã®ãƒ•ァイル記述å­ã‚’変更ã§ãã¾ã™ã€‚ {{トークン}}ã®å±•é–‹çµæžœãŒéžè² æ•´æ•°ã§ã¯ãªããƒã‚¤ãƒ•ン (+-+) ã¨ãªã£ãŸå ´åˆã¯ã€ãƒ•ァイル記述å­ã‚’複製ã™ã‚‹ä»£ã‚りã«é–‰ã˜ã¾ã™ã€‚æ¼”ç®—å­ +<&+ ã§ã¯æ¨™æº–入力ãŒã€æ¼”ç®—å­ +>&+ ã§ã¯æ¨™æº–出力ãŒãƒ‡ãƒ•ォルトã§é–‰ã˜ã‚‰ã‚Œã¾ã™ãŒã€æ¼”ç®—å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ã€é–‰ã˜ã‚‹ãƒ•ァイル記述å­ã‚’変更ã§ãã¾ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ã¯ã€++<&++ ã§è¤‡è£½ã™ã‚‹ãƒ•ァイル記述å­ã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ãªã‘れã°ãªã‚‰ãšã€++>&++ ã§è¤‡è£½ã™ã‚‹ãƒ•ァイル記述å­ã¯æ›¸ãè¾¼ã¿å¯èƒ½ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。 [[here]] == ヒアドキュメントã¨ãƒ’アストリング dfn:[ヒアドキュメント]・dfn:[ヒアストリング]を使ã†ã¨ã‚³ãƒžãƒ³ãƒ‰ã«ç›´æŽ¥ãƒ†ã‚­ã‚¹ãƒˆã‚’渡ã™ã“ã¨ãŒã§ãã¾ã™ã€‚ ヒアドキュメント:: +<< {{トークン}}+ + +<<- {{トークン}}+ ヒアストリング:: +<<< {{トークン}}+ ヒアドキュメント・ヒアストリングã§ã¯ã€æ¨™æº–入力ãŒãƒ’アドキュメント・ヒアストリングã®å†…容を読ã¿è¾¼ã¿å¯èƒ½ãªãƒ•ァイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ ãƒ’ã‚¢ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆæ¼”ç®—å­ (+<<+ ã¾ãŸã¯ +<<-+) ãŒã‚³ãƒžãƒ³ãƒ‰ä¸­ã«ç¾ã‚Œã‚‹ã¨ã€ãã®æ¼”ç®—å­ã®ã‚ã‚‹è¡Œã®æ¬¡ã®è¡Œã‹ã‚‰ã¯ãƒ’アドキュメントã®å†…容ã¨ã¿ãªã•れã¾ã™ã€‚ヒアドキュメントã®å†…容ã®éƒ¨åˆ†ã¯ã€ã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦ã¯è§£é‡ˆã•れã¾ã›ã‚“。演算å­ã®å¾Œã«ã‚ã‚‹{{トークン}}ã¯ãƒ’アドキュメントã®å†…容ã®çµ‚ã‚りを表ã—ã¾ã™ã€‚({{トークン}}ã§ã¯link:expand.html[展開]ã¯è¡Œã‚れã¾ã›ã‚“ãŒã€link:syntax.html[クォート]ã¯èªè­˜ã•れã¾ã™ã€‚) 演算å­ã®ã‚る行より後ã®è¡Œã§{{トークン}}ã ã‘ã‹ã‚‰ãªã‚‹è¡ŒãŒç¾ã‚ŒãŸæ™‚点ã§ãƒ’アドキュメントã®å†…容ã¯çµ‚ã‚りã ã¨åˆ¤æ–­ã•れã¾ã™ã€‚終ã‚りを表ã™è¡Œã¯ãƒ’アドキュメントã®å†…容ã«ã¯å«ã¾ã‚Œã¾ã›ã‚“ã€‚æ¼”ç®—å­ +<<-+ を使ã£ã¦ã„ã‚‹å ´åˆã¯ã€ãƒ’アドキュメントã®å†…容ã®å„行頭ã«ã‚るタブã¯ã™ã¹ã¦å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®ã¨ã{{トークン}}ã®å‰ã«ã‚¿ãƒ–ãŒã‚ã£ã¦ã‚‚ (ãã®è¡Œã«ä»–ã®ä½™è¨ˆãªæ–‡å­—ãŒãªã‘れã°) ヒアドキュメントã®å†…容ã®çµ‚ã‚りã¨ã—ã¦èªè­˜ã—ã¾ã™ã€‚ 一行ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ãŒã‚ã‚‹å ´åˆã¯ã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¯é †ç•ªã«å‡¦ç†ã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã®è¡Œã®æ¬¡ã®è¡Œã‹ã‚‰ã¯æœ€åˆã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¨ã—ã¦æ‰±ã‚れã€ãã®å†…容ãŒçµ‚ã‚ã£ãŸã‚‰ã€ãã®æ¬¡ã®è¡Œã‹ã‚‰ã¯æ¬¡ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚最後ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ãŒçµ‚ã‚ã£ãŸã‚‰ã€ãã®æ¬¡ã®è¡Œã‹ã‚‰ã¯å†ã³ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ リダイレクトã®å†…容ã¯åŸºæœ¬çš„ã«å˜ãªã‚‹æ–‡å­—列ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚内容ã«å«ã¾ã‚Œã‚‹ç©ºç™½ã‚„タブã€ãã®ä»–ã®è¨˜å·ã¯ãã®ã¾ã¾ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ãŸã ã—ã€{{トークン}}ãŒå…¨ãクォートã•れã¦ã„ãªã„å ´åˆã¯ã€ãƒ’アドキュメントã®å†…容ã¯link:expand.html#params[パラメータ展開]・link:expand.html#cmdsub[コマンド置æ›]・link:expand.html#arith[æ•°å¼å±•é–‹]ã•れã€++$++, ++`++, ++"++, ++\++ ã®ç›´å‰ã«ã‚ã‚‹å ´åˆãŠã‚ˆã³è¡Œã®é€£çµã‚’行ã†å ´åˆã«ã®ã¿ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’link:syntax.html#quotes[引用符]ã¨ã—ã¦æ‰±ãˆã¾ã™ã€‚ ヒアストリングã§ã¯ã€æ¼”ç®—å­ã®å¾Œã«ã‚ã‚‹{{トークン}}ã¯<>ã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ã€‚ã“ã®å±•é–‹çµæžœãŒãƒ’アストリングã®å†…容ã¨ãªã‚Šã¾ã™ã€‚ãŸã ã—ヒアストリングã®å†…å®¹ã®æœ«å°¾ã«ã¯è‡ªå‹•çš„ã«æ”¹è¡ŒãŒä»˜ãã¾ã™ã€‚ ヒアストリング㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ãŒã€bash, ksh, zsh ã«ã‚‚åŒæ§˜ã®æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚ [[pipe]] == パイプリダイレクト dfn:[パイプリダイレクト]を用ã„ã‚‹ã¨ãƒ—ロセス間通信ã«åˆ©ç”¨å¯èƒ½ãªãƒ‘イプを開ãã“ã¨ãŒã§ãã¾ã™ã€‚ パイプリダイレクト:: +>>| {{トークン}}+ {{トークン}}ã¯<>ã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ãŒã€ã“れã¯ãƒ•ァイルåã§ã¯ãªãファイル記述å­ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€{{トークン}}ã®å±•é–‹çµæžœã¯ãƒ•ァイル記述å­ã‚’表ã™éžè² æ•´æ•°ã¨ãªã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ パイプリダイレクトã¯ãƒ‘イプを開ãã¾ã™ã€‚標準出力 (æ¼”ç®—å­ +>>|+ ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã—ã¦ã„ã‚‹å ´åˆã¯ãã®å€¤ã®ãƒ•ァイル記述å­) ãŒãƒ‘ã‚¤ãƒ—ã«æ›¸ãã“ã‚€ãŸã‚ã®ãƒ•ァイル記述å­ã«ãªã‚Šã¾ã™ã€‚ã¾ãŸ{{トークン}}ã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ãŒãƒ‘イプã‹ã‚‰èª­ã¿è¾¼ã‚€ãŸã‚ã®ãƒ•ァイル記述å­ã«ãªã‚Šã¾ã™ã€‚ パイプリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚ [[process]] == プロセスリダイレクト プロセスリダイレクトを用ã„ã‚‹ã¨åˆ¥ã®ã‚³ãƒžãƒ³ãƒ‰ã®å…¥åŠ›ã¾ãŸã¯å‡ºåŠ›ã‚’å—ã‘æ¸¡ã›ã‚‹ãƒ‘イプを開ãã“ã¨ãŒã§ãã¾ã™ã€‚ プロセスリダイレクト:: +<({{サブコマンド}}…)+ + +>({{サブコマンド}}…)+ プロセスリダイレクトã§ã¯ã€{{サブコマンド}}ãŒlink:exec.html#subshell[サブシェル]ã§å®Ÿè¡Œã•れã¾ã™ã€‚ã“ã®ã¨ãã€+<({{サブコマンド}}…)+ ã®å½¢å¼ã®ãƒ—ロセスリダイレクトã§ã¯ã€{{サブコマンド}}ã®æ¨™æº–出力ãŒã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å…¥åŠ›ã«æ¸¡ã‚‹ã‚ˆã†ãƒ‘イプãŒé–‹ã‹ã‚Œã¾ã™ã€‚+>({{サブコマンド}}…)+ ã®å½¢å¼ã®ãƒ—ロセスリダイレクトã§ã¯ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ãŒ{{サブコマンド}}ã®æ¨™æº–å…¥åŠ›ã«æ¸¡ã‚‹ã‚ˆã†ãƒ‘イプãŒé–‹ã‹ã‚Œã¾ã™ã€‚ プロセスリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚Bash 㨠zsh ã«ã¯ãƒ—ロセスリダイレクトã¨åŒæ§˜ã®æ§‹æ–‡ã‚’用ã„るプロセス置æ›ã¨ã„ã†æ©Ÿèƒ½ãŒã‚りã¾ã™ãŒã€ãƒ—ロセスリダイレクトã¨ãƒ—ロセス置æ›ã®æŒ™å‹•ã¯ç•°ãªã£ã¦ãŠã‚Šã€äº’æ›æ€§ã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_pushd.html0000644000175000017500000000765512154557026016072 0ustar magicantmagicant Pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’追加ã—ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚

æ§‹æ–‡

  • pushd [-L|-P] [ディレクトリ]

説明

Pushd コマンド㯠cd コマンドã¨åŒæ§˜ã«ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚作業ディレクトリã®å¤‰æ›´ã«æˆåŠŸã™ã‚‹ã¨ã€æ–°ã—ã„作業ディレクトリをディレクトリスタックã«è¿½åŠ ã—ã¾ã™ã€‚

オプション

Cd コマンドã§ä½¿ãˆã‚‹ã‚ªãƒ—ションã«åŠ ãˆã¦ä»¥ä¸‹ã®ã‚ªãƒ—ション㌠pushd コマンドã§ä½¿ãˆã¾ã™ã€‚

--remove-duplicates

æ–°ã—ã„ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæ—¢ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«å…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€å…ƒã€…å…¥ã£ã¦ã„ãŸè¦ç´ ã‚’削除ã—ã¦é‡è¤‡ã‚’ãªãã—ã¾ã™ã€‚

オペランド

ディレクトリ

æ–°ã—ã„作業ディレクトリã®ãƒ‘スåã§ã™ã€‚絶対パスã¾ãŸã¯å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘ã‚¹ã§æŒ‡å®šã—ã¾ã™ã€‚

ã“ã®å€¤ãŒãƒã‚¤ãƒ•ン一㤠(-) ã®å ´åˆã€OLDPWD 変数ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

ã“ã®å€¤ãŒç¬¦å·ä»˜ãæ•´æ•°ã®å ´åˆã€ãã®æ•´æ•°ã‚’ディレクトリスタックã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¨ã¿ãªã—ã¦ã€ãã®è¦ç´ ãŒè¡¨ã™ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (指定ã•れãŸè¦ç´ ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰å‰Šé™¤ã•れã¾ã™)。

ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +1 ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (--default-directory オプションを指定ã—ãŸå ´åˆã‚’除ã)。

終了ステータス

作業ディレクトリを正ã—ã変更ã—ディレクトリスタックã«è¿½åŠ ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

POSIX ã«ã¯ pushd コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/_printf.txt0000644000175000017500000002102612154557026016110 0ustar magicantmagicant= Printf 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Printf 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Printf 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’æ•´å½¢ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +printf {{書å¼}} [{{値}}...]+ [[description]] == 説明 Printf コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸ{{書å¼}}ã«å¾“ã£ã¦{{値}}ã‚’æ•´å½¢ã—ã€æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚link:_echo.html[Echo コマンド]ã¨ã¯ç•°ãªã‚Šã€å‡ºåŠ›ã®æœ€å¾Œã«ã¯è‡ªå‹•çš„ã«æ”¹è¡Œã¯ä»˜ãã¾ã›ã‚“。 書å¼ã®æŒ‡å®šã®ä»•方㯠C 言語㮠printf 関数ã¨ã‚ˆãä¼¼ã¦ã„ã¾ã™ã€‚書å¼ã®ä¸­ã§ã¯ +%+ ã§å§‹ã¾ã‚‹å¤‰æ›æŒ‡å®šã¨ +\+ ã§å§‹ã¾ã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを使用ã§ãã¾ã™ã€‚書å¼ã«å«ã¾ã‚Œã‚‹å¤‰æ›æŒ‡å®šã¨ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ä»¥å¤–ã®æ–‡å­—ã¯ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚ [[convspec]] === å¤‰æ›æŒ‡å®š å¤‰æ›æŒ‡å®šã¯ãƒ‘ãƒ¼ã‚»ãƒ³ãƒˆè¨˜å· (+%+) ã‹ã‚‰å§‹ã¾ã‚Šã¾ã™ã€‚ +%%+ 以外ã®å¤‰æ›æŒ‡å®šã¯ã€å¯¾å¿œã™ã‚‹å€¤ã‚’ã¨ã‚Šã¾ã™ã€‚å¤‰æ›æŒ‡å®šã¯ã€å€¤ã‚’特定ã®å½¢å¼ã«æ•´å½¢ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚å¤‰æ›æŒ‡å®šã¨å€¤ã¯ä¸Žãˆã‚‰ã‚ŒãŸé †ç•ªã«å¯¾å¿œä»˜ã‘られã¾ã™ã€‚値ãŒä½™ã£ãŸå ´åˆã¯ã€å…¨ã¦ã®å€¤ã‚’処ç†ã—終ã‚ã‚‹ã¾ã§æ›¸å¼ã®æ•´å½¢ãƒ»å‡ºåŠ›ã‚’ç¹°ã‚Šè¿”ã—ã¾ã™ã€‚値ãŒè¶³ã‚Šãªã„å ´åˆã¯ã€ç©ºæ–‡å­—列 (文字列ã«é–¢ã™ã‚‹å¤‰æ›æŒ‡å®šã®å ´åˆ) ã¾ãŸã¯ 0 (数値ã«é–¢ã™ã‚‹å¤‰æ›æŒ‡å®šã®å ´åˆ) を仮定ã—ã¾ã™ã€‚値ãŒä¸€ã¤ã‚‚与ãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€æ›¸å¼ã¯ä¸€åº¦ã ã‘出力ã•れã¾ã™ã€‚ 利用å¯èƒ½ãªå¤‰æ›æŒ‡å®šã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +%d+:: +%i+:: æ•´æ•°ã®å€¤ã‚’ (符å·ä»˜ã) å進整数ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ +%u+:: æ•´æ•°ã®å€¤ã‚’ (符å·ãªã—) å進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ +%o+:: æ•´æ•°ã®å€¤ã‚’ (符å·ãªã—) 八進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ +%x+:: æ•´æ•°ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ãªã—) å六進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ +%X+:: æ•´æ•°ã®å€¤ã‚’大文字㮠(符å·ãªã—) å六進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ +%f+:: 実数ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ä»˜ã) å°æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ +%F+:: 実数ã®å€¤ã‚’大文字㮠(符å·ä»˜ã) å°æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ +%e+:: 実数ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ä»˜ã) æŒ‡æ•°è¡¨è¨˜å°æ•°ã§å‡ºåŠ›ã—ã¾ã™ã€‚ +%E+:: 実数ã®å€¤ã‚’大文字㮠(符å·ä»˜ã) æŒ‡æ•°è¡¨è¨˜å°æ•°ã§å‡ºåŠ›ã—ã¾ã™ã€‚ +%g+:: 値ã®å¤§ãã•や精度ã«å¿œã˜ã¦ +%f+ 㨠+%e+ ã®ã©ã¡ã‚‰ã‹ã®å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ +%G+:: 値ã®å¤§ãã•や精度ã«å¿œã˜ã¦ +%F+ 㨠+%E+ ã®ã©ã¡ã‚‰ã‹ã®å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ +%c+:: 文字列ã®å€¤ã®æœ€åˆã®æ–‡å­—を出力ã—ã¾ã™ã€‚ +%s+:: 文字列ã®å€¤ã‚’ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚ +%b+:: 文字列ã®å€¤ã‚’ã€ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ãªãŒã‚‰å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã“ã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンス㯠link:_echo.html[echo コマンド]ã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¨åŒã˜ã§ã™ã€‚ +%%+:: ãƒ‘ãƒ¼ã‚»ãƒ³ãƒˆè¨˜å· (+%+) を出力ã—ã¾ã™ã€‚ +%g+ 㨠+%G+ ã§ã¯ã€å°æ•°ã®æŒ‡æ•°éƒ¨ãŒ -5 ä»¥ä¸Šç²¾åº¦ä»¥ä¸‹ã®æ™‚ã« +%f+ ã¾ãŸã¯ +%F+ ã‚’ã€ãã‚Œä»¥å¤–ã®æ™‚ã« +%e+ ã¾ãŸã¯ +%E+ を使用ã—ã¾ã™ã€‚ +%%+ 以外ã®å¤‰æ›æŒ‡å®šã§ã¯ã€æœ€åˆã® +%+ ã®ç›´å¾Œã«å¤‰æ›æŒ‡å®šãƒ•ラグ・フィールド幅・精度をã“ã®é †ã§æŒ‡å®šã§ãã¾ã™ã€‚ã“れらを指定ã™ã‚‹ã“ã¨ã§å‡ºåŠ›ã®å½¢å¼ã‚’ç´°ã‹ã調整ã§ãã¾ã™ã€‚ [[convspec-flags]] ==== å¤‰æ›æŒ‡å®šãƒ•ラグ 指定ã§ãã‚‹å¤‰æ›æŒ‡å®šãƒ•ラグã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚フラグを複数指定ã—ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 マイナス (+-+):: ã“ã®ãƒ•ラグを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸãƒ•ィールド幅ã®ä¸­ã§å€¤ã‚’å·¦ã«å¯„ã›ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã®ãƒ•ラグを指定ã—ãªã„å ´åˆã€å€¤ã¯å³ã«å¯„りã¾ã™ã€‚ プラス (+++):: 数値ã®ç¬¦å· (æ­£å·ã¾ãŸã¯è² å·) ã‚’å¿…ãšå‡ºåŠ›ã—ã¾ã™ã€‚ 空白文字 (+ +):: 出力ã™ã‚‹æ•°å€¤ã«ç¬¦å· (æ­£å·ã¾ãŸã¯è² å·) ãŒä»˜ã‹ãªã„å ´åˆã¯ã€ç¬¦å·ã®ä»£ã‚りã«ç©ºç™½æ–‡å­—を出力ã—ã¾ã™ã€‚ +#+:: 値を別形å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ +%o+ ã®å ´åˆã€å‡ºåŠ›ã™ã‚‹å…«é€²æ•°ã®å…ˆé ­ã«å¿…ãšä¸€æ¡ä»¥ä¸Šã® 0 ãŒä»˜ãよã†ã«ã€å¿…è¦ã«å¿œã˜ã¦ 0 を付加ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ +%x+ (ã¾ãŸã¯ +%X+) ã®å ´åˆã€å€¤ãŒ 0 ã§ãªã‘ã‚Œã°æ•°å€¤ã®å…ˆé ­ã« +0x+ (ã¾ãŸã¯ +0X+) を付加ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ +%e+, +%E+, +%f+, +%F+, +%g+, +%G+ ã®å ´åˆã€å°æ•°ç‚¹ã®å¾Œã«æ•°å­—ãŒãªã„å ´åˆã§ã‚‚å°æ•°ç‚¹ã‚’çœç•¥ã—ãªã„よã†ã«ã—ã¾ã™ã€‚ã¾ãŸå¤‰æ›æŒ‡å®šãŒ +%g+, +%G+ ã®å ´åˆã€å°æ•°ç‚¹ã®å¾Œã« 0 ä»¥å¤–ã®æ•°å­—ãŒãªã„å ´åˆã§ã‚‚ 0 ã‚’çœç•¥ã—ãªã„よã†ã«ã—ã¾ã™ã€‚ ゼロ (+0+):: å¤‰æ›æŒ‡å®šãŒ +%d+, +%i+, +%u+, +%o+, +%x+, +%X+, +%e+, +%E+, +%f+, +%F+, +%g+, +%G+ ã®å ´åˆã€å‡ºåŠ›ãŒæŒ‡å®šã—ãŸãƒ•ィールド幅ã„ã£ã±ã„ã«ãªã‚‹ã¾ã§æ•°å€¤ã®å…ˆé ­ã« 0 を付加ã—ã¾ã™ã€‚ + ãƒžã‚¤ãƒŠã‚¹ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã“ã®ãƒ•ラグã¯ç„¡è¦–ã•れã¾ã™ã€‚ + å¤‰æ›æŒ‡å®šãŒ +%d+, +%i+, +%u+, +%o+, +%x+, +%X+ ã§ã€ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã“ã®ãƒ•ラグã¯ç„¡è¦–ã•れã¾ã™ã€‚ [[convspec-width]] ==== フィールド幅 フィールド幅ã¯ã€å…ˆé ­ã« 0 ã®ä»˜ã‹ãªã„å進整数ã®å½¢ã§æŒ‡å®šã—ã¾ã™ã€‚ フィールド幅ã¯å‡ºåŠ›ã®æœ€ä½Žãƒã‚¤ãƒˆæ•°ã‚’指示ã—ã¾ã™ã€‚出力ã®ãƒã‚¤ãƒˆæ•°ãŒãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰å¹…ã«æº€ãŸãªã„ã¨ãã¯ã€ãƒã‚¤ãƒˆæ•°ãŒãƒ•ィールド幅ã«ä¸€è‡´ã™ã‚‹ã¾ã§ç©ºç™½æ–‡å­—を付加ã—ã¾ã™ã€‚ [[convspec-precision]] ==== 精度 精度ã¯ã€ãƒ”リオド (+.+) ã®ç›´å¾Œã«å進整数を置ã„ãŸã‚‚ã®ã®å½¢ã§æŒ‡å®šã—ã¾ã™ã€‚ピリオドã®å¾Œã«æ•´æ•°ãŒãªã‘れã°ã€0 ãŒæŒ‡å®šã—ã¦ã‚ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ +%d+, +%i+, +%u+, +%o+, +%x+, +%X+ ã®å ´åˆã€ç²¾åº¦ã¯å‡ºåŠ›ã®æœ€ä½Žæ¡æ•°ã‚’指示ã—ã¾ã™ã€‚æ•°å€¤ãŒæœ€ä½Žæ¡æ•°ã«æº€ãŸãªã„å ´åˆã¯æœ€ä½Žæ¡æ•°ã«é”ã™ã‚‹ã¾ã§å…ˆé ­ã« 0 を付加ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 1 ã¨ã¿ãªã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ +%e+, +%E+, +%f+, +%F+ ã®å ´åˆã€ç²¾åº¦ã¯å°æ•°ç‚¹ä»¥é™ã®æ¡æ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 6 ã¨ã¿ãªã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ +%g+, +%G+ ã®å ´åˆã€ç²¾åº¦ã¯æ•°å€¤ã®æœ€å¤§æœ‰åŠ¹æ¡æ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 6 ã¨ã¿ãªã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ +%s+, +%b+ ã®å ´åˆã€ç²¾åº¦ã¯å‡ºåŠ›ã™ã‚‹æ–‡å­—åˆ—ã®æœ€å¤§ãƒã‚¤ãƒˆæ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ç„¡é™å¤§ã¨ã¿ãªã—ã¾ã™ã€‚ [[convspec-examples]] ==== 例 å¤‰æ›æŒ‡å®š +%f+ ã«ã‚¼ãƒ­ãƒ•ラグを指定ã—ã€ãƒ•ィールド幅㫠8ã€ç²¾åº¦ã« 3 を指定ã™ã‚‹å ´åˆã€æœ€çµ‚çš„ãªå¤‰æ›æŒ‡å®šã¯ +%08.3f+ ã¨ãªã‚Šã¾ã™ã€‚ã“ã®å¤‰æ›æŒ‡å®šã«å¯¾ã—ã¦å€¤ 12.34 を与ãˆã‚‹ã¨ã€å‡ºåŠ›ã¯ +0012.340+ ã¨ãªã‚Šã¾ã™ã€‚ [[escapes]] === エスケープシーケンス 書å¼ã®ä¸­ã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +\a+:: ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7) +\b+:: ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 8) +\f+:: フォームフィード (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 12) +\n+:: 改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10) +\r+:: 復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13) +\t+:: 水平タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 9) +\v+:: 垂直タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 11) +\\+:: ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ +\"+:: 二é‡å¼•用符 +\'+:: 一é‡å¼•用符 (ã‚¢ãƒã‚¹ãƒˆãƒ­ãƒ•ィー) +\{{xxx}}+:: 八進数 {{xxx}} (最大三æ¡) ã§è¡¨ã‚ã•れるコード番å·ã®æ–‡å­— [[operands]] == オペランド {{書å¼}}:: 出力ã™ã‚‹æ–‡å­—åˆ—ã®æ›¸å¼ã§ã™ã€‚ {{値}}:: å¤‰æ›æŒ‡å®šãŒå‡ºåŠ›ã™ã‚‹å€¤ (数値ã¾ãŸã¯æ–‡å­—列) ã§ã™ã€‚ + 数値を値ã¨ã—ã¦æŒ‡å®šã™ã‚‹éš›ã€ä¸€é‡ã¾ãŸã¯äºŒé‡å¼•用符ã®å¾Œã«ä½•ã‹æ–‡å­—ã‚’ç½®ã„ãŸã‚‚ã®ã‚’指定ã™ã‚‹ã“ã¨ã§ã€ãã®æ–‡å­—ã®ã‚³ãƒ¼ãƒ‰ç•ªå·ã‚’数値ã¨ã—ã¦æŒ‡å®šã§ãã¾ã™ã€‚例ãˆã° +3+ ã¨ã„ã†æ–‡å­—ã®ã‚³ãƒ¼ãƒ‰ç•ªå·ãŒ 51 ãªã‚‰ã°ã€ `printf '%d' '"3'` 㯠+51+ を出力ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š printf コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã§ã¯ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã®æ‰±ã„ã«ã¤ã„ã¦å޳坆ã«å®šç¾©ã—ã¦ã„ã¾ã›ã‚“。+%s+ å¤‰æ›æŒ‡å®šã§ç²¾åº¦ã‚’指定ã—ãŸå ´åˆã‚„ã€+%c+ å¤‰æ›æŒ‡å®šã‚’使用ã™ã‚‹å ´åˆã€å€¤ã«ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ãŒå«ã¾ã‚Œã¦ã„ã‚‹ã¨é©åˆ‡ãªå‡ºåŠ›ãŒå¾—られãªã„ã‹ã‚‚ã—れã¾ã›ã‚“。Yash ã§ã¯ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã¯å…¨ã¦ãƒ¯ã‚¤ãƒ‰æ–‡å­—ã«å¤‰æ›ã—ã¦ã‹ã‚‰å‡¦ç†ã™ã‚‹ã®ã§ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã®ä¸€éƒ¨ã®ãƒã‚¤ãƒˆã ã‘ãŒå‡ºåŠ›ã•れるよã†ãªã“ã¨ã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_bg.txt0000644000175000017500000000276212154557026015204 0ustar magicantmagicant= Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚¸ãƒ§ãƒ–ã‚’ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +bg [{{ジョブ}}...]+ [[description]] == 説明 Bg コマンドã¯ã‚¸ãƒ§ãƒ–ã‚’ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚ジョブã«ã¯ SIGCONT シグナルãŒé€ã‚‰ã‚Œã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ã¦ã„ã‚‹å ´åˆã¯å†é–‹ã•れã¾ã™ã€‚ ジョブã®å®Ÿè¡Œã‚’å†é–‹ã™ã‚‹å‰ã« bg コマンドã¯ã‚¸ãƒ§ãƒ–ã®åå‰ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ Bg コマンドã¯link:job.html[ジョブ制御]ãŒæœ‰åŠ¹ãªæ™‚ã—ã‹ä½¿ãˆã¾ã›ã‚“。 [[operands]] == オペランド {{ジョブ}}:: 実行ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®link:job.html#jobid[ジョブ ID]。 + ジョブを複数指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を実行ã—ã¾ã™ã€‚ + éž link:posix.html[POSIX 準拠モード]ã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® +%+ ã¯çœç•¥ã§ãã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š bg コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Bg コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã¯æŒ‡å®šã—ãŸã‚¸ãƒ§ãƒ–ãŒæ—¢ã«å®Ÿè¡Œä¸­ã®å ´åˆã¯ bg コマンドã¯ä½•ã‚‚ã—ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ãŒã€yash ã® bg コマンドã¯ã‚¸ãƒ§ãƒ–ãŒå®Ÿè¡Œä¸­ã‹ã©ã†ã‹ã«ã‹ã‹ã‚ら㚠SIGCONT シグナルをé€ä¿¡ã—ã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_export.html0000644000175000017500000000412112154557026016251 0ustar magicantmagicant Export 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Export 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã®å¤‰æ•°ã‚’表示・設定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • export [-prX] [変数[=値]…]

説明

Export コマンド㯠typeset コマンド㫠-gx オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠typeset コマンドã¨åŒæ§˜ã§ã™ã€‚

補足

Export コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ export コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã™ãŒã€ã‚ªãƒ—ション㯠-p ã—ã‹è¦å®šãŒã‚りã¾ã›ã‚“。ãã®ä»–ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠-p オプションをオペランドã¨ã¨ã‚‚ã«ä½¿ã†ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。

yash-2.35/doc/ja/_exit.html0000644000175000017500000001134112154557026015703 0ustar magicantmagicant Exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚

æ§‹æ–‡

  • exit [-f] [終了ステータス]

説明

Exit コマンドã¯ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã‚·ã‚§ãƒ« (ã¾ãŸã¯ã‚µãƒ–シェル) を終了ã—ã¾ã™ã€‚

åœæ­¢ã—ã¦ã„るジョブã®ã‚る対話モードã®ã‚·ã‚§ãƒ«ã‚’終了ã—よã†ã¨ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€çµ‚了ã—ã¾ã›ã‚“。-f (--force) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã‹ exit コマンドを二連続ã§å®Ÿè¡Œã™ã‚‹ã¨è­¦å‘Šã‚’無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’終了ã—ã¾ã™ã€‚

シェル終了時ã®ãƒˆãƒ©ãƒƒãƒ—ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ãŒçµ‚了ã™ã‚‹å‰ã«ãれãŒå®Ÿè¡Œã•れã¾ã™ã€‚

オプション

-f
--force

警告を無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’終了ã—ã¾ã™ã€‚

オペランド

終了ステータス

終了ã™ã‚‹ã‚·ã‚§ãƒ«ã®çµ‚了ステータスを指定ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚

ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€exit コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを用ã„ã¾ã™ (ãŸã ã—トラップを実行中ã®å ´åˆã¯ãƒˆãƒ©ãƒƒãƒ—ã«å…¥ã‚‹ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス)。

終了ã™ã‚‹ã‚·ã‚§ãƒ«ã®å®Ÿéš›ã®çµ‚了ステータスã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸæ•°ã‚’ 256 ã§å‰²ã£ãŸä½™ã‚Šã«ãªã‚Šã¾ã™ã€‚

終了ステータス

Exit コマンドã¯ã‚·ã‚§ãƒ«ã‚’終了ã™ã‚‹ã®ã§ã€exit コマンドãã®ã‚‚ã®ã®çµ‚了ステータスã¯ã‚りã¾ã›ã‚“。

例外ã¨ã—ã¦ã€exit コマンドãŒè­¦å‘Šã‚’表示ã—ã¦ã€ã‚·ã‚§ãƒ«ã‚’終了ã—ãªã‹ã£ãŸå ´åˆã€exit コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

Exit コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã§ã¯ã€çµ‚了ステータスã®å€¤ã¯ 0 以上 256 未満ã§ãªã‘れã°ãªã‚‰ãªã„ã¨ã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯æ‹¡å¼µã¨ã—㦠256 以上ã®å€¤ã‚‚å—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚

POSIX ã«ã¯ -f (--force) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

シェル終了時ã®ãƒˆãƒ©ãƒƒãƒ—ã®å®Ÿè¡Œä¸­ã« exit コマンドを実行ã™ã‚‹ã¨ã€å†ã³ãƒˆãƒ©ãƒƒãƒ—ãŒå®Ÿè¡Œã•れるã“ã¨ã¯ãªããã®ã¾ã¾ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚ã“ã®ã¨ã exit コマンドã«çµ‚了ステータスãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€ã‚‚ã—終了時ã®ãƒˆãƒ©ãƒƒãƒ—ãŒè¨­å®šã•れã¦ã„ãªã‹ã£ãŸå ´åˆã«ã‚·ã‚§ãƒ«ãŒè¿”ã—ãŸã‚ã†çµ‚了ステータスã§ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚(シェルã®çµ‚了もå‚ç…§)

yash-2.35/doc/ja/_suspend.txt0000644000175000017500000000304712154557026016272 0ustar magicantmagicant= Suspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Suspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Suspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ã‚’åœæ­¢ (サスペンド) ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +suspend [-f]+ [[description]] == 説明 Suspend コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスãŒå±žã™ã‚‹ãƒ—ロセスグループ内ã®ã™ã¹ã¦ã®ãƒ—ロセスã«å¯¾ã—㦠SIGSTOP シグナルをé€ä¿¡ã—ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‰ã‚ŒãŸå„プロセス (シェル自身をå«ã‚€) ã¯åœæ­¢ (サスペンド) 状態ã«ãªã‚Šã¾ã™ã€‚åœæ­¢çŠ¶æ…‹ã«ãªã£ãŸãƒ—ロセス㯠SIGCONT シグナルをå—ä¿¡ã™ã‚‹ã¨å®Ÿè¡Œã‚’å†é–‹ã—ã¾ã™ã€‚ シェルãŒlink:interact.html[対話モード]ã§ã€ã•らã«ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ—ロセスグループ ID ãŒã‚»ãƒƒã‚·ãƒ§ãƒ³ãƒªãƒ¼ãƒ€ãƒ¼ã®ãƒ—ロセス ID ã«ç­‰ã—ã„ã¨ãã¯ã€+-f+ (+--force+) オプションを付ã‘ãªã„é™ã‚Šã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã›ã‚“。ã“れã¯ã‚·ã‚§ãƒ«ãŒåœæ­¢ã—ãŸå¾Œå®Ÿè¡Œã‚’å†é–‹ã•ã›ã‚‹ã“ã¨ãŒã§ããªããªã£ã¦ã—ã¾ã†ã®ã‚’未然ã«é˜²ããŸã‚ã§ã™ã€‚ [[options]] == オプション +-f+:: +--force+:: 警告を無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’åœæ­¢ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス Suspend コマンドã®çµ‚了ステータスã¯ã€SIGSTOP ã‚·ã‚°ãƒŠãƒ«ã‚’ã‚·ã‚§ãƒ«ã«æ­£ã—ãé€ä¿¡ã§ããŸã¨ã㯠0ã€ãれ以外ãªã‚‰éž 0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ suspend コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/lineedit.txt0000644000175000017500000016015112154557026016247 0ustar magicantmagicant= 行編集 :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - 行編集 :description: Yash ã®è¡Œç·¨é›†æ©Ÿèƒ½ã®èª¬æ˜Ž dfn:[行編集]機能ã¯ã€link:interact.html[対話モード]ã®ã‚·ã‚§ãƒ«ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã™ã‚‹éš›ã«ä½¿ãˆã‚‹ã€ã‚³ãƒžãƒ³ãƒ‰ã®ç°¡æ˜“編集機能ã§ã™ã€‚行編集機能ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã™ã‚‹ãŸã‚ã®ç°¡å˜ãªã‚¨ãƒ‡ã‚£ã‚¿ã¨ã—ã¦åƒãã¾ã™ã€‚行編集機能ã¯link:interact.html#history[コマンド履歴]ã¨ã‚‚連æºã—ã¦ãŠã‚Šã€link:_fc.html[fc コマンド]を使ã£ã¦ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã™ã‚‹ä»£ã‚りã«è¡Œç·¨é›†ã§ç›´æŽ¥ã‚³ãƒžãƒ³ãƒ‰ã‚’編集・å†å®Ÿè¡Œã§ãã¾ã™ã€‚ 行編集ã«ã¯è¤‡æ•°ã®ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ãŒã‚りã€ãƒ¢ãƒ¼ãƒ‰ã”ã¨ã«ã‚­ãƒ¼æ“作ã®å‰²ã‚Šå½“ã¦ãŒç•°ãªã‚Šã¾ã™ã€‚è¡Œç·¨é›†ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’åˆ‡ã‚Šæ›¿ãˆãŸã‚Šãƒ¢ãƒ¼ãƒ‰ã‚’é¸æŠžã—ãŸã‚Šã™ã‚‹ã«ã¯ã€link:_set.html[set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ—ションを設定ã—ã¾ã™ã€‚ã‚るモードã«å¯¾å¿œã™ã‚‹ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãã®ãƒ¢ãƒ¼ãƒ‰ã®è¡Œç·¨é›†ãŒæœ‰åйã«ãªã‚Šã¾ã™ (åŒæ™‚ã«ä»–ã®ãƒ¢ãƒ¼ãƒ‰ã®ã‚ªãƒ—ションã¯è‡ªå‹•çš„ã«ç„¡åйã«ãªã‚Šã¾ã™)。ç¾åœ¨æœ‰åйã«ãªã£ã¦ã„るモードã®ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã¨ã€è¡Œç·¨é›†ã¯ç„¡åйã«ãªã‚Šã¾ã™ã€‚ç¾åœ¨ yash ãŒæ­è¼‰ã—ã¦ã„る編集モード㯠vi 風㨠emacs 風ã®äºŒç¨®é¡žã§ã€ãれãžã‚Œå¯¾å¿œã™ã‚‹ã‚ªãƒ—ション㯠+-o vi+ 㨠+-o emacs+ ã§ã™ã€‚ シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§èµ·å‹•ã—ãŸã¨ãã€æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ãªã‚‰ã°ã€vi 風行編集ãŒè‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚ 行編集ã¯ã€æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ã®ã¨ãã ã‘使ãˆã¾ã™ã€‚ã“ã®æ¡ä»¶ãŒæº€ãŸã•れã¦ã„ãªã„ã¨ãã¯ã€è¡Œç·¨é›†ã¯åƒãã¾ã›ã‚“。行編集ãŒåƒãã¨ãã€ã‚·ã‚§ãƒ«ã¯ termios インタフェースを使用ã—ã¦ç«¯æœ«ã®å…¥å‡ºåŠ›ãƒ¢ãƒ¼ãƒ‰ã‚’ä¸€æ™‚çš„ã«å¤‰æ›´ã—ã€terminfo インタフェースを使用ã—ã¦å…¥åŠ›ã•れãŸã‚­ãƒ¼ã®åˆ¤åˆ¥ãªã©ã‚’行ã„ã¾ã™ã€‚ [[options]] == 行編集ã®ã‚ªãƒ—ション 行編集を有効ã«ã—ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’é¸æŠžã™ã‚‹ã‚ªãƒ—ションã¨ã—ã¦ã€ä»¥ä¸‹ã®ã‚ªãƒ—ション㌠link:_set.html[set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§è¨­å®šã§ãã¾ã™ã€‚ link:_set.html#so-vi[vi]:: Vi 風編集モードを有効ã«ã—ã¾ã™ link:_set.html#so-emacs[emacs]:: Emacs 風編集モードを有効ã«ã—ã¾ã™ ã“ã®ä»–ã«ã€è¡Œç·¨é›†ã«é–¢ã‚ã‚‹ã‚‚ã®ã¨ã—ã¦ä»¥ä¸‹ã®ã‚ªãƒ—ションãŒè¨­å®šã§ãã¾ã™ã€‚ link:_set.html#so-lealwaysrp[le-always-rp]:: ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã¯ã€é•·ã„コマンドを入力ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ãŒå³ãƒ—ロンプトã«é”ã™ã‚‹ã¨ã€å³ãƒ—ロンプトã¯è¦‹ãˆãªããªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€å³ãƒ—ロンプトã¯è¦‹ãˆãªããªã‚‹ä»£ã‚りã«ä¸‹ã«ç§»å‹•ã—ã¾ã™ã€‚ link:_set.html#so-lecompdebug[le-comp-debug]:: <>を行ã†éš›ã«ãƒ‡ãƒãƒƒã‚°ç”¨ã®æƒ…報を出力ã—ã¾ã™ link:_set.html#so-leconvmeta[le-conv-meta]:: Terminfo データベースã§å¾—ã‚‰ã‚ŒãŸæƒ…報を無視ã—ã€å…¥åŠ›ã® 8 ビット目を常㫠meta-key フラグã¨ã¿ãªã—ã¾ã™ã€‚ link:_set.html#so-lenoconvmeta[le-no-conv-meta]:: Terminfo データベースã§å¾—ã‚‰ã‚ŒãŸæƒ…報を無視ã—ã€å…¥åŠ›ã® 8 ビット目を他ã®ãƒ“ットã¨åŒæ§˜ã«æ‰±ã„ã¾ã™ã€‚ + Le-conv-meta オプション㨠le-no-conv-meta オプションã¯ç‰‡æ–¹ã—ã‹æœ‰åйã«ã§ãã¾ã›ã‚“ (片方を有効ã«ã™ã‚‹ã¨ã‚‚ã†ç‰‡æ–¹ã¯è‡ªå‹•çš„ã«ç„¡åйã«ãªã‚Šã¾ã™)。ã©ã¡ã‚‰ã‚‚ç„¡åŠ¹ãªæ™‚㯠terminfo ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®æƒ…å ±ã«å¾“ã£ã¦ 8 ビット目を meta-key ã¨ã¿ãªã™ã‹ã©ã†ã‹åˆ¤æ–­ã—ã¾ã™ã€‚ link:_set.html#so-lepromptsp[le-prompt-sp]:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯link:interact.html#prompt[プロンプト]を出力ã™ã‚‹å‰ã«ã€ãƒ—ロンプトãŒå¿…ãšè¡Œé ­ã«æ¥ã‚‹ã‚ˆã†ã«ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã™ã‚‹ãŸã‚ã®ç‰¹æ®Šãªæ–‡å­—列を出力ã—ã¾ã™ã€‚ + ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã¯æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ link:_set.html#so-levisiblebell[le-visible-bell]:: シェルãŒè­¦å‘Šã‚’発ã™ã‚‹éš›ã€è­¦å‘ŠéŸ³ã‚’鳴らã™ä»£ã‚りã«ç«¯æœ«ã‚’点滅ã•ã›ã¾ã™ã€‚ [[modes]] == 編集モード dfn:[Vi 風編集モード]㯠vi ã«ä¼¼ãŸã‚­ãƒ¼æ“作ã§ç·¨é›†ã‚’行ã†ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚Vi 風編集モードã§ã¯ã€æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã¨ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã®äºŒã¤ã®ãƒ¢ãƒ¼ãƒ‰ã‚’é©å®œåˆ‡ã‚Šæ›¿ãˆã¦ç·¨é›†ã‚’行ã„ã¾ã™ã€‚編集ãŒå§‹ã¾ã‚‹ã¨ãã¯ãƒ¢ãƒ¼ãƒ‰ã¯å¿…ãšæŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«ãªã£ã¦ã„ã¾ã™ã€‚挿入モードã§ã¯å…¥åŠ›ã—ãŸæ–‡å­—ãŒåŸºæœ¬çš„ã«ãã®ã¾ã¾ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã•れã¾ã™ã€‚コマンドモードã§ã¯å…¥åŠ›ã—ãŸæ–‡å­—ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã—ãŸã‚Šæ–‡å­—を消去ã—ãŸã‚Šã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ dfn:[Emacs 風編集モード]㯠emacs ã«ä¼¼ãŸã‚­ãƒ¼æ“作ã§ç·¨é›†ã‚’行ã†ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚入力ã—ãŸæ–‡å­—ã¯åŸºæœ¬çš„ã«ãã®ã¾ã¾ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã•れã¾ã™ãŒã€ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れる一部ã®ã‚­ãƒ¼æ“作㌠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã¨ç•°ãªã‚Šã¾ã™ã€‚ ã“れらã®ãƒ¢ãƒ¼ãƒ‰ã®ä»–ã«ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®éš›ã«ç”¨ã„る検索モード㌠vi 風㨠emacs 風ã¨ãれãžã‚Œã«ã‚りã¾ã™ã€‚ [[commands]] == 行編集コマンド 行編集中ã«å…¥åŠ›ã•ã‚ŒãŸæ–‡å­—ã¯å…¨ã¦ä»¥ä¸‹ã®è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®ã„ãšã‚Œã‹ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚コマンドã¨ã‚­ãƒ¼ã®å¯¾å¿œã¯ link:_bindkey.html[bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§å¤‰æ›´ã§ãã¾ã™ (検索モードを除ã)。 以下ã®ä¸€è¦§ã«ã¯å„コマンドã«å¯¾å¿œã™ã‚‹ã‚­ãƒ¼å…¥åŠ›ã®åˆæœŸè¨­å®šã‚‚示ã—ã¦ã‚りã¾ã™ã€‚ãªãŠã€ ``vi-insert'' 㯠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã‚’〠``vi-command'' 㯠vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã‚’〠``vi-search'' 㯠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã‚’〠``emacs'' 㯠emacs 風編集モードを〠``emacs-search'' 㯠emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã‚’示ã—ã¾ã™ã€‚ コマンドã®ä¸­ã«ã¯å¼•数を指定ã™ã‚‹ã“ã¨ã§ãã®å‹•作を変更ã§ãã‚‹ã‚‚ã®ãŒã‚りã¾ã™ã€‚例ãˆã° forward-char コマンドã¯é€šå¸¸ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’一文字分å‰ã«ç§»å‹•ã—ã¾ã™ãŒã€å¼•数を指定ã™ã‚‹ã¨ãã®å¼•æ•°ã®æ–‡å­—数分ã ã‘カーソルを移動ã—ã¾ã™ã€‚引数ã¯ã€ç›®çš„ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å‰ã« digit-argument コマンドを使ã†ã“ã¨ã§æŒ‡å®šã§ãã¾ã™ã€‚ [[basic-commands]] === 基本的ãªç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ noop:: 何も行ã„ã¾ã›ã‚“。 + -- vi-command:: ifdef::basebackend-html[+++\^[+++] ifndef::basebackend-html[`\^[`] -- alert:: 警告音を発ã—ã¾ãŸã¯ç«¯æœ«ã‚’点滅ã•ã›ã¾ã™ã€‚ self-insert:: 入力ã—ãŸæ–‡å­—ã‚’ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚(<>ã«ã‚ˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã®å¯¾è±¡ã¨ãªã‚‹æ–‡å­—ã¯æŒ¿å…¥ã§ãã¾ã›ã‚“) + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\\+++] ifndef::basebackend-html[`\\`] -- insert-tab:: タブをç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^[\^I+++] ifndef::basebackend-html[`\^[\^I`] -- expect-verbatim:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã™ã‚‹ä¸€æ–‡å­—ã‚’ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã†ã¨ self-insert コマンドã§å…¥åŠ›ã§ããªã„文字も入力ã§ãã¾ã™ (ナル文字 `'\0'` を除ã)。 + -- vi-insert:: vi-search:: emacs-search:: ifdef::basebackend-html[+++\^V+++] ifndef::basebackend-html[`\^V`] emacs:: ifdef::basebackend-html[] +++\^Q, \^V+++ endif::basebackend-html[] ifndef::basebackend-html[`\^Q`, `\^V`] -- digit-argument:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ•°å­—ã¾ãŸã¯ãƒã‚¤ãƒ•ンã®å…¥åŠ›ã«å¯¾ã—ã¦ã®ã¿æœ‰åйã§ã™ã€‚入力ã—ãŸæ•°å­—を次ã®ã‚³ãƒžãƒ³ãƒ‰ã¸ã®å¼•æ•°ã¨ã—ã¦å—ã‘付ã‘ã¾ã™ (ãƒã‚¤ãƒ•ンã®å ´åˆã¯ç¬¦å·ã‚’å転ã—ã¾ã™)。 + Digit-argument コマンドを連続ã—ã¦ä½¿ã†ã“ã¨ã§è¤‡æ•°æ¡ã®å¼•数を指定ã§ãã¾ã™ã€‚例ãˆã° vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã§ +12l+ ã¨å…¥åŠ›ã™ã‚‹ã¨ã€forward-char コマンドã«å¼•æ•° 12 を与ãˆãŸã“ã¨ã«ãªã‚Šã¾ã™ (ã™ãªã‚ã¡ã‚«ãƒ¼ã‚½ãƒ«ãŒå·¦ã« 12 文字分移動ã—ã¾ã™)。 + -- vi-command:: ifdef::basebackend-html[] +++1, 2, 3, 4, 5, 6, 7, 8, 9+++ endif::basebackend-html[] ifndef::basebackend-html[`1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`] emacs:: ifdef::basebackend-html[] +++\^[0, \^[1, \^[2, \^[3, \^[4, \^[5, \^[6, \^[7, \^[8, \^[9, \^[-+++ endif::basebackend-html[] ifndef::basebackend-html[] `\^[0`, `\^[1`, `\^[2`, `\^[3`, `\^[4`, `\^[5`, `\^[6`, `\^[7`, `\^[8`, `\^[9`, `\^[-`, endif::basebackend-html[] -- bol-or-digit:: 引数ãŒãªã„å ´åˆã¯ beginning-of-line コマンドã¨åŒã˜ã‚ˆã†ã«ã€å¼•æ•°ãŒã‚ã‚‹å ´åˆã¯ digit-argument コマンドã¨åŒã˜ã‚ˆã†ã«å‹•作ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++0+++] ifndef::basebackend-html[`0`] -- accept-line:: 行編集を終了ã—ã€ç¾åœ¨ã®ãƒãƒƒãƒ•ã‚¡ã®å†…容をシェルã¸ã®å…¥åŠ›ã¨ã—ã¦ä¸Žãˆã¾ã™ã€‚è¡Œã®æœ«å°¾ã«ã¯è‡ªå‹•çš„ã«æ”¹è¡ŒãŒä»˜ã‘加ã‚りã¾ã™ã€‚ + -- vi-insert:: vi-command:: emacs:: emacs-search:: ifdef::basebackend-html[] +++\^J, \^M+++ endif::basebackend-html[] ifndef::basebackend-html[`\^J`, `\^M`] -- abort-line:: 行編集を中止ã—ã€ç©ºã®å…¥åŠ›ã‚’ã‚·ã‚§ãƒ«ã«ä¸Žãˆã¾ã™ã€‚ + -- vi-insert:: vi-command:: vi-search:: emacs:: emacs-search:: ifdef::basebackend-html[] +++\!, \^C+++ endif::basebackend-html[] ifndef::basebackend-html[`\!`, `\^C`] -- eof:: シェルã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。 eof-if-empty:: ãƒãƒƒãƒ•ã‚¡ãŒç©ºãªã‚‰ã°ã€è¡Œç·¨é›†ã‚’終了ã—ã€ã‚·ã‚§ãƒ«ã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。ãƒãƒƒãƒ•ã‚¡ãŒç©ºã§ãªã‘れã°ã€alert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-insert:: vi-command:: ifdef::basebackend-html[] +++\#, \^D+++ endif::basebackend-html[] ifndef::basebackend-html[`\#`, `\^D`] -- eof-or-delete:: ãƒãƒƒãƒ•ã‚¡ãŒç©ºãªã‚‰ã°ã€è¡Œç·¨é›†ã‚’終了ã—ã€ã‚·ã‚§ãƒ«ã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。ãƒãƒƒãƒ•ã‚¡ãŒç©ºã§ãªã‘れã°ã€delete-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\#, \^D+++ endif::basebackend-html[] ifndef::basebackend-html[`\#`, `\^D`] -- accept-with-hash:: 引数ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã‹ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã®æ–‡å­—㌠+#+ ã§ãªã‘れã°ã€ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã« +#+ を挿入ã—ã¾ã™ã€‚ãã†ã§ãªã‘れã°ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã® +#+ を削除ã—ã¾ã™ã€‚ã„ãšã‚Œã®å ´åˆã‚‚ã€ãã®å¾Œ accept-line コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++#+++] ifndef::basebackend-html[`#`] emacs:: ifdef::basebackend-html[+++\^[#+++] ifndef::basebackend-html[`\^[#`] -- setmode-viinsert:: 編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++i, \I+++] ifndef::basebackend-html[`i`, `\I`] -- setmode-vicommand:: 編集モードを vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-insert:: ifdef::basebackend-html[+++\^[+++] ifndef::basebackend-html[`\^[`] -- setmode-emacs:: 編集モードを emacs 風編集モードã«å¤‰æ›´ã—ã¾ã™ã€‚ expect-char:: abort-expect-char:: ã“れ㯠find-char コマンドãªã©ã‚’実装ã™ã‚‹ãŸã‚ã« yash 内部ã§ä½¿ã‚れã¦ã„るコマンドã§ã€ç›´æŽ¥ä½¿ç”¨ã—ã¦ã‚‚æ„味ã¯ã‚りã¾ã›ã‚“。 redraw-all:: 行編集ã®ãƒ—ロンプトやãƒãƒƒãƒ•ァを端末ã«è¡¨ç¤ºã—ãªãŠã—ã¾ã™ã€‚ + -- vi-insert:: vi-command:: vi-search:: emacs:: emacs-search:: ifdef::basebackend-html[+++\^L+++] ifndef::basebackend-html[`\^L`] -- clear-and-redraw-all:: 端末ã®è¡¨ç¤ºã‚’クリアã—ã€è¡Œç·¨é›†ã®ãƒ—ロンプトやãƒãƒƒãƒ•ァを端末ã«è¡¨ç¤ºã—ãªãŠã—ã¾ã™ã€‚ [[motion-commands]] === 移動コマンド dfn:[移動コマンド]ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã•ã›ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ã»ã¨ã‚“ã©ã®ç§»å‹•コマンドã¯å¼•数を与ãˆã‚‹ã“ã¨ã§ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’引数ã®å›žæ•°ã ã‘実行ã™ã‚‹ã®ã¨åŒã˜ã‚ˆã†ã«å‹•作ã•ã›ã‚‰ã‚Œã¾ã™ã€‚例ãˆã° forward-char コマンドã«å¼•æ•° 4 を与ãˆã‚‹ã¨ã€ã‚«ãƒ¼ã‚½ãƒ«ã‚’ 4 文字先ã«é€²ã‚ã¾ã™ã€‚ 以下ã€dfn:[bigword] ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸç©ºç™½ã§ãªã„文字をã„ã„ã€dfn:[semiword] ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸç©ºç™½ã§ã‚‚å¥èª­ç‚¹ã§ã‚‚ãªã„文字をã„ã„ã€dfn:[emacsword] ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸè‹±æ•°å­—ã‚’ã„ã„ã¾ã™ã€‚ã¾ãŸ dfn:[viword] ã¨ã¯ä»¥ä¸‹ã®ã„ãšã‚Œã‹ã‚’ã„ã„ã¾ã™ - 一文字以上ã®é€£ç¶šã—ãŸè‹±æ•°å­—ã¾ãŸã¯ä¸‹ç·š (+_+) - 一文字以上ã®é€£ç¶šã—ãŸã€è‹±æ•°å­—ã§ã‚‚下線ã§ã‚‚空白ã§ã‚‚ãªã„文字 以下ã«ç§»å‹•コマンドã®ä¸€è¦§ã‚’示ã—ã¾ã™ã€‚ forward-char:: ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-insert:: ifdef::basebackend-html[+++\R+++] ifndef::basebackend-html[`\R`] vi-command:: ifdef::basebackend-html[] +++l, (空白文字), \R+++ endif::basebackend-html[] ifndef::basebackend-html[`l`, (space), `\R`] emacs:: ifdef::basebackend-html[] +++\R, \^F+++ endif::basebackend-html[] ifndef::basebackend-html[`\R`, `\^F`] -- backward-char:: カーソルをå‰ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-insert:: ifdef::basebackend-html[+++\L+++] ifndef::basebackend-html[`\L`] vi-command:: ifdef::basebackend-html[] +++h, \B, \L, \?, \^H, +++ endif::basebackend-html[] ifndef::basebackend-html[`h`, `\B`, `\L`, `\?`, `\^H`] emacs:: ifdef::basebackend-html[] +++\L, \^B+++ endif::basebackend-html[] ifndef::basebackend-html[`\L`, `\^B`] -- forward-bigword:: カーソルを次㮠bigword ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++W+++] ifndef::basebackend-html[`W`] -- end-of-bigword:: カーソルを bigword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++E+++] ifndef::basebackend-html[`E`] -- backward-bigword:: カーソルをå‰ã® bigword ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++B+++] ifndef::basebackend-html[`B`] -- forward-semiword:: カーソルを次㮠semiword ã«ç§»å‹•ã—ã¾ã™ã€‚ end-of-semiword:: カーソルを semiword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚ backward-semiword:: カーソルをå‰ã® semiword ã«ç§»å‹•ã—ã¾ã™ã€‚ forward-viword:: カーソルを次㮠viword ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++w+++] ifndef::basebackend-html[`w`] -- end-of-viword:: カーソルを viword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++e+++] ifndef::basebackend-html[`e`] -- backward-viword:: カーソルをå‰ã® viword ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++b+++] ifndef::basebackend-html[`b`] -- forward-emacsword:: カーソルを次㮠emacsword ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[f, \^[F+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[f`, `\^[F`] -- backward-emacsword:: カーソルをå‰ã® emacsword ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[b, \^[B+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[b`, `\^[B`] -- beginning-of-line:: カーソルをãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-insert:: vi-command:: ifdef::basebackend-html[+++\H+++] ifndef::basebackend-html[`\H`] emacs:: ifdef::basebackend-html[] +++\H, \^A+++ endif::basebackend-html[] ifndef::basebackend-html[`\H`, `\^A`] -- end-of-line:: カーソルをãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-insert:: ifdef::basebackend-html[+++\E+++] ifndef::basebackend-html[`\E`] vi-command:: ifdef::basebackend-html[+++$, \E+++] ifndef::basebackend-html[`$`, `\E`] emacs:: ifdef::basebackend-html[] +++\E, \^E+++ endif::basebackend-html[] ifndef::basebackend-html[`\E`, `\^E`] -- go-to-column:: カーソルをãƒãƒƒãƒ•ァ内㮠{{n}} 文字目ã«ç§»å‹•ã—ã¾ã™ã€‚ãŸã ã— {{n}} ã¯å¼•æ•°ã§ã™ (引数ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ 1)。 + -- vi-command:: ifdef::basebackend-html[+++|+++] ifndef::basebackend-html[`|`] -- first-nonblank:: カーソルをãƒãƒƒãƒ•ã‚¡å†…ã®æœ€åˆã®ç©ºç™½ã§ãªã„文字ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++^+++] ifndef::basebackend-html[`^`] -- find-char:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’進ã‚ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++f+++] ifndef::basebackend-html[`f`] emacs:: ifdef::basebackend-html[+++\^\]+++] ifndef::basebackend-html[`\^\]`] -- find-char-rev:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’戻ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++F+++] ifndef::basebackend-html[`F`] emacs:: ifdef::basebackend-html[+++\^[\^\]+++] ifndef::basebackend-html[`\^[\^\]`] -- till-char:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã®ç›´å‰ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’進ã‚ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++t+++] ifndef::basebackend-html[`t`] -- till-char-rev:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã®ç›´å¾Œã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’戻ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++T+++] ifndef::basebackend-html[`T`] -- refind-char:: å‰å›žå®Ÿè¡Œã—㟠find-char, find-char-rev, till-char, till-char-rev コマンドをå†å®Ÿè¡Œã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++;+++] ifndef::basebackend-html[`;`] -- refind-char-rev:: å‰å›žå®Ÿè¡Œã—㟠find-char, find-char-rev, till-char, till-char-rev コマンドをã€ã‚«ãƒ¼ã‚½ãƒ«ã®é€²ã‚€å‘ãを逆ã«ã—ã¦å†å®Ÿè¡Œã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++,+++] ifndef::basebackend-html[`,`] -- [[editing-commands]] === 編集コマンド 編集コマンドã¯ãƒãƒƒãƒ•ã‚¡ã®å†…容を変更ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ã»ã¨ã‚“ã©ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¯å¼•数を与ãˆã‚‹ã“ã¨ã§ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’引数ã®å›žæ•°ã ã‘実行ã™ã‚‹ã®ã¨åŒã˜ã‚ˆã†ã«å‹•作ã•ã›ã‚‰ã‚Œã¾ã™ã€‚ åå‰ã« ``kill'' ãŒä»˜ãコマンドã§å‰Šé™¤ã—ãŸæ–‡å­—列ã¯dfn:[キルリング]ã¨ã„ã†å ´æ‰€ã«ä¿ç®¡ã•れã€å¾Œã§ put ãªã©ã®ã‚³ãƒžãƒ³ãƒ‰ã§ãƒãƒƒãƒ•ã‚¡ã«æˆ»ã™ã“ã¨ãŒã§ãã¾ã™ã€‚ 以下ã«ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®ä¸€è¦§ã‚’示ã—ã¾ã™ã€‚ delete-char:: カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\X+++] ifndef::basebackend-html[`\X`] -- delete-bigword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ bigword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-bigword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ delete-semiword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ semiword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-semiword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ delete-viword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ viword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-viword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ delete-emacsword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ emacsword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-emacsword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ backward-delete-char:: カーソルã®å‰ã«ã‚る文字を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-insert:: emacs:: ifdef::basebackend-html[] +++\B, \?, \^H+++ endif::basebackend-html[] ifndef::basebackend-html[`\B`, `\?`, `\^H`] -- backward-delete-bigword:: カーソルã®å‰ã«ã‚ã‚‹ bigword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-bigword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ backward-delete-semiword:: カーソルã®å‰ã«ã‚ã‚‹ semiword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-semiword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-insert:: ifdef::basebackend-html[+++\^W+++] ifndef::basebackend-html[`\^W`] -- backward-delete-viword:: カーソルã®å‰ã«ã‚ã‚‹ viword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-viword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ backward-delete-emacsword:: カーソルã®å‰ã«ã‚ã‚‹ emacsword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-emacsword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ delete-line:: ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã¾ã™ã€‚ forward-delete-line:: カーソル以é™ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã¾ã™ã€‚ backward-delete-line:: カーソルよりå‰ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã¾ã™ã€‚ + -- vi-insert:: ifdef::basebackend-html[] +++\$, \^U+++ endif::basebackend-html[] ifndef::basebackend-html[`\$`, `\^U`] -- kill-char:: カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[] +++x, \X+++ endif::basebackend-html[] ifndef::basebackend-html[`x`, `\X`] -- kill-bigword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ bigword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ kill-semiword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ semiword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ kill-viword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ viword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ kill-emacsword:: カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ emacsword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[d, \^[D+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[d`, `\^[D`] -- backward-kill-char:: カーソルã®å‰ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++X+++] ifndef::basebackend-html[`X`] -- backward-kill-bigword:: カーソルã®å‰ã«ã‚ã‚‹ bigword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^W+++] ifndef::basebackend-html[`\^W`] -- backward-kill-semiword:: カーソルã®å‰ã«ã‚ã‚‹ semiword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ backward-kill-viword:: カーソルã®å‰ã«ã‚ã‚‹ viword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ backward-kill-emacsword:: カーソルã®å‰ã«ã‚ã‚‹ emacsword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[\B, \^[\?, \^[\^H+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[\B`, `\^[\?`, `\^[\^H`] -- kill-line:: ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ forward-kill-line:: カーソル以é™ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^K+++] ifndef::basebackend-html[`\^K`] -- backward-kill-line:: カーソルよりå‰ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\$, \^U, \^X\B, \^X\?+++ endif::basebackend-html[] ifndef::basebackend-html[`\$`, `\^U`, `\^X\B`, `\^X\?`] -- put-before:: 最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å‰ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—åˆ—ã®æœ€å¾Œã®æ–‡å­—ã®ã¨ã“ã‚ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++P+++] ifndef::basebackend-html[`P`] -- put:: 最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å¾Œã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—åˆ—ã®æœ€å¾Œã®æ–‡å­—ã®ã¨ã“ã‚ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++p+++] ifndef::basebackend-html[`p`] -- put-left:: 最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å‰ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—列ã®ç›´å¾Œã«ç§»å‹•ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^Y+++] ifndef::basebackend-html[`\^Y`] -- put-pop:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ put-before, put, put-left, put-pop コマンドã®ç›´å¾Œã«ã ã‘使ãˆã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã‚­ãƒ«ãƒªãƒ³ã‚°ã‹ã‚‰æŒ¿å…¥ã—ãŸæ–‡å­—列を削除ã—ã€ä»£ã‚りã«ãã®æ–‡å­—列ã®å‰ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列を挿入ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[y, \^[Y+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[y`, `\^[Y`] -- undo:: ç›´å‰ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容をå‰ã®çŠ¶æ…‹ã«æˆ»ã—ã¾ã™ã€‚ + -- vi:: ifdef::basebackend-html[+++u+++] ifndef::basebackend-html[`u`] emacs:: ifdef::basebackend-html[] +++\^_, \^X\$, \^X\^U+++ endif::basebackend-html[] ifndef::basebackend-html[`\^_`, `\^X\$`, `\^X\^U`] -- undo-all:: å…¨ã¦ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…å®¹ã‚’åˆæœŸçŠ¶æ…‹ã«æˆ»ã—ã¾ã™ã€‚ + -- vi:: ifdef::basebackend-html[+++U+++] ifndef::basebackend-html[`U`] emacs:: ifdef::basebackend-html[] +++\^[\^R, \^[r, \^[R+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[\^R`, `\^[r`, `\^[R`] -- cancel-undo:: undo, undo-all ã«ã‚ˆã‚‹ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®å–り消ã—ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を復元ã—ã¾ã™ã€‚ + -- vi:: ifdef::basebackend-html[+++\^R+++] ifndef::basebackend-html[`\^R`] -- cancel-undo-all:: undo, undo-all ã«ã‚ˆã‚‹ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®å–り消ã—ã‚’å…¨ã¦å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を復元ã—ã¾ã™ã€‚ redo:: ç›´å‰ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’繰り返ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++.+++] ifndef::basebackend-html[`.`] -- [[completion-commands]] === 補完コマンド complete:: ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§<>を行ã„ã¾ã™ã€‚補完候補ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãã®ä¸€è¦§ã‚’表示ã—ã¾ã™ã€‚ complete-next-candidate:: 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\^I+++] ifndef::basebackend-html[`\^I`] -- complete-prev-candidate:: 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-insert:: emacs:: ifdef::basebackend-html[+++\bt+++] ifndef::basebackend-html[`\bt`] -- complete-next-column:: 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®åˆ—ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ complete-prev-column:: 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®åˆ—ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ complete-next-page:: 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®ãƒšãƒ¼ã‚¸ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ complete-prev-page:: 補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®ãƒšãƒ¼ã‚¸ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ complete-list:: ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã¾ã™ã€‚引数を指定ã—ãªã„å ´åˆã€è£œå®Œå€™è£œã®ä¸€è¦§ã‚’表示ã—ã¾ã™ã€‚引数を指定ã™ã‚‹ã¨ã€ãã®ç•ªå·ã®å€™è£œã§è£œå®Œå†…容を確定ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[?, \^[=+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[?`, `\^[=`] -- complete-all:: ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã€ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã«ã‚ã‚‹å˜èªžã‚’ã™ã¹ã¦ã®è£œå®Œå€™è£œã§ç½®ãæ›ãˆã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^[*+++] ifndef::basebackend-html[`\^[*`] -- complete-max:: ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã€å„è£œå®Œå€™è£œã®æœ€é•·å…±é€šå…ˆé ­éƒ¨åˆ†ã‚’カーソルä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚ clear-candidates:: 補完候補ã®ä¸€è¦§ã‚’消去ã—ã¾ã™ã€‚ [[vi-commands]] === Vi 固有ã®ã‚³ãƒžãƒ³ãƒ‰ vi-replace-char:: カーソルã®ã¨ã“ã‚ã«ã‚る文字をã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ã«ç½®ãæ›ãˆã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++r+++] ifndef::basebackend-html[`r`] -- vi-insert-beginning:: カーソルをãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++I+++] ifndef::basebackend-html[`I`] -- vi-append:: ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++I+++] ifndef::basebackend-html[`I`] -- vi-append-to-eol:: カーソルをãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++A+++] ifndef::basebackend-html[`A`] -- vi-replace:: Setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ãŒã€åŒæ™‚ã«ä¸Šæ›¸ãモードを有効ã«ã—ã¾ã™ã€‚上書ãモードã§ã¯ã€self-insert ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—を挿入ã™ã‚‹ä»£ã‚りã«ã‚«ãƒ¼ã‚½ãƒ«ã®ã¨ã“ã‚ã«ã‚ã‚‹æ–‡å­—ã‚’ç½®ãæ›ãˆã¾ã™ã€‚上書ãモードã¯ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’変更ã™ã‚‹ã¾ã§æœ‰åйã§ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++R+++] ifndef::basebackend-html[`R`] -- vi-switch-case:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字ã®å¤§æ–‡å­—ã¨å°æ–‡å­—を入れ替ãˆã¾ã™ã€‚ vi-switch-case-char:: カーソルã®ã¨ã“ã‚ã«ã‚る文字ã®å¤§æ–‡å­—ã¨å°æ–‡å­—を入れ替ãˆã¦ã€ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++~+++] ifndef::basebackend-html[`~`] -- vi-yank:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字をキルリングã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++y+++] ifndef::basebackend-html[`y`] -- vi-yank-to-eol:: カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字をキルリングã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++Y+++] ifndef::basebackend-html[`Y`] -- vi-delete:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++d+++] ifndef::basebackend-html[`d`] -- vi-delete-to-eol:: カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++D+++] ifndef::basebackend-html[`D`] -- vi-change:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字を削除ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++c+++] ifndef::basebackend-html[`c`] -- vi-change-to-eol:: カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字を削除ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ Delete the characters from the current cursor position to the end of the line and switch to the vi insert mode. + -- vi-command:: ifdef::basebackend-html[+++C+++] ifndef::basebackend-html[`C`] -- vi-change-line:: ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++S+++] ifndef::basebackend-html[`S`] -- vi-yank-and-change:: Vi-change コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚ vi-yank-and-change-to-eol:: Vi-change-to-eol コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚ vi-yank-and-change-line:: Vi-change-line コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚ vi-substitute:: カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—キルリングã«ä¿ç®¡ã—ãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++s+++] ifndef::basebackend-html[`s`] -- vi-append-last-bigword:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ãŠã‘る最後㮠bigword ã‚’ã€ç©ºç™½æ–‡å­—ã«ç¶šã‘ã¦ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã®ç›´å¾Œã«æŒ¿å…¥ã—ã¾ã™ã€‚引数 {{n}} を与ãˆãŸã¨ãã¯æœ€å¾Œã® bigword ã®ä»£ã‚り㫠{{n}} 番目㮠bigword を挿入ã—ã¾ã™ã€‚ãã®å¾Œã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++_+++] ifndef::basebackend-html[`_`] -- vi-exec-alias:: ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ã‚’ {{c}} ã¨ã™ã‚‹ã¨ã€+_{{c}}+ ã¨ã„ã†åå‰ã®link:syntax.html#aliases[エイリアス]ã®å†…容をシェルã¸ã®å…¥åŠ›ã¨ã¿ãªã—ã¦è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++@+++] ifndef::basebackend-html[`@`] -- vi-edit-and-accept:: エディタã¨ã—㦠vi ã‚’èµ·å‹•ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を編集ã•ã›ã¾ã™ã€‚エディタãŒçµ‚了ã™ã‚‹ã¨ç·¨é›†å¾Œã®å†…容をãƒãƒƒãƒ•ã‚¡ã«å映ã—ãŸå¾Œ accept-line コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ãŸã ã—エディタã®çµ‚了ステータス㌠0 ã§ãªã„ã¨ãã¯ä½•も行ã„ã¾ã›ã‚“。 + -- vi-command:: ifdef::basebackend-html[+++v+++] ifndef::basebackend-html[`v`] -- vi-complete-list:: Complete-list コマンドã¨åŒæ§˜ã§ã™ãŒã€å€™è£œã‚’確定ã—ãŸã¨ã編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++=+++] ifndef::basebackend-html[`=`] -- vi-complete-all:: Complete-all コマンドã¨åŒæ§˜ã§ã™ãŒã€å˜èªžã‚’ç½®ãæ›ãˆãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++*+++] ifndef::basebackend-html[`*`] -- vi-complete-max:: Complete-max コマンドã¨åŒæ§˜ã§ã™ãŒã€å€™è£œã‚’挿入ã—ãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++\\+++] ifndef::basebackend-html[`\\`] -- vi-search-forward:: 順方å‘ã®link:interact.html#history[履歴]検索を開始ã—ã¾ã™ã€‚編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++?+++] ifndef::basebackend-html[`?`] -- vi-search-backward:: 逆方å‘ã®link:interact.html#history[履歴]検索を開始ã—ã¾ã™ã€‚編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++/+++] ifndef::basebackend-html[`/`] -- [[emacs-commands]] === Emacs 固有ã®ã‚³ãƒžãƒ³ãƒ‰ emacs-transpose-chars:: カーソルã®å‰ã«ã‚る文字をå³ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^T+++] ifndef::basebackend-html[`\^T`] -- emacs-transpose-words:: カーソルã®å‰ã«ã‚ã‚‹ emacsword ã‚’å³ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[t, \^[T+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[t`, `\^[T`] -- emacs-downcase-word:: カーソルã®å¾Œã«ã‚ã‚‹ emacsword ã‚’å°æ–‡å­—ã«å¤‰æ›ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[l, \^[L+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[l`, `\^[L`] -- emacs-upcase-word:: カーソルã®å¾Œã«ã‚ã‚‹ emacsword を大文字ã«å¤‰æ›ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[] +++\^[u, \^[U+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[u`, `\^[U`] -- emacs-capitalize-word:: カーソルã®å¾Œã«ã‚ã‚‹ emacsword をキャピタライズã—ã¾ã™ (å„å˜èªžã®é ­æ–‡å­—ã ã‘大文字ã«ã™ã‚‹)。 + -- emacs:: ifdef::basebackend-html[] +++\^[c, \^[C+++ endif::basebackend-html[] ifndef::basebackend-html[`\^[c`, `\^[u`] -- emacs-delete-horizontal-space:: カーソルã®å‰å¾Œã«ã‚る空白を削除ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ã‚«ãƒ¼ã‚½ãƒ«ã®å‰ã«ã‚る空白を削除ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^[\\+++] ifndef::basebackend-html[`\^[\\`] -- emacs-just-one-space:: カーソルã®å‰å¾Œã«ã‚る空白ã®å€‹æ•°ã‚’一ã¤ã«èª¿æ•´ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãã®å¼•æ•°ã®æ•°ã ã‘空白を残ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^[ +++] ifndef::basebackend-html[`\^[`] (エスケープã®å¾Œã«ç©ºç™½æ–‡å­—) -- emacs-search-forward:: 順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^S+++] ifndef::basebackend-html[`\^S`] -- emacs-search-backward:: 順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^R+++] ifndef::basebackend-html[`\^R`] -- [[history-commands]] === コマンド履歴関連ã®ã‚³ãƒžãƒ³ãƒ‰ oldest-history:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 newest-history:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 return-history:: link:interact.html#history[コマンド履歴]ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 oldest-history-bol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++G+++] ifndef::basebackend-html[`G`] -- newest-history-bol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ return-history-bol:: link:interact.html#history[コマンド履歴]ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++g+++] ifndef::basebackend-html[`g`] -- oldest-history-eol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^[<+++] ifndef::basebackend-html[`\^[<`] -- newest-history-eol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ return-history-eol:: link:interact.html#history[コマンド履歴]ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚ + -- emacs:: ifdef::basebackend-html[+++\^[>+++] ifndef::basebackend-html[`\^[>`] -- next-history:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 prev-history:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 next-history-bol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ + -- vi-command:: ifdef::basebackend-html[] +++j, +, \D, \^N+++ endif::basebackend-html[] ifndef::basebackend-html[`j`, `+`, `\D`, `\^N`] -- prev-history-bol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ + -- vi-command:: ifdef::basebackend-html[] +++k, -, \U, \^P+++ endif::basebackend-html[] ifndef::basebackend-html[`k`, `-`, `\U`, `\^P`] -- next-history-eol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ + -- vi-insert:: emacs:: ifdef::basebackend-html[] +++\D, \^N+++ endif::basebackend-html[] ifndef::basebackend-html[`\D`, `\^N`] -- prev-history-eol:: link:interact.html#history[コマンド履歴]ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ + -- vi-insert:: emacs:: ifdef::basebackend-html[] +++\U, \^P+++ endif::basebackend-html[] ifndef::basebackend-html[`\U`, `\^P`] -- search-again:: 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++n+++] ifndef::basebackend-html[`n`] -- search-again-rev:: 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’æ–¹å‘を逆ã«ã—ã¦ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ + -- vi-command:: ifdef::basebackend-html[+++N+++] ifndef::basebackend-html[`N`] -- search-again-forward:: 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’順方å‘ã«ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ search-again-backward:: 最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’逆方å‘ã«ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚ beginning-search-forward:: link:interact.html#history[コマンド履歴]を順方å‘ã«æ¤œç´¢ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã¾ã§ã®é–“ã«ã‚る文字列ãŒåŒã˜æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 beginning-search-backward:: link:interact.html#history[コマンド履歴]を逆方å‘ã«æ¤œç´¢ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã¾ã§ã®é–“ã«ã‚る文字列ãŒåŒã˜å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。 [[search-commands]] === コマンド履歴検索モードã®ã‚³ãƒžãƒ³ãƒ‰ srch-self-insert:: 入力ã—ãŸæ–‡å­—を検索用ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã—ã¾ã™ã€‚(<>ã«ã‚ˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã®å¯¾è±¡ã¨ãªã‚‹æ–‡å­—ã¯æŒ¿å…¥ã§ãã¾ã›ã‚“) + -- vi-search:: emacs-search:: ifdef::basebackend-html[+++\\+++] ifndef::basebackend-html[`\\`] -- srch-backward-delete-char:: 検索用ãƒãƒƒãƒ•ã‚¡ã®æœ€å¾Œã®ä¸€æ–‡å­—を削除ã—ã¾ã™ã€‚検索用ãƒãƒƒãƒ•ã‚¡ãŒç©ºã®å ´åˆã¯: + -- - vi 風編集モードã§ã¯ srch-abort-search コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ - emacs 風編集モードã§ã¯ alert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ -- + -- vi-search:: emacs-search:: ifdef::basebackend-html[] +++\B, \?, \^H+++ endif::basebackend-html[] ifndef::basebackend-html[`\B`, `\?`, `\^H`] -- srch-backward-delete-line:: 検索用ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã¾ã™ã€‚ + -- vi-search:: emacs-search:: ifdef::basebackend-html[] +++\$, \^U+++ endif::basebackend-html[] ifndef::basebackend-html[`\$`, `\^U`] -- srch-continue-forward:: ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã®æ¬¡ã®çµæžœã‚’順方å‘ã«æŽ¢ã—ã¾ã™ã€‚ + -- emacs-search:: ifdef::basebackend-html[+++\^S+++] ifndef::basebackend-html[`\^S`] -- srch-continue-backward:: ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã®æ¬¡ã®çµæžœã‚’逆方å‘ã«æŽ¢ã—ã¾ã™ã€‚ + -- emacs-search:: ifdef::basebackend-html[+++\^R+++] ifndef::basebackend-html[`\^R`] -- srch-accept-search:: 検索を終了ã—ã€ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã‚’確定ã—ã¾ã™ã€‚æ¤œç´¢çµæžœã«ç§»å‹•ã—ã¾ã™ã€‚ + -- vi-search:: ifdef::basebackend-html[] +++\^J, \^M+++ endif::basebackend-html[] ifndef::basebackend-html[`\^J`, `\^M`] emacs-search:: ifdef::basebackend-html[] +++\^J, \^[+++ endif::basebackend-html[] ifndef::basebackend-html[`\^J`, `\^[`] -- srch-abort-search:: 検索を中止ã—ã€æ¤œç´¢ã‚’é–‹å§‹ã™ã‚‹å‰ã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚ + -- vi-search:: ifdef::basebackend-html[+++\^[+++] ifndef::basebackend-html[`\^[`] emacs-search:: ifdef::basebackend-html[+++\^G+++] ifndef::basebackend-html[`\^G`] -- [[escape]] == エスケープシーケンス link:_bindkey.html[Bindkey コマンド]ã§è¡Œç·¨é›†ã®ã‚­ãƒ¼è¨­å®šã‚’表示・設定ã™ã‚‹éš›ã€ãƒ•ァンクションキーãªã©ã®ç‰¹æ®Šãªã‚­ãƒ¼ã¯ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã§è¡¨ã‚ã—ã¾ã™ã€‚エスケープシーケンスã¯å…¨ã¦ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (+\+) ã§å§‹ã¾ã‚Šã¾ã™ã€‚ã¾ãŸãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãã®ã‚‚ã®ã‚‚エスケープã®å¯¾è±¡ã§ã™ã€‚エスケープシーケンスã«å¯¾ã™ã‚‹ã‚­ãƒ¼ã®å‰²ã‚Šå½“ã¦ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ `\\`:: ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (+\+) `\B`:: Backspace `\D`:: ↓矢å°ã‚­ãƒ¼ `\E`:: End `\H`:: Home `\I`:: Insert (Insert-char, Enter-insert-mode) `\L`:: â†çŸ¢å°ã‚­ãƒ¼ `\N`:: Page-down (Next-page) `\P`:: Page-up (Previous-page) `\R`:: →矢å°ã‚­ãƒ¼ `\U`:: ↑矢å°ã‚­ãƒ¼ `\X`:: Delete `\!`:: INTR `\#`:: EOF `\$`:: KILL `\?`:: ERASE `\^@`:: Ctrl + @ `\^A`, `\^B`, ..., `\^Z`:: Ctrl + A, Ctrl + B, ..., Ctrl + Z + ※ Ctrl + I 㯠Tabã€Ctrl + J 㯠Newlineã€Ctrl + M 㯠Carriage-return ã§ã™ã€‚ `\^[`:: Ctrl + [ (Escape) `\^\`:: Ctrl + \ `\^]`:: Ctrl + ] `\^^`:: Ctrl + ^ `\^_`:: Ctrl + _ `\^?`:: Ctrl + ? (Delete) `\F00`, `\F01`, ..., `\F63`:: F0, F1, ..., F63 `\a1`:: キーパッドã®å·¦ä¸Šã‚­ãƒ¼ `\a3`:: キーパッドã®å³ä¸Šã‚­ãƒ¼ `\b2`:: キーパッドã®ä¸­å¤®ã‚­ãƒ¼ `\bg`:: Beginning `\bt`:: Back-tab `\c1`:: キーパッドã®å·¦ä¸‹ã‚­ãƒ¼ `\c3`:: キーパッドã®å³ä¸‹ã‚­ãƒ¼ `\ca`:: Clear-all-tabs `\cl`:: Close `\cn`:: Cancel `\co`:: Command `\cp`:: Copy `\cr`:: Create `\cs`:: Clear-screen ã¾ãŸã¯ erase `\ct`:: Clear-tab `\dl`:: Delete-line `\ei`:: Exit-insert-mode `\el`:: Clear-to-end-of-line `\es`:: Clear-to-end-of-screen `\et`:: Enter (Send) `\ex`:: Exit `\fd`:: Find `\hp`:: Help `\il`:: Insert-line `\ll`:: Home-down `\me`:: Message `\mk`:: Mark `\ms`:: マウスイベント `\mv`:: Move `\nx`:: Next-object `\on`:: Open `\op`:: Options `\pr`:: Print (Copy) `\pv`:: Previous-object `\rd`:: Redo `\re`:: Resume `\rf`:: Ref (Reference) `\rh`:: Refresh `\rp`:: Replace `\rs`:: Restart `\sf`:: Scroll-forward (Scroll-down) `\sl`:: Select `\sr`:: Scroll-backward (Scroll-up) `\st`:: Set-tab `\su`:: Suspend `\sv`:: Save `\ud`:: Undo `\SE`:: Shift + End `\SH`:: Shift + Home `\SI`:: Shift + Insert `\SL`:: Shift + â†çŸ¢å°ã‚­ãƒ¼ `\SR`:: Shift + →矢å°ã‚­ãƒ¼ `\SX`:: Shift + Delete `\Sbg`:: Shift + Beginning `\Scn`:: Shift + Cancel `\Sco`:: Shift + Command `\Scp`:: Shift + Copy `\Scr`:: Shift + Create `\Sdl`:: Shift + Delete-line `\Sel`:: Shift + End-of-line `\Sex`:: Shift + Exit `\Sfd`:: Shift + Find `\Shp`:: Shift + Help `\Smg`:: Shift + Message `\Smv`:: Shift + Move `\Snx`:: Shift + Next `\Sop`:: Shift + Options `\Spr`:: Shift + Print `\Spv`:: Shift + Previous `\Srd`:: Shift + Redo `\Sre`:: Shift + Resume `\Srp`:: Shift + Replace `\Ssu`:: Shift + Suspend `\Ssv`:: Shift + Save `\Sud`:: Shift + Undo INTR, EOF, KILL, ERASE ã®å››ã¤ã¯ stty コマンドãªã©ã§è¨­å®šã•れる端末ã®ç‰¹æ®Šæ–‡å­—ã§ã™ã€‚一般的ãªç’°å¢ƒã§ã¯ã€INTR 㯠Ctrl + C ã«ã€EOF 㯠Ctrl + D ã«ã€KILL 㯠Ctrl + U ã«ã€ERASE 㯠Ctrl + H ã¾ãŸã¯ Ctrl + ? ã«è¨­å®šã•れã¦ã„ã¾ã™ã€‚ã“れら四ã¤ã¯ä»–ã®ã‚­ãƒ¼å…¥åŠ›ã‚ˆã‚Šã‚‚å„ªå…ˆã—ã¦èªè­˜ã•れã¾ã™ã€‚ [[completion]] == コマンドライン補完 行編集ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã—ã¦ã„る途中㧠Tab キーを押ã™ã“ã¨ã§ã€ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã‚„オプションã€å¼•数を補完ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚コマンドåやファイルåを途中ã¾ã§æ‰“ã¡è¾¼ã‚“ã ã¨ã“ã‚ã§ Tab キーを押ã™ã¨ã€ãã®åå‰ã«ä¸€è‡´ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰åやファイルåã®ä¸€è¦§ãŒç¾ã‚Œã¾ã™ã€‚ã•らã«ç¶šã‘㦠Tab キーを押ã™ã¨ã€å…¥åŠ›ã—ãŸã„åå‰ã‚’一覧ã®ä¸­ã‹ã‚‰é¸ã¶ã“ã¨ãŒã§ãã¾ã™ã€‚(一致ã™ã‚‹åå‰ãŒä¸€ã¤ã—ã‹ãªã„å ´åˆã¯ã€ä¸€è¦§ã¯ç¾ã‚Œãšã€ç›´æŽ¥åå‰ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å…¥åŠ›ã•れã¾ã™ã€‚) 補完ã®å¯¾è±¡ã¨ãªã‚‹åå‰ã« +*+ ã‚„ +?+ ãªã©ã®æ–‡å­—ãŒå…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®link:pattern.html[パターン]ã«ä¸€è‡´ã™ã‚‹åå‰å…¨ã¦ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å±•é–‹ã•れã¾ã™ã€‚(一覧ã«ã‚ˆã‚‹é¸æŠžã¯ã§ãã¾ã›ã‚“) 標準状態ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰åを入力ã—ã¦ã„ã‚‹ã¨ãã¯ã‚³ãƒžãƒ³ãƒ‰åãŒã€ã‚³ãƒžãƒ³ãƒ‰ã®å¼•数を入力ã—ã¦ã„ã‚‹ã¨ãã¯ãƒ•ァイルåãŒè£œå®Œã•れã¾ã™ã€‚ã—ã‹ã—補完を行ã†é–¢æ•° (dfn:[補完関数]) を定義ã™ã‚‹ã“ã¨ã§è£œå®Œå†…容を変更ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ [[completion-detail]] === 補完動作ã®è©³ç´° シェルを起動ã—ã¦ã‹ã‚‰åˆã‚ã¦è£œå®Œã‚’行ãŠã†ã¨ã—ãŸã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ +link:_dot.html[.] -AL completion/INIT+ を実行ã™ã‚‹ã®ã¨åŒæ§˜ã«ã—ã¦ã€ãƒ•ァイル completion/INIT ã‚’link:params.html#sv-yash_loadpath[ロードパス]ã‹ã‚‰èª­ã¿è¾¼ã¿ã¾ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã„å ´åˆã¯ã€ãã®ã¾ã¾è£œå®Œå‹•作を続ã‘ã¾ã™ã€‚(ã“ã®å‡¦ç†ã¯ä¸»ã«ã‚·ã‚§ãƒ«ã«ä»˜å±žã—ã¦ã„る補完関数を読ã¿è¾¼ã‚€ãŸã‚ã®ã‚‚ã®ã§ã™ãŒã€ãƒ­ãƒ¼ãƒ‰ãƒ‘ス内ã«è‡ªåˆ†ã§ç”¨æ„ã—ãŸãƒ•ァイルを置ã„ã¦ãŠãã“ã¨ã§ä»£ã‚りã«ãれを読ã¿è¾¼ã¾ã›ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚) 補完ã¯ã€å¯¾è±¡ã«å¿œã˜ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«è¡Œã„ã¾ã™ã€‚ コマンドå:: 関数 +completion//command+ ãŒå®šç¾©ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれを補完関数ã¨ã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚定義ã•れã¦ã„ãªã„å ´åˆã¯ã€å…¥åЛ䏭ã®å˜èªžã‚’コマンドåã¨ã—ã¦è£œå®Œã—ã¾ã™ã€‚ コマンドã®å¼•æ•°:: 関数 +completion//argument+ ãŒå®šç¾©ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれを補完関数ã¨ã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚定義ã•れã¦ã„ãªã„å ´åˆã¯ã€å…¥åЛ䏭ã®å˜èªžã‚’ファイルåã¨ã—ã¦è£œå®Œã—ã¾ã™ã€‚ ã“ã®ä»–ã€link:expand.html#tilde[ãƒãƒ«ãƒ€å±•é–‹]ã«ãŠã‘るユーザåã‚„link:expand.html#params[パラメータ展開]ã«ãŠã‘るパラメータåを入力ã—ã¦ã„ã‚‹ã¨ãã¯ã€ãƒ¦ãƒ¼ã‚¶åやパラメータåãŒå¸¸ã«è£œå®Œã•れã¾ã™ã€‚(補完ã®ã—ã‹ãŸã‚’変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“) è£œå®Œé–¢æ•°ã¯æ™®é€šã®link:exec.html#function[関数]ã¨åŒæ§˜ã« (link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ãªã—ã§) 実行ã•れã¾ã™ã€‚ãŸã ã—ã€è£œå®Œé–¢æ•°ã®å®Ÿè¡Œæ™‚ã«ã¯ä»¥ä¸‹ã®link:exec.html#localvar[ローカル変数]ãŒè‡ªå‹•çš„ã«è¨­å®šã•れã¾ã™ã€‚ link:params.html#sv-ifs[+IFS+]:: 空白文字・タブ・改行ã®ä¸‰æ–‡å­— (シェル起動時ã®ãƒ‡ãƒ•ォルト) +WORDS+:: æ—¢ã«å…¥åŠ›ã•れã¦ã„るコマンドåã¨ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã‚’å«ã‚€link:params.html#arrays[é…列]ã§ã™ã€‚コマンドåを補完ã—よã†ã¨ã—ã¦ã„ã‚‹ã¨ãã¯ã€ã“ã®é…列ã¯ç©ºã«ãªã‚Šã¾ã™ã€‚ +TARGETWORD+:: ç¾åœ¨è£œå®Œã‚’行ãŠã†ã¨ã—ã¦ã„ã‚‹ã€é€”中ã¾ã§å…¥åŠ›ã•れãŸã‚³ãƒžãƒ³ãƒ‰åã¾ãŸã¯ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã§ã™ã€‚ 補完関数ã®ä¸­ã§ link:_complete.html[complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を実行ã™ã‚‹ã“ã¨ã§ã€è£œå®Œå€™è£œãŒç”Ÿæˆã•れã¾ã™ã€‚シェルã¯è£œå®Œé–¢æ•°å®Ÿè¡Œä¸­ã«ç”Ÿæˆã•れãŸè£œå®Œå€™è£œã‚’用ã„ã¦è£œå®Œã‚’行ã„ã¾ã™ã€‚ 補完関数ã®å®Ÿè¡Œä¸­ã¯ã€ç«¯æœ«ã«å¯¾ã—ã¦å…¥å‡ºåŠ›ã‚’è¡Œã£ã¦ã¯ãªã‚Šã¾ã›ã‚“ (端末ã®è¡¨ç¤ºãŒä¹±ã‚Œã¦ã—ã¾ã„ã¾ã™)。スムーズãªè£œå®Œã‚’行ã†ãŸã‚ã«ã€è£œå®Œã®å®Ÿè¡Œä¸­ã«é•·ã„時間ã®ã‹ã‹ã‚‹å‡¦ç†ã‚’行ã†ã®ã¯é¿ã‘ã¦ãã ã•ã„。 補完ã®å®Ÿè¡Œä¸­ã¯ã€link:posix.html[POSIX 準拠モード]ãŒå¼·åˆ¶çš„ã«è§£é™¤ã•れã¾ã™ã€‚ã¾ãŸ link:_set.html#so-errexit[errexit オプション]ã¯ç„¡åйã¨ãªã‚Šã€link:_trap.html[トラップ]ã¯å®Ÿè¡Œã•れã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_fg.txt0000644000175000017500000000330612154557026015203 0ustar magicantmagicant= Fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚¸ãƒ§ãƒ–をフォアグラウンドã§å®Ÿè¡Œã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +fg [{{ジョブ}}...]+ [[description]] == 説明 Fg コマンドã¯ã‚¸ãƒ§ãƒ–をフォアグラウンドã«ç§»å‹•ã— SIGCONT シグナルをé€ã‚Šã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ã¦ã„ãŸå ´åˆã¯ãƒ•ォアグラウンドã§å®Ÿè¡ŒãŒå†é–‹ã•れã¾ã™ã€‚Fg コマンドã¯ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã¾ã§å¾…機ã—ã€ã‚¸ãƒ§ãƒ–ã®çµ‚了ステータスを返ã—ã¾ã™ã€‚ ジョブã®å®Ÿè¡Œã‚’å†é–‹ã™ã‚‹å‰ã« fg コマンドã¯ã‚¸ãƒ§ãƒ–ã®åå‰ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ Fg コマンドã¯link:job.html[ジョブ制御]ãŒæœ‰åŠ¹ãªæ™‚ã—ã‹ä½¿ãˆã¾ã›ã‚“。 [[operands]] == オペランド {{ジョブ}}:: 実行ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®link:job.html#jobid[ジョブ ID]。 + 複数指定ã™ã‚‹ã¨æŒ‡å®šã—ãŸé †ã«ä¸€ã¤ãšã¤ã‚¸ãƒ§ãƒ–をフォアグラウンドã§å®Ÿè¡Œã—ã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を実行ã—ã¾ã™ã€‚ + éž link:posix.html[POSIX 準拠モード]ã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® +%+ ã¯çœç•¥ã§ãã¾ã™ã€‚ [[exitstatus]] == 終了ステータス ジョブを正ã—ã実行ã§ããŸå ´åˆã€fg コマンドã®çµ‚了ステータス㯠(最後ã«) 実行ã—ãŸã‚¸ãƒ§ãƒ–ã®çµ‚了ステータスã§ã™ã€‚エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 Fg コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ã¯{{ジョブ}}ã¯ä¸€ã¤ã¾ã§ã—ã‹æŒ‡å®šã§ãã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_continue.txt0000644000175000017500000000472612154557026016442 0ustar magicantmagicant= Continue 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Continue 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Continue 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯å®Ÿè¡Œä¸­ã®ãƒ«ãƒ¼ãƒ—ã®æ¬¡ã®ç¹°ã‚Šè¿”ã—ã«å‡¦ç†ã‚’ç§»ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +continue [{{æ·±ã•}}]+ - +continue -i+ [[description]] == 説明 +-i+ (+--iteration+) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€continue コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã® link:syntax.html#for[for ループ]ã¾ãŸã¯ link:syntax.html#while-until[while ループ]ã¾ãŸã¯ link:syntax.html#while-until[until ループ]ã®ç¹°ã‚Šè¿”ã—を中断ã—ã€ç›´ã¡ã«æ¬¡ã®ç¹°ã‚Šè¿”ã—ã‚’é–‹å§‹ã—ã¾ã™ (while/until ループã«ã¤ã„ã¦ã¯ã€ãƒ«ãƒ¼ãƒ—ã®å®Ÿè¡Œæ¡ä»¶ã®åˆ¤å®šã‹ã‚‰ã‚„り直ã—ã¾ã™)。多é‡ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§å®Ÿè¡Œã—ãŸå ´åˆã€å†…å´ã‹ã‚‰æ•°ãˆã¦{{æ·±ã•}}番目ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ã€‚{{æ·±ã•}}ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æœ€ã‚‚内å´ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ ({{æ·±ã•}} = 1)。指定ã•れãŸ{{æ·±ã•}}ãŒå®Ÿéš›ã«å®Ÿè¡Œã—ã¦ã„る多é‡ãƒ«ãƒ¼ãƒ—ã®æ·±ã•より大ãã„å ´åˆã¯æœ€ã‚‚外å´ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ã€‚ +-i+ (+--iteration+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€continue コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®link:_eval.html#iter[å復実行]ã®ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’中断ã—ã€ç›´ã¡ã«æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’é–‹å§‹ã—ã¾ã™ã€‚ [[options]] == オプション +-i+:: +--iteration+:: ループã§ã¯ãªãå復実行ã«å¯¾ã—ã¦ä½œç”¨ã—ã¾ã™ã€‚ [[operands]] == オペランド {{æ·±ã•}}:: 内å´ã‹ã‚‰ä½•番目ã®ãƒ«ãƒ¼ãƒ—ã«ä½œç”¨ã™ã‚‹ã®ã‹ã‚’指定ã™ã‚‹ 1 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ [[exitstatus]] == 終了ステータス +-i+ (+--iteration+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã€continue コマンドã®å‡¦ç†ãŒæˆåŠŸã™ã‚‹ã¨çµ‚了ステータス㯠0 ã§ã™ã€‚+-i+ (+--iteration+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã€continue コマンドã®å‡¦ç†ãŒæˆåŠŸã™ã‚‹ã¨ continue コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠continue コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ [[notes]] == 補足 Continue コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ +-i+ (+--interact+) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_eval.txt0000644000175000017500000000526012154557026015537 0ustar magicantmagicant= Eval 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Eval 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Eval 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã—ã¦è§£é‡ˆã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +eval [-i] [{{コマンド}}...]+ Eval コマンドã§ã¯ã€link:posix.html[POSIX 準拠モード]ã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ [[description]] == 説明 Eval コマンドã¯ã€ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’シェルã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã€link:exec.html#environment[ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒ]ã§å®Ÿè¡Œã—ã¾ã™ã€‚ +-i+ (+--iteration+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’ã¾ã¨ã‚ã¦ä¸€åº¦ã«è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚複数ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ãれらを順ã«é€£çµã—ã¦ä¸€ã¤ã«ã—ã¦ã‹ã‚‰è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ (連çµã®éš›ã€å„オペランド間ã«ç©ºç™½æ–‡å­—を一ã¤ãšã¤åŒºåˆ‡ã‚Šã¨ã—ã¦æŒ¿å…¥ã—ã¾ã™)。 +-i+ (+--iteration+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’é †ã«ä¸€ã¤ãšã¤è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚ã“れをdfn:iter[å復実行]ã¨ã„ã„ã¾ã™ã€‚å復実行ã®é€”中㧠link:_continue.html[continue コマンド]ã‚’ +-i+ オプション付ãã§å®Ÿè¡Œã—ãŸå ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã¯ä¸­æ–­ã•れã€eval コマンドã«ä¸Žãˆã‚‰ã‚ŒãŸæ¬¡ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®è§£é‡ˆãƒ»å®Ÿè¡Œã«ç§»ã‚Šã¾ã™ã€‚å復実行ã®é€”中㧠link:_break.html[break コマンド]ã‚’ +-i+ オプション付ãã§å®Ÿè¡Œã—ãŸå ´åˆã€å復実行ã¯ä¸­æ–­ã•れã€ã“ã® eval コマンドã®å®Ÿè¡Œã¯çµ‚了ã—ã¾ã™ã€‚ [[options]] == オプション +-i+:: +--iteration+:: 与ãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ã‚’é †ã«å復実行ã—ã¾ã™ã€‚ [[operands]] == オペランド {{コマンド}}:: コマンドã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã™ã‚‹æ–‡å­—列ã§ã™ã€‚ [[exitstatus]] == 終了ステータス オペランドãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¾ãŸã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®ä¸­ã«ã‚³ãƒžãƒ³ãƒ‰ãŒä¸€ã¤ã‚‚å«ã¾ã‚Œã¦ã„ãªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚コマンドãŒä¸€ã¤ä»¥ä¸Šè§£é‡ˆãƒ»å®Ÿè¡Œã•れãŸå ´åˆã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠eval コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ [[notes]] == 補足 Eval コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_echo.html0000644000175000017500000001544512154557026015661 0ustar magicantmagicant Echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

æ§‹æ–‡

  • echo [文字列…]

Echo コマンドã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã‚’å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚オプションã¯ã€ä»¥ä¸‹ã«è¿°ã¹ã‚‹ä¾‹å¤–を除ã„ã¦ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。オプションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«ç½®ãå¿…è¦ãŒã‚りã¾ã™ã€‚Echo コマンドã§ã¯æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã¯çµ¶å¯¾ã«èµ·ãã¾ã›ã‚“。

説明

Echo コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨æ”¹è¡Œã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚引数ãŒãªã„å ´åˆã¯æ”¹è¡Œã ã‘を出力ã—ã¾ã™ã€‚引数ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãれãžã‚Œã‚’空白文字ã§åŒºåˆ‡ã£ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

エスケープシーケンス

Echo コマンドã«ä¸Žãˆã‚‹å¼•æ•°ã§ã¯ã€å¾Œè¿°ã® ECHO_STYLE 変数㨠-e ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

\a

ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7)

\b

ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 8)

\c

ã“れ以é™ä½•も出力ã—ãªã„。

\e

エスケープ文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 27)

\f

フォームフィード (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 12)

\n

改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10)

\r

復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13)

\t

水平タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 9)

\v

垂直タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 11)

\\

ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥

\0xxx

八進数 xxx (最大三æ¡) ã§è¡¨ã‚ã•れるコード番å·ã®æ–‡å­—

エスケープシーケンスãŒç„¡åŠ¹ã®æ™‚ã¯ã€ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¯è§£é‡ˆã›ãšã«ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚

ECHO_STYLE 変数

Echo コマンドãŒã‚ªãƒ—ションやエスケープシーケンスを解釈ã™ã‚‹ã‹ã©ã†ã‹ã¯ ECHO_STYLE 変数ã®å€¤ã«ã‚ˆã‚Šã¾ã™ã€‚以下ã«ã€ã“ã®å¤‰æ•°ã®å€¤ã¨ echo コマンドã®å‹•作ã¨ã®å¯¾å¿œã‚’示ã—ã¾ã™ã€‚

SYSV
XSI

オプションã¯ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。常ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ã¾ã™ã€‚

BSD

-n オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンスã¯ä¸€åˆ‡è§£é‡ˆã—ã¾ã›ã‚“。

GNU

-n, -e, -E オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンス㯠-e オプションを指定ã—ãŸã¨ãã ã‘解釈ã—ã¾ã™ã€‚

ZSH

-n, -e, -E オプションを解釈ã—ã¾ã™ã€‚エスケープシーケンス㯠-E オプションを指定ã—ãªã„ã‹ãŽã‚Šè§£é‡ˆã—ã¾ã™ã€‚

DASH

-n オプションを解釈ã—ã¾ã™ã€‚常ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ã¾ã™ã€‚

RAW

オプションもエスケープシーケンスも一切解釈ã—ã¾ã›ã‚“。

ECHO_STYLE 変数ãŒè¨­å®šã•れã¦ã„ãªã„ã¨ãã¯ã€å€¤ãŒ SYSV ã¾ãŸã¯ XSI ã®å ´åˆã®å‹•作をã—ã¾ã™ã€‚

オプション

-n

æœ€å¾Œã«æ”¹è¡Œã‚’出力ã—ãªã„よã†ã«ã™ã‚‹ã€‚

-e

エスケープシーケンスを解釈ã™ã‚‹ã‚ˆã†ã«ã™ã‚‹ã€‚

-E

エスケープシーケンスを解釈ã›ãšã€å…¨ã¦ã®æ–‡å­—ã‚’ãã®ã¾ã¾å‡ºåŠ›ã™ã‚‹ã‚ˆã†ã«ã™ã‚‹ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š echo コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

POSIX ã«ã¯ ECHO_STYLE 変数ãŠã‚ˆã³ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。POSIX ã§ã¯ã€-n ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れãŸã¨ãã¾ãŸã¯å¼•æ•°ã«ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã®å‹•作をè¦å®šã—ã¦ã„ã¾ã›ã‚“ã€‚å¯æ¬æ€§ã®ã‚るシェルスクリプトを書ãã«ã¯ã€echo コマンドよりも printf コマンドã®ä½¿ç”¨ã‚’推奨ã—ã¾ã™ã€‚

yash-2.35/doc/ja/_wait.html0000644000175000017500000001034112154557026015675 0ustar magicantmagicant Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã®ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã¡ã¾ã™ã€‚

æ§‹æ–‡

  • wait [ジョブ…]

説明

Wait コマンドã¯å®Ÿè¡Œä¸­ã®ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã¡ã¾ã™ã€‚ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãも終了ã—ãŸã¨ã¿ãªã—ã¾ã™ã€‚

Wait コマンドã¯ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйã§ãªã„ã¨ãã§ã‚‚éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を待ã¤ã®ã«ä½¿ãˆã¾ã™ã€‚

Wait コマンドã®å®Ÿè¡Œä¸­ã«ã‚·ã‚§ãƒ«ãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸå ´åˆã€ãã®ã‚·ã‚°ãƒŠãƒ«ã«å¯¾ã—トラップãŒè¨­å®šã—ã¦ã‚れã°ãã®ãƒˆãƒ©ãƒƒãƒ—ã‚’ç›´ã¡ã«å®Ÿè¡Œã— wait コマンドã¯ãã®ã¾ã¾çµ‚了ã—ã¾ã™ã€‚ã¾ãŸã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйãªå ´åˆã€ã‚·ã‚§ãƒ«ãŒ SIGINT シグナルをå—ä¿¡ã™ã‚‹ã¨ wait コマンドã¯ä¸­æ–­ã•れã¾ã™ã€‚

オペランド

ジョブ

終了を待ã¤ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ã‚¸ãƒ§ãƒ– ID ã¾ãŸã¯ãƒ—ロセス ID ã§ã™ã€‚

ジョブを何も指定ã—ãªã„ã¨ã‚·ã‚§ãƒ«ãŒæœ‰ã™ã‚‹å…¨ã¦ã®ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を待ã¡ã¾ã™ã€‚

存在ã—ãªã„ジョブ・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã™ã‚‹ã¨ã€çµ‚了ステータス 127 ã§æ—¢ã«çµ‚了ã—ãŸã‚¸ãƒ§ãƒ–ã‚’ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã€ã‚¨ãƒ©ãƒ¼ã«ã¯ã—ã¾ã›ã‚“。

終了ステータス

ジョブãŒä¸€ã¤ã‚‚与ãˆã‚‰ã‚Œã¦ãŠã‚‰ãšã€ã‚·ã‚§ãƒ«ãŒå…¨ã¦ã®ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を正ã—ãå¾…ã¤ã“ã¨ãŒã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚ジョブãŒä¸€ã¤ä»¥ä¸Šä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€æœ€å¾Œã®ã‚¸ãƒ§ãƒ–ã®çµ‚了ステータス㌠wait コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

Wait コマンドãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã€çµ‚了ステータスã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã‚’表㙠128 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚ãã®ä»–ã®ç†ç”±ã§ wait コマンドãŒã‚¸ãƒ§ãƒ–ã®çµ‚了を正ã—ãå¾…ã¤ã“ã¨ãŒã§ããªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠1 以上 126 以下ã§ã™ã€‚

補足

Wait ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã¯éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸç›´å¾Œã«ç‰¹æ®Šãƒ‘ラメータ ! ã®å€¤ã‚’見るã“ã¨ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйãªã¨ã㯠jobs コマンドã§ãƒ—ロセス ID を調ã¹ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚

yash-2.35/doc/ja/_fc.html0000644000175000017500000002034712154557026015330 0ustar magicantmagicant Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«è¨˜éŒ²ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œãƒ»è¡¨ç¤ºã—ã¾ã™ã€‚

æ§‹æ–‡

  • fc [-qr] [-e エディタ] [始点 [終点]]

  • fc -s[q] [å‰=後] [始点]

  • fc -l[nrv] [始点 [終点]]

説明

-l (--list) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€fc コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ã¾ã™ã€‚-s (--silent) オプションを付ã‘ã¦ã„ãªã„å ´åˆã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã™ã‚‹å‰ã«ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã§ãるよã†ã«ã—ã¾ã™ã€‚エディタãŒçµ‚了ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç·¨é›†å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚-s (--silent) オプションを付ã‘ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã›ãšç›´æŽ¥ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ã¾ã™ã€‚ã„ãšã‚Œã®å ´åˆã‚‚ã€å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯æ¨™æº–出力ã«å‡ºåŠ›ã—コマンド履歴ã«è¿½åŠ ã•れã¾ã™ã€‚

-l (--list) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€fc コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸç¯„囲ã®ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚標準ã§ã¯å±¥æ­´å†…ã®ã‚³ãƒžãƒ³ãƒ‰ã®å†…容を履歴番å·ã¨ã¨ã‚‚ã«è¡¨ç¤ºã—ã¾ã™ãŒã€-n (--no-numbers) ãŠã‚ˆã³ -v (--verbose) オプションã«ã‚ˆã‚Šå‡ºåЛ形å¼ã‚’変更ã§ãã¾ã™ã€‚

オプション

-e エディタ
--editor=エディタ

コマンドã®ç·¨é›†ã«ç”¨ã„るエディタ。

ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€FCEDIT 変数ã®å€¤ã‚’エディタã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚FCEDIT 変数も設定ã•れã¦ã„ãªã„å ´åˆã¯ã€vi をエディタã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚

-l
--list

コマンド履歴ã®å†…容を表示ã—ã¾ã™ã€‚

-n
--no-numbers

コマンド履歴ã®å†…容を表示ã™ã‚‹éš›ã€å±¥æ­´ç•ªå·ã‚’çœã„ã¦ã‚³ãƒžãƒ³ãƒ‰ã®ã¿è¡¨ç¤ºã—ã¾ã™ã€‚

-q
--quiet

コマンドを実行ã™ã‚‹å‰ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’出力ã—ãªã„よã†ã«ã—ã¾ã™ã€‚

-r
--reverse

始点ã¨çµ‚点を入れ替ãˆã¾ã™ã€‚

-s
--silent

コマンドを編集ã›ãšã«ç›´æŽ¥å†å®Ÿè¡Œã—ã¾ã™ã€‚

-v
--verbose

コマンド履歴ã®å†…容を表示ã™ã‚‹éš›ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ™‚刻も表示ã—ã¾ã™ã€‚

オペランド

始点ã¨çµ‚点

始点ã¨çµ‚点ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€å†å®Ÿè¡Œã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ç¯„囲を指定ã—ã¾ã™ã€‚始点ã‚ã‚‹ã„ã¯çµ‚ç‚¹ã«æ•´æ•°ã‚’指定ã™ã‚‹ã¨ã€ãれã¯å±¥æ­´ç•ªå·ã¨ã¿ãªã—ã¾ã™ã€‚è² ã®æ•´æ•°ã¯æœ€æ–°ã®å±¥æ­´ã‹ã‚‰æ•°ãˆãŸç•ªå·ã¨ãªã‚Šã¾ã™ã€‚例ãˆã° -2 ã¯æœ€å¾Œã‹ã‚‰äºŒç•ªç›®ã«å±¥æ­´ã«ç™»éŒ²ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’表ã—ã¾ã™ã€‚æ•´æ•°ä»¥å¤–ã®æ–‡å­—列を始点ã‚ã‚‹ã„ã¯çµ‚ç‚¹ã«æŒ‡å®šã™ã‚‹ã¨ã€ãã®æ–‡å­—列ã§å§‹ã¾ã‚‹æœ€æ–°ã®å±¥æ­´ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

Fc コマンドãŒå†å®Ÿè¡Œã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã€å§‹ç‚¹ã¨çµ‚ç‚¹ã§æŒ‡å®šã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¨ãã®é–“ã«ã‚る履歴ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚始点ãŒçµ‚点より後ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’指ã—ã¦ã„ã‚‹å ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®é †åºã¯é€†ã«ãªã‚Šã¾ã™ã€‚

始点ã¾ãŸã¯çµ‚点ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã®ãƒ‡ãƒ•ォルト値ã¯ä»¥ä¸‹ã®è¡¨ã®ã¨ãŠã‚Šã§ã™ã€‚

-l ã‚り -l ãªã—

始点

-16

-1

終点

-16

始点ã«åŒã˜

å‰=後

å‰=後ã®å½¢å¼ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®ä¸€éƒ¨ã‚’æ›¸ãæ›ãˆã‚‹ã“ã¨ã‚’指示ã—ã¾ã™ã€‚å†å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ä¸­ã«å‰ã¨åŒã˜æ–‡å­—列ãŒã‚ã‚‹å ´åˆã¯ã€ãã®éƒ¨åˆ†ã‚’後ã«ç½®ãæ›ãˆã¦å®Ÿè¡Œã—ã¾ã™ã€‚該当部分ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ã€æœ€åˆã®ã‚‚ã®ã ã‘ã‚’ç½®ãæ›ãˆã¾ã™ã€‚

終了ステータス

コマンドを正ã—ãå†å®Ÿè¡Œã§ããŸå ´åˆã€fc コマンドã®çµ‚了ステータスã¯å†å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚-l (--list) オプションを指定ã—ãŸå ´åˆã¯ã€å±¥æ­´ãŒæ­£ã—ã出力ã§ãれã°çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Fc ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ -q (--quiet) ãŠã‚ˆã³ -v (--verbose) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“れらã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

行編集ã®å‹•作中ã¯å±¥æ­´ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

yash-2.35/doc/ja/_false.html0000644000175000017500000000325512154557026016031 0ustar magicantmagicant False 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

False 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ä½•も行ã‚ãšã«éž 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚

æ§‹æ–‡

  • false

説明

False コマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚

終了ステータス

False コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

False ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

yash-2.35/doc/ja/pattern.txt0000644000175000017500000002052312154557026016125 0ustar magicantmagicant= パターンマッãƒãƒ³ã‚°è¨˜æ³• :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - パターンマッãƒãƒ³ã‚°è¨˜æ³• :description: Yash ãŒã‚µãƒãƒ¼ãƒˆã™ã‚‹ãƒ‘ターンマッãƒãƒ³ã‚°è¨˜æ³•ã«ã¤ã„㦠dfn:[パターンマッãƒãƒ³ã‚°è¨˜æ³•]ã¯ç‰¹å®šã®æ–‡å­—列ã®é›†åˆã‚’表ã™dfn:[パターン]ã®æ›¸å¼ã¨æ„味ã®å®šç¾©ã§ã™ã€‚ã‚る文字列ãŒã‚るパターンã®è¡¨ã™æ–‡å­—列ã®é›†åˆã«å«ã¾ã‚Œã‚‹æ™‚ã€ãã®æ–‡å­—列ã¯ãã®ãƒ‘ターンã«dfn:[マッãƒã™ã‚‹]ã¨ã„ã„ã¾ã™ã€‚文字列ãŒãƒ‘ターンã«å½“ã¦ã¯ã¾ã‚‹ã‹ã©ã†ã‹ã¯ã€ä»¥ä¸‹ã«ç¤ºã™å®šç¾©ã«å¾“ã£ã¦åˆ¤å®šã•れã¾ã™ã€‚ [[normal]] == é€šå¸¸ã®æ–‡å­— link:syntax.html#quotes[クォート]ã—ã¦ã‚る文字ãŠã‚ˆã³ä»¥ä¸‹ã«ç¤ºã™ç‰¹æ®Šãªæ„味をæŒã¤æ–‡å­—以外ã®ã™ã¹ã¦ã®æ–‡å­—ã¯ã€é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚パターンã«å«ã¾ã‚Œã‚‹é€šå¸¸ã®æ–‡å­—ã¯ã€ãã®æ–‡å­—自身ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ 例ãˆã° +abc+ ã¨ã„ã†ãƒ‘ターン㯠+abc+ ã¨ã„ã†æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚(ãã—ã¦ã“ã‚Œä»¥å¤–ã®æ–‡å­—列ã«ã¯ä¸€åˆ‡å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“) [[single]] == 一文字ワイルドカード 文字 +?+ ã¯ä»»æ„ã®ä¸€æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ 例ãˆã° +a?c+ ã¨ã„ã†ãƒ‘ターン㯠++aac++ã€++abc++ã€++a;c++ ãªã©ã€+a+ ã§å§‹ã¾ã‚Š +c+ ã§çµ‚ã‚ã‚‹ä»»æ„ã® 3 æ–‡å­—ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ [[multiple]] == 複数文字ワイルドカード 文字 +*+ ã¯ä»»æ„ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ã“ã“ã§ã„ã†ä»»æ„ã®æ–‡å­—列ã«ã¯ç©ºæ–‡å­—列もå«ã¾ã‚Œã¾ã™ã€‚ 例ãˆã° +a*c+ ã¨ã„ã†ãƒ‘ターン㯠++ac++ã€++abc++ã€++a;xyz;c++ ãªã©ã€+a+ ã§å§‹ã¾ã‚Š +c+ ã§çµ‚ã‚ã‚‹ä»»æ„ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ [[bracket]] == ブラケット記法 括弧 +[+ 㨠+]+ ã§å›²ã¾ã‚ŒãŸéƒ¨åˆ†ã¯dfn:[ブラケット記法]ã¨ã¿ãªã•れã¾ã™ã€‚ãŸã ã—ã€æ‹¬å¼§ã®é–“ã«ã¯å°‘ãªãã¨ã‚‚一文字挟ã¾ã‚Œã¦ã„ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚括弧ã®é–“ã«ã‚る文字ã¯ä»¥ä¸‹ã«ç¤ºã™ãƒ–ラケット記法ã®ãŸã‚ã®ç‰¹æ®Šãªãƒ‘ターン (dfn:[ブラケット記法パターン]) ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ブラケット記法ã¯ã€æ‹¬å¼§ã®é–“ã«ã‚るブラケット記法パターンãŒç¤ºã™æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ 最åˆã®æ‹¬å¼§ +[+ ã®ç›´å¾Œã«è¨˜å· +!+ ãŒã‚ã‚‹å ´åˆã€ãƒ–ラケット記法ã«å½“ã¦ã¯ã¾ã‚‹æ–‡å­—ã¨å½“ã¦ã¯ã¾ã‚‰ãªã„文字ã¨ãŒé€†è»¢ã—ã¾ã™ (ãã—ã¦ã“ã® +!+ ã¯ãƒ–ラケット記法パターンã®ä¸€éƒ¨ã¨ã¯ã¿ãªã•れã¾ã›ã‚“)。Yash ã§ã¯ +[+ ã®ç›´å¾Œã« +^+ ãŒã‚ã‚‹å ´åˆã‚‚åŒæ§˜ã«å½“ã¦ã¯ã¾ã‚‹æ–‡å­—ã¨å½“ã¦ã¯ã¾ã‚‰ãªã„文字ã¨ãŒé€†è»¢ã—ã¾ã™ (ãŒã€ä»–ã®ã‚·ã‚§ãƒ«ã§ã¯ +^+ ã®æ‰±ã„ãŒç•°ãªã‚‹ã“ã¨ã‚‚ã‚りã¾ã™)。 最åˆã®æ‹¬å¼§ +[+ ã®ç›´å¾Œ (ã‚ã‚‹ã„ã¯ä¸Šè¿°ã® +!+ ã¾ãŸã¯ +^+ ãŒã‚ã‚‹å ´åˆã¯ãã®ç›´å¾Œ) ã«æ‹¬å¼§ +]+ ãŒã‚ã‚‹å ´åˆã¯ã€ãれã¯ãƒ–ラケット記法ã®çµ‚ã‚ã‚Šã‚’ç¤ºã™æ‹¬å¼§ã¨ã—ã¦ã§ã¯ãªãブラケット記法パターンã®ä¸€éƒ¨ã¨ã¿ãªã•れã¾ã™ã€‚ブラケット記法パターンã®è§£é‡ˆã¯link:syntax.html#quotes[クォート]ã®å‡¦ç†ã®å¾Œã«è¡Œã‚れるã®ã§ã€ã‚¯ã‚©ãƒ¼ãƒˆã«ã‚ˆã£ã¦ãƒ–ãƒ©ã‚±ãƒƒãƒˆè¨˜æ³•ãƒ‘ã‚¿ãƒ¼ãƒ³å†…ã®æ–‡å­—ã‚’é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚ã›ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 パターンã®ä¸­ã« +[+ ãŒå«ã¾ã‚Œã¦ã„ã¦ã‚‚ã€ãã‚ŒãŒæ­£ã—ã„ブラケット記法ã®å½¢å¼ã«ãªã£ã¦ã„ãªã„å ´åˆã¯ã€ãã® +[+ ã¯ãƒ–ラケット記法ã§ã¯ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚ [[bra-normal]] == (ブラケット記法パターンã«ãŠã‘ã‚‹) é€šå¸¸ã®æ–‡å­— 以下ã«ç¤ºã™ç‰¹æ®Šãªæ„味をæŒã¤è¨˜å·ä»¥å¤–ã®æ–‡å­—ã¯ã™ã¹ã¦é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚é€šå¸¸ã®æ–‡å­—ã¯ãã®æ–‡å­—自身を表ã—ã¾ã™ã€‚ 例ãˆã° +[abc]+ ã¨ã„ã†ãƒ–ラケット記法㯠++a++ã€++b++ã€++c++ ã®ã©ã‚Œã‹ã®æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚従ã£ã¦ +a[abc]c+ ã¨ã„ã†ãƒ‘ターン㯠++aac++ã€++abc++ã€++acc++ ã¨ã„ã†ä¸‰ã¤ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ (ãã—ã¦ã“ã‚Œä»¥å¤–ã®æ–‡å­—列ã«ã¯å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“)。 [[bra-range]] == 範囲指定 二ã¤ã®æ–‡å­— (ã¾ãŸã¯<>) ã‚’ãƒã‚¤ãƒ•ン (+-+) ã§ã¤ãªã„ã ã‚‚ã®ã¯dfn:[範囲指定]ã¨ã¿ãªã•れã¾ã™ã€‚範囲指定ã¯ã€ãã®äºŒã¤ã®æ–‡å­—ã¨ç…§åˆé †åºä¸Šãã®é–“ã«ã‚ã‚‹å…¨ã¦ã®æ–‡å­—を表ã—ã¾ã™ã€‚dfn:[ç…§åˆé †åº]ã¨ã¯æ–‡å­—を辞書順ã«ä¸¦ã¹ã‚‹ãŸã‚ã«ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«å®šç¾©ã•れる文字ã®é †åºé–¢ä¿‚ã§ã™ã€‚使用中ã®ãƒ­ã‚±ãƒ¼ãƒ«ã«å®šç¾©ã•れã¦ã„ã‚‹ç…§åˆé †åºã«å¾“ã£ã¦äºŒã¤ã®æ–‡å­—ã®é–“ã«ã‚ã‚‹æ–‡å­—ãŒæ±ºã¾ã‚Šã¾ã™ã€‚ ãƒã‚¤ãƒ•ンã®å¾Œã« +]+ ã‚’ç½®ã„ãŸå ´åˆã¯ã€ã“ã® +]+ ã¯ãƒ–ラケット記法ã®çµ‚ã‚ã‚Šã‚’ç¤ºã™æ‹¬å¼§ã¨ã¿ãªã•れã€ãƒã‚¤ãƒ•ンã¯é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚ 例ãˆã° +[1-5]+ ã¨ã„ã†ãƒ–ラケット記法㯠++1++ã€++2++ã€++3++ã€++4++ã€++5++ ã¨ã„ã†äº”ã¤ã®æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ [[bra-colsym]] == ç…§åˆã‚·ãƒ³ãƒœãƒ« dfn:[ç…§åˆã‚·ãƒ³ãƒœãƒ«]を用ã„ã‚‹ã“ã¨ã§è¤‡æ•°ã®æ–‡å­—ã‹ã‚‰ãªã‚‹ç…§åˆè¦ç´ ã‚’一ã¤ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãã¾ã™ã€‚(dfn:[ç…§åˆè¦ç´ ]ã¨ã¯è¤‡æ•°ã®æ–‡å­—ã‚’ã¾ã¨ã‚ã¦ä¸€ã¤ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãるよã†ã«ã™ã‚‹ãŸã‚ã«è€ƒãˆã‚‰ã‚ŒãŸã€ã‚ˆã‚Šä¸€èˆ¬çš„ãªæ–‡å­—ã®æ¦‚念ã§ã™ã€‚パターンマッãƒãƒ³ã‚°ã«ãŠã„ã¦å…¨ã¦ã®æ–‡å­—ã¯å®Ÿéš›ã«ã¯ç…§åˆè¦ç´ ã¨ã—ã¦æ‰±ã‚れã¦ã„ã¾ã™ã€‚) ç…§åˆã‚·ãƒ³ãƒœãƒ«ã¯æ‹¬å¼§ +[. .]+ ã®ä¸­ã«ç…§åˆè¦ç´ ã‚’挟んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚æ‹¬å¼§å†…ã«æ›¸ã‘ã‚‹ç…§åˆè¦ç´ ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãŠã„ã¦ç…§åˆè¦ç´ ã¨ã—ã¦ç™»éŒ²ã•れã¦ã„ã‚‹ã‚‚ã®ã«é™ã‚Šã¾ã™ã€‚ 例ãˆã°å¾“æ¥ã‚¹ãƒšã‚¤ãƒ³èªžã§ã¯ ``ch'' ã¨ã„ã†äºŒæ–‡å­—ã‚’åˆã‚ã›ã¦ä¸€æ–‡å­—ã¨ã—ã¦æ‰±ã£ã¦ã„ã¾ã—ãŸã€‚ã“ã®äºŒæ–‡å­—ã®çµ„ã¿åˆã‚ã›ãŒç…§åˆè¦ç´ ã¨ã—ã¦ãƒ­ã‚±ãƒ¼ãƒ«ã«ç™»éŒ²ã•れã¦ã„ã‚‹ãªã‚‰ã°ã€++[[.ch.]df]++ ã¨ã„ã†ãƒ–ラケット記法㯠++ch++ã€++d++ã€++f++ ã®ã©ã‚Œã‹ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ã‚‚ã—ã“ã“ã§ +[chdf]+ ã¨ã„ã†ãƒ–ラケット記法を使ã†ã¨ã€ã“れ㯠++c++ã€++h++ã€++d++ã€++f++ ã®ã©ã‚Œã‹ã«å½“ã¦ã¯ã¾ã‚Šã€++ch++ ã«ã¯å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“。 [[bra-eqclass]] == 等価クラス 等価クラスを用ã„ã‚‹ã“ã¨ã§ã€ã‚る文字ã¨__等価__ã§ã‚ã‚‹ã¨ã¿ãªã•れる文字を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã¯æ‹¬å¼§ +[= =]+ ã®ä¸­ã«æ–‡å­—を挟んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚括弧ã®é–“ã«ã¯ç…§åˆã‚·ãƒ³ãƒœãƒ«ã®ã‚ˆã†ã«è¤‡æ•°ã®æ–‡å­—ã‹ã‚‰ãªã‚‹ç…§åˆè¦ç´ ã‚’書ãã“ã¨ã‚‚ã§ãã¾ã™ (上記å‚ç…§)。等価クラスã¯ã€æ‹¬å¼§ã§æŒŸã‚“ã æ–‡å­—ãã®ã‚‚ã®ã®ä»–ã«ã€ãã®æ–‡å­—ã¨åŒã˜ç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹å…¨ã¦ã®æ–‡å­—を表ã—ã¾ã™ã€‚ã©ã®æ–‡å­—ãŒç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹ã‹ã®å®šç¾©ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¾“ã„ã¾ã™ã€‚ 例ãˆã°ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãŠã„㦠a, à, á, â, ã, ä ã® 6 文字ãŒåŒã˜ç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹ã¨å®šç¾©ã•れã¦ã„ã‚‹ã¨ãã€+[[=a=]]+ ã¨ã„ã†ãƒ–ラケット記法ã¯ã“れら六ã¤ã®æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚+[[=à=]]+ ã‚„ +[[=á=]]+ ã‚‚åŒæ§˜ã§ã™ã€‚ [[bra-chclass]] == 文字クラス dfn:[文字クラス]ã¯ç‰¹å®šã®ç¨®é¡žã®æ–‡å­—ã®é›†åˆã‚’表ã—ã¾ã™ã€‚æ–‡å­—ã‚¯ãƒ©ã‚¹ã¯æ‹¬å¼§ +[: :]+ ã®é–“ã«æ–‡å­—クラスã®åå‰ã‚’囲んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚文字クラスã®åå‰ã¨ã—ã¦ã¯ã€ä»¥ä¸‹ã«æŒ™ã’ã‚‹å…±é€šã®æ–‡å­—クラスã®ä»–ã«ã€ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ã§å®šç¾©ã•れãŸç‹¬è‡ªã®æ–‡å­—クラスãŒä½¿ç”¨ã§ãã¾ã™ã€‚ã„ãšã‚Œã®æ–‡å­—クラスã®å ´åˆã‚‚ã€æ–‡å­—クラスã«ã©ã®æ–‡å­—ãŒå«ã¾ã‚Œã‚‹ã®ã‹ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ã«ãŠã‘る文字クラスã®å®šç¾©ã«å¾“ã„ã¾ã™ã€‚ +[:lower:]+:: å°æ–‡å­—ã®é›†åˆ +[:upper:]+:: 大文字ã®é›†åˆ +[:alpha:]+:: アルファベットã®é›†åˆ (+[:lower:]+ 㨠+[:upper:]+ ã‚’å«ã‚€) +[:digit:]+:: åé€²æ³•ã®æ•°å­—ã®é›†åˆ +[:xdigit:]+:: åå…­é€²æ³•ã®æ•°å­—ã®é›†åˆ +[:alnum:]+:: ã‚¢ãƒ«ãƒ•ã‚¡ãƒ™ãƒƒãƒˆã¨æ•°å­—ã®é›†åˆ (+[:alpha:]+ 㨠+[:digit:]+ ã‚’å«ã‚€) +[:blank:]+:: 空白文字ã®é›†åˆ (改行をå«ã¾ãªã„) +[:space:]+:: 空白文字ã®é›†åˆ (改行等をå«ã‚€) +[:punct:]+:: å¥èª­ç‚¹ç­‰ã®é›†åˆ +[:print:]+:: 表示å¯èƒ½ãªæ–‡å­—ã®é›†åˆ +[:cntrl:]+:: 制御文字ã®é›†åˆ 例ãˆã° `[[:lower:][:upper:]]` ã¨ã„ã†ãƒ–ラケット記法ã¯ä¸€æ–‡å­—ã®å°æ–‡å­—ã¾ãŸã¯å¤§æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_readonly.html0000644000175000017500000000433112154557026016550 0ustar magicantmagicant Readonly 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Readonly 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯èª­ã¿å–り専用ã®å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’表示・設定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • readonly [-pxX] [変数[=値]…]

  • readonly -f[p] [変数…]

説明

Readonly コマンド㯠typeset コマンド㫠-gr オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠typeset コマンドã¨åŒæ§˜ã§ã™ã€‚

補足

readonly コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ readonly コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã™ãŒã€ã‚ªãƒ—ション㯠-p ã—ã‹è¦å®šãŒã‚りã¾ã›ã‚“。ãã®ä»–ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠-p オプションをオペランドã¨ã¨ã‚‚ã«ä½¿ã†ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。

yash-2.35/doc/ja/exec.html0000644000175000017500000004177212154557026015532 0ustar magicantmagicant コマンドã®å®Ÿè¡Œã¨ãã®ç’°å¢ƒ

ã“ã®ç¯€ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ãŒã©ã®ã‚ˆã†ã«å®Ÿè¡Œã•れるã‹ã‚’説明ã—ã¾ã™ã€‚

å˜ç´”コマンドã®å®Ÿè¡Œ

å˜ç´”コマンドã¯ä»¥ä¸‹ã®æ‰‹é †ã«å¾“ã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚

  1. å˜ç´”コマンドã«å«ã¾ã‚Œã‚‹ã€å¤‰æ•°ä»£å…¥ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆä»¥å¤–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’å…¨ã¦å±•é–‹ã—ã¾ã™ã€‚展開エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。
    以下ã€å±•é–‹ã®çµæžœå¾—ã‚‰ã‚ŒãŸæœ€åˆã®å˜èªžã‚’コマンドåã€ãれ以外ã®å˜èªžã‚’コマンド引数ã¨å‘¼ã³ã¾ã™ã€‚得られãŸå˜èªžãŒä¸€ã¤ã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ã¯å­˜åœ¨ã—ã¾ã›ã‚“。得られãŸå˜èªžãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰åもコマンド引数も存在ã—ã¾ã›ã‚“。

  2. å˜ç´”コマンドã«å¯¾ã™ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚’実行ã—ã¾ã™ã€‚リダイレクトã«å«ã¾ã‚Œã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹ã¯ã“ã“ã§è¡Œã‚れã¾ã™ã€‚リダイレクトエラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。リダイレクトã«å«ã¾ã‚Œã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•開時ã®ã‚¨ãƒ©ãƒ¼ã¯ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã«å«ã¾ã‚Œã¾ã™ã€‚

  3. å˜ç´”コマンドã«å«ã¾ã‚Œã‚‹å¤‰æ•°ä»£å…¥ã‚’実行ã—ã¾ã™ (é…列ã®ä»£å…¥ã‚’å«ã‚€)。ãれãžã‚Œã®å¤‰æ•°ä»£å…¥ã«ã¤ã„ã¦ã€å€¤ãŒå±•é–‹ã•ã‚Œã€æŒ‡å®šã•れãŸåå‰ã®å¤‰æ•°ã«ä»£å…¥ã•れã¾ã™ã€‚代入エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯ã€ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œã¯ä¸­æ­¢ã•れã¾ã™ (ã“ã®ã¨ãå˜ç´”コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™)。代入ã•れる値ã®å±•開時ã®ã‚¨ãƒ©ãƒ¼ã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ã«å«ã¾ã‚Œã¾ã™ã€‚

    • コマンドåãŒå­˜åœ¨ã—ãªã„ã‹ã€ã‚ã‚‹ã„ã¯ã‚³ãƒžãƒ³ãƒ‰åãŒç‰¹æ®Šçµ„è¾¼ã¿ã¾ãŸã¯é–¢æ•°ã‚’示ã—ã¦ã„ã‚‹å ´åˆã¯ã€å¤‰æ•°ä»£å…¥ã¯æ’ä¹…çš„ã§ã™ã€‚ã™ãªã‚ã¡ã€ä»£å…¥ã®çµæžœã¯ã“ã®å˜ç´”コマンドã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã‚‚ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ã€‚

    • ãれ以外ã®å ´åˆã¯ã€å¤‰æ•°ä»£å…¥ã¯ä¸€æ™‚çš„ã§ã™ã€‚ã™ãªã‚ã¡ã€ä»£å…¥ã®åŠ¹æžœã¯ã“ã®å˜ç´”コマンドã®å®Ÿè¡Œä¸­ã®ã¿æœ‰åйã§ã€å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã«ä»£å…¥ã¯å–り消ã•れã¾ã™ã€‚

    コマンドåãŒæŒ‡å®šã•れãŸå ´åˆã¾ãŸã¯ all-export ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªå ´åˆã¯ã€ä»£å…¥ã•れる変数ã¯è‡ªå‹•çš„ã«ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚

  4. コマンドåãŒå­˜åœ¨ã—ãªã„å ´åˆã¯ã€å˜ç´”コマンドã®å®Ÿè¡Œã¯ã“れã§çµ‚ã‚りã§ã™ã€‚å˜ç´”コマンドã®çµ‚了ステータス㯠0 ã«ãªã‚Šã¾ã™ (ãŸã ã—å˜ç´”コマンド実行中ã«ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒè¡Œã‚ã‚ŒãŸæ™‚ã¯ã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒå˜ç´”コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™)。

  5. 後述ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®ä»•æ–¹ã«å¾“ã£ã¦å®Ÿè¡Œã™ã¹ãコマンドを特定ã—ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚

    • コマンドãŒå¤–部コマンドã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚µãƒ–シェル㧠exec システムコールを呼ã³å‡ºã™ã“ã¨ã«ã‚ˆã‚Šå®Ÿè¡Œã•れã¾ã™ã€‚コマンドåã¨ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ãŒèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ã¾ãŸã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã¨ãªã£ã¦ã„る変数ãŒç’°å¢ƒå¤‰æ•°ã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚

    • コマンドãŒçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰å¼•数を引数ã¨ã—ã¦çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れã¾ã™ã€‚

    • コマンドãŒé–¢æ•°ã®å ´åˆã¯ã€ãã®é–¢æ•°ã®å†…容ãŒå®Ÿè¡Œã•れã¾ã™ã€‚コマンド引数ãŒé–¢æ•°ã®å¼•æ•°ã¨ã—ã¦æ¸¡ã•れã¾ã™ã€‚

    実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒã“ã®å˜ç´”コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œã•れãšçµ‚了ステータス㯠127 ã«ãªã‚Šã¾ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã£ãŸãŒèµ·å‹•ã«å¤±æ•—ã—ãŸå ´åˆã¯ã€çµ‚了ステータス㯠126 ã«ãªã‚Šã¾ã™ã€‚コマンドãŒèµ·å‹•ã•れãŸãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã¯ã€çµ‚了ステータスã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã®ç•ªå·ã« 384 ã‚’è¶³ã—ãŸæ•°ã«ãªã‚Šã¾ã™ã€‚

    注
    POSIX ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã®çµ‚了ステータス㯠128 より大ããªæ•°ã¨ã—ã‹å®šã‚られã¦ã„ãªã„ã®ã§ã€yash 以外ã®ã‚·ã‚§ãƒ«ã§ã¯çµ‚了ステータスãŒç•°ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚

    éž POSIX 準拠モードã«ãŠã„ã¦ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãŸã ã—ã“ã®ã¨ãä½ç½®ãƒ‘ラメータã¯ã‚³ãƒžãƒ³ãƒ‰åã¨ã‚³ãƒžãƒ³ãƒ‰å¼•æ•°ã«ä¸€æ™‚çš„ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ã¾ãŸã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œä¸­ã«å®šç¾©ã•れãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了時ã«å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œæ™‚ã«ã¯ HANDLED ローカル変数ãŒç©ºæ–‡å­—列を値ã¨ã—ã¦ã‚らã‹ã˜ã‚定義ã•れã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œå¾Œã«ã“ã®å¤‰æ•°ã®å€¤ãŒç©ºæ–‡å­—列ã§ãªããªã£ã¦ã„れã°ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒã“ã®å˜ç´”コマンドã®çµ‚了ステータスã¨ãªã‚Šã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã“ã¨ã¯ã‚¨ãƒ©ãƒ¼ã¨ã¯ã¿ãªã•れã¾ã›ã‚“。

å˜ç´”コマンドã§å®Ÿè¡Œã™ã¹ãコマンドã¯ã€å±•é–‹ã§å¾—られãŸã‚³ãƒžãƒ³ãƒ‰åã«åŸºã¥ã„ã¦ä»¥ä¸‹ã®æ‰‹é †ã§ç‰¹å®šã•れã¾ã™ã€‚

  1. コマンドåã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (/) ãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã¯ã€ãれãŒå®Ÿè¡Œã™ã¹ã外部コマンドã¸ã®ãƒ‘スåã§ã‚ã‚‹ã¨ç‰¹å®šã•れã¾ã™ã€‚

  2. コマンドåãŒç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚

  3. コマンドåã¨åŒã˜åå‰ã®é–¢æ•°ãŒå­˜åœ¨ã™ã‚Œã°ã€ãã®é–¢æ•°ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚

  4. コマンドåãŒæº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚

  5. コマンドåãŒé€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã‚‰ã°ã€ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ã€‚(POSIX 準拠モードã®ã¨ãを除ã)

  6. PATH 変数ã®å€¤ã«å¾“ã£ã¦ã€å®Ÿè¡Œã™ã¹ã外部コマンドを検索ã—ãã®ãƒ‘スåを特定ã—ã¾ã™ã€‚

    PATH 変数ã®å€¤ã¯ã€ã„ãã¤ã‹ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スåをコロン (:) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ (空ã®ãƒ‘スåã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™)。ãれらã®å„ディレクトリã«ã¤ã„ã¦é †ã«ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ä¸­ã«ã‚³ãƒžãƒ³ãƒ‰åã¨åŒã˜åå‰ã®å®Ÿè¡Œå¯èƒ½ãªé€šå¸¸ã®ãƒ•ァイルãŒã‚ã‚‹ã‹èª¿æŸ»ã—ã¾ã™ã€‚ãã®ã‚ˆã†ãªãƒ•ァイルãŒã‚れã°ã€ãã®ãƒ•ァイルãŒå®Ÿè¡Œã™ã¹ã外部コマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™ (ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰åã¨åŒã˜åå‰ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒã‚れã°ã€ä»£ã‚りã«ãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã™ã¹ãコマンドã¨ã—ã¦ç‰¹å®šã•れã¾ã™)。ã©ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã‚‚ãã®ã‚ˆã†ãªãƒ•ァイルãŒè¦‹ã¤ã‹ã‚‰ãªã‘れã°ã€å®Ÿè¡Œã™ã¹ãコマンドã¯è¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚

å¤–éƒ¨ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ãŒæˆåŠŸã—パスåãŒç‰¹å®šã§ããŸå ´åˆã€ãã®ãƒ‘スåãŒçµ¶å¯¾ãƒ‘スãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ‘スåを記憶ã—ã€å†ã³åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹éš›ã«æ¤œç´¢ã®æ‰‹é–“ã‚’çœãã¾ã™ã€‚ãŸã ã—ã€å†ã³ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—よã†ã¨ã—ãŸéš›ã«ã€è¨˜æ†¶ã—ã¦ã„るパスåã«å®Ÿè¡Œå¯èƒ½ãƒ•ァイルãŒè¦‹å½“ãŸã‚‰ãªã„å ´åˆã¯ã€æ¤œç´¢ã‚’やり直ã—ã¾ã™ã€‚シェルãŒè¨˜æ†¶ã—ã¦ã„るパスå㯠hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç®¡ç†ã§ãã¾ã™ã€‚

シェルã®çµ‚了

シェルã¯ã€å…¥åŠ›ãŒçµ‚ã‚りã«é”ã—ã¦å…¨ã¦ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’解釈・実行ã—終ãˆãŸæ™‚ã‚„ã€exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ããªã©ã«çµ‚了ã—ã¾ã™ã€‚シェルã®çµ‚了ステータスã¯ã€ã‚·ã‚§ãƒ«ãŒæœ€å¾Œã«å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを 256 ã§å‰²ã£ãŸä½™ã‚Šã§ã™ (一ã¤ã‚‚コマンドを実行ã—ãªã‹ã£ãŸã¨ã㯠0)。

Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚·ã‚§ãƒ«çµ‚了時ã®ãƒãƒ³ãƒ‰ãƒ©ãŒç™»éŒ²ã•れã¦ã„ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ãŒçµ‚了ã™ã‚‹ç›´å‰ã«ãã®ãƒãƒ³ãƒ‰ãƒ©ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãŸã ã—ã“ã®ãƒãƒ³ãƒ‰ãƒ©å†…ã§å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®çµ‚了ステータスã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。

対話モードã§ãªã„シェルã®å®Ÿè¡Œä¸­ã«ä¸‹è¨˜ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ã“ã®ã¨ãシェルã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

  • 文法エラーã®ãŸã‚コマンドを解釈ã§ããªã„ã¨ã (シェルã®åˆæœŸåŒ–中を除ã)

  • POSIX 準拠モードã§ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹ã¨ã

  • POSIX 準拠モードã§ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã—ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã¾ãŸã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸã¨ã

  • 展開エラーãŒç™ºç”Ÿã—ãŸã¨ã (シェルã®åˆæœŸåŒ–中を除ã)

注
Yash ã¯ãã†ã§ã¯ã‚りã¾ã›ã‚“ãŒã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ãŠã„ã¦å®Ÿè¡Œã™ã¹ãコマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã«ç›´ã¡ã«çµ‚了ã™ã‚‹ã‚ˆã†ãªã‚·ã‚§ãƒ«ã‚‚ã‚りã¾ã™ã€‚

関数

関数ã¯ä¸€ã¤ã®è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã‚’å˜ç´”コマンドã®ã‚ˆã†ã«å‘¼ã³å‡ºã›ã‚‹ã‚ˆã†ã«ã™ã‚‹æ©Ÿæ§‹ã§ã™ã€‚関数ã¯é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã«ã‚ˆã£ã¦å®šç¾©ã§ãã€å˜ç´”コマンドã«ã‚ˆã£ã¦å®Ÿè¡Œã§ãã¾ã™ã€‚関数を削除ã™ã‚‹ã«ã¯ unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã„ã¾ã™ã€‚

Yash ã«ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰å®šç¾©ã•れã¦ã„る関数ã¯ä¸€ã¤ã‚‚ã‚りã¾ã›ã‚“。

関数ã®å®Ÿè¡Œã¯ã€é–¢æ•°ã®å†…容ã§ã‚る複åˆã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦è¡Œã‚れã¾ã™ã€‚関数ã®å®Ÿè¡Œä¸­ã¯ã€é–¢æ•°ã®å¼•æ•°ãŒä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚ãれã¾ã§ã®ä½ç½®ãƒ‘ラメータã¯ä¸€æ™‚çš„ã«ä½¿ãˆãªããªã‚Šã¾ã™ãŒé–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸæ™‚ã«å…ƒã®ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã«æˆ»ã‚Šã¾ã™ã€‚

ローカル変数

ローカル変数ã¨ã¯ã€é–¢æ•°ã®å®Ÿè¡Œä¸­ã«ã ã‘有効ãªä¸€æ™‚çš„ãªå¤‰æ•°ã§ã™ã€‚ローカル変数㯠typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã£ã¦ä½œã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚関数ã®å®Ÿè¡Œä¸­ã«ä½œã‚‰ã‚ŒãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸæ™‚ã«å‰Šé™¤ã•れã€ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’作るå‰ã®å…ƒã®å¤‰æ•°ã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚

関数内ã§å®šç¾©ã—ãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¯ã€é–¢æ•°ã®å®Ÿè¡Œã«å…ˆç«‹ã£ã¦å®šç¾©ã—ã¦ã‚ã£ãŸåŒåã®ä»–ã®å¤‰æ•°ã‚’隠蔽ã—ã¾ã™ã€‚隠蔽ã•れãŸå¤‰æ•°ã¯ã€é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ã¦ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒãªããªã‚‹ã¾ã§ä½¿ãˆãªããªã‚Šã¾ã™ã€‚

関数ã®å®Ÿè¡Œä¸­ã§ãªã„ã¨ãã«ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’作るã“ã¨ã¯ã§ãã¾ã›ã‚“。ローカル変数を作ã‚ã†ã¨ã—ã¦ã‚‚ã€é€šå¸¸ã®å¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚

コマンドã®å®Ÿè¡Œç’°å¢ƒ

シェルã¯å®Ÿè¡Œæ™‚ã«ä»¥ä¸‹ã®æƒ…å ±ã‚’ä¿æŒã—ã¾ã™ã€‚

  • 作業ディレクトリ

  • é–‹ã„ã¦ã„るファイル記述å­

  • ファイル作æˆãƒžã‚¹ã‚¯ (umask)

  • å—ä¿¡æ™‚ã®æŒ™å‹•㌠『無視〠ã«è¨­å®šã•れãŸã‚·ã‚°ãƒŠãƒ«ã®é›†åˆ (trap)

  • 環境変数

  • ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™ (ulimit)

ã“ã‚Œã‚‰ã®æƒ…å ±ã¯ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã«å…ƒã®ãƒ—ログラムã‹ã‚‰ã‚·ã‚§ãƒ«ã«å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚ãã—ã¦ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å¤–部コマンドやサブシェルã«ã‚‚シェルã‹ã‚‰å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚

ã“ã‚Œã‚‰ã®æƒ…å ±ã¯æ‰€å®šã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ç­‰ã‚’使ã£ã¦å¤‰æ›´å¯èƒ½ã§ã™ã€‚

サブシェル

サブシェルã¯ã€å®Ÿè¡Œä¸­ã®ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã®ã‚³ãƒ”ーã§ã™ã€‚ã‚µãƒ–ã‚·ã‚§ãƒ«ã¯æ‹¬å¼§ ( ) ã§å›²ã‚“ã ã‚°ãƒ«ãƒ¼ãƒ”ングやパイプラインã§ä½¿ã‚れã¾ã™ã€‚

サブシェルã¯ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã®ã‚³ãƒ”ーã§ã‚ã‚‹ãŸã‚ã€ä¸Šè¨˜ã®æƒ…å ±ã®ä»–ã«ã‚·ã‚§ãƒ«ã§å®šç¾©ã•れãŸé–¢æ•°ã‚„エイリアスãªã©ã®æƒ…報も元ã®ã‚·ã‚§ãƒ«ã‹ã‚‰å—ã‘ç¶™ãŽã¾ã™ã€‚ãŸã ã—ã€

  • Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç™»éŒ²ã—ãŸã‚·ã‚°ãƒŠãƒ«ãƒãƒ³ãƒ‰ãƒ©ã¯ã€(å—ä¿¡æ™‚ã®æŒ™å‹•㌠『無視〠ã®ã‚‚ã®ã‚’除ã) サブシェルã§ã¯ã™ã¹ã¦è§£é™¤ã•れã¾ã™ã€‚

  • サブシェルã§ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã¨ã‚¸ãƒ§ãƒ–制御ã¯è§£é™¤ã•れã€å…ƒã®ã‚·ã‚§ãƒ«ã®ã‚¸ãƒ§ãƒ–ã®æƒ…å ±ã¯å—ã‘ç¶™ãŒã‚Œã¾ã›ã‚“。

サブシェルã¯å…ƒã®ã‚·ã‚§ãƒ«ã¨ã¯ç‹¬ç«‹ã—ã¦ã„ã‚‹ãŸã‚ã€ã‚µãƒ–シェルã§ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å¤‰æ›´ã‚„変数代入ã¯å…ƒã®ã‚·ã‚§ãƒ«ã«å½±éŸ¿ã—ã¾ã›ã‚“。

yash-2.35/doc/ja/_times.txt0000644000175000017500000000207112154557026015726 0ustar magicantmagicant= Times 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Times 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Times 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ã¨ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒæ¶ˆè²»ã—㟠CPU 時間を表示ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +times+ [[description]] == 説明 Times コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã¨ãã®å­ãƒ—ãƒ­ã‚»ã‚¹ãŒæ¶ˆè²»ã—㟠CPU 時間を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚一行目ã«ã‚·ã‚§ãƒ«ãƒ—ロセス自身ãŒãƒ¦ãƒ¼ã‚¶ãƒ¢ãƒ¼ãƒ‰ãŠã‚ˆã³ã‚·ã‚¹ãƒ†ãƒ ãƒ¢ãƒ¼ãƒ‰ã§æ¶ˆè²»ã—㟠CPU 時間をãれãžã‚Œè¡¨ç¤ºã—ã¾ã™ã€‚二行目ã«ã‚·ã‚§ãƒ«ã®å…¨ã¦ã®å­å­«ãƒ—ロセス (親プロセス㌠wait ã—ã¦ã„ãªã„ã‚‚ã®ã‚’除ã) ãŒãƒ¦ãƒ¼ã‚¶ãƒ¢ãƒ¼ãƒ‰ãŠã‚ˆã³ã‚·ã‚¹ãƒ†ãƒ ãƒ¢ãƒ¼ãƒ‰ã§æ¶ˆè²»ã—㟠CPU 時間をãれãžã‚Œè¡¨ç¤ºã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š times コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Times コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_pushd.txt0000644000175000017500000000450312154557026015732 0ustar magicantmagicant= Pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:_dirs.html[ディレクトリスタック]ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’追加ã—ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +pushd [-L|-P] [{{ディレクトリ}}]+ [[description]] == 説明 Pushd コマンド㯠link:_cd.html[cd コマンド]ã¨åŒæ§˜ã«ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚作業ディレクトリã®å¤‰æ›´ã«æˆåŠŸã™ã‚‹ã¨ã€æ–°ã—ã„作業ディレクトリをlink:_dirs.html[ディレクトリスタック]ã«è¿½åŠ ã—ã¾ã™ã€‚ [[options]] == オプション link:_cd.html#options[Cd コマンドã§ä½¿ãˆã‚‹ã‚ªãƒ—ション]ã«åŠ ãˆã¦ä»¥ä¸‹ã®ã‚ªãƒ—ション㌠pushd コマンドã§ä½¿ãˆã¾ã™ã€‚ +--remove-duplicates+:: æ–°ã—ã„ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæ—¢ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«å…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€å…ƒã€…å…¥ã£ã¦ã„ãŸè¦ç´ ã‚’削除ã—ã¦é‡è¤‡ã‚’ãªãã—ã¾ã™ã€‚ [[operands]] == オペランド {{ディレクトリ}}:: æ–°ã—ã„作業ディレクトリã®ãƒ‘スåã§ã™ã€‚絶対パスã¾ãŸã¯å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘ã‚¹ã§æŒ‡å®šã—ã¾ã™ã€‚ + ã“ã®å€¤ãŒãƒã‚¤ãƒ•ン一㤠(+-+) ã®å ´åˆã€link:params.html#sv-oldpwd[+OLDPWD+ 変数]ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ + ã“ã®å€¤ãŒç¬¦å·ä»˜ãæ•´æ•°ã®å ´åˆã€ãã®æ•´æ•°ã‚’link:_dirs.html[ディレクトリスタック]ã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¨ã¿ãªã—ã¦ã€ãã®è¦ç´ ãŒè¡¨ã™ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (指定ã•れãŸè¦ç´ ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰å‰Šé™¤ã•れã¾ã™)。 + ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ ++1+ ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (+--default-directory+ オプションを指定ã—ãŸå ´åˆã‚’除ã)。 [[exitstatus]] == 終了ステータス 作業ディレクトリを正ã—ã変更ã—ディレクトリスタックã«è¿½åŠ ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ pushd コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_continue.html0000644000175000017500000001024212154557026016555 0ustar magicantmagicant Continue 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Continue 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œä¸­ã®ãƒ«ãƒ¼ãƒ—ã®æ¬¡ã®ç¹°ã‚Šè¿”ã—ã«å‡¦ç†ã‚’ç§»ã—ã¾ã™ã€‚

æ§‹æ–‡

  • continue [æ·±ã•]

  • continue -i

説明

-i (--iteration) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€continue コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã® for ループã¾ãŸã¯ while ループã¾ãŸã¯ until ループã®ç¹°ã‚Šè¿”ã—を中断ã—ã€ç›´ã¡ã«æ¬¡ã®ç¹°ã‚Šè¿”ã—ã‚’é–‹å§‹ã—ã¾ã™ (while/until ループã«ã¤ã„ã¦ã¯ã€ãƒ«ãƒ¼ãƒ—ã®å®Ÿè¡Œæ¡ä»¶ã®åˆ¤å®šã‹ã‚‰ã‚„り直ã—ã¾ã™)。多é‡ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§å®Ÿè¡Œã—ãŸå ´åˆã€å†…å´ã‹ã‚‰æ•°ãˆã¦æ·±ã•番目ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ã€‚æ·±ã•ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æœ€ã‚‚内å´ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ (深㕠= 1)。指定ã•ã‚ŒãŸæ·±ã•ãŒå®Ÿéš›ã«å®Ÿè¡Œã—ã¦ã„る多é‡ãƒ«ãƒ¼ãƒ—ã®æ·±ã•より大ãã„å ´åˆã¯æœ€ã‚‚外å´ã®ãƒ«ãƒ¼ãƒ—ã«å¯¾ã—ã¦ã“ã®å‹•作を行ã„ã¾ã™ã€‚

-i (--iteration) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€continue コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®å復実行ã®ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’中断ã—ã€ç›´ã¡ã«æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã‚’é–‹å§‹ã—ã¾ã™ã€‚

オプション

-i
--iteration

ループã§ã¯ãªãå復実行ã«å¯¾ã—ã¦ä½œç”¨ã—ã¾ã™ã€‚

オペランド

æ·±ã•

内å´ã‹ã‚‰ä½•番目ã®ãƒ«ãƒ¼ãƒ—ã«ä½œç”¨ã™ã‚‹ã®ã‹ã‚’指定ã™ã‚‹ 1 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚

終了ステータス

-i (--iteration) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã€continue コマンドã®å‡¦ç†ãŒæˆåŠŸã™ã‚‹ã¨çµ‚了ステータス㯠0 ã§ã™ã€‚-i (--iteration) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã€continue コマンドã®å‡¦ç†ãŒæˆåŠŸã™ã‚‹ã¨ continue コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠continue コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

補足

Continue コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ -i (--interact) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/_suspend.html0000644000175000017500000000554212154557026016421 0ustar magicantmagicant Suspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Suspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã‚’åœæ­¢ (サスペンド) ã—ã¾ã™ã€‚

æ§‹æ–‡

  • suspend [-f]

説明

Suspend コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスãŒå±žã™ã‚‹ãƒ—ロセスグループ内ã®ã™ã¹ã¦ã®ãƒ—ロセスã«å¯¾ã—㦠SIGSTOP シグナルをé€ä¿¡ã—ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‰ã‚ŒãŸå„プロセス (シェル自身をå«ã‚€) ã¯åœæ­¢ (サスペンド) 状態ã«ãªã‚Šã¾ã™ã€‚åœæ­¢çŠ¶æ…‹ã«ãªã£ãŸãƒ—ロセス㯠SIGCONT シグナルをå—ä¿¡ã™ã‚‹ã¨å®Ÿè¡Œã‚’å†é–‹ã—ã¾ã™ã€‚

シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ã€ã•らã«ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ—ロセスグループ ID ãŒã‚»ãƒƒã‚·ãƒ§ãƒ³ãƒªãƒ¼ãƒ€ãƒ¼ã®ãƒ—ロセス ID ã«ç­‰ã—ã„ã¨ãã¯ã€-f (--force) オプションを付ã‘ãªã„é™ã‚Šã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã›ã‚“。ã“れã¯ã‚·ã‚§ãƒ«ãŒåœæ­¢ã—ãŸå¾Œå®Ÿè¡Œã‚’å†é–‹ã•ã›ã‚‹ã“ã¨ãŒã§ããªããªã£ã¦ã—ã¾ã†ã®ã‚’未然ã«é˜²ããŸã‚ã§ã™ã€‚

オプション

-f
--force

警告を無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’åœæ­¢ã—ã¾ã™ã€‚

終了ステータス

Suspend コマンドã®çµ‚了ステータスã¯ã€SIGSTOP ã‚·ã‚°ãƒŠãƒ«ã‚’ã‚·ã‚§ãƒ«ã«æ­£ã—ãé€ä¿¡ã§ããŸã¨ã㯠0ã€ãれ以外ãªã‚‰éž 0 ã§ã™ã€‚

補足

POSIX ã«ã¯ suspend コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/syntax.html0000644000175000017500000007456512154557026016142 0ustar magicantmagicant ã‚³ãƒžãƒ³ãƒ‰ã®æ–‡æ³•

シェルã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’一行ãšã¤èª­ã¿è¾¼ã‚“ã§è§£é‡ˆã—ã€å®Ÿè¡Œã—ã¾ã™ã€‚一行ã«è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ãれら全ã¦ã‚’解釈ã—ã¦ã‹ã‚‰å®Ÿè¡Œã—ã¾ã™ã€‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãŒè¤‡æ•°è¡Œã«ã¾ãŸãŒã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’解釈ã—終ãˆã‚‹ã®ã«å¿…è¦ãªã ã‘後続ã®è¡ŒãŒèª­ã¿è¾¼ã¾ã‚Œã¾ã™ã€‚コマンドを正ã—ã解釈ã§ããªã„å ´åˆã¯ã€æ–‡æ³•エラーã¨ãªã‚Šã€ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œã•れã¾ã›ã‚“。

éžå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§æ–‡æ³•エラーãŒç™ºç”Ÿã—ãŸæ™‚ã¯ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®èª­ã¿è¾¼ã¿ã‚’中止ã™ã‚‹ãŸã‚ã€ãれ以é™ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ä¸€åˆ‡èª­ã¿è¾¼ã¾ã‚Œã¾ã›ã‚“。

トークンã®è§£æžã¨äºˆç´„語

コマンドã¯ã€ã„ãã¤ã‹ã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã‚ˆã£ã¦æ§‹æˆã•れã¾ã™ã€‚トークンã¨ã¯ã€ã‚·ã‚§ãƒ«ã®æ–‡æ³•ã«ãŠã‘る一ã¤ä¸€ã¤ã®å˜èªžã®ã“ã¨ã‚’言ã„ã¾ã™ã€‚トークンã¯åŽŸå‰‡ã¨ã—ã¦ç©ºç™½ (空白文字ã¾ãŸã¯ã‚¿ãƒ–文字) ã«ã‚ˆã£ã¦åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ãŸã ã—コマンド置æ›ãªã©ã«å«ã¾ã‚Œã‚‹ç©ºç™½ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ã¯è¦‹ãªã—ã¾ã›ã‚“。

以下ã®è¨˜å·ã¯ã€ã‚·ã‚§ãƒ«ã®æ–‡æ³•ã«ãŠã„ã¦ç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚ã“れらã®è¨˜å·ã‚‚多ãã®å ´åˆä»–ã®é€šå¸¸ã®ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ãªã‚Šã¾ã™ã€‚

; & | < > ( ) [newline]

以下ã®è¨˜å·ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã«ã¯ãªã‚Šã¾ã›ã‚“ãŒã€æ–‡æ³•ä¸Šç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚

$ ` \ " ' * ? [ # ~ = %

以下ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ç‰¹å®šã®å ´é¢ã«ãŠã„ã¦äºˆç´„語ã¨è¦‹ãªã•れã¾ã™ã€‚予約語ã¯è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ãªã©ã‚’æ§‹æˆã™ã‚‹ä¸€éƒ¨ã¨ãªã‚Šã¾ã™ã€‚

! { } case do done elif else esac fi
for function if in then until while

ã“れらã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ä»¥ä¸‹ã®å ´é¢ã«ãŠã„ã¦äºˆç´„語ã¨ãªã‚Šã¾ã™ã€‚

  • ãれãŒã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã®ã¨ã

  • ãれãŒä»–ã®äºˆç´„語 (case, for, in を除ã) ã®ç›´å¾Œã®ãƒˆãƒ¼ã‚¯ãƒ³ã®ã¨ã

  • ãれãŒã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã§ã¯ãªã„ãŒã€è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã®ä¸­ã§äºˆç´„語ã¨ã—ã¦æ‰±ã‚れるã¹ãトークンã§ã‚ã‚‹ã¨ã

トークン㌠# ã§å§‹ã¾ã‚‹å ´åˆã€ãã® # ã‹ã‚‰è¡Œæœ«ã¾ã§ã¯ã‚³ãƒ¡ãƒ³ãƒˆã¨è¦‹ãªã•れã¾ã™ã€‚コマンドã®è§£é‡ˆã«ãŠã„ã¦ã‚³ãƒ¡ãƒ³ãƒˆã¯å®Œå…¨ã«ç„¡è¦–ã•れã¾ã™ã€‚

クォート

空白や上記ã®åŒºåˆ‡ã‚Šè¨˜å·ãƒ»äºˆç´„語ãªã©ã‚’é€šå¸¸ã®æ–‡å­—ã¨åŒã˜ã‚ˆã†ã«æ‰±ã†ã«ã¯ã€é©åˆ‡ãªå¼•用符ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚引用符ã¯ã€ãれ自体をクォートã—ãªã„é™ã‚Šé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦ã¯æ‰±ã‚れã¾ã›ã‚“。シェルã§ã¯ä»¥ä¸‹ã®ä¸‰ç¨®é¡žã®å¼•用符ãŒä½¿ãˆã¾ã™ã€‚

  • ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\) ã¯ç›´å¾Œã®ä¸€æ–‡å­—をクォートã—ã¾ã™ã€‚
    例外ã¨ã—ã¦ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã®ç›´å¾Œã«æ”¹è¡ŒãŒã‚ã‚‹å ´åˆã€ãã‚Œã¯æ”¹è¡Œã‚’クォートã—ã¦ã„ã‚‹ã®ã§ã¯ãªãã€è¡Œã®é€£çµã¨è¦‹ãªã•れã¾ã™ã€‚ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¨æ”¹è¡ŒãŒå‰Šé™¤ã•れã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒã‚ã£ãŸè¡Œã¨ãã®æ¬¡ã®è¡ŒãŒå…ƒã€…一ã¤ã®è¡Œã§ã‚ã£ãŸã‹ã®ã‚ˆã†ã«æ‰±ã‚れã¾ã™ã€‚

  • 二ã¤ã®ä¸€é‡å¼•用符 (') ã§å›²ã‚“ã éƒ¨åˆ†ã§ã¯ã€å…¨ã¦ã®æ–‡å­—ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒã˜ã‚ˆã†ã«æ‰±ã‚れã¾ã™ã€‚改行を一é‡å¼•用符ã§å›²ã‚€ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ãŸã ã—ã€ä¸€é‡å¼•用符を一é‡å¼•用符ã§å›²ã‚€ã“ã¨ã¯ã§ãã¾ã›ã‚“。

  • 二ã¤ã®äºŒé‡å¼•用符 (") ã§å›²ã‚“ã éƒ¨åˆ†ã‚‚一é‡å¼•用符ã§å›²ã‚“ã éƒ¨åˆ†ã¨åŒæ§˜ã«ã‚¯ã‚©ãƒ¼ãƒˆã•れã¾ã™ãŒã€ã„ãã¤ã‹ä¾‹å¤–ãŒã‚りã¾ã™ã€‚二é‡å¼•用符ã§å›²ã‚“ã éƒ¨åˆ†ã§ã¯ã€ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ãŒé€šå¸¸é€šã‚Šè§£é‡ˆã•れã¾ã™ã€‚ã¾ãŸãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯ $, `, ", \ ã®ç›´å‰ã«ã‚ã‚‹å ´åˆãŠã‚ˆã³è¡Œã®é€£çµã‚’行ã†å ´åˆã«ã®ã¿å¼•用符ã¨ã—ã¦æ‰±ã‚れã€ãれ以外ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒæ§˜ã«æ‰±ã‚れã¾ã™ã€‚

エイリアス

コマンドを構æˆã™ã‚‹å„トークンã¯ã€ãれãŒäºˆã‚登録ã•れãŸã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã«ä¸€è‡´ã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã‚‰ã‚Œã¾ã™ã€‚一致ã™ã‚‹ã‚‚ã®ãŒã‚れã°ã€ãã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ãã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®å†…容ã«ç½®ãæ›ãˆã‚‰ã‚Œã¦ã€ãã®å¾Œã‚³ãƒžãƒ³ãƒ‰ã®è§£æžãŒç¶šã‘られã¾ã™ã€‚ã“れをエイリアス置æ›ã¨ã„ã„ã¾ã™ã€‚

エイリアスã®åå‰ã«å¼•用符をå«ã‚ã‚‹ã“ã¨ã¯ã§ããªã„ã®ã§ã€å¼•用符をå«ã‚€ãƒˆãƒ¼ã‚¯ãƒ³ã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ç½®æ›ã•れã¾ã›ã‚“。ã¾ãŸã€äºˆç´„語やコマンドを区切る記å·ã‚‚エイリアス置æ›ã•れã¾ã›ã‚“。

エイリアスã«ã¯é€šå¸¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¨ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®äºŒç¨®é¡žãŒã‚りã¾ã™ã€‚通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã®ã¿ä¸€è‡´ã—ã¾ã™ã€‚グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ã‚³ãƒžãƒ³ãƒ‰å†…ã®å…¨ã¦ã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒä¸€è‡´ã®å¯¾è±¡ã§ã™ã€‚グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ POSIX è¦æ ¼ã«ã¯ãªã„拡張機能ã§ã™ã€‚

通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã§ç½®æ›ã•れãŸéƒ¨åˆ†ã®æœ€å¾Œã®æ–‡å­—ãŒç©ºç™½ã®å ´åˆã€ç‰¹ä¾‹ã¨ã—ã¦ãã®ç›´å¾Œã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã‚‚通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®ç½®æ›ãŒè¡Œã‚れã¾ã™ã€‚

エイリアス置æ›ã®çµæžœãŒã•らã«åˆ¥ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ä¸€è‡´ã—ã¦ç½®æ›ã•れる場åˆã‚‚ã‚りã¾ã™ã€‚ã—ã‹ã—ã€åŒã˜ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«å†ã³ä¸€è‡´ã™ã‚‹ã“ã¨ã¯ã‚りã¾ã›ã‚“。

エイリアスを登録ã™ã‚‹ã«ã¯ alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’ã€ç™»éŒ²ã‚’削除ã™ã‚‹ã«ã¯ unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã—ã¾ã™ã€‚

å˜ç´”コマンド

最åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒäºˆç´„語ã§ãªã„コマンドã¯ã€å˜ç´”コマンドã§ã™ã€‚å˜ç´”コマンドã¯å˜ç´”コマンドã®å®Ÿè¡Œã®ã—ã‹ãŸã«å¾“ã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚

å˜ç´”コマンドã®åˆã‚ã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒ åå‰=値 ã®å½¢å¼ã«ãªã£ã¦ã„ã‚‹å ´åˆã¯ã€ãれã¯å¤‰æ•°ä»£å…¥ã¨è¦‹ãªã•れã¾ã™ã€‚ãŸã ã—ã“ã“ã§ã®åå‰ã¯ã€ä¸€æ–‡å­—以上ã®ã‚¢ãƒ«ãƒ•ァベット・数字ã¾ãŸã¯ä¸‹ç·š (_) ã§ã€ã‹ã¤æœ€åˆãŒæ•°å­—ã§ãªã„ã‚‚ã®ã§ã™ã€‚変数代入ã§ã¯ãªã„最åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã¨è§£é‡ˆã•れã¾ã™ã€‚ãれ以é™ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ (ãŸã¨ãˆå¤‰æ•°ä»£å…¥ã®å½¢å¼ã‚’ã—ã¦ã„ãŸã¨ã—ã¦ã‚‚) コマンドã®å¼•æ•°ã¨è§£é‡ˆã•れã¾ã™ã€‚

åå‰=(トークン列) ã®å½¢ã«ãªã£ã¦ã„る変数代入ã¯ã€é…列ã®ä»£å…¥ã¨ãªã‚Šã¾ã™ã€‚括弧内ã«ã¯ä»»æ„ã®å€‹æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’書ãã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸã“れらã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ç©ºç™½ãƒ»ã‚¿ãƒ–ã ã‘ã§ãªã改行ã§åŒºåˆ‡ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚

パイプライン

パイプラインã¯ã€ä¸€ã¤ä»¥ä¸Šã®ã‚³ãƒžãƒ³ãƒ‰ (å˜ç´”コマンドã€è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã€ã¾ãŸã¯é–¢æ•°å®šç¾©) ã‚’è¨˜å· | ã§ç¹‹ã„ã ã‚‚ã®ã§ã™ã€‚

二ã¤ä»¥ä¸Šã®ã‚³ãƒžãƒ³ãƒ‰ã‹ã‚‰ãªã‚‹ãƒ‘イプラインã®å®Ÿè¡Œã¯ã€ãƒ‘イプラインã«å«ã¾ã‚Œã‚‹å„コマンドをãれãžã‚Œç‹¬ç«‹ã—ãŸã‚µãƒ–シェルã§åŒæ™‚ã«å®Ÿè¡Œã™ã‚‹ã“ã¨ã§è¡Œã‚れã¾ã™ã€‚ã“ã®æ™‚ã€å„ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å‡ºåŠ›ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力ã«ãƒ‘イプã§å—ã‘æ¸¡ã•れã¾ã™ã€‚最åˆã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å…¥åŠ›ã¨æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ã¯å…ƒã®ã¾ã¾ã§ã™ã€‚最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒãƒ‘イプラインã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

パイプラインã®å…ˆé ­ã«ã¯ã€è¨˜å· ! を付ã‘ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘イプラインã®çµ‚了ステータスãŒé€†è»¢ã—ã¾ã™ã€‚ã¤ã¾ã‚Šã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ã®ã¨ãã¯ãƒ‘イプラインã®çµ‚了ステータス㯠1 ã«ãªã‚Šã€ãれ以外ã®å ´åˆã¯ 0 ã«ãªã‚Šã¾ã™ã€‚

注
最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒãƒ‘イプラインã®çµ‚了ステータスã«ãªã‚‹ãŸã‚ã€ãƒ‘イプラインã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã®ã¯å°‘ãªãã¨ã‚‚最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸå¾Œã§ã™ã€‚ã—ã‹ã—ãã®ã¨ãä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ã¦ã„ã‚‹ã¨ã¯é™ã‚Šã¾ã›ã‚“。ã¾ãŸã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸã‚‰ã™ãã«ãƒ‘イプラインã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã¨ã‚‚é™ã‚Šã¾ã›ã‚“。(シェルã¯ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã‚‹ã¾ã§å¾…ã¤å ´åˆãŒã‚りã¾ã™)
注
POSIX è¦æ ¼ã§ã¯ã€ãƒ‘イプライン内ã®å„コマンドã¯ã‚µãƒ–シェルã§ã¯ãªãç¾åœ¨ã®ã‚·ã‚§ãƒ«ã§å®Ÿè¡Œã—ã¦ã‚‚よã„ã“ã¨ã«ãªã£ã¦ã„ã¾ã™ã€‚

And/or リスト

And/or リストã¯ä¸€ã¤ä»¥ä¸Šã®ãƒ‘ã‚¤ãƒ—ãƒ©ã‚¤ãƒ³ã‚’è¨˜å· && ã¾ãŸã¯ || ã§ç¹‹ã„ã ã‚‚ã®ã§ã™ã€‚

And/or リストã®å®Ÿè¡Œã¯ã€and/or リストã«å«ã¾ã‚Œã‚‹å„パイプラインをæ¡ä»¶ä»˜ãã§å®Ÿè¡Œã™ã‚‹ã“ã¨ã§è¡Œã‚れã¾ã™ã€‚最åˆã®ãƒ‘イプラインã¯å¸¸ã«å®Ÿè¡Œã•れã¾ã™ã€‚ãれ以é™ã®ãƒ‘イプラインã®å®Ÿè¡Œã¯ã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータスã«ã‚ˆã‚Šã¾ã™ã€‚

  • 二ã¤ã®ãƒ‘イプライン㌠&& ã§ç¹‹ãŒã‚Œã¦ã„ã‚‹å ´åˆã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータス㌠0 ãªã‚‰ã°å¾Œã®ãƒ‘イプラインãŒå®Ÿè¡Œã•れã¾ã™ã€‚

  • 二ã¤ã®ãƒ‘イプライン㌠|| ã§ç¹‹ãŒã‚Œã¦ã„ã‚‹å ´åˆã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータス㌠0 ã§ãªã‘れã°å¾Œã®ãƒ‘イプラインãŒå®Ÿè¡Œã•れã¾ã™ã€‚

  • ãれ以外ã®å ´åˆã¯ã€and/or リストã®å®Ÿè¡Œã¯ãã“ã§çµ‚了ã—ã€ãれ以é™ã®ãƒ‘イプラインã¯å®Ÿè¡Œã•れã¾ã›ã‚“。

最後ã«å®Ÿè¡Œã—ãŸãƒ‘イプラインã®çµ‚了ステータス㌠and/or リストã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

構文上ã€and/or リストã®ç›´å¾Œã«ã¯åŽŸå‰‡ã¨ã—ã¦è¨˜å· ; ã¾ãŸã¯ & ãŒå¿…è¦ã§ã™ (コマンドã®åŒºåˆ‡ã‚Šã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰å‚ç…§)。

コマンドã®åŒºåˆ‡ã‚Šã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰

シェルãŒå—ã‘å–るコマンドã®å…¨ä½“ã¯ã€and/or リストを ; ã¾ãŸã¯ & ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚行末〠;; ã¾ãŸã¯ ) ã®ç›´å‰ã«ã‚ã‚‹ ; ã¯çœç•¥ã§ãã¾ã™ãŒã€ãれ以外ã®å ´åˆã¯ and/or リストã®ç›´å¾Œã«ã¯å¿…ãš ; 㨠& ã®ã©ã¡ã‚‰ã‹ãŒå¿…è¦ã§ã™ã€‚

And/or リストã®ç›´å¾Œã« ; ãŒã‚ã‚‹å ´åˆã¯ã€ãã® and/or リストã¯åŒæœŸçš„ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã® and/or リストã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã«æ¬¡ã® and/or リストãŒå®Ÿè¡Œã•れã¾ã™ã€‚And/or リストã®ç›´å¾Œã« & ãŒã‚ã‚‹å ´åˆã¯ã€ãã® and/or リストã¯éžåŒæœŸçš„ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã® and/or リストã®å®Ÿè¡Œã‚’é–‹å§‹ã—ãŸå¾Œã€çµ‚了を待ãŸãšã«ã€ã™ãã•ã¾æ¬¡ã® and/or リストã®å®Ÿè¡Œã«ç§»ã‚Šã¾ã™ã€‚éžåŒæœŸãª and/or リストã¯å¸¸ã«ã‚µãƒ–シェルã§å®Ÿè¡Œã•れã¾ã™ã€‚ã¾ãŸçµ‚了ステータスã¯å¸¸ã« 0 ã§ã™ã€‚

ジョブ制御を行ã£ã¦ã„ãªã„シェルã«ãŠã‘ã‚‹éžåŒæœŸãª and/or リストã§ã¯ã€æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れるã¨ã¨ã‚‚ã«ã€SIGINT 㨠SIGQUIT ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作㌠『無視〠ã«è¨­å®šã•れã“れらã®ã‚·ã‚°ãƒŠãƒ«ã‚’å—ã‘ã¦ã‚‚プログラムãŒçµ‚了ã—ãªã„よã†ã«ã—ã¾ã™ã€‚(POSIX 準拠モードã§ã¯ã€æ¨™æº–入力を /dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã™ã‚‹ã®ã¯ã‚¸ãƒ§ãƒ–制御を行ã£ã¦ã„ãªã„シェルã§ã¯ãªã対話モードã®ã‚·ã‚§ãƒ«ã§ã™ã€‚ã¾ãŸ POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ–制御を行ã£ã¦ã„ã¦ã‚‚ SIGINT 㨠SIGQUIT ㌠『無視〠ã«è¨­å®šã•れã¾ã™)

ジョブ制御を行ã£ã¦ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ãã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID を記憶ã—ã¾ã™ã€‚特殊パラメータ ! ã‚’å‚ç…§ã™ã‚‹ã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID を知るã“ã¨ãŒã§ãã¾ã™ã€‚éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çŠ¶æ…‹ã‚„çµ‚äº†ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ã¯ jobs ã‚„ wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

複åˆã‚³ãƒžãƒ³ãƒ‰

複åˆã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚ˆã‚Šè¤‡é›‘ãªãƒ—ログラムã®åˆ¶å¾¡ã‚’è¡Œã†æ‰‹æ®µã‚’æä¾›ã—ã¾ã™ã€‚

グルーピング

グルーピングを使ã†ã¨ã€è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãã¾ã™ã€‚

通常ã®ã‚°ãƒ«ãƒ¼ãƒ”ãƒ³ã‚°ã®æ§‹æ–‡

{ コマンド…; }

サブシェルã®ã‚°ãƒ«ãƒ¼ãƒ”ãƒ³ã‚°ã®æ§‹æ–‡

(コマンド…)

{ 㨠} ã¯äºˆç´„語ãªã®ã§ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‘ã¦æ›¸ã„ã¦ã¯ã„ã‘ã¾ã›ã‚“。一方 ( 㨠) ã¯ç‰¹æ®ŠãªåŒºåˆ‡ã‚Šè¨˜å·ã¨è¦‹ãªã•れるã®ã§ã€ä»–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‘ã¦æ›¸ãã“ã¨ãŒã§ãã¾ã™ã€‚

通常ã®ã‚°ãƒ«ãƒ¼ãƒ”ング構文 ({ 㨠} ã§å›²ã‚€) ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ (ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«) ç¾åœ¨ã®ã‚·ã‚§ãƒ«ã§å®Ÿè¡Œã•れã¾ã™ã€‚サブシェルã®ã‚°ãƒ«ãƒ¼ãƒ”ング構文 (( 㨠) ã§å›²ã‚€) ã§ã¯ã€æ‹¬å¼§å†…ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–°ãŸãª​サブシェルã§å®Ÿè¡Œã•れã¾ã™ã€‚

POSIX 準拠モードã§ã¯æ‹¬å¼§å†…ã«å°‘ãªãã¨ã‚‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãŒå¿…è¦ã§ã™ãŒã€éž POSIX 準拠モードã§ã¯ã‚³ãƒžãƒ³ãƒ‰ã¯ä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。

グルーピングã®çµ‚了ステータスã¯ã€ã‚°ãƒ«ãƒ¼ãƒ”ングã®ä¸­ã§å®Ÿè¡Œã•ã‚ŒãŸæœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚グルーピング内ã«ã‚³ãƒžãƒ³ãƒ‰ãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã‚°ãƒ«ãƒ¼ãƒ”ングã®çµ‚了ステータスã¯ã‚°ãƒ«ãƒ¼ãƒ”ングã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

If æ–‡

If æ–‡ã¯æ¡ä»¶åˆ†å²ã‚’行ã„ã¾ã™ã€‚分å²ã®è¤‡é›‘ã•ã«å¿œã˜ã¦ã„ãã¤ã‹æ§‹æ–‡ã®ãƒãƒªã‚¨ãƒ¼ã‚·ãƒ§ãƒ³ãŒã‚りã¾ã™ã€‚

If æ–‡ã®åŸºæœ¬æ§‹æ–‡

if æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; then 内容コマンド…; fi

Else ãŒã‚ã‚‹å ´åˆ

if æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; then 内容コマンド…; else 内容コマンド…; fi

Elif ãŒã‚ã‚‹å ´åˆ

if æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; then 内容コマンド…; elif æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; then 内容コマンド…; fi

Elif 㨠else ãŒã‚ã‚‹å ´åˆ

if æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; then 内容コマンド…; elif æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; then 内容コマンド…; else 内容コマンド…; fi

If æ–‡ã®å®Ÿè¡Œã§ã¯ã€ã©ã®æ§‹æ–‡ã®å ´åˆã§ã‚‚ã€if ã®ç›´å¾Œã«ã‚ã‚‹æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ãŒã¾ãšå®Ÿè¡Œã•れã¾ã™ã€‚æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ãªã‚‰ã°ã€æ¡ä»¶ãŒçœŸã§ã‚ã‚‹ã¨è¦‹ãªã•れ㦠then ã®ç›´å¾Œã«ã‚る内容コマンドãŒå®Ÿè¡Œã•れã€if æ–‡ã®å®Ÿè¡Œã¯ãれã§çµ‚了ã—ã¾ã™ã€‚終了ステータス㌠0 ã§ãªã‘れã°ã€æ¡ä»¶ãŒå½ã§ã‚ã‚‹ã¨è¦‹ãªã•れã¾ã™ã€‚ã“ã“ã§ else ã‚‚ elif ã‚‚ãªã‘れã°ã€if æ–‡ã®å®Ÿè¡Œã¯ã“れã§çµ‚ã‚りã§ã™ã€‚else ãŒã‚ã‚‹å ´åˆã¯ã€else ã®ç›´å¾Œã®å†…容コマンドãŒå®Ÿè¡Œã•れã¾ã™ã€‚elif ãŒã‚ã‚‹å ´åˆã¯ã€elif ã®ç›´å¾Œã®æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れã€ãã®çµ‚了ステータス㌠0 ã§ã‚ã‚‹ã‹ã©ã†ã‹åˆ¤å®šã•れã¾ã™ã€‚ãã®å¾Œã¯å…ˆç¨‹ã¨åŒæ§˜ã«æ¡ä»¶åˆ†å²ã‚’行ã„ã¾ã™ã€‚

elif …; then …; ã¯ä¸€ã¤ã® if 文内ã«è¤‡æ•°ã‚ã£ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。

If 文全体ã®çµ‚了ステータスã¯ã€å®Ÿè¡Œã•れãŸå†…容コマンドã®çµ‚了ステータスã§ã™ã€‚内容コマンドãŒå®Ÿè¡Œã•れãªã‹ã£ãŸå ´åˆ (ã©ã®æ¡ä»¶ã‚‚å½ã§ã€else ãŒãªã„å ´åˆ) 㯠0 ã§ã™ã€‚

While ãŠã‚ˆã³ until ループ

While ループ㨠until ループã¯å˜ç´”ãªãƒ«ãƒ¼ãƒ—æ§‹æ–‡ã§ã™ã€‚

While ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡

while æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; do 内容コマンド…; done

Until ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡

until æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰…; do 内容コマンド…; done

éž POSIX 準拠モードã§ã¯ æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰â€¦; ãŠã‚ˆã³ 内容コマンド…; ã¯çœç•¥å¯èƒ½ã§ã™ã€‚

While ループã®å®Ÿè¡Œã§ã¯ã¾ãšæ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ãªã‚‰ã°ã€å†…容コマンドãŒå®Ÿè¡Œã•れãŸã®ã¡ã€å†ã³æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã«æˆ»ã‚Šã¾ã™ã€‚ã“ã®ç¹°ã‚Šè¿”ã—ã¯æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ã§ãªããªã‚‹ã¾ã§ç¶šãã¾ã™ã€‚

注
æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚äº†ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ãŒæœ€åˆã‹ã‚‰ 0 ã§ãªã„ã¨ãã¯ã€å†…容コマンドã¯ä¸€åº¦ã‚‚実行ã•れã¾ã›ã‚“。

Until ループã¯ã€ãƒ«ãƒ¼ãƒ—を続行ã™ã‚‹æ¡ä»¶ãŒé€†ã«ãªã£ã¦ã„る以外㯠while ループã¨åŒã˜ã§ã™ã€‚ã™ãªã‚ã¡ã€æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ã§ãªã‘れã°å†…容コマンドãŒå®Ÿè¡Œã•れã¾ã™ã€‚

While/until ループ全体ã®çµ‚了ステータスã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸå†…容コマンドã®çµ‚了ステータスã§ã™ã€‚(内容コマンドãŒå­˜åœ¨ã—ãªã„ã‹ã€ä¸€åº¦ã‚‚実行ã•れãªã‹ã£ãŸã¨ã㯠0)

For ループ

For ãƒ«ãƒ¼ãƒ—ã¯æŒ‡å®šã•れãŸãれãžã‚Œã®å˜èªžã«ã¤ã„ã¦åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚

For ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡

for 変数å in å˜èªž…; do コマンド…; done
for 変数å do コマンド…; done

in ã®ç›´å¾Œã®å˜èªžã¯ä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“ãŒã€do ã®ç›´å‰ã® ; (ã¾ãŸã¯æ”¹è¡Œ) ã¯å¿…è¦ã§ã™ã€‚ã“れらã®å˜èªžãƒˆãƒ¼ã‚¯ãƒ³ã¯äºˆç´„語ã¨ã—ã¦ã¯èªè­˜ã•れã¾ã›ã‚“ãŒã€& ãªã©ã®è¨˜å·ã‚’å«ã‚ã‚‹ã«ã¯é©åˆ‡ãªã‚¯ã‚©ãƒ¼ãƒˆãŒå¿…è¦ã§ã™ã€‚in …; ã‚’çœç•¥ã™ã‚‹å ´åˆã¯ã€æœ¬æ¥ã¯å¤‰æ•°å㨠do ã®é–“ã« ; を入れã¦ã¯ã„ã‘ã¾ã›ã‚“ãŒã€éž POSIX 準拠モードã§ã¯ ; ãŒã‚ã£ã¦ã‚‚許容ã•れã¾ã™ã€‚ã¾ãŸéž POSIX 準拠モードã§ã¯ コマンド…; ãŒãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。

For ループã®å®Ÿè¡Œã§ã¯ã¾ãšå˜èªžãŒå˜ç´”コマンド実行時ã®å˜èªžã®å±•é–‹ã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ (in …; ãŒãªã„構文を使用ã—ã¦ã„ã‚‹å ´åˆã¯ã€in "$@"; ãŒçœç•¥ã•れã¦ã„ã‚‹ã‚‚ã®ã¨è¦‹ãªã•れã¾ã™)。続ã„ã¦ã€å±•é–‹ã§ç”Ÿæˆã•れãŸãれãžã‚Œã®å˜èªžã«ã¤ã„ã¦é †ç•ªã«ä¸€åº¦ãšã¤ä»¥ä¸‹ã®å‡¦ç†ã‚’行ã„ã¾ã™ã€‚

  1. å˜èªžã‚’変数åã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ä»£å…¥ã™ã‚‹

  2. コマンドを実行ã™ã‚‹

å˜èªžã¯ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¨ã—ã¦ä»£å…¥ã•れã¾ã™ (POSIX 準拠モードã®ã¨ãを除ã)。展開ã®çµæžœå˜èªžãŒä¸€ã¤ã‚‚生æˆã•れãªã‹ã£ãŸå ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ä¸€åˆ‡å®Ÿè¡Œã•れã¾ã›ã‚“。

For ループ全体ã®çµ‚了ステータスã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚コマンドãŒã‚ã‚‹ã®ã«ä¸€åº¦ã‚‚実行ã•れãªã‹ã£ãŸã¨ã㯠0 ã§ã™ã€‚コマンドãŒãªã„å ´åˆã€for ループã®çµ‚了ステータス㯠for ループã®ä¸€ã¤å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

Case æ–‡

Case æ–‡ã¯å˜èªžã«å¯¾ã—ã¦ãƒ‘ターンマッãƒãƒ³ã‚°ã‚’行ã„ã€ãã®çµæžœã«å¯¾å¿œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚

Case æ–‡ã®æ§‹æ–‡

case å˜èªž in caseitem… esac

Caseitem ã®æ§‹æ–‡

(パターン) コマンド…;;

case 㨠in ã®é–“ã®å˜èªžã¯ã¡ã‚‡ã†ã©ä¸€ãƒˆãƒ¼ã‚¯ãƒ³ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®å˜èªžãƒˆãƒ¼ã‚¯ãƒ³ã¯äºˆç´„語ã¨ã—ã¦ã¯èªè­˜ã•れã¾ã›ã‚“ãŒã€& ãªã©ã®è¨˜å·ã‚’å«ã‚ã‚‹ã«ã¯é©åˆ‡ãªã‚¯ã‚©ãƒ¼ãƒˆãŒå¿…è¦ã§ã™ã€‚in 㨠esac ã®é–“ã«ã¯ä»»æ„ã®å€‹æ•°ã® caseitem ã‚’ç½®ãã¾ã™ (0 個ã§ã‚‚よã„)。Caseitem ã®æœ€åˆã® ( 㨠esac ã®ç›´å‰ã® ;; ã¯çœç•¥ã§ãã¾ã™ã€‚ã¾ãŸã‚³ãƒžãƒ³ãƒ‰ãŒ ; ã§çµ‚ã‚ã‚‹å ´åˆã¯ãã® ; ã‚‚çœç•¥ã§ãã¾ã™ã€‚Caseitem ã® ) 㨠;; ã¨ã®é–“ã«ã‚³ãƒžãƒ³ãƒ‰ãŒä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。

Caseitem ã®ãƒ‘ターンã«ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã‚’指定ã—ã¾ã™ã€‚å„トークンを | ã§åŒºåˆ‡ã‚‹ã“ã¨ã§è¤‡æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’パターンã¨ã—ã¦æŒ‡å®šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚

Case æ–‡ã®å®Ÿè¡Œã§ã¯ã€ã¾ãšå˜èªžãŒå››ç¨®å±•é–‹ã•れã¾ã™ã€‚ãã®å¾Œã€å„ caseitem ã«å¯¾ã—ã¦é †ã«ä»¥ä¸‹ã®å‹•作を行ã„ã¾ã™ã€‚

  1. パターントークンをå˜èªžã¨åŒæ§˜ã«å±•é–‹ã—ã€å±•é–‹ã—ãŸãƒ‘ターンãŒå±•é–‹ã—ãŸå˜èªžã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ (パターンマッãƒãƒ³ã‚°è¨˜æ³•å‚ç…§)。パターンã¨ã—ã¦æŒ‡å®šã•れãŸãƒˆãƒ¼ã‚¯ãƒ³ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãれらå„トークンã«å¯¾ã—ã¦ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ (ã©ã‚Œã‹ã®ãƒ‘ターントークンãŒãƒžãƒƒãƒã—ãŸã‚‰ãれ以é™ã®ãƒ‘ターントークンã¯å±•é–‹ã•れã¾ã›ã‚“。Yash ã¯ãƒˆãƒ¼ã‚¯ãƒ³ãŒæ›¸ã‹ã‚Œã¦ã„る順番ã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹ã‚’調ã¹ã¾ã™ãŒã€ä»–ã®ã‚·ã‚§ãƒ«ã‚‚ã“ã®é †åºã§èª¿ã¹ã‚‹ã¨ã¯é™ã‚Šã¾ã›ã‚“)。

  2. マッãƒã—ãŸå ´åˆã¯ã€ç›´å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã€ãれã§ã“ã® case æ–‡ã®å®Ÿè¡Œã¯çµ‚了ã§ã™ã€‚マッãƒã—ãªã‹ã£ãŸå ´åˆã¯ã€æ¬¡ã® caseitem ã®å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚

Case 文全体ã®çµ‚了ステータスã¯ã€å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚コマンドãŒå®Ÿè¡Œã•れãªã‹ã£ãŸå ´åˆ (ã©ã®ãƒ‘ターンもマッãƒã—ãªã‹ã£ãŸã‹ã€caseitem ãŒä¸€ã¤ã‚‚ãªã„ã‹ã€ãƒžãƒƒãƒã—ãŸãƒ‘ターンã®å¾Œã«ã‚³ãƒžãƒ³ãƒ‰ãŒãªã„å ´åˆ) ã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚

POSIX 準拠モードã§ã¯ã€(| ã§åŒºåˆ‡ã‚‰ã‚ŒãŸæœ€åˆã®) パターントークンを esac ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

関数定義

関数定義コマンドã¯ã€é–¢æ•°ã‚’定義ã—ã¾ã™ã€‚

é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã®æ§‹æ–‡

関数å ( ) 複åˆã‚³ãƒžãƒ³ãƒ‰
function 関数å 複åˆã‚³ãƒžãƒ³ãƒ‰
function 関数å ( ) 複åˆã‚³ãƒžãƒ³ãƒ‰

予約語 function を用ã„ãªã„一ã¤ç›®ã®å½¢å¼ã§ã¯ã€é–¢æ•°åã«ã¯å¼•用符ãªã©ã®ç‰¹æ®Šãªè¨˜å·ã‚’å«ã‚ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。予約語 function を用ã„る二ã¤ç›®ã¾ãŸã¯ä¸‰ã¤ç›®ã®å½¢å¼ã§ã¯ã€é–¢æ•°åã¯å®Ÿè¡Œæ™‚ã«å››ç¨®å±•é–‹ã•れã¾ã™ã€‚(POSIX 準拠モードã§ã¯äºˆç´„語 function を用ã„ã‚‹å½¢å¼ã®é–¢æ•°å®šç¾©ã¯ä½¿ãˆã¾ã›ã‚“。)

関数定義コマンドを実行ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸé–¢æ•°åã®é–¢æ•°ãŒè¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã‚’内容ã¨ã—ã¦å®šç¾©ã•れã¾ã™ã€‚

関数定義コマンドã«å¯¾ã—ã¦ç›´æŽ¥ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚’行ã†ã“ã¨ã¯ã§ãã¾ã›ã‚“ã€‚é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã®æœ€å¾Œã«ã‚るリダイレクトã¯ã€é–¢æ•°ã®å†…容ã§ã‚る複åˆã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã™ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¨è¦‹ãªã•れã¾ã™ã€‚例ãˆã° func() { cat; } >/dev/null ã¨æ›¸ã„ãŸå ´åˆã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れるã®ã¯ func() { cat; } ã§ã¯ãªã { cat; } ã§ã™ã€‚

関数定義コマンドã®çµ‚了ステータスã¯ã€é–¢æ•°ãŒæ­£ã—ã定義ã•れãŸå ´åˆã¯ 0ã€ãã†ã§ãªã‘れã°éž 0 ã§ã™ã€‚

yash-2.35/doc/ja/_test.txt0000644000175000017500000002055312154557026015571 0ustar magicantmagicant= Test 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Test 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Test 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯å¼•æ•°ã§æŒ‡å®šã—ãŸå†…容ã®åˆ¤å®šã‚’行ã„ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +test {{判定å¼}}+ - +[ {{判定å¼}} ]+ Test コマンドã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã‚’区別ã—ã¾ã›ã‚“。コマンドライン引数ã¯å…¨ã¦{{判定å¼}}ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚コマンド㌠+[+ ã®åå‰ã§å®Ÿè¡Œã•ã‚ŒãŸæ™‚ã¯ã€åˆ¤å®šå¼ã®å¾Œã« +]+ ãŒå¿…è¦ã§ã™ã€‚ [[description]] == 説明 Test コマンドã¯å¼•æ•°ã§ä¸Žãˆã‚‰ã‚ŒãŸ{{判定å¼}}を評価ã—ã€çµæžœãŒçœŸãªã‚‰ã° 0 ã®çµ‚了ステータスをã€å½ãªã‚‰ã° 1 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚判定å¼ã¯ä½•種類ã‹ã®æ¼”ç®—å­ã¨ãれã«å¯¾ã™ã‚‹è¢«æ¼”ç®—å­ã¨ã‹ã‚‰ãªã‚Šã¾ã™ã€‚ ファイルã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚指定ã—ãŸãƒ•ァイルãŒã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã®å ´åˆã€ãã®ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ãŒæŒ‡ã—ã¦ã„ã‚‹å…ˆã®ãƒ•ァイルã«ã¤ã„ã¦åˆ¤å®šã‚’行ã„ã¾ã™ (+-h+, +-L+ 演算å­ã‚’除ã)。 +-b {{ファイル}}+:: {{ファイル}}ãŒãƒ–ロックスペシャルファイルã‹ã©ã†ã‹ +-c {{ファイル}}+:: {{ファイル}}ãŒã‚­ãƒ£ãƒ©ã‚¯ã‚¿ã‚¹ãƒšã‚·ãƒ£ãƒ«ãƒ•ァイルã‹ã©ã†ã‹ +-d {{ファイル}}+:: {{ファイル}}ãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã©ã†ã‹ +-e {{ファイル}}+:: {{ファイル}}ãŒå­˜åœ¨ã™ã‚‹ã‹ã©ã†ã‹ +-f {{ファイル}}+:: {{ファイル}}ãŒé€šå¸¸ã®ãƒ•ァイルã‹ã©ã†ã‹ +-G {{ファイル}}+:: {{ファイル}}ã®ã‚°ãƒ«ãƒ¼ãƒ— ID ãŒã‚·ã‚§ãƒ«ã®å®ŸåŠ¹ã‚°ãƒ«ãƒ¼ãƒ— ID ã«ç­‰ã—ã„ã‹ã©ã†ã‹ +-g {{ファイル}}+:: {{ファイル}}ã® set-group-ID ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ +-h {{ファイル}}+:: +-L {{ファイル}}+ ã«åŒã˜ +-k {{ファイル}}+:: {{ファイル}}ã® sticky ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ +-L {{ファイル}}+:: {{ファイル}}ãŒã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‹ã©ã†ã‹ +-N {{ファイル}}+:: {{ファイル}}ã®æœ€çµ‚å¤‰æ›´æ—¥æ™‚ãŒæœ€çµ‚アクセス日時より後ã‹ã©ã†ã‹ +-O {{ファイル}}+:: {{ファイル}}ã®ãƒ¦ãƒ¼ã‚¶ ID ãŒã‚·ã‚§ãƒ«ã®å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ã«ç­‰ã—ã„ã‹ã©ã†ã‹ +-p {{ファイル}}+:: {{ファイル}}㌠FIFO (åå‰ä»˜ãパイプ) ã‹ã©ã†ã‹ +-r {{ファイル}}+:: {{ファイル}}ãŒèª­ã¿è¾¼ã¿å¯èƒ½ã‹ã©ã†ã‹ +-S {{ファイル}}+:: {{ファイル}}ãŒã‚½ã‚±ãƒƒãƒˆã‹ã©ã†ã‹ +-s {{ファイル}}+:: {{ファイル}}サイズãŒç©ºã§ãªã„ã‹ã©ã†ã‹ +-u {{ファイル}}+:: {{ファイル}}ã® set-user-ID ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ +-w {{ファイル}}+:: {{ファイル}}ãŒæ›¸ãè¾¼ã¿å¯èƒ½ã‹ã©ã†ã‹ +-x {{ファイル}}+:: {{ファイル}}ãŒå®Ÿè¡Œå¯èƒ½ã‹ã©ã†ã‹ ファイル記述å­ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +-t {{ファイル記述å­}}+:: {{ファイル記述å­}}ãŒç«¯æœ«ã‹ã©ã†ã‹ (ファイル記述å­ã¯ 0 以上ã®è‡ªç„¶æ•°ã§æŒ‡å®šã—ã¾ã™) 文字列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +-n {{文字列}}+:: 文字列ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹ +-z {{文字列}}+:: 文字列ãŒç©ºæ–‡å­—列ã‹ã©ã†ã‹ link:_set.html[シェルã®ã‚ªãƒ—ション]ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +-o ?{{オプション}}+:: {{オプション}}ãŒæ­£ã—ã„オプションåã§ã‚ã‚‹ã‹ã©ã†ã‹ +-o {{オプション}}+:: {{オプション}}ãŒæ­£ã—ã„オプションåã§ã‚りã€ã‹ã¤ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйã«è¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ ファイルã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ (存在ã—ãªã„ファイルã¯ä»–ã®ãƒ•ァイルよりå¤ã„ã¨ã¿ãªã—ã¾ã™)。 +{{ファイル1}} -nt {{ファイル2}}+:: {{ファイル1}}ã®æ›´æ–°æ™‚刻ãŒ{{ファイル2}}より新ã—ã„ã‹ã©ã†ã‹ +{{ファイル1}} -ot {{ファイル2}}+:: {{ファイル1}}ã®æ›´æ–°æ™‚刻ãŒ{{ファイル2}}よりå¤ã„ã‹ã©ã†ã‹ +{{ファイル1}} -ef {{ファイル2}}+:: 二ã¤ã®ãƒ•ァイルãŒäº’ã„ã®ãƒãƒ¼ãƒ‰ãƒªãƒ³ã‚¯ã§ã‚ã‚‹ã‹ã©ã†ã‹ 文字列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +{{文字列1}} = {{文字列2}}+:: 二ã¤ã®æ–‡å­—列ãŒåŒã˜ã‹ã©ã†ã‹ +{{文字列1}} != {{文字列2}}+:: 二ã¤ã®æ–‡å­—列ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ 以下ã®äºŒé …演算å­ã¯ç¾åœ¨ã®ãƒ­ã‚±ãƒ¼ãƒ«ã®è¾žæ›¸å¼é †åºã«å¾“ã£ã¦æ–‡å­—列を比較ã—ã¾ã™ã€‚ +{{文字列1}} === {{文字列2}}+:: 二ã¤ã®æ–‡å­—列ãŒåŒã˜ã‹ã©ã†ã‹ +{{文字列1}} !== {{文字列2}}+:: 二ã¤ã®æ–‡å­—列ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ +{{文字列1}} < {{文字列2}}+:: {{文字列1}} ㌠{{文字列2}} よりも順åºãŒæ‰‹å‰ã‹ã©ã†ã‹ +{{文字列1}} <= {{文字列2}}+:: {{文字列1}} ㌠{{文字列2}} よりも順åºãŒæ‰‹å‰ã¾ãŸã¯åŒã˜ã‹ã©ã†ã‹ +{{文字列1}} > {{文字列2}}+:: {{文字列1}} ㌠{{文字列2}} よりも順åºãŒå¾Œã‹ã©ã†ã‹ +{{文字列1}} >= {{文字列2}}+:: {{文字列1}} ㌠{{文字列2}} よりも順åºãŒå¾Œã¾ãŸã¯åŒã˜ã‹ã©ã†ã‹ パターンマッãƒãƒ³ã‚°ã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +{{文字列}} =~ {{パターン}}+:: 拡張正è¦è¡¨ç¾{{パターン}}ãŒ{{文字列}}ã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹ æ•´æ•°ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +{{v1}} -eq {{v2}}+:: {{v1}} 㨠{{v2}} ãŒç­‰ã—ã„ã‹ã©ã†ã‹ +{{v1}} -ne {{v2}}+:: {{v1}} 㨠{{v2}} ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ +{{v1}} -gt {{v2}}+:: {{v1}} ㌠{{v2}} よりも大ãã„ã‹ã©ã†ã‹ +{{v1}} -ge {{v2}}+:: {{v1}} ㌠{{v2}} 以上ã‹ã©ã†ã‹ +{{v1}} -lt {{v2}}+:: {{v1}} ㌠{{v2}} よりもå°ã•ã„ã‹ã©ã†ã‹ +{{v1}} -le {{v2}}+:: {{v1}} ㌠{{v2}} 以下ã‹ã©ã†ã‹ ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã‚’è¡¨ã™æ–‡å­—列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚文字列ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã¨ã—ã¦ã®æ¯”較ã®ã—ã‹ãŸã¯å¾Œè¿°ã—ã¾ã™ã€‚ +{{v1}} -veq {{v2}}+:: {{v1}} 㨠{{v2}} ãŒç­‰ã—ã„ã‹ã©ã†ã‹ +{{v1}} -vne {{v2}}+:: {{v1}} 㨠{{v2}} ãŒç•°ãªã‚‹ã‹ã©ã†ã‹ +{{v1}} -vgt {{v2}}+:: {{v1}} ㌠{{v2}} よりも大ãã„ã‹ã©ã†ã‹ +{{v1}} -vge {{v2}}+:: {{v1}} ㌠{{v2}} 以上ã‹ã©ã†ã‹ +{{v1}} -vlt {{v2}}+:: {{v1}} ㌠{{v2}} よりもå°ã•ã„ã‹ã©ã†ã‹ +{{v1}} -vle {{v2}}+:: {{v1}} ㌠{{v2}} 以下ã‹ã©ã†ã‹ ä»–ã®åˆ¤å®šå¼ã‚’組ã¿åˆã‚ã›ã¦ã‚ˆã‚Šè¤‡é›‘ãªåˆ¤å®šå¼ã‚’作る演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ +! {{判定å¼}}+:: {{判定å¼}}ãŒå½ã‹ã©ã†ã‹ (判定å¼ã®çœŸå½ã‚’逆転ã—ã¾ã™) +( {{判定å¼}} )+:: {{判定å¼}}ãŒçœŸã‹ã©ã†ã‹ (判定å¼ã®æ§‹æ–‡ä¸Šã®å„ªå…ˆé †ä½ã‚’高ãã—ã¾ã™) +{{判定å¼1}} -a {{判定å¼2}}+:: 二ã¤ã®åˆ¤å®šå¼ãŒä¸¡æ–¹ã¨ã‚‚真ã‹ã©ã†ã‹ +{{判定å¼1}} -o {{判定å¼2}}+:: 二ã¤ã®åˆ¤å®šå¼ã®å°‘ãªãã¨ã‚‚片方ãŒçœŸã‹ã©ã†ã‹ 判定å¼ãŒç©ºã®å ´åˆã€çµæžœã¯å½ã¨ã¿ãªã—ã¾ã™ã€‚判定å¼ãŒ (演算å­ã®ä»˜ã„ã¦ã„ãªã„) 文字列一ã¤ã®å ´åˆã€ãã®æ–‡å­—列ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹ã‚’判定ã—ã¾ã™ã€‚ [[version-compare]] === ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã®æ¯”較 文字列ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã¨ã—ã¦ã®æ¯”較ã¯ã€åŸºæœ¬çš„ã«ã¯ç¾åœ¨ã®ãƒ­ã‚±ãƒ¼ãƒ«æƒ…å ±ã«å¾“ã£ãŸè¾žæ›¸å¼é †åºã§è¡Œã„ã¾ã™ã€‚ãŸã ã—ã€é€£ç¶šã™ã‚‹æ•°å­—ã¯ä¸€ã¤ã®è‡ªç„¶æ•°ã¨ã—ã¦æ¯”較ã—ã¾ã™ã€‚ã¾ãŸæ•°å­—ã¨ãã‚Œä»¥å¤–ã®æ–‡å­—ã¨ã®æ¯”較ã§ã¯å¸¸ã«æ•°å­—ã®æ–¹ãŒå¤§ãã„ã¨ã¿ãªã—ã¾ã™ã€‚ 例ãˆã°ã€+0.1.2-3+ 㨠+00.001.02-3+ ã¯ç­‰ã—ãã€+0.2.1+ 㨠+0.10.0+ ã¨ã§ã¯å¾Œè€…ã®æ–¹ãŒå¤§ãã„ã¨åˆ¤å®šã•れã¾ã™ã€‚ [[exitstatus]] == 終了ステータス Test コマンドã®çµ‚了ステータスã¯ã€{{判定å¼}}ã®è©•ä¾¡çµæžœãŒçœŸãªã‚‰ã° 0ã€å½ãªã‚‰ã° 1 ã§ã™ã€‚{{判定å¼}}ã®æ§‹æ–‡ã«èª¤ã‚ŠãŒã‚ã‚‹å ´åˆãã®ä»–ã®ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸã¨ãã¯ã€çµ‚了ステータス㯠2 ã§ã™ã€‚ [[notes]] == 補足 複雑ãªåˆ¤å®šå¼ã¯èª¤ã£ã¦è§£é‡ˆã•れるã“ã¨ãŒã‚ã‚‹ã®ã§é¿ã‘ã‚‹ã“ã¨ã‚’ãŠå‹§ã‚ã—ã¾ã™ã€‚例ãˆã° +[ 1 -eq 1 -a -t = 1 -a ! foo ]+ 㯠+[ 1 -eq 1 ] && [ -t = 1 ] && ! [ foo ]+ ã®ã‚ˆã†ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’分ã‘ã‚‹ã¨å¼ãŒã‚ˆã‚Šæ˜Žç¢ºã«ãªã‚Šã¾ã™ã€‚ POSIX ã¯ã€ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã®çµ‚了ステータスを ``2 以上'' ã¨å®šã‚ã¦ã„ã¾ã™ã€‚ã¾ãŸ POSIX ã«ã¯ä»¥ä¸‹ã®æ¼”ç®—å­ã®è¦å®šã¯ã‚りã¾ã›ã‚“: +-nt+, +-ot+, +-ef+, +==+, +===+, +!==+, +<+, +<=+, +>+, +>=+, +=~+, +-veq+, +-vne+, +-vgt+, +-vge+, +-vlt+, ++-vle++。 POSIX ã« +-o+ ã®å˜é …演算å­ã¨ã—ã¦ã®è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_break.txt0000644000175000017500000000370112154557026015672 0ustar magicantmagicant= Break 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Break 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Break 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯å®Ÿè¡Œä¸­ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +break [{{æ·±ã•}}]+ - +break -i+ [[description]] == 説明 +-i+ (+--iteration+) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€break コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã® link:syntax.html#for[for ループ]ã¾ãŸã¯ link:syntax.html#while-until[while ループ]ã¾ãŸã¯ link:syntax.html#while-until[until ループ]を中断ã—ã¾ã™ã€‚多é‡ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§å®Ÿè¡Œã—ãŸå ´åˆã€å†…å´ã‹ã‚‰æ•°ãˆã¦{{æ·±ã•}}番目ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚{{æ·±ã•}}ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æœ€ã‚‚内å´ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ ({{æ·±ã•}} = 1)。指定ã•れãŸ{{æ·±ã•}}ãŒå®Ÿéš›ã«å®Ÿè¡Œã—ã¦ã„る多é‡ãƒ«ãƒ¼ãƒ—ã®æ·±ã•より大ãã„å ´åˆã¯æœ€ã‚‚外å´ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚ +-i+ (+--iteration+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€break コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®link:_eval.html#iter[å復実行]を中断ã—ã¾ã™ã€‚ [[options]] == オプション +-i+:: +--iteration+:: ループã§ã¯ãªãå復実行を中断ã—ã¾ã™ã€‚ [[operands]] == オペランド {{nest}}:: 内å´ã‹ã‚‰ä½•番目ã®ãƒ«ãƒ¼ãƒ—を中断ã™ã‚‹ã®ã‹ã‚’指定ã™ã‚‹ 1 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ [[exitstatus]] == 終了ステータス ループã®ä¸­æ–­ã«æˆåŠŸã™ã‚‹ã¨çµ‚了ステータス㯠0 ã§ã™ã€‚å復実行ã®ä¸­æ–­ã«æˆåŠŸã™ã‚‹ã¨ break コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠break コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ [[notes]] == 補足 Break コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ +-i+ (+--interact+) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_test.html0000644000175000017500000003602212154557026015714 0ustar magicantmagicant Test 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Test 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¼•æ•°ã§æŒ‡å®šã—ãŸå†…容ã®åˆ¤å®šã‚’行ã„ã¾ã™ã€‚

æ§‹æ–‡

  • test 判定å¼

  • [ åˆ¤å®šå¼ ]

Test コマンドã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã‚’区別ã—ã¾ã›ã‚“。コマンドライン引数ã¯å…¨ã¦åˆ¤å®šå¼ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚コマンド㌠[ ã®åå‰ã§å®Ÿè¡Œã•ã‚ŒãŸæ™‚ã¯ã€åˆ¤å®šå¼ã®å¾Œã« ] ãŒå¿…è¦ã§ã™ã€‚

説明

Test コマンドã¯å¼•æ•°ã§ä¸Žãˆã‚‰ã‚ŒãŸåˆ¤å®šå¼ã‚’評価ã—ã€çµæžœãŒçœŸãªã‚‰ã° 0 ã®çµ‚了ステータスをã€å½ãªã‚‰ã° 1 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚判定å¼ã¯ä½•種類ã‹ã®æ¼”ç®—å­ã¨ãれã«å¯¾ã™ã‚‹è¢«æ¼”ç®—å­ã¨ã‹ã‚‰ãªã‚Šã¾ã™ã€‚

ファイルã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚指定ã—ãŸãƒ•ァイルãŒã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã®å ´åˆã€ãã®ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ãŒæŒ‡ã—ã¦ã„ã‚‹å…ˆã®ãƒ•ァイルã«ã¤ã„ã¦åˆ¤å®šã‚’行ã„ã¾ã™ (-h, -L 演算å­ã‚’除ã)。

-b ファイル

ファイルãŒãƒ–ロックスペシャルファイルã‹ã©ã†ã‹

-c ファイル

ファイルãŒã‚­ãƒ£ãƒ©ã‚¯ã‚¿ã‚¹ãƒšã‚·ãƒ£ãƒ«ãƒ•ァイルã‹ã©ã†ã‹

-d ファイル

ファイルãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã©ã†ã‹

-e ファイル

ファイルãŒå­˜åœ¨ã™ã‚‹ã‹ã©ã†ã‹

-f ファイル

ファイルãŒé€šå¸¸ã®ãƒ•ァイルã‹ã©ã†ã‹

-G ファイル

ファイルã®ã‚°ãƒ«ãƒ¼ãƒ— ID ãŒã‚·ã‚§ãƒ«ã®å®ŸåŠ¹ã‚°ãƒ«ãƒ¼ãƒ— ID ã«ç­‰ã—ã„ã‹ã©ã†ã‹

-g ファイル

ファイル㮠set-group-ID ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹

-h ファイル

-L ファイル ã«åŒã˜

-k ファイル

ファイル㮠sticky ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹

-L ファイル

ファイルãŒã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‹ã©ã†ã‹

-N ファイル

ãƒ•ã‚¡ã‚¤ãƒ«ã®æœ€çµ‚å¤‰æ›´æ—¥æ™‚ãŒæœ€çµ‚アクセス日時より後ã‹ã©ã†ã‹

-O ファイル

ファイルã®ãƒ¦ãƒ¼ã‚¶ ID ãŒã‚·ã‚§ãƒ«ã®å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ã«ç­‰ã—ã„ã‹ã©ã†ã‹

-p ファイル

ファイル㌠FIFO (åå‰ä»˜ãパイプ) ã‹ã©ã†ã‹

-r ファイル

ファイルãŒèª­ã¿è¾¼ã¿å¯èƒ½ã‹ã©ã†ã‹

-S ファイル

ファイルãŒã‚½ã‚±ãƒƒãƒˆã‹ã©ã†ã‹

-s ファイル

ファイルサイズãŒç©ºã§ãªã„ã‹ã©ã†ã‹

-u ファイル

ファイル㮠set-user-ID ビットãŒè¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹

-w ファイル

ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ›¸ãè¾¼ã¿å¯èƒ½ã‹ã©ã†ã‹

-x ファイル

ファイルãŒå®Ÿè¡Œå¯èƒ½ã‹ã©ã†ã‹

ファイル記述å­ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

-t ファイル記述å­

ファイル記述å­ãŒç«¯æœ«ã‹ã©ã†ã‹ (ファイル記述å­ã¯ 0 以上ã®è‡ªç„¶æ•°ã§æŒ‡å®šã—ã¾ã™)

文字列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

-n 文字列

文字列ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹

-z 文字列

文字列ãŒç©ºæ–‡å­—列ã‹ã©ã†ã‹

シェルã®ã‚ªãƒ—ションã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†å˜é …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

-o ?オプション

ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæ­£ã—ã„オプションåã§ã‚ã‚‹ã‹ã©ã†ã‹

-o オプション

ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæ­£ã—ã„オプションåã§ã‚りã€ã‹ã¤ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйã«è¨­å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹

ファイルã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ (存在ã—ãªã„ファイルã¯ä»–ã®ãƒ•ァイルよりå¤ã„ã¨ã¿ãªã—ã¾ã™)。

ファイル1 -nt ファイル2

ファイル1ã®æ›´æ–°æ™‚刻ãŒãƒ•ァイル2より新ã—ã„ã‹ã©ã†ã‹

ファイル1 -ot ファイル2

ファイル1ã®æ›´æ–°æ™‚刻ãŒãƒ•ァイル2よりå¤ã„ã‹ã©ã†ã‹

ファイル1 -ef ファイル2

二ã¤ã®ãƒ•ァイルãŒäº’ã„ã®ãƒãƒ¼ãƒ‰ãƒªãƒ³ã‚¯ã§ã‚ã‚‹ã‹ã©ã†ã‹

文字列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

文字列1 = 文字列2

二ã¤ã®æ–‡å­—列ãŒåŒã˜ã‹ã©ã†ã‹

文字列1 != 文字列2

二ã¤ã®æ–‡å­—列ãŒç•°ãªã‚‹ã‹ã©ã†ã‹

以下ã®äºŒé …演算å­ã¯ç¾åœ¨ã®ãƒ­ã‚±ãƒ¼ãƒ«ã®è¾žæ›¸å¼é †åºã«å¾“ã£ã¦æ–‡å­—列を比較ã—ã¾ã™ã€‚

文字列1 === 文字列2

二ã¤ã®æ–‡å­—列ãŒåŒã˜ã‹ã©ã†ã‹

文字列1 !== 文字列2

二ã¤ã®æ–‡å­—列ãŒç•°ãªã‚‹ã‹ã©ã†ã‹

文字列1 < 文字列2

文字列1 ㌠文字列2 よりも順åºãŒæ‰‹å‰ã‹ã©ã†ã‹

文字列1 <= 文字列2

文字列1 ㌠文字列2 よりも順åºãŒæ‰‹å‰ã¾ãŸã¯åŒã˜ã‹ã©ã†ã‹

文字列1 > 文字列2

文字列1 ㌠文字列2 よりも順åºãŒå¾Œã‹ã©ã†ã‹

文字列1 >= 文字列2

文字列1 ㌠文字列2 よりも順åºãŒå¾Œã¾ãŸã¯åŒã˜ã‹ã©ã†ã‹

パターンマッãƒãƒ³ã‚°ã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

文字列 =~ パターン

拡張正è¦è¡¨ç¾ãƒ‘ã‚¿ãƒ¼ãƒ³ãŒæ–‡å­—列ã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹

æ•´æ•°ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

v1 -eq v2

v1 㨠v2 ãŒç­‰ã—ã„ã‹ã©ã†ã‹

v1 -ne v2

v1 㨠v2 ãŒç•°ãªã‚‹ã‹ã©ã†ã‹

v1 -gt v2

v1 ㌠v2 よりも大ãã„ã‹ã©ã†ã‹

v1 -ge v2

v1 ㌠v2 以上ã‹ã©ã†ã‹

v1 -lt v2

v1 ㌠v2 よりもå°ã•ã„ã‹ã©ã†ã‹

v1 -le v2

v1 ㌠v2 以下ã‹ã©ã†ã‹

ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã‚’è¡¨ã™æ–‡å­—列ã«é–¢ã™ã‚‹åˆ¤å®šã‚’行ã†äºŒé …演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚文字列ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã¨ã—ã¦ã®æ¯”較ã®ã—ã‹ãŸã¯å¾Œè¿°ã—ã¾ã™ã€‚

v1 -veq v2

v1 㨠v2 ãŒç­‰ã—ã„ã‹ã©ã†ã‹

v1 -vne v2

v1 㨠v2 ãŒç•°ãªã‚‹ã‹ã©ã†ã‹

v1 -vgt v2

v1 ㌠v2 よりも大ãã„ã‹ã©ã†ã‹

v1 -vge v2

v1 ㌠v2 以上ã‹ã©ã†ã‹

v1 -vlt v2

v1 ㌠v2 よりもå°ã•ã„ã‹ã©ã†ã‹

v1 -vle v2

v1 ㌠v2 以下ã‹ã©ã†ã‹

ä»–ã®åˆ¤å®šå¼ã‚’組ã¿åˆã‚ã›ã¦ã‚ˆã‚Šè¤‡é›‘ãªåˆ¤å®šå¼ã‚’作る演算å­ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

! 判定å¼

判定å¼ãŒå½ã‹ã©ã†ã‹ (判定å¼ã®çœŸå½ã‚’逆転ã—ã¾ã™)

( åˆ¤å®šå¼ )

判定å¼ãŒçœŸã‹ã©ã†ã‹ (判定å¼ã®æ§‹æ–‡ä¸Šã®å„ªå…ˆé †ä½ã‚’高ãã—ã¾ã™)

判定å¼1 -a 判定å¼2

二ã¤ã®åˆ¤å®šå¼ãŒä¸¡æ–¹ã¨ã‚‚真ã‹ã©ã†ã‹

判定å¼1 -o 判定å¼2

二ã¤ã®åˆ¤å®šå¼ã®å°‘ãªãã¨ã‚‚片方ãŒçœŸã‹ã©ã†ã‹

判定å¼ãŒç©ºã®å ´åˆã€çµæžœã¯å½ã¨ã¿ãªã—ã¾ã™ã€‚判定å¼ãŒ (演算å­ã®ä»˜ã„ã¦ã„ãªã„) 文字列一ã¤ã®å ´åˆã€ãã®æ–‡å­—列ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹ã‚’判定ã—ã¾ã™ã€‚

ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã®æ¯”較

文字列ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã¨ã—ã¦ã®æ¯”較ã¯ã€åŸºæœ¬çš„ã«ã¯ç¾åœ¨ã®ãƒ­ã‚±ãƒ¼ãƒ«æƒ…å ±ã«å¾“ã£ãŸè¾žæ›¸å¼é †åºã§è¡Œã„ã¾ã™ã€‚ãŸã ã—ã€é€£ç¶šã™ã‚‹æ•°å­—ã¯ä¸€ã¤ã®è‡ªç„¶æ•°ã¨ã—ã¦æ¯”較ã—ã¾ã™ã€‚ã¾ãŸæ•°å­—ã¨ãã‚Œä»¥å¤–ã®æ–‡å­—ã¨ã®æ¯”較ã§ã¯å¸¸ã«æ•°å­—ã®æ–¹ãŒå¤§ãã„ã¨ã¿ãªã—ã¾ã™ã€‚

例ãˆã°ã€0.1.2-3 㨠00.001.02-3 ã¯ç­‰ã—ãã€0.2.1 㨠0.10.0 ã¨ã§ã¯å¾Œè€…ã®æ–¹ãŒå¤§ãã„ã¨åˆ¤å®šã•れã¾ã™ã€‚

終了ステータス

Test コマンドã®çµ‚了ステータスã¯ã€åˆ¤å®šå¼ã®è©•ä¾¡çµæžœãŒçœŸãªã‚‰ã° 0ã€å½ãªã‚‰ã° 1 ã§ã™ã€‚判定å¼ã®æ§‹æ–‡ã«èª¤ã‚ŠãŒã‚ã‚‹å ´åˆãã®ä»–ã®ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸã¨ãã¯ã€çµ‚了ステータス㯠2 ã§ã™ã€‚

補足

複雑ãªåˆ¤å®šå¼ã¯èª¤ã£ã¦è§£é‡ˆã•れるã“ã¨ãŒã‚ã‚‹ã®ã§é¿ã‘ã‚‹ã“ã¨ã‚’ãŠå‹§ã‚ã—ã¾ã™ã€‚例ãˆã° [ 1 -eq 1 -a -t = 1 -a ! foo ] 㯠[ 1 -eq 1 ] && [ -t = 1 ] && ! [ foo ] ã®ã‚ˆã†ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’分ã‘ã‚‹ã¨å¼ãŒã‚ˆã‚Šæ˜Žç¢ºã«ãªã‚Šã¾ã™ã€‚

POSIX ã¯ã€ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã®çµ‚了ステータスを 『2 以上〠ã¨å®šã‚ã¦ã„ã¾ã™ã€‚ã¾ãŸ POSIX ã«ã¯ä»¥ä¸‹ã®æ¼”ç®—å­ã®è¦å®šã¯ã‚りã¾ã›ã‚“: -nt, -ot, -ef, ==, ===, !==, <, <=, >, >=, =~, -veq, -vne, -vgt, -vge, -vlt, -vle。 POSIX ã« -o ã®å˜é …演算å­ã¨ã—ã¦ã®è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/_wait.txt0000644000175000017500000000531112154557026015551 0ustar magicantmagicant= Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã®link:job.html[ジョブ]ãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã¡ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +wait [{{ジョブ}}...]+ [[description]] == 説明 Wait コマンドã¯å®Ÿè¡Œä¸­ã®ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã¡ã¾ã™ã€‚link:job.html[ジョブ制御]ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãも終了ã—ãŸã¨ã¿ãªã—ã¾ã™ã€‚ Wait コマンドã¯ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйã§ãªã„ã¨ãã§ã‚‚link:syntax.html#async[éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰]ã®çµ‚了を待ã¤ã®ã«ä½¿ãˆã¾ã™ã€‚ Wait コマンドã®å®Ÿè¡Œä¸­ã«ã‚·ã‚§ãƒ«ãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸå ´åˆã€ãã®ã‚·ã‚°ãƒŠãƒ«ã«å¯¾ã—link:_trap.html[トラップ]ãŒè¨­å®šã—ã¦ã‚れã°ãã®ãƒˆãƒ©ãƒƒãƒ—ã‚’ç›´ã¡ã«å®Ÿè¡Œã— wait コマンドã¯ãã®ã¾ã¾çµ‚了ã—ã¾ã™ã€‚ã¾ãŸã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйãªå ´åˆã€ã‚·ã‚§ãƒ«ãŒ SIGINT シグナルをå—ä¿¡ã™ã‚‹ã¨ wait コマンドã¯ä¸­æ–­ã•れã¾ã™ã€‚ [[operands]] == オペランド {{ジョブ}}:: 終了を待ã¤ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®link:job.html#jobid[ジョブ ID] ã¾ãŸã¯ãƒ—ロセス ID ã§ã™ã€‚ {{ジョブ}}を何も指定ã—ãªã„ã¨ã‚·ã‚§ãƒ«ãŒæœ‰ã™ã‚‹å…¨ã¦ã®ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を待ã¡ã¾ã™ã€‚ 存在ã—ãªã„ジョブ・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã™ã‚‹ã¨ã€çµ‚了ステータス 127 ã§æ—¢ã«çµ‚了ã—ãŸã‚¸ãƒ§ãƒ–ã‚’ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã€ã‚¨ãƒ©ãƒ¼ã«ã¯ã—ã¾ã›ã‚“。 [[exitstatus]] == 終了ステータス {{ジョブ}}ãŒä¸€ã¤ã‚‚与ãˆã‚‰ã‚Œã¦ãŠã‚‰ãšã€ã‚·ã‚§ãƒ«ãŒå…¨ã¦ã®ã‚¸ãƒ§ãƒ–・éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了を正ã—ãå¾…ã¤ã“ã¨ãŒã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚{{ジョブ}}ãŒä¸€ã¤ä»¥ä¸Šä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€æœ€å¾Œã®{{ジョブ}}ã®çµ‚了ステータス㌠wait コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ Wait コマンドãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸå ´åˆã€çµ‚了ステータスã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã‚’表㙠128 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚ãã®ä»–ã®ç†ç”±ã§ wait コマンドãŒã‚¸ãƒ§ãƒ–ã®çµ‚了を正ã—ãå¾…ã¤ã“ã¨ãŒã§ããªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠1 以上 126 以下ã§ã™ã€‚ [[notes]] == 補足 Wait コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã¯éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸç›´å¾Œã«link:params.html#special[特殊パラメータ +!+] ã®å€¤ã‚’見るã“ã¨ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйãªã¨ã㯠link:_jobs.html[jobs コマンド]ã§ãƒ—ロセス ID を調ã¹ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_history.txt0000644000175000017500000000526012154557026016311 0ustar magicantmagicant= History 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - History 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[History 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:interact.html#history[コマンド履歴]を編集ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +history [-cF] [-d {{é …ç›®}}] [-s {{コマンド}}] [-r {{ファイル}}] [-w {{ファイル}}] [{{個数}}]+ [[description]] == 説明 History コマンドã¯link:interact.html#history[コマンド履歴]ã®å†…容を編集・表示ã—ã¾ã™ã€‚ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã—ã¦ã‚ã‚‹å ´åˆã€history コマンドã¯ãã®ã‚ªãƒ—ションã«å¾“ã£ã¦ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容を編集ã—ã¾ã™ã€‚複数ã®ã‚ªãƒ—ションãŒã‚ã‚‹å ´åˆã¯æŒ‡å®šã—ãŸé †ã«å‡¦ç†ã—ã¾ã™ã€‚ オペランドã§{{個数}}ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã€history コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容をãã®å€‹æ•°ã ã‘標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚出力ã®å½¢å¼ã¯ link:_fc.html[fc コマンド]ã«æº–ã˜ã¾ã™ã€‚ オプションもオペランドも与ãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€history コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…å®¹ã‚’å…¨ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ [[options]] == オプション +-c+:: +--clear+:: コマンド履歴をã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚ +-d {{é …ç›®}}+:: +--delete={{é …ç›®}}+:: 指定ã—ãŸ{{é …ç›®}}をコマンド履歴ã‹ã‚‰å‰Šé™¤ã—ã¾ã™ã€‚{{é …ç›®}}ã®æŒ‡å®šã®ä»•方㯠link:_fc.html#operands[fc コマンドã®{{始点}}・{{終点}}]オペランドã¨åŒã˜ã§ã™ã€‚ +-F+:: +--flush-file+:: å±¥æ­´ãƒ•ã‚¡ã‚¤ãƒ«ã‚’å†æ§‹ç¯‰ã—ã¾ã™ã€‚ +-r {{ファイル}}+:: +--read={{ファイル}}+:: 指定ã—ãŸ{{ファイル}}ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã¿å±¥æ­´ã«è¿½åŠ ã—ã¾ã™ã€‚ファイルã®å†…容ã¯å˜ãªã‚‹ãƒ†ã‚­ã‚¹ãƒˆãƒ•ァイルã¨ã—ã¦è§£é‡ˆã•れã€ãれãžã‚Œã®è¡Œã®å†…容ãŒä¸€ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è¿½åŠ ã•れã¾ã™ã€‚ +-s {{コマンド}}+:: +--set={{コマンド}}+:: ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®æœ€å¾Œã®é …目を削除ã—ã€ä»£ã‚ã‚Šã«æŒ‡å®šã—ãŸ{{コマンド}}を追加ã—ã¾ã™ã€‚ +-w {{ファイル}}+:: +--write={{ファイル}}+:: 指定ã—ãŸ{{ファイル}}ã«ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…å®¹ã‚’å…¨ã¦æ›¸ã出ã—ã¾ã™ã€‚æ—¢ã«ã‚るファイルã®å†…å®¹ã¯æ¶ˆåŽ»ã—ã¾ã™ã€‚履歴ã¯å˜ãªã‚‹ãƒ†ã‚­ã‚¹ãƒˆã¨ã—ã¦ä¸€è¡Œãšã¤æ›¸ã出ã—ã¾ã™ã€‚ [[operands]] == オペランド {{個数}}:: 表示ã™ã‚‹å±¥æ­´ã®å€‹æ•°ã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š history コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ history コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 link:lineedit.html[行編集]ã®å‹•作中ã¯å±¥æ­´ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_disown.txt0000644000175000017500000000224012154557026016106 0ustar magicantmagicant= Disown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Disown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Disown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +disown [-a] [{{ジョブ}}...}+ [[description]] == 説明 Disown コマンドã¯ã‚·ã‚§ãƒ«ãŒç®¡ç†ã—ã¦ã„るジョブを削除ã—ã¾ã™ã€‚削除ã—ãŸã‚¸ãƒ§ãƒ–ã¯link:job.html[ジョブ制御]ã®å¯¾è±¡ã‹ã‚‰å¤–れã¾ã™ãŒã€ã‚¸ãƒ§ãƒ–ã‚’æ§‹æˆã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã¯ç¶™ç¶šã—ã¾ã™ã€‚ [[options]] == オプション +-a+:: +--all+:: å…¨ã¦ã®ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚ [[operands]] == オペランド {{ジョブ}}:: 削除ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®link:job.html#jobid[ジョブ ID]。 + 複数指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚éž link:posix.html[POSIX 準拠モード]ã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® +%+ ã¯çœç•¥ã§ãã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š disown コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ disown コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/yash.txt0000644000175000017500000000327412154557026015420 0ustar magicantmagicant= YASH(1) 裕貴 渡邊 v{yashversion}, :encoding: UTF-8 :lang: ja == åå‰ yash - POSIX 準拠コマンドラインシェル == æ›¸å¼ +yash [オプション...] [--] [オペランド...]+ :leveloffset: 1 include::intro.txt[] include::invoke.txt[] include::syntax.txt[] include::params.txt[] include::expand.txt[] include::pattern.txt[] include::redir.txt[] include::exec.txt[] include::interact.txt[] include::job.txt[] include::builtin.txt[] include::lineedit.txt[] include::posix.txt[] include::fgrammar.txt[] include::_alias.txt[] include::_array.txt[] include::_bg.txt[] include::_bindkey.txt[] include::_break.txt[] include::_cd.txt[] include::_colon.txt[] include::_command.txt[] include::_complete.txt[] include::_continue.txt[] include::_dirs.txt[] include::_disown.txt[] include::_dot.txt[] include::_echo.txt[] include::_eval.txt[] include::_exec.txt[] include::_exit.txt[] include::_export.txt[] include::_false.txt[] include::_fc.txt[] include::_fg.txt[] include::_getopts.txt[] include::_hash.txt[] include::_help.txt[] include::_history.txt[] include::_jobs.txt[] include::_kill.txt[] include::_popd.txt[] include::_printf.txt[] include::_pushd.txt[] include::_pwd.txt[] include::_read.txt[] include::_readonly.txt[] include::_return.txt[] include::_set.txt[] include::_shift.txt[] include::_suspend.txt[] include::_test.txt[] include::_times.txt[] include::_trap.txt[] include::_true.txt[] include::_type.txt[] include::_typeset.txt[] include::_ulimit.txt[] include::_umask.txt[] include::_unalias.txt[] include::_unset.txt[] include::_wait.txt[] :leveloffset: 0 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_printf.html0000644000175000017500000003306612154557026016244 0ustar magicantmagicant Printf 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Printf 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’æ•´å½¢ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

æ§‹æ–‡

  • printf æ›¸å¼ [値…]

説明

Printf コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸæ›¸å¼ã«å¾“ã£ã¦å€¤ã‚’æ•´å½¢ã—ã€æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚Echo コマンドã¨ã¯ç•°ãªã‚Šã€å‡ºåŠ›ã®æœ€å¾Œã«ã¯è‡ªå‹•çš„ã«æ”¹è¡Œã¯ä»˜ãã¾ã›ã‚“。

書å¼ã®æŒ‡å®šã®ä»•方㯠C 言語㮠printf 関数ã¨ã‚ˆãä¼¼ã¦ã„ã¾ã™ã€‚書å¼ã®ä¸­ã§ã¯ % ã§å§‹ã¾ã‚‹å¤‰æ›æŒ‡å®šã¨ \ ã§å§‹ã¾ã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを使用ã§ãã¾ã™ã€‚書å¼ã«å«ã¾ã‚Œã‚‹å¤‰æ›æŒ‡å®šã¨ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ä»¥å¤–ã®æ–‡å­—ã¯ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚

å¤‰æ›æŒ‡å®š

å¤‰æ›æŒ‡å®šã¯ãƒ‘ãƒ¼ã‚»ãƒ³ãƒˆè¨˜å· (%) ã‹ã‚‰å§‹ã¾ã‚Šã¾ã™ã€‚

%% 以外ã®å¤‰æ›æŒ‡å®šã¯ã€å¯¾å¿œã™ã‚‹å€¤ã‚’ã¨ã‚Šã¾ã™ã€‚å¤‰æ›æŒ‡å®šã¯ã€å€¤ã‚’特定ã®å½¢å¼ã«æ•´å½¢ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚å¤‰æ›æŒ‡å®šã¨å€¤ã¯ä¸Žãˆã‚‰ã‚ŒãŸé †ç•ªã«å¯¾å¿œä»˜ã‘られã¾ã™ã€‚値ãŒä½™ã£ãŸå ´åˆã¯ã€å…¨ã¦ã®å€¤ã‚’処ç†ã—終ã‚ã‚‹ã¾ã§æ›¸å¼ã®æ•´å½¢ãƒ»å‡ºåŠ›ã‚’ç¹°ã‚Šè¿”ã—ã¾ã™ã€‚値ãŒè¶³ã‚Šãªã„å ´åˆã¯ã€ç©ºæ–‡å­—列 (文字列ã«é–¢ã™ã‚‹å¤‰æ›æŒ‡å®šã®å ´åˆ) ã¾ãŸã¯ 0 (数値ã«é–¢ã™ã‚‹å¤‰æ›æŒ‡å®šã®å ´åˆ) を仮定ã—ã¾ã™ã€‚値ãŒä¸€ã¤ã‚‚与ãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€æ›¸å¼ã¯ä¸€åº¦ã ã‘出力ã•れã¾ã™ã€‚

利用å¯èƒ½ãªå¤‰æ›æŒ‡å®šã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

%d
%i

æ•´æ•°ã®å€¤ã‚’ (符å·ä»˜ã) å進整数ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

%u

æ•´æ•°ã®å€¤ã‚’ (符å·ãªã—) å進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

%o

æ•´æ•°ã®å€¤ã‚’ (符å·ãªã—) 八進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

%x

æ•´æ•°ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ãªã—) å六進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

%X

æ•´æ•°ã®å€¤ã‚’大文字㮠(符å·ãªã—) å六進éžè² æ•´æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

%f

実数ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ä»˜ã) å°æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

%F

実数ã®å€¤ã‚’大文字㮠(符å·ä»˜ã) å°æ•°ã¨ã—ã¦å‡ºåŠ›ã—ã¾ã™ã€‚

%e

実数ã®å€¤ã‚’å°æ–‡å­—ã® (符å·ä»˜ã) æŒ‡æ•°è¡¨è¨˜å°æ•°ã§å‡ºåŠ›ã—ã¾ã™ã€‚

%E

実数ã®å€¤ã‚’大文字㮠(符å·ä»˜ã) æŒ‡æ•°è¡¨è¨˜å°æ•°ã§å‡ºåŠ›ã—ã¾ã™ã€‚

%g

値ã®å¤§ãã•や精度ã«å¿œã˜ã¦ %f 㨠%e ã®ã©ã¡ã‚‰ã‹ã®å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚

%G

値ã®å¤§ãã•や精度ã«å¿œã˜ã¦ %F 㨠%E ã®ã©ã¡ã‚‰ã‹ã®å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚

%c

文字列ã®å€¤ã®æœ€åˆã®æ–‡å­—を出力ã—ã¾ã™ã€‚

%s

文字列ã®å€¤ã‚’ãã®ã¾ã¾å‡ºåŠ›ã—ã¾ã™ã€‚

%b

文字列ã®å€¤ã‚’ã€ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã—ãªãŒã‚‰å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã“ã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンス㯠echo コマンドã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¨åŒã˜ã§ã™ã€‚

%%

ãƒ‘ãƒ¼ã‚»ãƒ³ãƒˆè¨˜å· (%) を出力ã—ã¾ã™ã€‚

%g 㨠%G ã§ã¯ã€å°æ•°ã®æŒ‡æ•°éƒ¨ãŒ -5 ä»¥ä¸Šç²¾åº¦ä»¥ä¸‹ã®æ™‚ã« %f ã¾ãŸã¯ %F ã‚’ã€ãã‚Œä»¥å¤–ã®æ™‚ã« %e ã¾ãŸã¯ %E を使用ã—ã¾ã™ã€‚

%% 以外ã®å¤‰æ›æŒ‡å®šã§ã¯ã€æœ€åˆã® % ã®ç›´å¾Œã«å¤‰æ›æŒ‡å®šãƒ•ラグ・フィールド幅・精度をã“ã®é †ã§æŒ‡å®šã§ãã¾ã™ã€‚ã“れらを指定ã™ã‚‹ã“ã¨ã§å‡ºåŠ›ã®å½¢å¼ã‚’ç´°ã‹ã調整ã§ãã¾ã™ã€‚

å¤‰æ›æŒ‡å®šãƒ•ラグ

指定ã§ãã‚‹å¤‰æ›æŒ‡å®šãƒ•ラグã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚フラグを複数指定ã—ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。

マイナス (-)

ã“ã®ãƒ•ラグを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸãƒ•ィールド幅ã®ä¸­ã§å€¤ã‚’å·¦ã«å¯„ã›ã¦å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã®ãƒ•ラグを指定ã—ãªã„å ´åˆã€å€¤ã¯å³ã«å¯„りã¾ã™ã€‚

プラス (+)

数値ã®ç¬¦å· (æ­£å·ã¾ãŸã¯è² å·) ã‚’å¿…ãšå‡ºåŠ›ã—ã¾ã™ã€‚

空白文字 ( )

出力ã™ã‚‹æ•°å€¤ã«ç¬¦å· (æ­£å·ã¾ãŸã¯è² å·) ãŒä»˜ã‹ãªã„å ´åˆã¯ã€ç¬¦å·ã®ä»£ã‚りã«ç©ºç™½æ–‡å­—を出力ã—ã¾ã™ã€‚

#

値を別形å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ %o ã®å ´åˆã€å‡ºåŠ›ã™ã‚‹å…«é€²æ•°ã®å…ˆé ­ã«å¿…ãšä¸€æ¡ä»¥ä¸Šã® 0 ãŒä»˜ãよã†ã«ã€å¿…è¦ã«å¿œã˜ã¦ 0 を付加ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ %x (ã¾ãŸã¯ %X) ã®å ´åˆã€å€¤ãŒ 0 ã§ãªã‘ã‚Œã°æ•°å€¤ã®å…ˆé ­ã« 0x (ã¾ãŸã¯ 0X) を付加ã—ã¾ã™ã€‚ å¤‰æ›æŒ‡å®šãŒ %e, %E, %f, %F, %g, %G ã®å ´åˆã€å°æ•°ç‚¹ã®å¾Œã«æ•°å­—ãŒãªã„å ´åˆã§ã‚‚å°æ•°ç‚¹ã‚’çœç•¥ã—ãªã„よã†ã«ã—ã¾ã™ã€‚ã¾ãŸå¤‰æ›æŒ‡å®šãŒ %g, %G ã®å ´åˆã€å°æ•°ç‚¹ã®å¾Œã« 0 ä»¥å¤–ã®æ•°å­—ãŒãªã„å ´åˆã§ã‚‚ 0 ã‚’çœç•¥ã—ãªã„よã†ã«ã—ã¾ã™ã€‚

ゼロ (0)

å¤‰æ›æŒ‡å®šãŒ %d, %i, %u, %o, %x, %X, %e, %E, %f, %F, %g, %G ã®å ´åˆã€å‡ºåŠ›ãŒæŒ‡å®šã—ãŸãƒ•ィールド幅ã„ã£ã±ã„ã«ãªã‚‹ã¾ã§æ•°å€¤ã®å…ˆé ­ã« 0 を付加ã—ã¾ã™ã€‚

ãƒžã‚¤ãƒŠã‚¹ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã“ã®ãƒ•ラグã¯ç„¡è¦–ã•れã¾ã™ã€‚

å¤‰æ›æŒ‡å®šãŒ %d, %i, %u, %o, %x, %X ã§ã€ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã“ã®ãƒ•ラグã¯ç„¡è¦–ã•れã¾ã™ã€‚

フィールド幅

フィールド幅ã¯ã€å…ˆé ­ã« 0 ã®ä»˜ã‹ãªã„å進整数ã®å½¢ã§æŒ‡å®šã—ã¾ã™ã€‚

フィールド幅ã¯å‡ºåŠ›ã®æœ€ä½Žãƒã‚¤ãƒˆæ•°ã‚’指示ã—ã¾ã™ã€‚出力ã®ãƒã‚¤ãƒˆæ•°ãŒãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰å¹…ã«æº€ãŸãªã„ã¨ãã¯ã€ãƒã‚¤ãƒˆæ•°ãŒãƒ•ィールド幅ã«ä¸€è‡´ã™ã‚‹ã¾ã§ç©ºç™½æ–‡å­—を付加ã—ã¾ã™ã€‚

精度

精度ã¯ã€ãƒ”リオド (.) ã®ç›´å¾Œã«å進整数を置ã„ãŸã‚‚ã®ã®å½¢ã§æŒ‡å®šã—ã¾ã™ã€‚ピリオドã®å¾Œã«æ•´æ•°ãŒãªã‘れã°ã€0 ãŒæŒ‡å®šã—ã¦ã‚ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

å¤‰æ›æŒ‡å®šãŒ %d, %i, %u, %o, %x, %X ã®å ´åˆã€ç²¾åº¦ã¯å‡ºåŠ›ã®æœ€ä½Žæ¡æ•°ã‚’指示ã—ã¾ã™ã€‚æ•°å€¤ãŒæœ€ä½Žæ¡æ•°ã«æº€ãŸãªã„å ´åˆã¯æœ€ä½Žæ¡æ•°ã«é”ã™ã‚‹ã¾ã§å…ˆé ­ã« 0 を付加ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 1 ã¨ã¿ãªã—ã¾ã™ã€‚

å¤‰æ›æŒ‡å®šãŒ %e, %E, %f, %F ã®å ´åˆã€ç²¾åº¦ã¯å°æ•°ç‚¹ä»¥é™ã®æ¡æ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 6 ã¨ã¿ãªã—ã¾ã™ã€‚

å¤‰æ›æŒ‡å®šãŒ %g, %G ã®å ´åˆã€ç²¾åº¦ã¯æ•°å€¤ã®æœ€å¤§æœ‰åŠ¹æ¡æ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ 6 ã¨ã¿ãªã—ã¾ã™ã€‚

å¤‰æ›æŒ‡å®šãŒ %s, %b ã®å ´åˆã€ç²¾åº¦ã¯å‡ºåŠ›ã™ã‚‹æ–‡å­—åˆ—ã®æœ€å¤§ãƒã‚¤ãƒˆæ•°ã‚’指示ã—ã¾ã™ã€‚ç²¾åº¦ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã€ç²¾åº¦ã¯ç„¡é™å¤§ã¨ã¿ãªã—ã¾ã™ã€‚

例

å¤‰æ›æŒ‡å®š %f ã«ã‚¼ãƒ­ãƒ•ラグを指定ã—ã€ãƒ•ィールド幅㫠8ã€ç²¾åº¦ã« 3 を指定ã™ã‚‹å ´åˆã€æœ€çµ‚çš„ãªå¤‰æ›æŒ‡å®šã¯ %08.3f ã¨ãªã‚Šã¾ã™ã€‚ã“ã®å¤‰æ›æŒ‡å®šã«å¯¾ã—ã¦å€¤ 12.34 を与ãˆã‚‹ã¨ã€å‡ºåŠ›ã¯ 0012.340 ã¨ãªã‚Šã¾ã™ã€‚

エスケープシーケンス

書å¼ã®ä¸­ã§ä½¿ãˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

\a

ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7)

\b

ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 8)

\f

フォームフィード (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 12)

\n

改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10)

\r

復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13)

\t

水平タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 9)

\v

垂直タブ (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 11)

\\

ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥

\"

二é‡å¼•用符

\'

一é‡å¼•用符 (ã‚¢ãƒã‚¹ãƒˆãƒ­ãƒ•ィー)

\xxx

八進数 xxx (最大三æ¡) ã§è¡¨ã‚ã•れるコード番å·ã®æ–‡å­—

オペランド

書å¼

出力ã™ã‚‹æ–‡å­—åˆ—ã®æ›¸å¼ã§ã™ã€‚

値

å¤‰æ›æŒ‡å®šãŒå‡ºåŠ›ã™ã‚‹å€¤ (数値ã¾ãŸã¯æ–‡å­—列) ã§ã™ã€‚

数値を値ã¨ã—ã¦æŒ‡å®šã™ã‚‹éš›ã€ä¸€é‡ã¾ãŸã¯äºŒé‡å¼•用符ã®å¾Œã«ä½•ã‹æ–‡å­—ã‚’ç½®ã„ãŸã‚‚ã®ã‚’指定ã™ã‚‹ã“ã¨ã§ã€ãã®æ–‡å­—ã®ã‚³ãƒ¼ãƒ‰ç•ªå·ã‚’数値ã¨ã—ã¦æŒ‡å®šã§ãã¾ã™ã€‚例ãˆã° 3 ã¨ã„ã†æ–‡å­—ã®ã‚³ãƒ¼ãƒ‰ç•ªå·ãŒ 51 ãªã‚‰ã°ã€ printf '%d' '"3' 㯠51 を出力ã—ã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š printf コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

POSIX ã§ã¯ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã®æ‰±ã„ã«ã¤ã„ã¦å޳坆ã«å®šç¾©ã—ã¦ã„ã¾ã›ã‚“。%s å¤‰æ›æŒ‡å®šã§ç²¾åº¦ã‚’指定ã—ãŸå ´åˆã‚„ã€%c å¤‰æ›æŒ‡å®šã‚’使用ã™ã‚‹å ´åˆã€å€¤ã«ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ãŒå«ã¾ã‚Œã¦ã„ã‚‹ã¨é©åˆ‡ãªå‡ºåŠ›ãŒå¾—られãªã„ã‹ã‚‚ã—れã¾ã›ã‚“。Yash ã§ã¯ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã¯å…¨ã¦ãƒ¯ã‚¤ãƒ‰æ–‡å­—ã«å¤‰æ›ã—ã¦ã‹ã‚‰å‡¦ç†ã™ã‚‹ã®ã§ã€ãƒžãƒ«ãƒãƒã‚¤ãƒˆæ–‡å­—ã®ä¸€éƒ¨ã®ãƒã‚¤ãƒˆã ã‘ãŒå‡ºåŠ›ã•れるよã†ãªã“ã¨ã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/pattern.html0000644000175000017500000002737712154557026016270 0ustar magicantmagicant パターンマッãƒãƒ³ã‚°è¨˜æ³•

パターンマッãƒãƒ³ã‚°è¨˜æ³•ã¯ç‰¹å®šã®æ–‡å­—列ã®é›†åˆã‚’表ã™ãƒ‘ã‚¿ãƒ¼ãƒ³ã®æ›¸å¼ã¨æ„味ã®å®šç¾©ã§ã™ã€‚ã‚る文字列ãŒã‚るパターンã®è¡¨ã™æ–‡å­—列ã®é›†åˆã«å«ã¾ã‚Œã‚‹æ™‚ã€ãã®æ–‡å­—列ã¯ãã®ãƒ‘ターンã«ãƒžãƒƒãƒã™ã‚‹ã¨ã„ã„ã¾ã™ã€‚文字列ãŒãƒ‘ターンã«å½“ã¦ã¯ã¾ã‚‹ã‹ã©ã†ã‹ã¯ã€ä»¥ä¸‹ã«ç¤ºã™å®šç¾©ã«å¾“ã£ã¦åˆ¤å®šã•れã¾ã™ã€‚

é€šå¸¸ã®æ–‡å­—

クォートã—ã¦ã‚る文字ãŠã‚ˆã³ä»¥ä¸‹ã«ç¤ºã™ç‰¹æ®Šãªæ„味をæŒã¤æ–‡å­—以外ã®ã™ã¹ã¦ã®æ–‡å­—ã¯ã€é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚パターンã«å«ã¾ã‚Œã‚‹é€šå¸¸ã®æ–‡å­—ã¯ã€ãã®æ–‡å­—自身ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚

例ãˆã° abc ã¨ã„ã†ãƒ‘ターン㯠abc ã¨ã„ã†æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚(ãã—ã¦ã“ã‚Œä»¥å¤–ã®æ–‡å­—列ã«ã¯ä¸€åˆ‡å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“)

一文字ワイルドカード

文字 ? ã¯ä»»æ„ã®ä¸€æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚

例ãˆã° a?c ã¨ã„ã†ãƒ‘ターン㯠aacã€abcã€a;c ãªã©ã€a ã§å§‹ã¾ã‚Š c ã§çµ‚ã‚ã‚‹ä»»æ„ã® 3 æ–‡å­—ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚

複数文字ワイルドカード

文字 * ã¯ä»»æ„ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ã“ã“ã§ã„ã†ä»»æ„ã®æ–‡å­—列ã«ã¯ç©ºæ–‡å­—列もå«ã¾ã‚Œã¾ã™ã€‚ 例ãˆã° a*c ã¨ã„ã†ãƒ‘ターン㯠acã€abcã€a;xyz;c ãªã©ã€a ã§å§‹ã¾ã‚Š c ã§çµ‚ã‚ã‚‹ä»»æ„ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚

ブラケット記法

括弧 [ 㨠] ã§å›²ã¾ã‚ŒãŸéƒ¨åˆ†ã¯ãƒ–ラケット記法ã¨ã¿ãªã•れã¾ã™ã€‚ãŸã ã—ã€æ‹¬å¼§ã®é–“ã«ã¯å°‘ãªãã¨ã‚‚一文字挟ã¾ã‚Œã¦ã„ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚括弧ã®é–“ã«ã‚る文字ã¯ä»¥ä¸‹ã«ç¤ºã™ãƒ–ラケット記法ã®ãŸã‚ã®ç‰¹æ®Šãªãƒ‘ターン (ブラケット記法パターン) ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ブラケット記法ã¯ã€æ‹¬å¼§ã®é–“ã«ã‚るブラケット記法パターンãŒç¤ºã™æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚

最åˆã®æ‹¬å¼§ [ ã®ç›´å¾Œã«è¨˜å· ! ãŒã‚ã‚‹å ´åˆã€ãƒ–ラケット記法ã«å½“ã¦ã¯ã¾ã‚‹æ–‡å­—ã¨å½“ã¦ã¯ã¾ã‚‰ãªã„文字ã¨ãŒé€†è»¢ã—ã¾ã™ (ãã—ã¦ã“ã® ! ã¯ãƒ–ラケット記法パターンã®ä¸€éƒ¨ã¨ã¯ã¿ãªã•れã¾ã›ã‚“)。Yash ã§ã¯ [ ã®ç›´å¾Œã« ^ ãŒã‚ã‚‹å ´åˆã‚‚åŒæ§˜ã«å½“ã¦ã¯ã¾ã‚‹æ–‡å­—ã¨å½“ã¦ã¯ã¾ã‚‰ãªã„文字ã¨ãŒé€†è»¢ã—ã¾ã™ (ãŒã€ä»–ã®ã‚·ã‚§ãƒ«ã§ã¯ ^ ã®æ‰±ã„ãŒç•°ãªã‚‹ã“ã¨ã‚‚ã‚りã¾ã™)。

最åˆã®æ‹¬å¼§ [ ã®ç›´å¾Œ (ã‚ã‚‹ã„ã¯ä¸Šè¿°ã® ! ã¾ãŸã¯ ^ ãŒã‚ã‚‹å ´åˆã¯ãã®ç›´å¾Œ) ã«æ‹¬å¼§ ] ãŒã‚ã‚‹å ´åˆã¯ã€ãれã¯ãƒ–ラケット記法ã®çµ‚ã‚ã‚Šã‚’ç¤ºã™æ‹¬å¼§ã¨ã—ã¦ã§ã¯ãªãブラケット記法パターンã®ä¸€éƒ¨ã¨ã¿ãªã•れã¾ã™ã€‚ブラケット記法パターンã®è§£é‡ˆã¯ã‚¯ã‚©ãƒ¼ãƒˆã®å‡¦ç†ã®å¾Œã«è¡Œã‚れるã®ã§ã€ã‚¯ã‚©ãƒ¼ãƒˆã«ã‚ˆã£ã¦ãƒ–ãƒ©ã‚±ãƒƒãƒˆè¨˜æ³•ãƒ‘ã‚¿ãƒ¼ãƒ³å†…ã®æ–‡å­—ã‚’é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚ã›ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

パターンã®ä¸­ã« [ ãŒå«ã¾ã‚Œã¦ã„ã¦ã‚‚ã€ãã‚ŒãŒæ­£ã—ã„ブラケット記法ã®å½¢å¼ã«ãªã£ã¦ã„ãªã„å ´åˆã¯ã€ãã® [ ã¯ãƒ–ラケット記法ã§ã¯ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚

(ブラケット記法パターンã«ãŠã‘ã‚‹) é€šå¸¸ã®æ–‡å­—

以下ã«ç¤ºã™ç‰¹æ®Šãªæ„味をæŒã¤è¨˜å·ä»¥å¤–ã®æ–‡å­—ã¯ã™ã¹ã¦é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚é€šå¸¸ã®æ–‡å­—ã¯ãã®æ–‡å­—自身を表ã—ã¾ã™ã€‚

例ãˆã° [abc] ã¨ã„ã†ãƒ–ラケット記法㯠aã€bã€c ã®ã©ã‚Œã‹ã®æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚従ã£ã¦ a[abc]c ã¨ã„ã†ãƒ‘ターン㯠aacã€abcã€acc ã¨ã„ã†ä¸‰ã¤ã®æ–‡å­—列ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ (ãã—ã¦ã“ã‚Œä»¥å¤–ã®æ–‡å­—列ã«ã¯å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“)。

範囲指定

二ã¤ã®æ–‡å­— (ã¾ãŸã¯ç…§åˆã‚·ãƒ³ãƒœãƒ«) ã‚’ãƒã‚¤ãƒ•ン (-) ã§ã¤ãªã„ã ã‚‚ã®ã¯ç¯„囲指定ã¨ã¿ãªã•れã¾ã™ã€‚範囲指定ã¯ã€ãã®äºŒã¤ã®æ–‡å­—ã¨ç…§åˆé †åºä¸Šãã®é–“ã«ã‚ã‚‹å…¨ã¦ã®æ–‡å­—を表ã—ã¾ã™ã€‚ç…§åˆé †åºã¨ã¯æ–‡å­—を辞書順ã«ä¸¦ã¹ã‚‹ãŸã‚ã«ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«å®šç¾©ã•れる文字ã®é †åºé–¢ä¿‚ã§ã™ã€‚使用中ã®ãƒ­ã‚±ãƒ¼ãƒ«ã«å®šç¾©ã•れã¦ã„ã‚‹ç…§åˆé †åºã«å¾“ã£ã¦äºŒã¤ã®æ–‡å­—ã®é–“ã«ã‚ã‚‹æ–‡å­—ãŒæ±ºã¾ã‚Šã¾ã™ã€‚

ãƒã‚¤ãƒ•ンã®å¾Œã« ] ã‚’ç½®ã„ãŸå ´åˆã¯ã€ã“ã® ] ã¯ãƒ–ラケット記法ã®çµ‚ã‚ã‚Šã‚’ç¤ºã™æ‹¬å¼§ã¨ã¿ãªã•れã€ãƒã‚¤ãƒ•ンã¯é€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚

例ãˆã° [1-5] ã¨ã„ã†ãƒ–ラケット記法㯠1ã€2ã€3ã€4ã€5 ã¨ã„ã†äº”ã¤ã®æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚

ç…§åˆã‚·ãƒ³ãƒœãƒ«

ç…§åˆã‚·ãƒ³ãƒœãƒ«ã‚’用ã„ã‚‹ã“ã¨ã§è¤‡æ•°ã®æ–‡å­—ã‹ã‚‰ãªã‚‹ç…§åˆè¦ç´ ã‚’一ã¤ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãã¾ã™ã€‚(ç…§åˆè¦ç´ ã¨ã¯è¤‡æ•°ã®æ–‡å­—ã‚’ã¾ã¨ã‚ã¦ä¸€ã¤ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãるよã†ã«ã™ã‚‹ãŸã‚ã«è€ƒãˆã‚‰ã‚ŒãŸã€ã‚ˆã‚Šä¸€èˆ¬çš„ãªæ–‡å­—ã®æ¦‚念ã§ã™ã€‚パターンマッãƒãƒ³ã‚°ã«ãŠã„ã¦å…¨ã¦ã®æ–‡å­—ã¯å®Ÿéš›ã«ã¯ç…§åˆè¦ç´ ã¨ã—ã¦æ‰±ã‚れã¦ã„ã¾ã™ã€‚) ç…§åˆã‚·ãƒ³ãƒœãƒ«ã¯æ‹¬å¼§ [. .] ã®ä¸­ã«ç…§åˆè¦ç´ ã‚’挟んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚æ‹¬å¼§å†…ã«æ›¸ã‘ã‚‹ç…§åˆè¦ç´ ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãŠã„ã¦ç…§åˆè¦ç´ ã¨ã—ã¦ç™»éŒ²ã•れã¦ã„ã‚‹ã‚‚ã®ã«é™ã‚Šã¾ã™ã€‚

例ãˆã°å¾“æ¥ã‚¹ãƒšã‚¤ãƒ³èªžã§ã¯ 『ch〠ã¨ã„ã†äºŒæ–‡å­—ã‚’åˆã‚ã›ã¦ä¸€æ–‡å­—ã¨ã—ã¦æ‰±ã£ã¦ã„ã¾ã—ãŸã€‚ã“ã®äºŒæ–‡å­—ã®çµ„ã¿åˆã‚ã›ãŒç…§åˆè¦ç´ ã¨ã—ã¦ãƒ­ã‚±ãƒ¼ãƒ«ã«ç™»éŒ²ã•れã¦ã„ã‚‹ãªã‚‰ã°ã€[[.ch.]df] ã¨ã„ã†ãƒ–ラケット記法㯠chã€dã€f ã®ã©ã‚Œã‹ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚ã‚‚ã—ã“ã“ã§ [chdf] ã¨ã„ã†ãƒ–ラケット記法を使ã†ã¨ã€ã“れ㯠cã€hã€dã€f ã®ã©ã‚Œã‹ã«å½“ã¦ã¯ã¾ã‚Šã€ch ã«ã¯å½“ã¦ã¯ã¾ã‚Šã¾ã›ã‚“。

等価クラス

等価クラスを用ã„ã‚‹ã“ã¨ã§ã€ã‚る文字ã¨ç­‰ä¾¡ã§ã‚ã‚‹ã¨ã¿ãªã•れる文字を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã¯æ‹¬å¼§ [= =] ã®ä¸­ã«æ–‡å­—を挟んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚括弧ã®é–“ã«ã¯ç…§åˆã‚·ãƒ³ãƒœãƒ«ã®ã‚ˆã†ã«è¤‡æ•°ã®æ–‡å­—ã‹ã‚‰ãªã‚‹ç…§åˆè¦ç´ ã‚’書ãã“ã¨ã‚‚ã§ãã¾ã™ (上記å‚ç…§)。等価クラスã¯ã€æ‹¬å¼§ã§æŒŸã‚“ã æ–‡å­—ãã®ã‚‚ã®ã®ä»–ã«ã€ãã®æ–‡å­—ã¨åŒã˜ç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹å…¨ã¦ã®æ–‡å­—を表ã—ã¾ã™ã€‚ã©ã®æ–‡å­—ãŒç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹ã‹ã®å®šç¾©ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«å¾“ã„ã¾ã™ã€‚

例ãˆã°ãƒ­ã‚±ãƒ¼ãƒ«ãƒ‡ãƒ¼ã‚¿ã«ãŠã„㦠a, à, á, â, ã, ä ã® 6 文字ãŒåŒã˜ç¬¬ä¸€ç­‰ä¾¡ã‚¯ãƒ©ã‚¹ã«å±žã™ã‚‹ã¨å®šç¾©ã•れã¦ã„ã‚‹ã¨ãã€[[=a=]] ã¨ã„ã†ãƒ–ラケット記法ã¯ã“れら六ã¤ã®æ–‡å­—ã®ã©ã‚Œã‹ä¸€ã¤ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚[[=à=]] ã‚„ [[=á=]] ã‚‚åŒæ§˜ã§ã™ã€‚

文字クラス

文字クラスã¯ç‰¹å®šã®ç¨®é¡žã®æ–‡å­—ã®é›†åˆã‚’表ã—ã¾ã™ã€‚æ–‡å­—ã‚¯ãƒ©ã‚¹ã¯æ‹¬å¼§ [: :] ã®é–“ã«æ–‡å­—クラスã®åå‰ã‚’囲んã ã‚‚ã®ã¨ã—ã¦è¡¨ã—ã¾ã™ã€‚文字クラスã®åå‰ã¨ã—ã¦ã¯ã€ä»¥ä¸‹ã«æŒ™ã’ã‚‹å…±é€šã®æ–‡å­—クラスã®ä»–ã«ã€ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ã§å®šç¾©ã•れãŸç‹¬è‡ªã®æ–‡å­—クラスãŒä½¿ç”¨ã§ãã¾ã™ã€‚ã„ãšã‚Œã®æ–‡å­—クラスã®å ´åˆã‚‚ã€æ–‡å­—クラスã«ã©ã®æ–‡å­—ãŒå«ã¾ã‚Œã‚‹ã®ã‹ã¯ä½¿ç”¨ä¸­ã®ãƒ­ã‚±ãƒ¼ãƒ«ã«ãŠã‘る文字クラスã®å®šç¾©ã«å¾“ã„ã¾ã™ã€‚

[:lower:]

å°æ–‡å­—ã®é›†åˆ

[:upper:]

大文字ã®é›†åˆ

[:alpha:]

アルファベットã®é›†åˆ ([:lower:] 㨠[:upper:] ã‚’å«ã‚€)

[:digit:]

åé€²æ³•ã®æ•°å­—ã®é›†åˆ

[:xdigit:]

åå…­é€²æ³•ã®æ•°å­—ã®é›†åˆ

[:alnum:]

ã‚¢ãƒ«ãƒ•ã‚¡ãƒ™ãƒƒãƒˆã¨æ•°å­—ã®é›†åˆ ([:alpha:] 㨠[:digit:] ã‚’å«ã‚€)

[:blank:]

空白文字ã®é›†åˆ (改行をå«ã¾ãªã„)

[:space:]

空白文字ã®é›†åˆ (改行等をå«ã‚€)

[:punct:]

å¥èª­ç‚¹ç­‰ã®é›†åˆ

[:print:]

表示å¯èƒ½ãªæ–‡å­—ã®é›†åˆ

[:cntrl:]

制御文字ã®é›†åˆ

例ãˆã° [[:lower:][:upper:]] ã¨ã„ã†ãƒ–ラケット記法ã¯ä¸€æ–‡å­—ã®å°æ–‡å­—ã¾ãŸã¯å¤§æ–‡å­—ã«å½“ã¦ã¯ã¾ã‚Šã¾ã™ã€‚

yash-2.35/doc/ja/_shift.html0000644000175000017500000000500312154557026016045 0ustar magicantmagicant Shift 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Shift 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ä½ç½®ãƒ‘ラメータã®ã„ãã¤ã‹ã‚’削除ã—ã¾ã™ã€‚

æ§‹æ–‡

  • shift [個数]

説明

Shift コマンドã¯ä½ç½®ãƒ‘ラメータã®ã†ã¡æœ€åˆã®ã„ãã¤ã‹ã‚’削除ã—ã¾ã™ã€‚削除ã™ã‚‹ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã®æ•°ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ã¾ã™ã€‚

オペランド

個数

削除ã™ã‚‹ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’指示ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚

実際ã®ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚ˆã‚Šå¤§ãã„æ•°ã‚’指定ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚çœç•¥ã™ã‚‹ã¨ 1 を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š shift コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Shift コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã¯ç‰¹æ®Šãƒ‘ラメータ # ã«ã‚ˆã£ã¦çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

yash-2.35/doc/ja/_history.html0000644000175000017500000001163212154557026016436 0ustar magicantmagicant History 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

History 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚’編集ã—ã¾ã™ã€‚

æ§‹æ–‡

  • history [-cF] [-d é …ç›®] [-s コマンド] [-r ファイル] [-w ファイル] [個数]

説明

History コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容を編集・表示ã—ã¾ã™ã€‚

ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã—ã¦ã‚ã‚‹å ´åˆã€history コマンドã¯ãã®ã‚ªãƒ—ションã«å¾“ã£ã¦ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容を編集ã—ã¾ã™ã€‚複数ã®ã‚ªãƒ—ションãŒã‚ã‚‹å ´åˆã¯æŒ‡å®šã—ãŸé †ã«å‡¦ç†ã—ã¾ã™ã€‚

オペランドã§å€‹æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã€history コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…容をãã®å€‹æ•°ã ã‘標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚出力ã®å½¢å¼ã¯ fc ã‚³ãƒžãƒ³ãƒ‰ã«æº–ã˜ã¾ã™ã€‚

オプションもオペランドも与ãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€history コマンドã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…å®¹ã‚’å…¨ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

オプション

-c
--clear

コマンド履歴をã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚

-d é …ç›®
--delete=é …ç›®

指定ã—ãŸé …目をコマンド履歴ã‹ã‚‰å‰Šé™¤ã—ã¾ã™ã€‚é …ç›®ã®æŒ‡å®šã®ä»•方㯠fc コマンドã®å§‹ç‚¹ãƒ»çµ‚点オペランドã¨åŒã˜ã§ã™ã€‚

-F
--flush-file

å±¥æ­´ãƒ•ã‚¡ã‚¤ãƒ«ã‚’å†æ§‹ç¯‰ã—ã¾ã™ã€‚

-r ファイル
--read=ファイル

指定ã—ãŸãƒ•ァイルã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã¿å±¥æ­´ã«è¿½åŠ ã—ã¾ã™ã€‚ファイルã®å†…容ã¯å˜ãªã‚‹ãƒ†ã‚­ã‚¹ãƒˆãƒ•ァイルã¨ã—ã¦è§£é‡ˆã•れã€ãれãžã‚Œã®è¡Œã®å†…容ãŒä¸€ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è¿½åŠ ã•れã¾ã™ã€‚

-s コマンド
--set=コマンド

ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®æœ€å¾Œã®é …目を削除ã—ã€ä»£ã‚ã‚Šã«æŒ‡å®šã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’追加ã—ã¾ã™ã€‚

-w ファイル
--write=ファイル

指定ã—ãŸãƒ•ァイルã«ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã®å†…å®¹ã‚’å…¨ã¦æ›¸ã出ã—ã¾ã™ã€‚æ—¢ã«ã‚るファイルã®å†…å®¹ã¯æ¶ˆåŽ»ã—ã¾ã™ã€‚履歴ã¯å˜ãªã‚‹ãƒ†ã‚­ã‚¹ãƒˆã¨ã—ã¦ä¸€è¡Œãšã¤æ›¸ã出ã—ã¾ã™ã€‚

オペランド

個数

表示ã™ã‚‹å±¥æ­´ã®å€‹æ•°ã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š history コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

POSIX ã«ã¯ history コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

行編集ã®å‹•作中ã¯å±¥æ­´ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

yash-2.35/doc/ja/_dirs.txt0000644000175000017500000000622412154557026015552 0ustar magicantmagicant= Dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を表示ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +dirs [-cv] [{{インデックス}}..]+ [[description]] == 説明 dfn:[ディレクトリスタック]ã¨ã¯ã€ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å¤‰æ›´ã®å±¥æ­´ã‚’ã¨ã‚‹ä»•組ã¿ã§ã™ã€‚link:_pushd.html[Pushd コマンド]ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã™ã‚‹ã¨ã€å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«è¿½åŠ ã•れã¾ã™ã€‚link:_popd.html[Popd コマンド]を使ã†ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«ä¿å­˜ã—ã¦ã‚ã‚‹å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«æˆ»ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚Dirs コマンドを使ã†ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を表示ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ディレクトリスタックã®å†…容㯠link:params.html#sv-dirstack[+DIRSTACK+ é…列]㨠link:params.html#sv-pwd[+PWD+ 変数]ã«ä¿å­˜ã•れã¾ã™ã€‚ã“れらã®å€¤ã‚’変更ã™ã‚‹ã¨ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚ ディレクトリスタックã«ä¿å­˜ã—ã¦ã‚るディレクトリã¯dfn:[インデックス]ã§åŒºåˆ¥ã—ã¾ã™ã€‚インデックス㯠+-v+ (+--verbose+) オプションを付ã‘㦠dirs コマンドを実行ã™ã‚‹ã“ã¨ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯æ­£å· (+++) ã¾ãŸã¯è² å· (+-+) ã®ä»˜ã„ãŸæ•´æ•°ã®å½¢ã§è¡¨ã‚ã—ã¾ã™ã€‚整数㯠pushd コマンドã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã«è¿½åŠ ã—ãŸé †ã«æŒ¯ã‚‰ã‚Œã¾ã™ã€‚例ãˆã°ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ ++0+ ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚インデックス ++1+ ã¯æœ€å¾Œã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã§ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ ++2+ ã¯ãã®ä¸€ã¤å‰ã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚インデックス +-0+ ã¯æœ€åˆã« 追加ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +-1+ ã¯ãã®æ¬¡ã«è¿½åŠ ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã—ã¾ã™ã€‚ +-c+ (+--clear+) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€dirs コマンドã¯ç¾åœ¨ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã‚’一ã¤ãšã¤æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ +-c+ (+--clear+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€dirs コマンドã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ ++0+ 以外ã®è¦ç´ ã‚’ã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚ [[options]] == オプション +-c+:: +--clear+:: ディレクトリスタックã®è¦ç´ ã‚’ (ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¯¾å¿œã™ã‚‹ã‚‚ã®ã‚’除ã„ã¦) ã™ã¹ã¦å‰Šé™¤ã—ã¾ã™ã€‚ +-v+:: +--verbose+:: ディレクトリスタックã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚‚出力ã—ã¾ã™ã€‚ [[operands]] == オペランド {{インデックス}}:: 表示ã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã™ã€‚インデックスを一ã¤ã‚‚指定ã—ãªã„ã¨ãã¯ã€å…¨ã¦ã®è¦ç´ ã‚’インデックス ++0+ ã®ã‚‚ã®ã‹ã‚‰é †ã«è¡¨ç¤ºã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š dirs コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ dirs コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_type.txt0000644000175000017500000000204212154557026015564 0ustar magicantmagicant= Type 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Type 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Type 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã‚’特定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +type [-abefkp] [{{コマンド}}...]+ [[description]] == 説明 Type コマンド㯠link:_command.html[command コマンド]ã« +-V+ オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠command コマンドã¨åŒã˜ã§ã™ã€‚ [[notes]] == 補足 POSIX ã§ã¯ã€type コマンド㨠command コマンドã¨ã®é–¢ä¿‚ã«ã¤ã„ã¦è¦å®šã—ã¦ã„ã¾ã›ã‚“。従ã£ã¦ä»–ã®ã‚·ã‚§ãƒ«ã® type コマンド㯠command コマンド㫠+-V+ オプションを付ã‘ãŸã‚‚ã®ã¨ã¯ç•°ãªã‚‹å‹•作をã™ã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ã¾ãŸ POSIX 㯠type コマンドã®ã‚ªãƒ—ションをè¦å®šã—ã¦ã„ã¾ã›ã‚“。 link:posix.html[POSIX 準拠モード]ã§ã¯å°‘ãªãã¨ã‚‚一ã¤{{コマンド}}を指定ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/index.html0000644000175000017500000004536112154557026015713 0ustar magicantmagicant Yet another shell (yash) マニュアル

目次

  1. ã¯ã˜ã‚ã«

  2. シェルã®èµ·å‹•

  3. ã‚³ãƒžãƒ³ãƒ‰ã®æ–‡æ³•

  4. パラメータã¨å¤‰æ•°

  5. å˜èªžã®å±•é–‹

  6. パターンマッãƒãƒ³ã‚°è¨˜æ³•

  7. リダイレクト

  8. コマンドã®å®Ÿè¡Œã¨ãã®ç’°å¢ƒ

  9. 対話モード

  10. ジョブ制御

  11. 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

  12. 行編集

  13. POSIX 準拠モード

  14. æ§‹æ–‡ã®å½¢å¼çš„定義

組込ã¿ã‚³ãƒžãƒ³ãƒ‰

「*〠ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’〠「+ã€ ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’表ã—ã¾ã™ã€‚ (組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã‚’å‚ç…§)

組込ã¿ã‚³ãƒžãƒ³ãƒ‰ä¸€è¦§ (アルファベット順)

種類別組込ã¿ã‚³ãƒžãƒ³ãƒ‰ä¸€è¦§

実行制御

コマンド実行環境関連

ジョブ制御・シグナル関連

パラメータ・変数関連

作業ディレクトリ関連

エイリアス関連

コマンド履歴関連

文字列出力

行編集関連

ãã®ä»–ã®ã‚³ãƒžãƒ³ãƒ‰

yash-2.35/doc/ja/index.txt.in0000644000175000017500000001064612154557026016171 0ustar magicantmagicant= Yet another shell (yash) マニュアル 渡邊裕貴 v{yashversion}, :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Yet another shell (yash) マニュアル :description: Yash ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã®ç›®æ¬¡ [[contents-list]] == 目次 [role="list-group"] -- // (Replaced with generated contents list) // -- [[builtins]] == 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ `*' ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’〠`+' ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’表ã—ã¾ã™ã€‚ (link:builtin.html#types[組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡ž]ã‚’å‚ç…§) [[alpha-order]] === 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ä¸€è¦§ (アルファベット順) [role="list-group"] - link:_dot.html[+.+ (ドット)] * - link:_colon.html[+:+ (コロン)] * - link:_test.html[+[+ (括弧)] - link:_alias.html[+alias+] + - link:_array.html[+array+] - link:_bg.html[+bg+] + - link:_bindkey.html[+bindkey+] - link:_break.html[+break+] * - link:_cd.html[+cd+] + - link:_command.html[+command+] + - link:_complete.html[+complete+] - link:_continue.html[+continue+] * - link:_dirs.html[+dirs+] - link:_disown.html[+disown+] - link:_echo.html[+echo+] - link:_eval.html[+eval+] * - link:_exec.html[+exec+] * - link:_exit.html[+exit+] * - link:_export.html[+export+] * - link:_false.html[+false+] + - link:_fc.html[+fc+] + - link:_fg.html[+fg+] + - link:_getopts.html[+getopts+] + - link:_hash.html[+hash+] - link:_help.html[+help+] - link:_history.html[+history+] - link:_jobs.html[+jobs+] + - link:_kill.html[+kill+] + - link:_popd.html[+popd+] - link:_printf.html[+printf+] - link:_pushd.html[+pushd+] - link:_pwd.html[+pwd+] + - link:_read.html[+read+] + - link:_readonly.html[+readonly+] * - link:_return.html[+return+] * - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_suspend.html[+suspend+] * - link:_test.html[+test+] - link:_times.html[+times+] * - link:_trap.html[+trap+] * - link:_true.html[+true+] + - link:_type.html[+type+] - link:_typeset.html[+typeset+] - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_unalias.html[+unalias+] + - link:_unset.html[+unset+] * - link:_wait.html[+wait+] + [[groups]] === 種類別組込ã¿ã‚³ãƒžãƒ³ãƒ‰ä¸€è¦§ [[g-control]] ==== 実行制御 [role="list-group"] - link:_eval.html[+eval+] * - link:_dot.html[+.+ (ドット)] * - link:_exec.html[+exec+] * - link:_command.html[+command+] + - link:_hash.html[+hash+] - link:_break.html[+break+] * - link:_continue.html[+continue+] * - link:_return.html[+return+] * - link:_suspend.html[+suspend+] * - link:_exit.html[+exit+] * [[g-environ]] ==== コマンド実行環境関連 [role="list-group"] - link:_set.html[+set+] * - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_trap.html[+trap+] * - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_times.html[+times+] * [[g-job]] ==== ジョブ制御・シグナル関連 [role="list-group"] - link:_jobs.html[+jobs+] + - link:_fg.html[+fg+] + - link:_bg.html[+bg+] + - link:_wait.html[+wait+] + - link:_disown.html[+disown+] - link:_kill.html[+kill+] + - link:_trap.html[+trap+] * [[g-variable]] ==== パラメータ・変数関連 [role="list-group"] - link:_typeset.html[+typeset+] - link:_export.html[+export+] * - link:_readonly.html[+readonly+] * - link:_array.html[+array+] - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_read.html[+read+] + - link:_getopts.html[+getopts+] + - link:_unset.html[+unset+] * [[g-directory]] ==== 作業ディレクトリ関連 [role="list-group"] - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_pushd.html[+pushd+] - link:_popd.html[+popd+] - link:_dirs.html[+dirs+] [[g-alias]] ==== エイリアス関連 [role="list-group"] - link:_alias.html[+alias+] + - link:_unalias.html[+unalias+] + [[g-history]] ==== コマンド履歴関連 [role="list-group"] - link:_fc.html[+fc+] + - link:_history.html[+history+] [[g-print]] ==== 文字列出力 [role="list-group"] - link:_echo.html[+echo+] - link:_printf.html[+printf+] [[g-lineedit]] ==== 行編集関連 [role="list-group"] - link:_bindkey.html[+bindkey+] - link:_complete.html[+complete+] [[g-misc]] ==== ãã®ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ [role="list-group"] - link:_help.html[+help+] - link:_colon.html[+:+ (コロン)] * - link:_true.html[+true+] + - link:_false.html[+false+] + - link:_test.html[+[+ (括弧), +test+] - link:_type.html[+type+] // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_disown.html0000644000175000017500000000522212154557026016236 0ustar magicantmagicant Disown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Disown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚

æ§‹æ–‡

  • disown [-a] [ジョブ…}

説明

Disown コマンドã¯ã‚·ã‚§ãƒ«ãŒç®¡ç†ã—ã¦ã„るジョブを削除ã—ã¾ã™ã€‚削除ã—ãŸã‚¸ãƒ§ãƒ–ã¯ã‚¸ãƒ§ãƒ–制御ã®å¯¾è±¡ã‹ã‚‰å¤–れã¾ã™ãŒã€ã‚¸ãƒ§ãƒ–ã‚’æ§‹æˆã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã¯ç¶™ç¶šã—ã¾ã™ã€‚

オプション

-a
--all

å…¨ã¦ã®ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚

オペランド

ジョブ

削除ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID。

複数指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を削除ã—ã¾ã™ã€‚éž POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® % ã¯çœç•¥ã§ãã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š disown コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

POSIX ã«ã¯ disown コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/invoke.txt0000644000175000017500000001537612154557026015755 0ustar magicantmagicant= シェルã®èµ·å‹• :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - シェルã®èµ·å‹• :description: Yash ã®èµ·å‹•時ã®åˆæœŸåŒ–処ç†ã«ã¤ã„㦠Yash ãŒãƒ—ログラムã¨ã—ã¦èµ·å‹•ã•れるã¨ã€yash ã¯ã„ãã¤ã‹ã®åˆæœŸåŒ–処ç†ã‚’行ã£ãŸå¾Œã€ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦å®Ÿè¡Œã™ã‚‹å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ã“れらã®å‡¦ç†ã®å†…容ã¯ã€ä¸»ã«èµ·å‹•時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«ã‚ˆã£ã¦æ±ºã¾ã‚Šã¾ã™ã€‚ [[arguments]] == 起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•° Yash ã®èµ·å‹•時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数㯠POSIX ã«æº–æ‹ ã—ã¦ã„ã¾ã™ã€‚POSIX ã§å®šã‚られã¦ã„ã‚‹ã¨ãŠã‚Šã€å¼•数㯠dfn:[オプション] 㨠dfn:[オペランド] ã«åˆ†é¡žã•れã¾ã™ã€‚å¼•æ•°ã®æ›¸å¼ã«é–¢ã™ã‚‹ä¸€èˆ¬çš„ãªèª¬æ˜Žã«ã¤ã„ã¦ã¯link:builtin.html#argsyntax[コマンドã®å¼•æ•°ã®æ§‹æ–‡]ã‚’å‚ç…§ã—ã¦ãã ã•ã„。オプションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«æŒ‡å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ オプション㫠+-c+ (+--cmdline+) オプションãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’å°‘ãªãã¨ã‚‚一ã¤ä¸Žãˆã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚シェルã¯ã€ã“ã®æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚二ã¤ç›®ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€link:params.html#sp-zero[特殊パラメータ +0+] ãŒãれã«åˆæœŸåŒ–ã•れã¾ã™ã€‚三ã¤ç›®ä»¥é™ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã«ãªã‚Šã¾ã™ã€‚ +-c+ (+--cmdline+) オプションを指定ã—ãŸå ´åˆã¯ã€ãƒ•ァイルや標準入力ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€ã“ã¨ã¯ã‚りã¾ã›ã‚“ (ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã—ãŸã¨ãを除ã)。 オプション㫠+-s+ (+--stdin+) オプションãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯æ¨™æº–入力ã‹ã‚‰ä¸€è¡Œãšã¤ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦ã€è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚オペランドã¯ã™ã¹ã¦link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã®åˆæœŸåŒ–ã«ä½¿ã‚れã¾ã™ã€‚link:params.html#sp-zero[特殊パラメータ +0+] ã¯ã“ã®ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã«å…ƒã®ãƒ—ログラムã‹ã‚‰å—ã‘å–ã£ãŸæœ€åˆã®å¼•æ•°ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ +-c+ (+--cmdline+) オプションも +-s+ (+--stdin+) オプションも指定ã•れãªã‹ã£ãŸå ´åˆã¯ã€ã‚·ã‚§ãƒ«ã¯ãƒ•ァイルã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒèª­ã¿è¾¼ã‚€ãƒ•ァイルåã¨è¦‹ãªã•れã€ç‰¹æ®Šãƒ‘ラメータ +0+ ã®å€¤ã¨ãªã‚Šã¾ã™ã€‚残りã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã«ãªã‚Šã¾ã™ã€‚オペランドãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¯ã€ +-s+ (+--stdin+) オプションを指定ã—ãŸã¨ãã¨åŒæ§˜ã«æ¨™æº–入力ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã¿ã¾ã™ã€‚ +-c+ (+--cmdline+) オプション㨠+-s+ (+--stdin+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 +--help+ オプションã¾ãŸã¯ +--version+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€é€šå¸¸ã®åˆæœŸåŒ–処ç†ã‚„コマンドã®è§£é‡ˆãƒ»å®Ÿè¡Œã¯ä¸€åˆ‡è¡Œã„ã¾ã›ã‚“。ãれãžã‚Œã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®ç°¡å˜ãªèª¬æ˜Žã¨ãƒãƒ¼ã‚¸ãƒ§ãƒ³æƒ…報を標準出力ã«å‡ºåŠ›ã—ãŸå¾Œã€ãã®ã¾ã¾ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚ +--version+ オプションを +--verbose+ オプションã¨å…±ã«ä½¿ç”¨ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã§åˆ©ç”¨å¯èƒ½ãªæ©Ÿèƒ½ã®ä¸€è¦§ã‚‚出力ã•れã¾ã™ã€‚ +-i+ (+--interactive+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚逆㫠`+i` (`++interactive`) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã›ã‚“。 +-l+ (+--login+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯ãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¾ã™ã€‚ +--noprofile+, +--norcfile+, +--profile+, +--rcfile+ å„オプションã¯ã€ã‚·ã‚§ãƒ«ã®åˆæœŸåŒ–処ç†ã®å‹•作を指定ã—ã¾ã™ (後述)。 ãã®ä»–ã®ã‚ªãƒ—ションã¨ã—ã¦ã€link:_set.html[set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§æŒ‡å®šå¯èƒ½ãªå„種オプションをシェルã®èµ·å‹•æ™‚ã«æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚(`+` ã§å§‹ã¾ã‚‹ã‚ªãƒ—ションをå«ã‚€) 最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ +-+ ã§ã‚りã€ã‹ã¤ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ +--+ ã§åŒºåˆ‡ã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€ãã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ç‰¹åˆ¥ã«ç„¡è¦–ã•れã¾ã™ã€‚ [[init]] == シェルã®åˆæœŸåŒ–å‡¦ç† ã‚·ã‚§ãƒ«ã®åˆæœŸåŒ–処ç†ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«è¡Œã‚れã¾ã™ã€‚ . Yash ã¯ã¾ãšã€(コマンドライン引数ã®å‰ã«æ¸¡ã•れる) ãれ自身ã®èµ·å‹•時ã®åå‰ã‚’è§£æžã—ã¾ã™ã€‚ãã®åå‰ãŒ +-+ ã§å§‹ã¾ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ã¯ãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¾ã™ã€‚ã¾ãŸåå‰ãŒ +sh+ ã§ã‚ã‚‹å ´åˆ (+/bin/sh+ ã®ã‚ˆã†ã« +sh+ ã§çµ‚ã‚ã‚‹å ´åˆã‚’å«ã‚€) ã¯ã€ã‚·ã‚§ãƒ«ã¯ link:posix.html[POSIX 準拠モード]ã«ãªã‚Šã¾ã™ã€‚ . オペランドãŒä¸€ã¤ã‚‚ãªãã€ã‹ã¤æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã©ã¡ã‚‰ã‚‚端末ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯è‡ªå‹•çš„ã«link:interact.html[対話モード]ã«ãªã‚Šã¾ã™ã€‚ãŸã ã— `+i` (`++interactive`) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ãã¡ã‚‰ã‚’優先ã—ã¾ã™ã€‚ . 対話モードã®ã‚·ã‚§ãƒ«ã§ã¯è‡ªå‹•çš„ã«link:job.html[ジョブ制御]ãŒæœ‰åйã«ãªã‚Šã¾ã™ã€‚ãŸã ã— `+m` (`++monitor`) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ãã¡ã‚‰ã‚’優先ã—ã¾ã™ã€‚ . シェルã¯ä»¥ä¸‹ã®åˆæœŸåŒ–スクリプトを読ã¿è¾¼ã‚“ã§è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã—シェルプロセスã®å®Ÿãƒ¦ãƒ¼ã‚¶ ID ã¨å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ãŒç•°ãªã£ã¦ã„ã‚‹ã‹ã€å®Ÿã‚°ãƒ«ãƒ¼ãƒ— ID ã¨å®ŸåŠ¹ã‚°ãƒ«ãƒ¼ãƒ— ID ãŒç•°ãªã£ã¦ã„ã‚‹å ´åˆã‚’除ã) .. シェルãŒãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¦ã„ã‚‹å ´åˆã¯ã€ +--profile={{ファイルå}}+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸãƒ•ァイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã— +--noprofile+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã‹ link:posix.html[POSIX 準拠モード]ã®å ´åˆã‚’除ã) + +--profile={{ファイルå}}+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€ link:expand.html#tilde[~]/.yash_profile ãŒãƒ‡ãƒ•ォルトã®ãƒ•ァイルã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚ .. シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®å ´åˆã¯ã€ +--rcfile={{ファイルå}}+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸãƒ•ァイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã— +--norcfile+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã‚’除ã) + +--rcfile+ ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€éž POSIX 準拠モードã§ã¯ãƒ•ァイル link:expand.html#tilde[~]/.yashrc ãŒãƒ‡ãƒ•ォルトã®ãƒ•ァイルã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚POSIX 準拠モードã§ã¯ã€ link:params.html#sv-env[+ENV+ 環境変数]ã®å€¤ãŒlink:expand.html#params[パラメータ展開]ã•れã€ãã®çµæžœã‚’ファイルåã¨è¦‹ãªã—ã¦ãƒ•ァイルを読ã¿è¾¼ã¿ã¾ã™ã€‚ [NOTE] Yash 㯠/etc/profile ã‚„ /etc/yashrc ã‚„ link:expand.html#tilde[~]/.profile を自動的ã«èª­ã‚€ã“ã¨ã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_popd.html0000644000175000017500000000544212154557026015701 0ustar magicantmagicant Popd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Popd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’削除ã—ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’戻ã—ã¾ã™ã€‚

æ§‹æ–‡

  • popd [インデックス]

説明

Popd コマンドã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®è¦ç´ ã‚’削除ã—ã¾ã™ã€‚インデックス +0 ã®è¦ç´ ã‚’削除ã—ãŸå ´åˆã¯ã€æ–°ãŸã«ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +0 ã®è¦ç´ ã¨ãªã£ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

オペランド

インデックス

削除ã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã™ã€‚çœç•¥ã™ã‚‹ã¨ +0 を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

終了ステータス

ディレクトリスタックã®è¦ç´ ã‚’æ­£ã—ã削除ã—作業ディレクトリを変更ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

ディレクトリスタックã«è¦ç´ ãŒä¸€ã¤ã—ã‹ãªã„å ´åˆã¯ãれ以上è¦ç´ ã‚’削除ã§ããªã„ã®ã§ã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚

POSIX ã«ã¯ popd コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/_hash.html0000644000175000017500000001232712154557026015662 0ustar magicantmagicant Hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Hash 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¤–部コマンドã®ãƒ‘スを検索・表示ã—ã¾ã™ã€‚

æ§‹æ–‡

  • hash コマンド

  • hash -r [コマンド…]

  • hash [-a]

  • hash -d ユーザå

  • hash -dr [ユーザå…]

  • hash -d

説明

オプションを指定ã—ãªã„å ´åˆã€hash コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤–部コマンドã®ãƒ‘スを検索ã—ã€çµæžœã‚’記憶ã—ã¾ã™ (æ—¢ã«è¨˜æ†¶ã—ã¦ã„ã‚‹å ´åˆã¯å†åº¦æ¤œç´¢ãƒ»è¨˜æ†¶ã—ã¾ã™)。

-r (--remove) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€hash コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤–部コマンドã®ãƒ‘スã«é–¢ã™ã‚‹è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚-r (--remove) オプションを指定ã—ã‹ã¤ã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã—ãªã„å ´åˆã€å…¨ã¦ã®è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚

-r (--remove) オプションを指定ã›ãšã‚³ãƒžãƒ³ãƒ‰ã‚‚指定ã—ãªã„å ´åˆã€è¨˜æ†¶ã—ã¦ã„るパスã®ä¸€è¦§ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

-d (--directory) オプションを指定ã—ãŸå ´åˆã€hash コマンドã¯å¤–部コマンドã®ãƒ‘スã®ä»£ã‚りã«ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを検索・記憶ã¾ãŸã¯è¡¨ç¤ºã—ã¾ã™ã€‚記憶ã—ãŸãƒ‘スã¯ãƒãƒ«ãƒ€å±•é–‹ã§ä½¿ç”¨ã—ã¾ã™ã€‚

オプション

-a
--all

シェルãŒè¨˜æ†¶ã—ã¦ã„ã‚‹å…¨ã¦ã®ãƒ‘スを出力ã—ã¾ã™ã€‚

ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€ã‚·ã‚§ãƒ«ãŒè¨˜æ†¶ã—ã¦ã„るパスã®ã†ã¡çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã™ã‚‹ã‚‚ã®ã¯å‡ºåŠ›ã—ã¾ã›ã‚“。

-d
--directory

外部コマンドã®ãƒ‘スã®ä»£ã‚りã«ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを扱ã„ã¾ã™ã€‚

-r
--remove

指定ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¾ãŸã¯ãƒ¦ãƒ¼ã‚¶åã«å¯¾ã™ã‚‹ãƒ‘スã®è¨˜æ†¶ã‚’消去ã—ã¾ã™ã€‚

オペランド

コマンド

パスを記憶・消去ã™ã‚‹å¤–部コマンドã®åå‰ã§ã™ã€‚スラッシュをå«ã‚€ãƒ‘スを指定ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

ユーザå

ホームディレクトリã®ãƒ‘スを記憶・消去ã™ã‚‹ãƒ¦ãƒ¼ã‚¶åã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š hash コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

シェルã¯ã€å¤–部コマンド (ã¾ãŸã¯ãƒãƒ«ãƒ€å±•é–‹) を実行ã™ã‚‹éš›ã«è‡ªå‹•çš„ã«ã‚³ãƒžãƒ³ãƒ‰ (ã¾ãŸã¯ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒª) ã®ãƒ‘スを記憶ã™ã‚‹ã®ã§ã€é€šå¸¸ã¯ã‚ã–ã‚ã– hash コマンドを使ã£ã¦ãƒ‘スを記憶ã•ã›ã‚‹å¿…è¦ã¯ã‚りã¾ã›ã‚“。

PATH 変数ã®å€¤ãŒå¤‰ã‚ã£ãŸæ™‚ã¯ã€è¨˜æ†¶ã—ãŸå¤–部コマンドã®ãƒ‘スã¯è‡ªå‹•çš„ã«ã™ã¹ã¦æ¶ˆåŽ»ã•れã¾ã™ã€‚

POSIX ãŒè¦å®šã—ã¦ã„るオプション㯠-r ã ã‘ã§ã™ã€‚よã£ã¦ä»–ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/_export.txt0000644000175000017500000000203712154557026016130 0ustar magicantmagicant= Export 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Export 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Export 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã®link:params.html#variables[変数]を表示・設定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +export [-prX] [{{変数}}[={{値}}]...]+ [[description]] == 説明 Export コマンド㯠link:_typeset.html[typeset コマンド]ã« +-gx+ オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠typeset コマンドã¨åŒæ§˜ã§ã™ã€‚ [[notes]] == 補足 Export コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ export コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã™ãŒã€ã‚ªãƒ—ション㯠+-p+ ã—ã‹è¦å®šãŒã‚りã¾ã›ã‚“。ãã®ä»–ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠+-p+ オプションをオペランドã¨ã¨ã‚‚ã«ä½¿ã†ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_complete.html0000644000175000017500000002621212154557026016545 0ustar magicantmagicant Complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³è£œå®Œã«ãŠã„ã¦è£œå®Œå€™è£œã‚’生æˆã—ã¾ã™ã€‚ã“ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯è£œå®Œé–¢æ•°ã®å®Ÿè¡Œä¸­ã«ã ã‘使ãˆã¾ã™ã€‚

æ§‹æ–‡

  • complete [-A パターン] [-R パターン] [-T] [-P 接頭辞] [-S 接尾辞] [-abcdfghjkuv] [[-O] [-D 説明] å˜èªž…]

説明

補完関数ã®ä¸­ã§ã“ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã¨ã€complete ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸå¼•æ•°ã«å¾“ã£ã¦è£œå®Œå€™è£œã‚’生æˆã—ã¾ã™ã€‚ã©ã®ã‚ªãƒ—ション・オペランドã§å€™è£œã‚’生æˆã™ã‚‹ã«ã›ã‚ˆã€å®Ÿéš›ã«ç”Ÿæˆã•れる候補ã¯ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹ (コマンドライン上ã«é€”中ã¾ã§å…¥åŠ›ã•れãŸ) å˜èªžã«ä¸€è‡´ã™ã‚‹ã‚‚ã®ã«é™ã‚‰ã‚Œã¾ã™ã€‚

オプション

-A パターン
--accept=パターン

ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸãƒ‘ターンã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã ã‘を生æˆã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯è¤‡æ•°å›žæŒ‡å®šã§ãã¾ã™ (指定ã—ãŸå…¨ã¦ã®ãƒ‘ターンã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã ã‘を生æˆã—ã¾ã™)。

-D 説明
--description=説明

ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸèª¬æ˜ŽãŒè£œå®Œã®éš›ã«å€™è£œã®èª¬æ˜Žã¨ã—ã¦è¡¨ç¤ºã•れã¾ã™ã€‚

-O
--option

生æˆã™ã‚‹å€™è£œã‚’コマンドã®ã‚ªãƒ—ションã¨ã¿ãªã™ã‚ˆã†ã«ã—ã¾ã™ã€‚候補を画é¢ä¸Šã«ä¸€è¦§è¡¨ç¤ºã™ã‚‹éš›ã«è‡ªå‹•çš„ã«å…ˆé ­ã«ãƒã‚¤ãƒ•ンを付加ã—ã¾ã™ã€‚

-P 接頭辞
--prefix=接頭辞

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã™ã‚‹æŽ¥é ­è¾žã¯ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžã®æŽ¥é ­è¾žã«ãªã£ã¦ã„ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€å€™è£œç”Ÿæˆã®éš›ã«ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸæŽ¥é ­è¾žã‚’ç„¡è¦–ã—ã¦ãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ã€‚例ãˆã°è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžãŒ file:///home/user/docume ã§ã‚りã€ã“ã® URL をファイルåã¨ã—ã¦è£œå®Œã—ãŸã„ã¨ã—ã¾ã—ょã†ã€‚ã“ã®å ´åˆã¯ã€complete -P file:// -f ã¨ã™ã‚‹ã¨ URL ã‹ã‚‰ file:// を除ã„ãŸæ®‹ã‚Šã® /home/user/docume ã®éƒ¨åˆ†ã«å¯¾ã—ã¦ãƒ•ァイルåã¨ã—ã¦ã®è£œå®Œå€™è£œãŒç”Ÿæˆã•れã¾ã™ã€‚

-R パターン
--reject=パターン

ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸãƒ‘ターンã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã‚’生æˆã—ã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションã¯è¤‡æ•°å›žæŒ‡å®šã§ãã¾ã™ (指定ã—ãŸãƒ‘ターンã®å°‘ãªãã¨ã‚‚一ã¤ã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã‚’å…¨ã¦é™¤å¤–ã—ã¾ã™)。

-S 接尾辞
--suffix=接尾辞

生æˆã—ãŸå„å€™è£œã®æœ«å°¾ã«æŽ¥å°¾è¾žã‚’付加ã—ã¾ã™ã€‚

-T
--no-termination

通常ã¯ã€è£œå®ŒãŒçµ‚ã‚ã£ãŸå¾Œã«æ¬¡ã®å˜èªžã‚’ã™ã入力ã§ãるよã†ã«ã€è£œå®Œã—ãŸå˜èªžã®ç›´å¾Œã«ç©ºç™½ã‚’è‡ªå‹•çš„ã«æŒ¿å…¥ã—ã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ションを指定ã—ãŸã¨ãã¯ç©ºç™½ã‚’挿入ã—ã¾ã›ã‚“。

補完方å¼è¨­å®šã®ãŸã‚ã®ã‚ªãƒ—ション

-a
--alias

エイリアス (--normal-alias --global-alias ã«åŒã˜)

--array-variable

é…列

--bindkey

Bindkey コマンドã§åˆ©ç”¨å¯èƒ½ãª​行編集コマンド

-b
--builtin-command

組込ã¿ã‚³ãƒžãƒ³ãƒ‰ (--special-builtin --semi-special-builtin --regular-builtin ã«åŒã˜)

-c
--command

コマンド (--builtin-command --external-command --function ã«åŒã˜)

-d
--directory

ディレクトリ

--dirstack-index

ディレクトリスタックã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹

--executable-file

実行å¯èƒ½ãƒ•ァイル

--external-command

外部コマンド

-f
--file

ファイル (ディレクトリå«ã‚€)

--finished-job

終了ã—ãŸã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID

--function

関数

--global-alias

グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹

-g
--group

(ファイルã®ãƒ‘ーミッションãªã©ã«ãŠã‘ã‚‹) グループ

-h
--hostname

ホストå

-j
--job

ジョブ ID

-k
--keyword

シェルã®äºˆç´„語

--normal-alias

通常㮠(グローãƒãƒ«ã§ãªã„) エイリアス

--regular-builtin

通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰

--running-job

実行中ã®ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID

--scalar-variable

(é…列を除ã„ãŸé€šå¸¸ã®) 変数

--semi-special-builtin

準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰

--signal

シグナル

--special-builtin

特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰

--stopped-job

åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID

-u
--username

ユーザã®ãƒ­ã‚°ã‚¤ãƒ³å

-v
--variable

変数

-d (--directory) オプションを指定ã›ãšã« -f (--file) オプションを指定ã—ãŸå ´åˆã€-S … (--suffix=…) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šã®æœ‰ç„¡ã«ã‹ã‹ã‚らãšã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを表ã™è£œå®Œå€™è£œã«ã¯æŽ¥å°¾è¾žã¨ã—ã¦ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒä»˜ãã€å€™è£œã®ç›´å¾Œã«ã¯ç©ºç™½ãŒå…¥ã‚Šã¾ã›ã‚“ (-S / -T を指定ã—ãŸã¨ãã¨åŒã˜å‹•作)。

ジョブ ID ã®è£œå®Œã¯å…ˆé ­ã® % を除ã„ãŸéƒ¨åˆ†ã«å¯¾ã—ã¦è¡Œã‚れるã®ã§ã€è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžãŒæ—¢ã« % ã‚’å«ã‚“ã§ã„ã‚‹å ´åˆã¯ % を接頭辞ã¨ã—ã¦æŒ‡å®šã—ã¦ãã ã•ã„。

オペランド

Complete コマンドã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€å„オペランドãŒãれãžã‚Œè£œå®Œå€™è£œã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚指定ã—ãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®ã†ã¡ã€ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžã«åˆã†ã‚‚ã®ãŒè£œå®Œå€™è£œã¨ãªã‚Šã¾ã™ã€‚

終了ステータス

候補ãŒå°‘ãªãã¨ã‚‚一ã¤ç”Ÿæˆã§ããŸå ´åˆã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚æ–°ãŸãªå€™è£œãŒä¸€ã¤ã‚‚生æˆã§ããªã‹ã£ãŸã¨ãã¯ã€çµ‚了ステータス㯠1 ã§ã™ã€‚ãã®ä»–ã®ã‚¨ãƒ©ãƒ¼ã®å ´åˆã¯ 2 以上ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

補足

POSIX ã«ã¯ complete コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/_unalias.html0000644000175000017500000000474512154557026016400 0ustar magicantmagicant Unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’削除ã—ã¾ã™ã€‚

æ§‹æ–‡

  • unalias エイリアスå

  • unalias -a

説明

Unalias コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’削除ã—ã¾ã™ã€‚

オプション

-a
--all

å…¨ã¦ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’削除ã—ã¾ã™ã€‚

オペランド

エイリアスå

削除ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š unalias コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚存在ã—ãªã„ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå ´åˆã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚

補足

Unalias ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

yash-2.35/doc/ja/asciidoc.conf0000644000175000017500000000160612154557026016335 0ustar magicantmagicant[macros] (?su)dfn:\[(?P.*?)\]=dfn (?su)dfn:(?P\w+)\[(?P.*?)\]=dfnid (?su)lang:(?P\w+)\[(?P.*?)\]=lang [quotes] ~= ((|))= (((|)))= +=code ++=#code `=#code {{|}}=#var ifdef::basebackend-html[] [tags] code=| var=| [dfn-inlinemacro] {value} [dfnid-inlinemacro] {value} ifdef::backend-xhtml11[] [lang-inlinemacro] {value} endif::backend-xhtml11[] ifndef::backend-xhtml11[] [lang-inlinemacro] {value} endif::backend-xhtml11[] endif::basebackend-html[] ifdef::basebackend-docbook[] [tags] code=| var=| [dfn-inlinemacro] {value} [dfnid-inlinemacro] {value} [lang-inlinemacro] {value} endif::basebackend-docbook[] # vim: set filetype=cfg: yash-2.35/doc/ja/_command.html0000644000175000017500000002202212154557026016346 0ustar magicantmagicant Command 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Command 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ã¾ãŸã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã‚’特定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • command [-befp] コマンド [引数…]

  • command -v|-V [-abefkp] コマンド

説明

-v (--identify) オプションãªã‚‰ã³ã« -V (--verbose-identify) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€command コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ã‚’与ãˆã‚‰ã‚ŒãŸå¼•æ•°ã§å®Ÿè¡Œã—ã¾ã™ã€‚コマンドã®å®Ÿè¡Œã®ä»•æ–¹ã¯å˜ç´”コマンドã®å®Ÿè¡Œã®æœ€å¾Œã®ã‚¹ãƒ†ãƒƒãƒ—ã«æº–ã˜ã¾ã™ãŒã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã§ã¯å¤–部コマンド・組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»é–¢æ•°ã®å†…ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸã‚‚ã®ã—ã‹æ¤œç´¢ã—ã¾ã›ã‚“。ã¾ãŸã‚³ãƒžãƒ³ãƒ‰ãŒç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ãŸã‚Šãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã‚„代入エラーãŒèµ·ããŸã‚Šã—ã¦ã‚‚シェルã¯çµ‚了ã—ã¾ã›ã‚“。

-v (--identify) オプションã¾ãŸã¯ -V (--verbose-identify) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€command コマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã¨ãƒ‘スを特定ã—ãれを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚コマンドã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚„関数ã§ã‚ã£ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。

-v (--identify) オプションを付ã‘ã¦å®Ÿè¡Œã—ãŸã¨ãã®å‡ºåŠ›ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚

  • ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®çµæžœè¦‹ã¤ã‹ã£ãŸã‚³ãƒžãƒ³ãƒ‰ãŠã‚ˆã³ãã®ä»–ã®å¤–部コマンドã¯ã€ãã®çµ¶å¯¾ãƒ‘スを出力ã—ã¾ã™ã€‚

  • ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ã‚ˆã‚‰ãšå®Ÿè¡Œã•れる組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„関数ã¯ã€å˜ã«ãã®åå‰ã‚’出力ã—ã¾ã™ã€‚

  • 予約語ã¯ã€å˜ã«ãã®åå‰ã‚’出力ã—ã¾ã™ã€‚

  • エイリアスã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œå¯èƒ½ãªå½¢å¼ã§ãã®åå‰ã¨å€¤ã‚’出力ã—ã¾ã™ã€‚

  • コマンドãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€ä½•も出力ã—ã¾ã›ã‚“。(終了ステータスãŒéž 0 ã«ãªã‚Šã¾ã™)

-V (--verbose-identify) オプション使用時ã¯ã€å‡ºåŠ›ã®å½¢å¼ãŒäººé–“ã«ã¨ã£ã¦ã‚ˆã‚Šèª­ã¿ã‚„ã™ããªã‚Šã¾ã™ã€‚

オプション

-a
--alias

コマンドã¨ã—ã¦ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ -v (--identify) ã¾ãŸã¯ -V (--verbose-identify) オプションã¨ä¸€ç·’ã«ä½¿ã†å¿…è¦ãŒã‚りã¾ã™ã€‚

-b
--builtin-command

コマンドã¨ã—ã¦çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚

-e
--external-command

コマンドã¨ã—ã¦å¤–部コマンドを検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚

-f
--function

コマンドã¨ã—ã¦é–¢æ•°ã‚’検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚

-k
--keyword

コマンドã¨ã—ã¦äºˆç´„語を検索ã®å¯¾è±¡ã«ã—ã¾ã™ã€‚ -v (--identify) ã¾ãŸã¯ -V (--verbose-identify) オプションã¨ä¸€ç·’ã«ä½¿ã†å¿…è¦ãŒã‚りã¾ã™ã€‚

-p
--standard-path

ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ãŠã„ã¦ã€PATH 変数ã®ä»£ã‚りã«ã€æ¨™æº–ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’ã™ã¹ã¦å«ã‚€ã‚ˆã†ãªã‚·ã‚¹ãƒ†ãƒ å›ºæœ‰ã®ãƒ‡ãƒ•ォルトパスを用ã„ã¦å¤–部コマンドを検索ã—ã¾ã™ã€‚

-v
--identify

与ãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã¨ãƒ‘スを特定ã—ã€ç°¡å˜ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

-V
--verbose-identify

与ãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã¨ãƒ‘スを特定ã—ã€äººé–“ã«ã¨ã£ã¦èª­ã¿ã‚„ã™ã„å½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

-a (--alias), -b (--builtin-command), -e (--external-command), -f (--function), -k (--keyword) オプションã®ã©ã‚Œã‚‚指定ã—ãªã‹ã£ãŸå ´åˆã¯ã€ä»¥ä¸‹ã®ã‚ªãƒ—ションを指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

-v (--identify) ã‚ã‚‹ã„㯠-V (--verbose-identify) オプションを指定ã—ã¦ã„ãªã„ã¨ã

-b -e

-v (--identify) ã¾ãŸã¯ -V (--verbose-identify) オプションを指定ã—ã¦ã„ã‚‹ã¨ã

-a -b -e -f -k

オペランド

コマンド

実行ã™ã‚‹ã¾ãŸã¯ç¨®é¡žã‚’特定ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã§ã™ã€‚

引数

実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚

終了ステータス

-v (--identify) ã‚ã‚‹ã„㯠-V (--verbose-identify) オプションを指定ã—ã¦ã„ãªã„ã¨ã

実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス

-v (--identify) ã¾ãŸã¯ -V (--verbose-identify) オプションを指定ã—ã¦ã„ã‚‹ã¨ã

エラーãŒãªã„é™ã‚Š 0

補足

Command ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«è¦å®šã®ã‚るオプション㯠-p, -v, -V ã ã‘ã§ã™ã€‚ã“れ以外ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯ -v ã¾ãŸã¯ -V オプションを使用ã™ã‚‹ã¨ãコマンドã¯ã¡ã‚‡ã†ã©ä¸€ã¤ã—ã‹æŒ‡å®šã§ãã¾ã›ã‚“。

POSIX 㯠-v オプション㨠-V ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«æŒ‡å®šã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。Yash ã§ã¯ã“れら二ã¤ã®ã‚ªãƒ—ションを両方指定ã™ã‚‹ã¨æœ€å¾Œã«æŒ‡å®šã—ãŸã‚‚ã®ãŒæœ‰åйã«ãªã‚Šã¾ã™ã€‚

yash-2.35/doc/ja/_shift.txt0000644000175000017500000000227412154557026015727 0ustar magicantmagicant= Shift 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Shift 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Shift 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã®ã„ãã¤ã‹ã‚’削除ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +shift [{{個数}}]+ [[description]] == 説明 Shift コマンドã¯link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã®ã†ã¡æœ€åˆã®ã„ãã¤ã‹ã‚’削除ã—ã¾ã™ã€‚削除ã™ã‚‹ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã®æ•°ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ã¾ã™ã€‚ [[operands]] == オペランド {{個数}}:: 削除ã™ã‚‹ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’指示ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ + 実際ã®ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚ˆã‚Šå¤§ãã„æ•°ã‚’指定ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚çœç•¥ã™ã‚‹ã¨ 1 を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š shift コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Shift コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã¯link:params.html#special[特殊パラメータ +#+] ã«ã‚ˆã£ã¦çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_jobs.html0000644000175000017500000001036112154557026015670 0ustar magicantmagicant Jobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Jobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ãŒæœ‰ã—ã¦ã„るジョブを表示ã—ã¾ã™ã€‚

æ§‹æ–‡

  • jobs [-lnprs] [ジョブ…]

説明

Jobs コマンドã¯ã‚·ã‚§ãƒ«ãŒç¾åœ¨æœ‰ã—ã¦ã„るジョブã®åå‰ã‚„状態を表示ã—ã¾ã™ã€‚

標準ã§ã¯å„ジョブã«ã¤ã„ã¦ä»¥ä¸‹ã®æƒ…報を一行ãšã¤è¡¨ç¤ºã—ã¾ã™ã€‚

  • ジョブ番å·

  • ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–を示ã™è¨˜å· (+ ã¾ãŸã¯ -)

  • 状態

  • コマンドå

オプション

-l
--verbose

ジョブを構æˆã—ã¦ã„るパイプラインã®è¦ç´ ã”ã¨ã«ãƒ—ロセス ID ã¨çŠ¶æ…‹ã¨ã‚³ãƒžãƒ³ãƒ‰åを表示ã—ã¾ã™ã€‚

-n
--new

状態ãŒå¤‰åŒ–ã—ã¦ã‹ã‚‰ã¾ã ä¸€åº¦ã‚‚表示ã—ã¦ã„ãªã„ジョブã ã‘を表示ã—ã¾ã™ã€‚

-p
--pgid-only

ジョブã®ãƒ—ロセスグループ ID ã ã‘を表示ã—ã¾ã™ã€‚

-r
--running-only

実行中ã®ã‚¸ãƒ§ãƒ–ã ã‘を表示ã—ã¾ã™ã€‚

-s
--stopped-only

åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ã ã‘を表示ã—ã¾ã™ã€‚

オペランド

ジョブ

表示ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID ã§ã™ã€‚一ã¤ã‚‚指定ã—ãªã„å ´åˆã¯å…¨ã¦ã®ã‚¸ãƒ§ãƒ–を表示ã—ã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š jobs コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Jobs ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã§è¦å®šã•れã¦ã„るオプション㯠-l 㨠-p ã ã‘ã§ã™ã€‚従ã£ã¦ POSIX 準拠モードã§ã¯ã“れ以外ã®ã‚ªãƒ—ションã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯ã€-l オプション指定時ã€ãƒ—ロセスã”ã¨ã§ã¯ãªãジョブã”ã¨ã«çŠ¶æ…‹ã‚’è¡¨ç¤ºã—ã¾ã™ã€‚

Yash ã§ã¯ã€ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスグループ ID ã¯ã‚¸ãƒ§ãƒ–ã‚’æ§‹æˆã™ã‚‹ãƒ‘ã‚¤ãƒ—ãƒ©ã‚¤ãƒ³ã®æœ€åˆã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã«ä¸€è‡´ã—ã¾ã™ã€‚

yash-2.35/doc/ja/index.txt0000644000175000017500000002157112154557026015563 0ustar magicantmagicant= Yet another shell (yash) マニュアル 渡邊裕貴 v{yashversion}, :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Yet another shell (yash) マニュアル :description: Yash ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã®ç›®æ¬¡ [[contents-list]] == 目次 [role="list-group"] -- . link:intro.html[ã¯ã˜ã‚ã«] . link:invoke.html[シェルã®èµ·å‹•] .. link:invoke.html#arguments[起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°] .. link:invoke.html#init[シェルã®åˆæœŸåŒ–処ç†] . link:syntax.html[ã‚³ãƒžãƒ³ãƒ‰ã®æ–‡æ³•] .. link:syntax.html#tokens[トークンã®è§£æžã¨äºˆç´„語] .. link:syntax.html#quotes[クォート] .. link:syntax.html#aliases[エイリアス] .. link:syntax.html#simple[å˜ç´”コマンド] .. link:syntax.html#pipelines[パイプライン] .. link:syntax.html#and-or[And/or リスト] .. link:syntax.html#async[コマンドã®åŒºåˆ‡ã‚Šã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰] .. link:syntax.html#compound[複åˆã‚³ãƒžãƒ³ãƒ‰] ... link:syntax.html#grouping[グルーピング] ... link:syntax.html#if[If æ–‡] ... link:syntax.html#while-until[While ãŠã‚ˆã³ until ループ] ... link:syntax.html#for[For ループ] ... link:syntax.html#case[Case æ–‡] .. link:syntax.html#funcdef[関数定義] . link:params.html[パラメータã¨å¤‰æ•°] .. link:params.html#positional[ä½ç½®ãƒ‘ラメータ] .. link:params.html#special[特殊パラメータ] .. link:params.html#variables[変数] ... link:params.html#shellvars[シェルãŒä½¿ç”¨ã™ã‚‹å¤‰æ•°] ... link:params.html#arrays[é…列] . link:expand.html[å˜èªžã®å±•é–‹] .. link:expand.html#tilde[ãƒãƒ«ãƒ€å±•é–‹] .. link:expand.html#params[パラメータ展開] ... link:expand.html#param-prefix[å‰ç½®è©ž] ... link:expand.html#param-name[パラメータå] ... link:expand.html#param-index[インデックス] ... link:expand.html#param-mod[加工指定] .. link:expand.html#cmdsub[コマンド置æ›] .. link:expand.html#arith[æ•°å¼å±•é–‹] .. link:expand.html#brace[ブレース展開] .. link:expand.html#split[å˜èªžåˆ†å‰²] .. link:expand.html#glob[パスå展開] ... link:expand.html#extendedglob[パスåå±•é–‹ã®æ‹¡å¼µæ©Ÿèƒ½] . link:pattern.html[パターンマッãƒãƒ³ã‚°è¨˜æ³•] .. link:pattern.html#normal[é€šå¸¸ã®æ–‡å­—] .. link:pattern.html#single[一文字ワイルドカード] .. link:pattern.html#multiple[複数文字ワイルドカード] .. link:pattern.html#bracket[ブラケット記法] .. link:pattern.html#bra-normal[(ブラケット記法パターンã«ãŠã‘ã‚‹) é€šå¸¸ã®æ–‡å­—] .. link:pattern.html#bra-range[範囲指定] .. link:pattern.html#bra-colsym[ç…§åˆã‚·ãƒ³ãƒœãƒ«] .. link:pattern.html#bra-eqclass[等価クラス] .. link:pattern.html#bra-chclass[文字クラス] . link:redir.html[リダイレクト] .. link:redir.html#file[ファイルã¸ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ] ... link:redir.html#socket[ソケットリダイレクト] .. link:redir.html#dup[ファイル記述å­ã®è¤‡è£½] .. link:redir.html#here[ヒアドキュメントã¨ãƒ’アストリング] .. link:redir.html#pipe[パイプリダイレクト] .. link:redir.html#process[プロセスリダイレクト] . link:exec.html[コマンドã®å®Ÿè¡Œã¨ãã®ç’°å¢ƒ] .. link:exec.html#simple[å˜ç´”コマンドã®å®Ÿè¡Œ] ... link:exec.html#search[ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢] .. link:exec.html#exit[シェルã®çµ‚了] .. link:exec.html#function[関数] ... link:exec.html#localvar[ローカル変数] .. link:exec.html#environment[コマンドã®å®Ÿè¡Œç’°å¢ƒ] ... link:exec.html#subshell[サブシェル] . link:interact.html[対話モード] .. link:interact.html#prompt[プロンプト] .. link:interact.html#history[コマンド履歴] .. link:interact.html#mailcheck[メールãƒã‚§ãƒƒã‚¯] . link:job.html[ジョブ制御] .. link:job.html#jobid[ジョブ ID] . link:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰] .. link:builtin.html#types[組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡ž] .. link:builtin.html#argsyntax[コマンドã®å¼•æ•°ã®æ§‹æ–‡] . link:lineedit.html[行編集] .. link:lineedit.html#options[行編集ã®ã‚ªãƒ—ション] .. link:lineedit.html#modes[編集モード] .. link:lineedit.html#commands[行編集コマンド] ... link:lineedit.html#basic-commands[基本的ãªç·¨é›†ã‚³ãƒžãƒ³ãƒ‰] ... link:lineedit.html#motion-commands[移動コマンド] ... link:lineedit.html#editing-commands[編集コマンド] ... link:lineedit.html#completion-commands[補完コマンド] ... link:lineedit.html#vi-commands[Vi 固有ã®ã‚³ãƒžãƒ³ãƒ‰] ... link:lineedit.html#emacs-commands[Emacs 固有ã®ã‚³ãƒžãƒ³ãƒ‰] ... link:lineedit.html#history-commands[コマンド履歴関連ã®ã‚³ãƒžãƒ³ãƒ‰] ... link:lineedit.html#search-commands[コマンド履歴検索モードã®ã‚³ãƒžãƒ³ãƒ‰] .. link:lineedit.html#escape[エスケープシーケンス] .. link:lineedit.html#completion[コマンドライン補完] ... link:lineedit.html#completion-detail[補完動作ã®è©³ç´°] . link:posix.html[POSIX 準拠モード] . link:fgrammar.html[æ§‹æ–‡ã®å½¢å¼çš„定義] -- [[builtins]] == 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ `*' ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’〠`+' ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’表ã—ã¾ã™ã€‚ (link:builtin.html#types[組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡ž]ã‚’å‚ç…§) [[alpha-order]] === 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ä¸€è¦§ (アルファベット順) [role="list-group"] - link:_dot.html[+.+ (ドット)] * - link:_colon.html[+:+ (コロン)] * - link:_test.html[+[+ (括弧)] - link:_alias.html[+alias+] + - link:_array.html[+array+] - link:_bg.html[+bg+] + - link:_bindkey.html[+bindkey+] - link:_break.html[+break+] * - link:_cd.html[+cd+] + - link:_command.html[+command+] + - link:_complete.html[+complete+] - link:_continue.html[+continue+] * - link:_dirs.html[+dirs+] - link:_disown.html[+disown+] - link:_echo.html[+echo+] - link:_eval.html[+eval+] * - link:_exec.html[+exec+] * - link:_exit.html[+exit+] * - link:_export.html[+export+] * - link:_false.html[+false+] + - link:_fc.html[+fc+] + - link:_fg.html[+fg+] + - link:_getopts.html[+getopts+] + - link:_hash.html[+hash+] - link:_help.html[+help+] - link:_history.html[+history+] - link:_jobs.html[+jobs+] + - link:_kill.html[+kill+] + - link:_popd.html[+popd+] - link:_printf.html[+printf+] - link:_pushd.html[+pushd+] - link:_pwd.html[+pwd+] + - link:_read.html[+read+] + - link:_readonly.html[+readonly+] * - link:_return.html[+return+] * - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_suspend.html[+suspend+] * - link:_test.html[+test+] - link:_times.html[+times+] * - link:_trap.html[+trap+] * - link:_true.html[+true+] + - link:_type.html[+type+] - link:_typeset.html[+typeset+] - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_unalias.html[+unalias+] + - link:_unset.html[+unset+] * - link:_wait.html[+wait+] + [[groups]] === 種類別組込ã¿ã‚³ãƒžãƒ³ãƒ‰ä¸€è¦§ [[g-control]] ==== 実行制御 [role="list-group"] - link:_eval.html[+eval+] * - link:_dot.html[+.+ (ドット)] * - link:_exec.html[+exec+] * - link:_command.html[+command+] + - link:_hash.html[+hash+] - link:_break.html[+break+] * - link:_continue.html[+continue+] * - link:_return.html[+return+] * - link:_suspend.html[+suspend+] * - link:_exit.html[+exit+] * [[g-environ]] ==== コマンド実行環境関連 [role="list-group"] - link:_set.html[+set+] * - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_trap.html[+trap+] * - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_times.html[+times+] * [[g-job]] ==== ジョブ制御・シグナル関連 [role="list-group"] - link:_jobs.html[+jobs+] + - link:_fg.html[+fg+] + - link:_bg.html[+bg+] + - link:_wait.html[+wait+] + - link:_disown.html[+disown+] - link:_kill.html[+kill+] + - link:_trap.html[+trap+] * [[g-variable]] ==== パラメータ・変数関連 [role="list-group"] - link:_typeset.html[+typeset+] - link:_export.html[+export+] * - link:_readonly.html[+readonly+] * - link:_array.html[+array+] - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_read.html[+read+] + - link:_getopts.html[+getopts+] + - link:_unset.html[+unset+] * [[g-directory]] ==== 作業ディレクトリ関連 [role="list-group"] - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_pushd.html[+pushd+] - link:_popd.html[+popd+] - link:_dirs.html[+dirs+] [[g-alias]] ==== エイリアス関連 [role="list-group"] - link:_alias.html[+alias+] + - link:_unalias.html[+unalias+] + [[g-history]] ==== コマンド履歴関連 [role="list-group"] - link:_fc.html[+fc+] + - link:_history.html[+history+] [[g-print]] ==== 文字列出力 [role="list-group"] - link:_echo.html[+echo+] - link:_printf.html[+printf+] [[g-lineedit]] ==== 行編集関連 [role="list-group"] - link:_bindkey.html[+bindkey+] - link:_complete.html[+complete+] [[g-misc]] ==== ãã®ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ [role="list-group"] - link:_help.html[+help+] - link:_colon.html[+:+ (コロン)] * - link:_true.html[+true+] + - link:_false.html[+false+] + - link:_test.html[+[+ (括弧), +test+] - link:_type.html[+type+] // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/asciidoc.css0000644000175000017500000000342612154557026016202 0ustar magicantmagicanthtml, body { color: black; background: white; } body { margin: 1em 5%; text-align: justify; } h1, h2, h3, h4, h5, h6 { padding: 0; padding-left: 0.5em; border-style: none none solid solid; border-bottom-width: 1px; } h1, h2, h3 { margin: 1em -3.5% 0.5em; } h4, h5, h6 { margin: 1em -2.5% 0.5em; } h1 { border-color: orange; border-left-width: 1em; } h2 { border-color: navy; border-left-width: 0.7em; } h3 { border-color: green; border-left-width: 0.5em; } .sectionbody { /*margin: 0 3%;*/ } #footer { margin: 1em -3% 0; font-size: small; border: none; border-top: 2px solid silver; } .title { border-bottom: 1px solid maroon; font-weight: bold; } .list-group p { margin-top: 0.2em; margin-bottom: 0.2em; } .admonitionblock td.icon { vertical-align: top; padding-right: 0.5em; } .exampleblock { margin: 0.8em auto; border: 0.15em dotted maroon; padding: 0 0.5em; } .exampleblock > .title { margin-top: 0.5em; } ul, ol { list-style-position: outside; } ol.arabic { list-style-type: decimal; } ol.loweralpha { list-style-type: lower-alpha; } ol.upperalpha { list-style-type: upper-alpha; } ol.lowerroman { list-style-type: lower-roman; } ol.upperroman { list-style-type: upper-roman; } li p { margin-top: 0.65em; margin-bottom: 0.65em; } dd p { margin-top: 0.1em; margin-bottom: 0.65em; } pre { border: dashed 1px gray; padding: 0.3em; } code, kbd, samp { border: dotted 1px gray; padding: 1px; text-decoration: none; white-space: pre-wrap; } pre > code:only-child, pre > kbd:only-child, pre > samp:only-child { display: block; } pre code, pre kbd, pre samp { white-space: inherit; } code { background: #efe; } kbd { background: #ffd; } samp { background: #eef; } var { color: maroon; background: inherit; } dfn { font-style: normal; font-weight: bold; } yash-2.35/doc/ja/expand.txt0000644000175000017500000007075412154557026015742 0ustar magicantmagicant= å˜èªžã®å±•é–‹ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - å˜èªžã®å±•é–‹ :description: Yash ãŒã‚µãƒãƒ¼ãƒˆã™ã‚‹å˜èªžå±•é–‹ã«ã¤ã„㦠コマンドを構æˆã™ã‚‹å„å˜èªžã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã¨ãã«å±•é–‹ã•れã¾ã™ã€‚dfn:[展開]ã¨ã¯å˜èªžã«å«ã¾ã‚Œã‚‹ãƒ‘ラメータやパターンを処ç†ã—ã¦å…·ä½“çš„ãªæ–‡å­—列値ã«ç½®ãæ›ãˆã‚‹ã“ã¨ã§ã™ã€‚展開ã«ã¯ä»¥ä¸‹ã®ä¸ƒç¨®é¡žãŒã‚りã¾ã™ã€‚ . <> . <> . <> . <> . <> . <> . <> ã“れらã®å±•é–‹ã¯ä¸Šã«æŒ™ã’ãŸé †åºã§è¡Œã‚れã¾ã™ã€‚ç‰¹ã«æœ€åˆã®å››ã¤ (ãƒãƒ«ãƒ€å±•開・パラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹) ã‚’dfn:[四種展開]ã¨ã„ã„ã¾ã™ã€‚ [[tilde]] == ãƒãƒ«ãƒ€å±•é–‹ dfn:[ãƒãƒ«ãƒ€å±•é–‹]ã¯ã€+~+ ã§å§‹ã¾ã‚‹å˜èªžã‚’特定ã®ãƒ‘スåã«ç½®ãæ›ãˆã‚‹å±•é–‹ã§ã™ã€‚å˜èªžã®å…ˆé ­ã«ã‚ã‚‹ +~+ ã‹ã‚‰æœ€åˆã® +/+ ã¾ã§ (+/+ ãŒãªã„å ´åˆã¯å˜èªžå…¨ä½“) ãŒæŒ‡å®šã•れãŸãƒ‘スåã«å¤‰æ›ã•れã¾ã™ã€‚ãŸã ã—ã€ç½®ãæ›ãˆã‚‰ã‚Œã‚‹éƒ¨åˆ†ãŒä¸€æ–‡å­—ã§ã‚‚link:syntax.html#quotes[クォート]ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãƒãƒ«ãƒ€å±•é–‹ã¯è¡Œã‚れã¾ã›ã‚“。 展開ã•れる内容ã¯ã€ç½®ãæ›ãˆã‚‰ã‚Œã‚‹éƒ¨åˆ†ã®æ›¸å¼ã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«æ±ºã¾ã‚Šã¾ã™ã€‚ +~+:: å˜ãªã‚‹ +~+ ã¯ã€link:params.html#sv-home[+HOME+ 変数]ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ +~{{username}}+:: +~+ ã®å¾Œã«ãƒ¦ãƒ¼ã‚¶åãŒæ›¸ã‹ã‚Œã¦ã„ã‚‹å ´åˆã¯ã€ãã®ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スåã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ +~++:: +~++ ã¯ã€link:params.html#sv-pwd[+PWD+ 変数]ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ +~-+:: +~-+ ã¯ã€link:params.html#sv-oldpwd[+OLDPWD+ 変数]ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ +~+{{n}}+:: +~-{{n}}+:: ã“ã® {{n}} 㯠0 ä»¥ä¸Šã®æ•´æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®å½¢å¼ã®ãƒãƒ«ãƒ€å±•é–‹ã¯ã€+{{n}} ã¾ãŸã¯ -{{n}} ã§æŒ‡å®šã•れるディレクトリスタック内ã®ãƒ‘スã®ä¸€ã¤ã«å±•é–‹ã•れã¾ã™ã€‚(link:_dirs.html[dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]å‚ç…§) 変数代入ã®å€¤ã«å¯¾ã—ã¦ãƒãƒ«ãƒ€å±•é–‹ãŒè¡Œã‚れる際ã€å€¤ãŒã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦ã‚ã‚‹å ´åˆã¯ã€ã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦ã‚ã‚‹å„部分をãれãžã‚Œå˜èªžã¨ã¿ãªã—ã¦ãƒãƒ«ãƒ€å±•é–‹ã—ã¾ã™ã€‚例ãˆã° +HOME+ 変数ã®å€¤ãŒ +/home/foo+ ã®ã¨ã〠---- VAR=~/a:~/b:~/c ---- 㯠---- VAR=/home/foo/a:/home/foo/b:/home/foo/c ---- ã¨ç­‰ä¾¡ã§ã™ã€‚ ãƒãƒ«ãƒ€å±•é–‹ã«å¤±æ•—ã—ãŸå ´åˆ (指定ã•れãŸãƒ‘スåãŒä½•らã‹ã®åŽŸå› ã§å¾—られãªã‹ã£ãŸå ´åˆ) ã®å‹•作㯠POSIX ã§ã¯è¦å®šã•れã¦ã„ã¾ã›ã‚“ãŒã€yash ã§ã¯ä½•事もãªã‹ã£ãŸã‹ã®ã‚ˆã†ã«å‡¦ç†ã‚’続行ã—ã¾ã™ (ç½®ãæ›ãˆã‚‰ã‚Œã‚‹ã¯ãšã ã£ãŸéƒ¨åˆ†ã¯ãã®ã¾ã¾æ®‹ã•れã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãªã©ã¯å‡ºã¾ã›ã‚“)。 link:posix.html[POSIX 準拠モード]ã§ã¯ +~+ 㨠+~{{ユーザå}}+ ã®å½¢å¼ã®å±•é–‹ã®ã¿ãŒæœ‰åйã§ã™ã€‚ [[params]] == パラメータ展開 dfn:[パラメータ展開]ã¯ã€å˜èªžã®ä¸€éƒ¨ã‚’パラメータã®å€¤ã«ç½®ãæ›ãˆã‚‹å±•é–‹ã§ã™ã€‚ よã使ã‚れるå˜ç´”ãªãƒ‘ラメータ展開ã®å½¢å¼ã¯ +${{{パラメータå}}}+ ã§ã™ã€‚ã“れã¯{{パラメータå}}ã§æŒ‡å®šã•れãŸãƒ‘ラメータã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚ã•らã«ã€ä»¥ä¸‹ã®å ´åˆã«ã¯{{パラメータå}}を囲む括弧をçœç•¥ã—㦠+${{パラメータå}}+ ã®ã‚ˆã†ã«æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ã€‚ - {{パラメータå}}ãŒlink:params.html#special[特殊パラメータ]ã®å ´åˆ - {{パラメータå}}ãŒä¸€æ¡ã®link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã®å ´åˆ - {{パラメータå}}ãŒå¤‰æ•°åã§ã€ç›´å¾Œã«å¤‰æ•°åã®ä¸€éƒ¨ã¨ã—ã¦èª¤è§£ã•れるæã‚Œã®ã‚る文字ãŒãªã„å ´åˆã€‚例ãˆã° +${path}-name+ ã¨ã„ã†å˜èªžã¯ +$path-name+ ã¨æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ãŒã€ +${path}name+ ã‚’ +$pathname+ ã¨æ›¸ãã“ã¨ã¯ã§ãã¾ã›ã‚“。 {{パラメータå}}ã¨ã—ã¦ç‰¹æ®Šãƒ‘ラメータã§ã‚‚ä½ç½®ãƒ‘ラメータã§ã‚‚変数åã§ã‚‚ãªã„ã‚‚ã®ã‚’指定ã—ãŸå ´åˆã¯ã€æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚(Yash 以外ã®ã‚·ã‚§ãƒ«ã§ã¯æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã§ã¯ãªã展開エラーã«ãªã‚‹ã‚‚ã®ã‚‚ã‚りã¾ã™) シェル㮠link:_set.html#so-unset[unset オプション]ãŒç„¡åйãªå ´åˆã€{{パラメータå}}ã«å­˜åœ¨ã—ãªã„変数を指定ã™ã‚‹ã¨å±•開エラーã«ãªã‚Šã¾ã™ã€‚Unset ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªå ´åˆã¯ã€å­˜åœ¨ã—ãªã„変数ã¯ç©ºæ–‡å­—列ã«å±•é–‹ã•れã¾ã™ã€‚ より複雑ãªãƒ‘ラメータ展開ã®å½¢å¼ã§ã¯ã€ãƒ‘ラメータã®å€¤ã‚’加工ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚パラメータ展開ã®ä¸€èˆ¬å½¢ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ パラメータ展開:: +${ {{å‰ç½®è©ž}} {{パラメータå}} {{インデックス}} {{加工指定}} }+ ã“ã“ã§ã¯ä¾¿å®œä¸Š{{パラメータå}}ã‚„{{インデックス}}ã®å‘¨ã‚Šã«ç©ºç™½ã‚’入れã¾ã—ãŸãŒã€å®Ÿéš›ã«ã¯ç©ºç™½ã‚’入れã¦ã¯ã„ã‘ã¾ã›ã‚“。{{パラメータå}}以外ã®éƒ¨åˆ†ã¯ã„ãšã‚Œã‚‚çœç•¥å¯èƒ½ã§ã™ã€‚ [[param-prefix]] === å‰ç½®è©ž {{å‰ç½®è©ž}}ã¨ã—ã¦{{パラメータå}}ã®ç›´å‰ã«è¨˜å· +#+ ã‚’ç½®ãã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚展開ã—よã†ã¨ã—ã¦ã„ã‚‹ã®ãŒé…列変数ã®å ´åˆã€å„è¦ç´ ãŒãれãžã‚Œæ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ [[param-name]] === パラメータå {{パラメータå}}ã«ã¯ã€link:params.html#special[特殊パラメータ]・link:params.html#positional[ä½ç½®ãƒ‘ラメータ]・変数を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿å±•é–‹ã¯æŒ‡å®šã•れãŸãƒ‘ラメータã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚指定ã—ãŸ{{パラメータå}}ãŒlink:params.html#arrays[é…列]変数ã®å ´åˆã€é…列ã®å„è¦ç´ ãŒç‰¹æ®Šãƒ‘ラメータ +@+ ã®å ´åˆã¨åŒæ§˜ã«å˜èªžåˆ†å‰²ã•れã¾ã™ (インデックス +[*]+ ãŒæŒ‡å®šã•れãŸå ´åˆã‚’除ã)。 {{パラメータå}}ã¨ã—ã¦ãƒ‘ラメータ展開・<>・<>を指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“れã¯ç‰¹ã«dfn:[展開ã®å…¥ã‚Œå­]ã¨è¨€ã„ã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘ラメータ展開ã¯å†…å´ã®å±•é–‹ã®å±•é–‹çµæžœã«å±•é–‹ã•れã¾ã™ã€‚ãªãŠã€å†…å´ã®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿å±•é–‹ã®æ‹¬å¼§ +{ }+ ã¯çœç•¥ã§ãã¾ã›ã‚“。ã¾ãŸå±•é–‹ã®å…¥ã‚Œå­ã¯ link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 [[param-index]] === インデックス {{インデックス}}ã¯å±•é–‹ã™ã‚‹å€¤ã®ä¸€éƒ¨ã‚’抜ã出ã™ã®ã«ä½¿ã„ã¾ã™ã€‚インデックスã¯ä»¥ä¸‹ã®æ›¸å¼ã‚’ã—ã¦ã„ã¾ã™ã€‚ インデックス:: +[{{å˜èªž1}}]+ + +[{{å˜èªž1}},{{å˜èªž2}}]+ ã“ã“ã§ã®{{å˜èªž1}}ãŠã‚ˆã³{{å˜èªž2}}ã¯é€šå¸¸ã®link:syntax.html#tokens[トークン]ã¨åŒæ§˜ã«è§£é‡ˆã•れã¾ã™ãŒã€+,+ 㨠+]+ ã§å¼·åˆ¶çš„ã«åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ã¾ãŸç©ºç™½ã‚„タブã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ã¯ã¿ãªã—ã¾ã›ã‚“。 インデックスã¯ã€ä»¥ä¸‹ã®ã‚ˆã†ã«è§£é‡ˆã•れã¾ã™ã€‚ . ã¾ãšã€{{インデックス}}ã«å«ã¾ã‚Œã‚‹{{å˜èªž1}}・{{å˜èªž2}}ã«å¯¾ã—ã¦ãƒ‘ラメータ展開・<>・<>を行ã„ã¾ã™ã€‚ . {{インデックス}}㌠+[{{å˜èªž1}}]+ ã®æ›¸å¼ã‚’ã—ã¦ã„ã¦ã€{{å˜èªž1}}ã®ä¸Šè¨˜å±•é–‹çµæžœãŒ ++*++ã€++@++ã€++#++ ã®ã„ãšã‚Œã‹ã®å ´åˆã¯ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®è§£é‡ˆã¯çµ‚了ã§ã™ã€‚ . {{å˜èªž1}}ã¨{{å˜èªž2}}ã®ä¸Šè¨˜å±•é–‹çµæžœã‚’æ•°å¼ã¨ã¿ãªã—ã¦ã€æ•°å¼å±•é–‹ã¨åŒæ§˜ã«è¨ˆç®—ã—ã¾ã™ã€‚計算ã®çµæžœå¾—られる整数ãŒã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¨ãªã‚Šã¾ã™ã€‚æ•°å¼å±•é–‹ã®çµæžœãŒæ•´æ•°ã§ãªã„å ´åˆã¯å±•開エラーã§ã™ã€‚{{å˜èªž2}}ãŒãªã„å½¢å¼ã§ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’指定ã—ã¦ã„ã‚‹å ´åˆã¯ã€{{å˜èªž2}}ã¯{{å˜èªž1}}ã¨åŒã˜æ•´æ•°ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚ {{パラメータå}}ãŒlink:params.html#arrays[é…列]変数ã®å ´åˆã¾ãŸã¯ç‰¹æ®Šãƒ‘ラメータ link:params.html#sp-asterisk[+*+] ã¾ãŸã¯ link:params.html#sp-at[+@+] ã®å ´åˆã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯é…列ã®è¦ç´ ã¾ãŸã¯ä½ç½®ãƒ‘ラメータã®ä¸€éƒ¨ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚{{パラメータå}}ãŒä¸Šè¨˜ä»¥å¤–ã®å ´åˆã¯ã€ãƒ‘ラメータã®å€¤ã®ä¸€éƒ¨ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚インデックスã§é¸æŠžã•れãŸé…列ã®è¦ç´ ã¾ãŸã¯ãƒ‘ラメータã®å€¤ã®ä¸€éƒ¨ã®ã¿ãŒã€ãƒ‘ラメータ展開ã®çµæžœã¨ã—ã¦å±•é–‹çµæžœã«æ®‹ã‚Šã¾ã™ã€‚インデックスã«ã‚ˆã‚‹é¸æŠžã«ã¤ã„ã¦ä»¥ä¸‹ã®è¦å‰‡ãŒé©ç”¨ã•れã¾ã™ã€‚ - ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ãŒè² æ•°ã®ã¨ãã¯ã€è¦ç´ ã¾ãŸã¯æ–‡å­—を最後ã‹ã‚‰æ•°ãˆã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚例ãˆã°ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +[-2,-1]+ ã¯é…åˆ—ã®æœ€å¾Œã®äºŒã¤ã®è¦ç´  (ã¾ãŸã¯ãƒ‘ラメータã®å€¤ã®æœ€å¾Œã® 2 文字) ã‚’é¸æŠžã—ã¾ã™ã€‚ - ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ãŒå­˜åœ¨ã—ãªã„è¦ç´ ã¾ãŸã¯æ–‡å­—を指示ã—ã¦ã„ã‚‹å ´åˆã§ã‚‚ã€ã‚¨ãƒ©ãƒ¼ã«ã¯ãªã‚Šã¾ã›ã‚“。例ãˆã°é…列ã®è¦ç´ æ•°ãŒ 4 ã®ã¨ãã«ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +[3,5]+ ãŒä¸Žãˆã‚‰ã‚ŒãŸã¨ã㯠3 番目以é™ã®å…¨ã¦ã®è¦ç´ ãŒé¸æŠžã•れã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +[5,7]+ ãŒä¸Žãˆã‚‰ã‚ŒãŸæ™‚ã¯ã©ã®è¦ç´ ã‚‚é¸æŠžã•れã¾ã›ã‚“。 - ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ã®ä¸€æ–¹ãŒ 0 ãªã‚‰ã°ã€(ã‚‚ã†ä¸€æ–¹ãŒä½•ã§ã‚れ) å±•é–‹çµæžœã«ã¯ä½•も残りã¾ã›ã‚“。 {{インデックス}}㌠+[{{å˜èªž1}}]+ ã®æ›¸å¼ã‚’ã—ã¦ã„ã¦ã€{{å˜èªž1}}ã®å±•é–‹çµæžœãŒ ++*++ã€++@++ã€++#++ ã®ã„ãšã‚Œã‹ã ã£ãŸå ´åˆã¯ã€ãƒ‘ラメータã¯ä»¥ä¸‹ã®ã‚ˆã†ã«å‡¦ç†ã•れã¾ã™ã€‚ +*+:: {{パラメータå}}ãŒé…列変数ã®å ´åˆã€é…列ã®å…¨è¦ç´ ã‚’連çµã—一ã¤ã®æ–‡å­—列ã«ã—ã¾ã™ã€‚{{パラメータå}}ãŒç‰¹æ®Šãƒ‘ラメータ +*+ ã¾ãŸã¯ +@+ ã®å ´åˆã€å…¨ã¦ã®ä½ç½®ãƒ‘ラメータを連çµã—一ã¤ã®æ–‡å­—列ã«ã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +[1,-1]+ ã¨åŒæ§˜ã§ã™ã€‚(連çµã®ä»•æ–¹ã¯link:params.html#sp-asterisk[特殊パラメータ +*+] ã®ä½ç½®ãƒ‘ラメータã®é€£çµã®ä»•æ–¹ã¨åŒã˜ã§ã™) +@+:: インデックス +[1,-1]+ ã¨åŒæ§˜ã§ã™ã€‚ +#+:: {{パラメータå}}ãŒé…列変数ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯é…列ã®è¦ç´ æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚{{パラメータå}}ãŒç‰¹æ®Šãƒ‘ラメータ +*+ ã¾ãŸã¯ +@+ ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚ãれ以外ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚ パラメータ展開ã«{{インデックス}}ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€{{インデックス}}ã¨ã—㦠+[@]+ ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚{{インデックス}}ã¯link:posix.html[POSIX 準拠モード]ã§ã¯ä¸€åˆ‡ä½¿ãˆã¾ã›ã‚“。 .通常ã®å¤‰æ•°ã®å±•é–‹ ==== 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 +ABC+ を出力ã—ã¾ã™: ---- var='123ABC789' echo "${var[4,6]}" ---- ==== .ä½ç½®ãƒ‘ラメータã®å±•é–‹ ==== 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 +2 3 4+ を出力ã—ã¾ã™: ---- set 1 2 3 4 5 echo "${*[2,-2]}" ---- ==== .é…列ã®å±•é–‹ ==== 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 +2 3 4+ を出力ã—ã¾ã™: ---- array=(1 2 3 4 5) echo "${array[2,-2]}" ---- ==== [[param-mod]] === 加工指定 {{加工指定}}ã¯ãƒ‘ラメータã®å€¤ã‚’加工ã—ã¾ã™ã€‚加工ã•れãŸå¾Œã®å€¤ãŒãƒ‘ラメータ展開ã®çµæžœã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚加工指定ã«ã¯ä»¥ä¸‹ã®å½¢å¼ãŒã‚りã¾ã™ã€‚ +-{{å˜èªž}}+:: {{パラメータå}}ãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã“ã®ãƒ‘ラメータ展開ã¯{{å˜èªž}}ã«å±•é–‹ã•れã¾ã™ã€‚(link:_set.html#so-unset[Unset オプション]ãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“) ++{{å˜èªž}}+:: {{パラメータå}}ãŒå­˜åœ¨ã™ã‚‹å¤‰æ•°ã‚’指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã“ã®ãƒ‘ラメータ展開ã¯{{å˜èªž}}ã«å±•é–‹ã•れã¾ã™ã€‚(link:_set.html#so-unset[Unset オプション]ãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“) +={{å˜èªž}}+:: {{パラメータå}}ãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€{{å˜èªž}}ã®å±•é–‹çµæžœãŒãã®å¤‰æ•°ã«ä»£å…¥ã•れãŸå¾Œã€ã“ã®ãƒ‘ラメータ展開ã¯ãã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚変数以外ã®ã‚‚ã®ã«å¯¾ã—ã¦ä»£å…¥ã—よã†ã¨ã™ã‚‹ã¨å±•開エラーã«ãªã‚Šã¾ã™ã€‚(link:_set.html#so-unset[Unset オプション]ãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“) +?{{å˜èªž}}+:: {{パラメータå}}ãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¨ã—ã¦{{å˜èªž}}を標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚({{å˜èªž}}ãŒãªã„å ´åˆã¯ãƒ‡ãƒ•ォルトã®ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒå‡ºã¾ã™) +:-{{å˜èªž}}+:: +:+{{å˜èªž}}+:: +:={{å˜èªž}}+:: +:?{{å˜èªž}}+:: ã“れらã¯ä¸Šè¨˜ã® ++-++ã€+++++ã€++=++ã€++?++ ã¨{{å˜èªž}}ã®çµ„ã¿åˆã‚ã›ã®åŠ å·¥æŒ‡å®šã¨åŒæ§˜ã§ã™ãŒã€{{å˜èªž}}を使用ã™ã‚‹æ¡ä»¶ãŒç•°ãªã‚Šã¾ã™ã€‚先頭㫠+:+ ãŒä»˜ã‹ãªã„ã‚‚ã®ã§ã¯ ``変数ãŒå­˜åœ¨ã™ã‚‹ã‹ã©ã†ã‹'' ã§åˆ¤å®šã•れã¾ã™ãŒã€+:+ ãŒä»˜ãã‚‚ã®ã§ã¯ ``変数ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹'' ã§åˆ¤å®šã•れã¾ã™ã€‚ +#{{å˜èªž}}+:: {{å˜èªž}}ã‚’link:pattern.html[パターン]ã¨ã—ã¦è¦‹ãŸã¨ãã€ãれãŒã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®å…ˆé ­éƒ¨åˆ†ã«ãƒžãƒƒãƒã™ã‚‹ãªã‚‰ã°ã€ãã®ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã‚’削除ã—ã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã“ã®ãƒ‘ラメータ展開ã¯ãƒžãƒƒãƒã—ãªã‹ã£ãŸæ®‹ã‚Šã®éƒ¨åˆ†ã«å±•é–‹ã•れã¾ã™ã€‚マッãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘短ãマッãƒã•ã›ã¾ã™ã€‚ +##{{å˜èªž}}+:: ã“ã®åŠ å·¥æŒ‡å®šã¯ +#{{å˜èªž}}+ ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ +%{{å˜èªž}}+:: ã“ã®åŠ å·¥æŒ‡å®šã¯ +#{{å˜èªž}}+ ã¨åŒæ§˜ã§ã™ãŒã€å€¤ã®å…ˆé ­éƒ¨åˆ†ã§ã¯ãªã末尾部分ã«ãƒžãƒƒãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ +%%{{å˜èªž}}+:: ã“ã®åŠ å·¥æŒ‡å®šã¯ +%{{å˜èªž}}+ ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ +/{{å˜èªž1}}/{{å˜èªž2}}+:: {{å˜èªž1}}をパターンã¨ã—ã¦è¦‹ãŸã¨ãã€ãれãŒã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®ä¸€éƒ¨ã«ãƒžãƒƒãƒã™ã‚‹ãªã‚‰ã°ã€ãã®ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã‚’{{å˜èªž2}}ã«ç½®ãæ›ãˆã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã“ã®ãƒ‘ラメータ展開ã¯ãƒžãƒƒãƒã—ãŸéƒ¨åˆ†ã‚’{{å˜èªž2}}ã«ç½®ãæ›ãˆãŸå€¤ã«å±•é–‹ã•れã¾ã™ã€‚マッãƒã™ã‚‹ç®‡æ‰€ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ã€æœ€åˆã®ç®‡æ‰€ãŒé¸ã°ã‚Œã¾ã™ã€‚マッãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã¾ã™ã€‚ + ã“ã®åŠ å·¥æŒ‡å®šã¯ link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 +/#{{å˜èªž1}}/{{å˜èªž2}}+:: ã“ã®åŠ å·¥æŒ‡å®šã¯ +/{{å˜èªž1}}/{{å˜èªž2}}+ ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®å…ˆé ­éƒ¨åˆ†ã«ã—ã‹ãƒžãƒƒãƒã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚ +/%{{å˜èªž1}}/{{å˜èªž2}}+:: ã“ã®åŠ å·¥æŒ‡å®šã¯ +/{{å˜èªž1}}/{{å˜èªž2}}+ ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æœ«å°¾éƒ¨åˆ†ã«ã—ã‹ãƒžãƒƒãƒã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚ +//{{å˜èªž1}}/{{å˜èªž2}}+:: ã“ã®åŠ å·¥æŒ‡å®šã¯ +/{{å˜èªž1}}/{{å˜èªž2}}+ ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã™ã‚‹ç®‡æ‰€ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯æœ€åˆã®ç®‡æ‰€ã ã‘ã§ã¯ãªãå…¨ã¦ã®ç®‡æ‰€ã‚’{{å˜èªž2}}ã«ç½®ãæ›ãˆã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ +:/{{å˜èªž1}}/{{å˜èªž2}}+:: ã“ã®åŠ å·¥æŒ‡å®šã¯ +/{{å˜èªž1}}/{{å˜èªž2}}+ ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値全体ã«ãƒžãƒƒãƒã™ã‚‹å ´åˆã—ã‹å¯¾è±¡ã¨ã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚ ã„ãšã‚Œã®å½¢å¼ã«ãŠã„ã¦ã‚‚ã€åŠ å·¥æŒ‡å®šã«å«ã¾ã‚Œã‚‹å˜èªžã¯ (ãれãŒä½¿ç”¨ã•れるã¨ãã®ã¿) 四種展開ã•れã¾ã™ã€‚ 展開ã—よã†ã¨ã—ã¦ã„ã‚‹{{パラメータå}}ãŒé…列変数ã¾ãŸã¯ç‰¹æ®Šãƒ‘ラメータ link:params.html#sp-at[+@+] ã¾ãŸã¯ link:params.html#sp-asterisk[+*+] ã®å ´åˆã€åŠ å·¥æŒ‡å®šã¯é…列ã®å„è¦ç´ ã¾ãŸã¯å„ä½ç½®ãƒ‘ラメータã«å¯¾ã—ã¦ãれãžã‚Œä½œç”¨ã—ã¾ã™ã€‚ [[cmdsub]] == ã‚³ãƒžãƒ³ãƒ‰ç½®æ› dfn:[コマンド置æ›]ã¯ã€æŒ‡å®šã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ãã®å‡ºåŠ›ã‚’ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å±•é–‹ã—ã¾ã™ã€‚コマンド置æ›ã®æ›¸å¼ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ コマンド置æ›:: +$({{コマンド}})+ + +`{{コマンド}}`+ コマンド置æ›ã§ã¯ã€{{コマンド}}ãŒlink:exec.html#subshell[サブシェル]ã§å®Ÿè¡Œã•れã¾ã™ã€‚ã“ã®ã¨ãã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ãŒãƒ‘イプを通ã˜ã¦ã‚·ã‚§ãƒ«ã«é€ã‚‰ã‚Œã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å‡ºåŠ›çµæžœã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã®å‡ºåŠ›ã®æœ«å°¾ã«ã‚る改行ã¯é™¤ãã¾ã™ã€‚ +$(+ 㨠+)+ ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®{{コマンド}}ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®å…¥ã‚Œå­ã‚„リダイレクトãªã©ã‚’考慮ã—ã¦äºˆã‚è§£æžã•れã¾ã™ã€‚従ã£ã¦ã€+$(+ 㨠+)+ ã®é–“ã«ã¯åŸºæœ¬çš„ã«é€šå¸¸é€šã‚Šã‚³ãƒžãƒ³ãƒ‰ã‚’書ãã“ã¨ãŒã§ãã¾ã™ã€‚ãŸã ã—ã€<>ã¨ã®æ··åŒã‚’é¿ã‘ã‚‹ãŸã‚ã€ä¸­ã®{{コマンド}}㌠+(+ ã§å§‹ã¾ã‚‹å ´åˆã¯{{コマンド}}ã®æœ€åˆã«ç©ºç™½ã‚’æŒ¿ã—æŒŸã‚“ã§ãã ã•ã„。 +`+ ã§å›²ã‚€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®å…¥ã‚Œå­ãªã©ã¯è€ƒæ…®ã›ãšã«ã€{{コマンド}}ã®ä¸­ã«æœ€åˆã« (ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§link:syntax.html#quotes[クォート]ã—ã¦ã„ãªã„) +`+ ãŒç¾ã‚ŒãŸã¨ã“ã‚ã§ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®çµ‚ã‚りã¨ã¿ãªã•れã¾ã™ã€‚+`+ ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã« +`+ ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚’書ãå ´åˆã¯ã€å†…å´ã® +`+ ã‚’ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ãã®ä»–ã€{{コマンド}}ã®ä¸€éƒ¨ã¨ã—㦠+`+ を入れãŸã„ã¨ãã¯ã€(ãれãŒ{{コマンド}}内部ã§ä¸€é‡ã¾ãŸã¯äºŒé‡å¼•用符ã§ã‚¯ã‚©ãƒ¼ãƒˆã•れã¦ã„ã¦ã‚‚) ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ +$(+ 㨠+)+ ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚’å«ã‚€ã‚³ãƒžãƒ³ãƒ‰ã‚’è§£æžã™ã‚‹æ™‚ã«ä¸€ç·’ã«è§£æžã•れã¾ã™ (link:posix.html[POSIX 準拠モード]を除ã)。+`+ ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«é–¢ã‚らãšã€ãã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒå®Ÿè¡Œã•ã‚Œã‚‹æ™‚ã«æ¯Žå›žè§£æžã•れã¾ã™ã€‚ [[arith]] == æ•°å¼å±•é–‹ dfn:[æ•°å¼å±•é–‹]ã¯ã€æ–‡å­—列を数å¼ã¨ã—ã¦è§£é‡ˆã—ã¦ã€ãã®è¨ˆç®—çµæžœã‚’è¡¨ã™æ•°å€¤ã«å±•é–‹ã—ã¾ã™ã€‚æ•°å¼å±•é–‹ã®æ›¸å¼ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚ æ•°å¼å±•é–‹:: +$(({{å¼}}))+ æ•°å¼å±•é–‹ã§ã¯ã€ã¾ãš{{å¼}}ã«å¯¾ã—ã¦<>・<>・(入れå­ã®) æ•°å¼å±•é–‹ãŒè¡Œã‚れã¾ã™ã€‚ãã®çµæžœå¾—ã‚‰ã‚ŒãŸæ–‡å­—列を以下ã®ã‚ˆã†ã«æ•°å¼ã¨ã—ã¦è§£é‡ˆã—ã€ãã®è¨ˆç®—çµæžœã‚’è¡¨ã™æ•°å€¤ã«å±•é–‹ã•れã¾ã™ã€‚ Yash ã§ã¯ã€æ•°å¼ã®ä¸­ã§æ•´æ•° (C 言語㮠long åž‹) ã¨æµ®å‹•å°æ•°ç‚¹æ•° (C 言語㮠double åž‹) を扱ã†ã“ã¨ãŒã§ãã¾ã™ã€‚ãŸã ã— link:posix.html[POSIX 準拠モード]ã§ã¯æµ®å‹•å°æ•°ç‚¹æ•°ã¯ä½¿ãˆã¾ã›ã‚“。整数åŒå£«ã®æ¼”ç®—ã®çµæžœã¯æ•´æ•°ã«ã€æµ®å‹•å°æ•°ç‚¹æ•°ã‚’å«ã‚€æ¼”ç®—ã®çµæžœã¯æµ®å‹•å°æ•°ç‚¹æ•°ã«ãªã‚Šã¾ã™ã€‚ æ•°å¼ã§ã¯ C 言語㨠(ã»ã¼) åŒæ§˜ã«ä»¥ä¸‹ã®æ¼”ç®—å­ãŒä½¿ãˆã¾ã™ã€‚ . +( )+ . `++` +--+ (後置演算å­) . `++` +--+ `+` +-+ +~+ +!+ (å‰ç½®æ¼”ç®—å­) . +*+ +/+ +%+ . `+` +-+ (二項演算å­) . +<<+ +>>+ . +<+ +<=+ +>+ +>=+ . +==+ +!=+ . +&+ . +^+ . +|+ . +&&+ . +||+ . +? :+ (三項演算å­) . +=+ +*=+ +/=+ +%=+ `+=` +-=+ +<<=+ +>>=+ +&=+ +^=+ +|=+ `++` ãŠã‚ˆã³ `--` 演算å­ã¯ POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。 原å­å¼ã¨ã—ã¦ã¯æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ãƒ»æµ®å‹•å°æ•°ç‚¹æ•°ãƒªãƒ†ãƒ©ãƒ«ãƒ»å¤‰æ•°ãŒä½¿ç”¨ã§ãã¾ã™ã€‚æ•°ãƒªãƒ†ãƒ©ãƒ«ã®æ›¸å¼ã¯ C è¨€èªžã«æº–ã˜ã¾ã™ã€‚+0+ ã§å§‹ã¾ã‚‹æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ã¯å…«é€²æ•°ã€+0x+ ã§å§‹ã¾ã‚‹æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ã¯å六進数ã¨ã¿ãªã•れã¾ã™ã€‚æµ®å‹•å°æ•°ç‚¹æ•°ãƒªãƒ†ãƒ©ãƒ«ã§ã¯æŒ‡æ•°è¡¨è¨˜ã‚‚使ãˆã¾ã™ (例ãˆã° 1.23×10^6^ 㯠+1.23e+6+)。変数ã¯ã€ãã®å€¤ãŒæ•°å€¤ã§ãªã„å ´åˆã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ [[brace]] == ブレース展開 dfn:[ブレース展開]ã¯ã€ãƒ–レース (+{ }+) ã§å›²ã‚“ã éƒ¨åˆ†ã‚’ã„ãã¤ã‹ã®å˜èªžã«åˆ†å‰²ã—ã¾ã™ã€‚ブレース展開㯠link:_set.html#so-braceexpand[brace-expand オプション]ãŒæœ‰åŠ¹ãªæ™‚ã®ã¿è¡Œã‚れã¾ã™ã€‚ブレース展開ã«ã¯äºŒç¨®é¡žã®å½¢å¼ãŒã‚りã¾ã™ã€‚ カンマ区切りã®ãƒ–レース展開:: +{{{å˜èªž1}},{{å˜èªž2}},...,{{å˜èªžn}}}+ 連続ã—ãŸæ•°å€¤ã®ãƒ–レース展開:: +{{{始点}}..{{終点}}}+ + +{{{始点}}..{{終点}}..{{差分}}}+ 一ã¤ç›®ã®å½¢å¼ã¯ã€ãƒ–レースã§å›²ã‚“ã éƒ¨åˆ†ã‚’一ã¤ä»¥ä¸Šã®ã‚«ãƒ³ãƒž (+,+) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚区切られãŸãれãžã‚Œã®éƒ¨åˆ†ãŒãƒ–レース展開ã®å‰å¾Œã®éƒ¨åˆ†ã¨çµåˆã•れã¦ã€ãれãžã‚Œå˜èªžã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚例ãˆã° +a{1,2,3}b+ 㯠++a1b++ã€++a2b++ã€++a3b++ ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚ 二ã¤ç›®ã®å½¢å¼ã¯ +{{{始点}}..{{終点}}}+ ã¾ãŸã¯ +{{{始点}}..{{終点}}..{{差分}}}+ ã§ã™ã€‚{{始点}}・{{終点}}・{{差分}}ã¯å…¨ã¦æ•´æ•°ã§ã‚ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ã“ã®å½¢å¼ã®ãƒ–レース展開ã§ã¯ã€{{始点}}ã‹ã‚‰{{終点}}ã¾ã§ã®å„æ•´æ•°ãŒãƒ–レース展開ã®å‰å¾Œã®éƒ¨åˆ†ã¨çµåˆã•れã¦ã€ãれãžã‚Œå˜èªžã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚{{差分}}ã¯æ•´æ•°ã®é–“隔を指定ã—ã¾ã™ã€‚例ãˆã° +a{1..3}b+ 㯠++a1b++ã€++a2b++ã€++a3b++ ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã€+a{1..7..2}b+ 㯠++a1b++ã€++a3b++ã€++a5b++ã€++a7b++ ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚{{始点}}ãŒ{{終点}}より大ãã„å ´åˆã¯æ•´æ•°ã¯é™é †ã«å±•é–‹ã•れã¾ã™ã€‚ 複数ã®ãƒ–レース展開を組ã¿åˆã‚ã›ãŸã‚Šã€å…¥ã‚Œå­ã«ã—ãŸã‚Šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ブレースをブレース展開ã¨ã—ã¦ã§ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã«ã¯ã€ãƒ–レースをクォートã—ã¦ãã ã•ã„。ã¾ãŸã‚«ãƒ³ãƒžã‚’区切りã¨ã—ã¦ã§ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã«ã¯ã€ã‚«ãƒ³ãƒžã‚’クォートã—ã¦ãã ã•ã„。 ブレース展開ã§ã¯å±•開エラーã¯ç™ºç”Ÿã—ã¾ã›ã‚“ã€‚ãƒ–ãƒ¬ãƒ¼ã‚¹å±•é–‹ãŒæ­£ã—ãã§ããªã„å ´åˆã¯ã€å˜ã«ãれã¯ãƒ–レース展開ã§ã¯ãªã‹ã£ãŸã‚‚ã®ã¨ã—ã¦ã€ãã®ã¾ã¾æ®‹ã•れã¾ã™ã€‚ [[split]] == å˜èªžåˆ†å‰² dfn:[å˜èªžåˆ†å‰²]ã¯ã€å±•é–‹ã®çµæžœã‚’ã„ãã¤ã‹ã®å˜èªžã«åˆ†å‰²ã—ã¾ã™ã€‚ å˜èªžåˆ†å‰²ã§åˆ†å‰²ã®å¯¾è±¡ã¨ãªã‚‹ã®ã¯ã€<>・<>・<>ã§å±•é–‹ã•れãŸçµæžœã®éƒ¨åˆ†ã ã‘ã§ã™ã€‚ã¾ãŸã€äºŒé‡å¼•用符ã«ã‚ˆã‚‹link:syntax.html#quotes[クォート]ã®ä¸­ã§å±•é–‹ã•れãŸéƒ¨åˆ†ã¯ã€(link:params.html#sp-at[特殊パラメータ +@+] ã®å±•開を除ã„ã¦) 分割ã®å¯¾è±¡ã¨ãªã‚Šã¾ã›ã‚“。 å˜èªžåˆ†å‰²ã¯ link:params.html#sv-ifs[+IFS+ 変数]ã®å€¤ã«å¾“ã£ã¦è¡Œã‚れã¾ã™ã€‚+IFS+ 変数ãŒå­˜åœ¨ã—ãªã„å ´åˆã¯ã€ç©ºç™½æ–‡å­—・タブ・改行ã®ä¸‰æ–‡å­—㌠+IFS+ 変数ã®å€¤ã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚ +IFS+ 変数ã®å€¤ã«å«ã¾ã‚Œã¦ã„る文字を dfn:[IFS 文字]ã¨ã„ã„ã¾ã™ã€‚IFS 文字ã®ã†ã¡ç©ºç™½æ–‡å­—ã¾ãŸã¯ã‚¿ãƒ–ã¾ãŸã¯æ”¹è¡Œã§ã‚ã‚‹ã‚‚ã®ã‚’ dfn:[IFS 空白類]ã¨ã„ã„ã¾ã™ã€‚IFS 空白類以外㮠IFS 文字を dfn:[IFS éžç©ºç™½é¡ž]ã¨ã„ã„ã¾ã™ã€‚ 分割ã¯ä»¥ä¸‹ã®è¦å‰‡ã«å¾“ã£ã¦è¡Œã‚れã¾ã™ã€‚ . 分割ã¯ã€åˆ†å‰²ã®å¯¾è±¡ã¨ãªã‚‹å±•é–‹çµæžœã®éƒ¨åˆ†ã®ä¸­ã§ã€IFS 文字ãŒç¾ã‚Œã‚‹ç®‡æ‰€ã§è¡Œã‚れã¾ã™ã€‚以下ã“ã®ã‚ˆã†ãªç®‡æ‰€ã‚’dfn:[分割点]ã¨å‘¼ã³ã¾ã™ã€‚複数㮠IFS 文字ãŒé€£ç¶šã—ã¦ç¾ã‚Œã‚‹å ´åˆã¯ã€ãれらをã¾ã¨ã‚ã¦ä¸€ã¤ã®åˆ†å‰²ç‚¹ã¨ã—ã¾ã™ã€‚ . 分割点㫠IFS éžç©ºç™½é¡žãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ãã®åˆ†å‰²ç‚¹ã«å«ã¾ã‚Œã‚‹ IFS 空白類ã¯ã™ã¹ã¦ç„¡è¦–ã•れã¾ã™ã€‚ãã—ã¦åˆ†å‰²ç‚¹ã«å«ã¾ã‚Œã‚‹å„ IFS éžç©ºç™½é¡žã®å‰å¾Œã§å˜èªžãŒåˆ†å‰²ã•れã¾ã™ã€‚ . 分割点㫠IFS éžç©ºç™½é¡žãŒå«ã¾ã‚Œã¦ã„ãªã„ (分割点㌠IFS 空白類ã ã‘ã‹ã‚‰ãªã‚‹) å ´åˆã€ãã®åˆ†å‰²ç‚¹ã®å‰å¾Œã§å˜èªžãŒåˆ†å‰²ã•れã¾ã™ã€‚ãŸã ã—ã€ã“ã®ã‚ˆã†ãªåˆ†å‰²ç‚¹ãŒå…ƒã®å˜èªžã®å…ˆé ­ã¾ãŸã¯æœ«å°¾ã«ã‚ã‚‹å ´åˆã‚’除ãã¾ã™ã€‚ . ã„ãšã‚Œã®å ´åˆã‚‚ã€åˆ†å‰²ç‚¹ã¯å˜èªžåˆ†å‰²å¾Œã®å˜èªžã«ã¯æ®‹ã‚Šã¾ã›ã‚“。 [NOTE] +IFS+ 変数ã®å€¤ãŒç©ºæ–‡å­—列ã®å ´åˆã¯ã€å˜èªžã¯ä¸€åˆ‡åˆ†å‰²ã•れã¾ã›ã‚“。 [[glob]] == パスå展開 dfn:[パスå展開]ã¯ã€å˜èªžã‚’link:pattern.html[パターン]ã¨ã¿ãªã—ã¦ãƒ•ァイルを検索ã—ã€ãƒ‘ターンã«ãƒžãƒƒãƒã™ã‚‹å®Ÿåœ¨ã®ãƒ•ァイルã¸ã®ãƒ‘スåã«å±•é–‹ã—ã¾ã™ã€‚ パスå展開㯠link:_set.html#so-glob[glob オプション]ãŒç„¡åŠ¹ãªæ™‚ã¯è¡Œã‚れã¾ã›ã‚“。 パスå展開ã«ãŠã„ã¦ãƒ‘ターンãŒãƒžãƒƒãƒã™ã‚‹ã«ã¯ã€æ¤œç´¢ã®å¯¾è±¡ã¨ãªã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®èª­ã¿è¾¼ã¿æ¨©é™ãŒå¿…è¦ã§ã™ã€‚検索ã—よã†ã¨ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒã‚·ã‚§ãƒ«ã«ã¨ã£ã¦èª­ã¿è¾¼ã¿å¯èƒ½ã§ãªã‘れã°ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯ç©ºã§ã‚ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚ 以下ã®ã‚ªãƒ—ションãŒãƒ‘スå展開ã®çµæžœã«å½±éŸ¿ã—ã¾ã™ã€‚ [[opt-nullglob]]null-glob:: マッãƒã™ã‚‹ãƒ•ァイルãŒãªã„時ã€é€šå¸¸ (ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚) ã¯ãƒ‘ターンã¯ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ãƒ‘ターンã¯å‰Šé™¤ã•れ何も残りã¾ã›ã‚“。 [[opt-caseglob]]case-glob:: 通常 (ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚) ã¯ã€å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¦ãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã¯å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã›ãšãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ã€‚ [[opt-dotglob]]dot-glob:: 通常 (ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚) ã¯ã€+*+ ã‚„ +?+ ãªã©ã®ãƒ¯ã‚¤ãƒ«ãƒ‰ã‚«ãƒ¼ãƒ‰ã‚„ブラケット記法ã§å§‹ã¾ã‚‹ãƒ‘ターンã¯ãƒ”リオドã§å§‹ã¾ã‚‹ãƒ•ァイルåã«ãƒžãƒƒãƒã—ã¾ã›ã‚“。ã—ã‹ã—ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã“ã®ã‚ˆã†ãªåˆ¶ç´„ã¯è§£é™¤ã•れã¾ã™ã€‚ [[opt-markdirs]]mark-dirs:: ã“ã®ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãƒžãƒƒãƒã—ãŸãƒ•ァイルã®ç¨®é¡žãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å ´åˆã«å±•é–‹ã•れるパスåã®æœ€å¾Œã« +/+ ãŒä»˜ãã¾ã™ã€‚ [[opt-extendedglob]]extended-glob:: ifdef::basebackend-html[] ã“ã®ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãƒ‘スå展開ã«ãŠã‘ã‚‹<>ãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ endif::basebackend-html[] ifdef::basebackend-docbook[] ã“ã®ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãƒ‘スå展開ã«ãŠã‘る拡張機能 (後述) ãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ endif::basebackend-docbook[] パスå展開ã§ã¯ã‚¨ãƒ©ãƒ¼ã¯ç™ºç”Ÿã—ã¾ã›ã‚“。マッãƒã™ã‚‹ãƒ•ァイルãŒãªã„å ´åˆã¾ãŸã¯ãƒ‘ターンãŒä¸æ­£ãªå ´åˆã¯ã€å±•é–‹ã¯è¡Œã‚れãšãƒ‘ターンã¯ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ (null-glob ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚を除ã)。 ãƒ•ã‚¡ã‚¤ãƒ«ã®æ¤œç´¢ã¨ãƒ‘ターンマッãƒãƒ³ã‚°ã¯ +/+ ã§åŒºåˆ‡ã‚‰ã‚ŒãŸãƒ‘スåã®æ§‹æˆè¦ç´ ã”ã¨ã«è¡Œã‚れã¾ã™ã€‚ワイルドカードやブラケット記法を全ãå«ã¾ãªã„æ§‹æˆè¦ç´ ã¯ãƒ‘ターンã¨ã¯ã¿ãªã•れãšã€æ¤œç´¢ã¨ãƒžãƒƒãƒãƒ³ã‚°ã¯è¡Œã‚れã¾ã›ã‚“。従ã£ã¦ã€case-glob オプションãŒç„¡åŠ¹ãªæ™‚ã€+/*/foo+ 㨠+/*/fo[o]+ ã®å±•é–‹çµæžœãŒç•°ãªã‚‹å¯èƒ½æ€§ãŒã‚りã¾ã™ (å‰è€…ã§ã¯ +foo+ ã®éƒ¨åˆ†ãŒãƒ‘ターンã¨ã¯ã¿ãªã•れãªã„ã®ã§ã€ä¾‹ãˆã° /bar/FOO ã¨ã„ã†ãƒ•ァイルãŒã‚ã£ã¦ã‚‚マッãƒã—ã¾ã›ã‚“。)。 [[extendedglob]] === パスåå±•é–‹ã®æ‹¡å¼µæ©Ÿèƒ½ <>ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ä»¥ä¸‹ã®ç‰¹æ®Šãªãƒ‘ターンãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ +**+:: 指定ã•れãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ„リーã«å¯¾ã—å†å¸°çš„ã«æ¤œç´¢ã‚’行ã„ã¾ã™ã€‚ã™ãªã‚ã¡ã€æŒ‡å®šã•れãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¨ã€ãã®ã‚µãƒ–ディレクトリã€ã•らã«ãã®ã‚µãƒ–ディレクトリãªã©ã«å¯¾ã—検索を行ã„ã¾ã™ã€‚ãŸã ã—åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯æ¤œç´¢ã®å¯¾è±¡ã«ãªã‚Šã¾ã›ã‚“。例ãˆã° +dir/**/file+ ã¨ã„ã†ãƒ‘ターンã¯ã€dir/file ã‚„ dir/foo/file ã‚„ dir/a/b/c/file ãªã©ã€dir ディレクトリã®ä¸­ã«ã‚ã‚‹å…¨ã¦ã® file ファイルã¸ã®ãƒ‘スã«å±•é–‹ã•れã¾ã™ã€‚ + ã“ã®ç‰¹æ®Šãªãƒ‘ターンã¯ã€ +foo/bar/**+ ã®ã‚ˆã†ã«ãƒ‘ã‚¿ãƒ¼ãƒ³å…¨ä½“ã®æœ€å¾Œã«ã‚ã‚‹å ´åˆã«ã¯åŠ¹æžœãŒã‚りã¾ã›ã‚“。 +.**+:: +**+ パターンã¨åŒæ§˜ã§ã™ãŒã€åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚‚å«ã‚ã¦æ¤œç´¢ã™ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ +***+:: +**+ パターンã¨åŒæ§˜ã§ã™ãŒã€æ¤œç´¢ã®ä¸­ã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¸ã®ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ä¸­ã‚‚検索ã®å¯¾è±¡ã«å«ã‚る点ãŒç•°ãªã‚Šã¾ã™ã€‚ +.***+:: +***+ パターンã¨åŒæ§˜ã§ã™ãŒã€åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚‚å«ã‚ã¦æ¤œç´¢ã™ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_dot.html0000644000175000017500000001315512154557026015525 0ustar magicantmagicant ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰

ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ãƒ†ã‚­ã‚¹ãƒˆãƒ•ァイルを開ã„ã¦ã€ãã®å†…容をコマンドã¨ã—ã¦è§£é‡ˆã—実行ã—ã¾ã™ã€‚

æ§‹æ–‡

  • . [-AL] ファイルå [引数…]

説明

ドットコマンドã¯ä¸Žãˆã‚‰ã‚ŒãŸãƒ•ァイルåã®ãƒ•ァイルを開ãã€ãã®å†…容をコマンドã¨ã—ã¦è§£é‡ˆã—ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã§å®Ÿè¡Œã—ã¾ã™ã€‚

ファイルåã«ç¶šã‘ã¦å¼•æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€é–¢æ•°ã®å®Ÿè¡Œã®æ™‚ã¨åŒæ§˜ã«ã€ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œå‰ã«å¼•æ•°ãŒä½ç½®ãƒ‘ラメータã«è¨­å®šã•れã€å®Ÿè¡Œå¾Œã«å…ƒã®ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã«æˆ»ã‚Šã¾ã™ã€‚

ファイルåã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (/) ãŒä¸€ã¤ã‚‚å…¥ã£ã¦ã„ãªã„å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®ã¨ãã¨åŒæ§˜ã« PATH å¤‰æ•°ã®æ¤œç´¢ã‚’行ã„ã€é–‹ãã¹ãファイルを探ã—ã¾ã™ã€‚ãŸã ã—ファイルã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ã•ãˆã‚れã°å®Ÿè¡Œå¯èƒ½ã§ã‚ã‚‹å¿…è¦ã¯ã‚りã¾ã›ã‚“。検索ã®çµæžœãƒ•ァイルãŒè¦‹ã¤ã‹ã‚Œã°ã€ãã®ãƒ•ァイルã®å†…容を解釈・実行ã—ã¾ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã€POSIX 準拠モードã§ã¯ç›´ã¡ã«ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚POSIX 準拠モードã§ãªã„ã¨ãã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ•ァイルを開ãã“ã¨ã‚’試ã¿ã¾ã™ã€‚

オプション

-A
--no-alias

ファイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã™ã‚‹éš›ã€ã‚¨ã‚¤ãƒªã‚¢ã‚¹å±•開を行ã„ã¾ã›ã‚“。

-L
--autoload

ファイルåãŒã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’å«ã‚“ã§ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€PATH 変数ã®ä»£ã‚り㫠YASH_LOADPATH 変数を検索ã—ã¦é–‹ãã¹ãファイルを探ã—ã¾ã™ã€‚ファイルåã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘スåã¨ã¯ã¿ãªã—ã¾ã›ã‚“。

ドットコマンドã§ã¯ã€æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚

オペランド

ファイルå

読ã¿è¾¼ã‚€ãƒ•ァイルã®ãƒ‘スåã§ã™ã€‚

引数

ファイルã®å†…容を実行ã—ã¦ã„ã‚‹é–“ã«ä½ç½®ãƒ‘ラメータã«è¨­å®šã™ã‚‹æ–‡å­—列ã§ã™ã€‚

終了ステータス

ドットコマンドã®çµ‚了ステータスã¯ã€ãƒ•ァイルã‹ã‚‰èª­ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ãŸæœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚ファイルã®å†…容ã«ä¸€ã¤ã‚‚コマンドãŒå…¥ã£ã¦ã„ãªã‹ã£ãŸã¨ãã¯çµ‚了ステータス㯠0 ã§ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚Šé–‹ã‘ãªã‹ã£ãŸã‚Šã—ãŸã¨ãã¯çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

ドットコマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

シェル㌠POSIX 準拠モードã§ã€ã‹ã¤å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ãªã„ã¨ãã€èª­ã¿è¾¼ã‚€ã¹ãファイルãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚Šé–‹ã‘ãªã‹ã£ãŸã‚Šã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚

POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

POSIX ã«ã¯å¼•数オペランドã«ã‚ˆã£ã¦ä½ç½®ãƒ‘ラメータを変更ã§ãã‚‹ã“ã¨ã«ã¤ã„ã¦ã®è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ POSIX 準拠モードã§ã¯å¼•数オペランドを与ãˆã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚

yash-2.35/doc/ja/_typeset.html0000644000175000017500000001567712154557026016447 0ustar magicantmagicant Typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’表示・設定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • typeset [-gprxX] [変数[=値]…]

  • typeset -f[pr] [関数…]

説明

-f (--functions) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯å¤‰æ•°ã‚’出力ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚-f (--functions) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯é–¢æ•°ã‚’出力ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚

-p (--print) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚-p (--print) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€typeset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸå¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’設定ã—ã¾ã™ã€‚オペランドを一ã¤ã‚‚与ãˆãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€-p (--print) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æœ‰ç„¡ã«ã‹ã‹ã‚ら㚠typeset コマンドã¯å…¨ã¦ã®å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’出力ã—ã¾ã™ (ã“ã®ã¨ã -g (--global) オプションãŒã‚ã‚Œã°æœ¬å½“ã«ã™ã¹ã¦ã®å¤‰æ•°ã‚’ã€ãã†ã§ãªã„ã¨ãã¯ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã ã‘を出力ã—ã¾ã™)。

オプション

-f
--functions

変数ã§ã¯ãªã関数を表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚

-g
--global

ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æ–°ã—ã変数を作æˆã™ã‚‹å ´åˆãã®å¤‰æ•°ã‚’グローãƒãƒ«å¤‰æ•°ã¨ã—ã¾ã™ã€‚ã™ãªã‚ã¡å¤‰æ•°ã¯é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ã¦ã‚‚残りã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€è¨­å®šã™ã‚‹å¤‰æ•°ã¯ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚

オペランドãŒãªã„å ´åˆã¯ã€ã“ã®ã‚ªãƒ—ションを指定ã—ã¦ã„ã‚‹ã¨å…¨ã¦ã®å¤‰æ•°ã‚’出力ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ã¦ã„ãªã„ã¨ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã ã‘出力ã—ã¾ã™ã€‚

-p
--print

変数ã¾ãŸã¯é–¢æ•°ã®å®šç¾©ã‚’ (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 出力ã—ã¾ã™ã€‚

-r
--readonly

設定ã™ã‚‹å¤‰æ•°ãƒ»é–¢æ•°ã‚’読ã¿å–り専用ã«ã—ã¾ã™ã€‚読ã¿å–り専用ã®å¤‰æ•°ãƒ»é–¢æ•°ã¯ã€å€¤ã‚’変更ã—ãŸã‚Šå‰Šé™¤ã—ãŸã‚Šã§ããªããªã‚Šã¾ã™ã€‚

変数・関数を出力ã™ã‚‹éš›ã¯ã€èª­ã¿å–り専用ã®å¤‰æ•°ãƒ»é–¢æ•°ã ã‘出力ã—ã¾ã™ã€‚

-x
--export

設定ã™ã‚‹å¤‰æ•°ã‚’エクスãƒãƒ¼ãƒˆå¯¾è±¡ã«ã—ã¾ã™ã€‚

変数を出力ã™ã‚‹éš›ã¯ã€ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã®å¤‰æ•°ã ã‘出力ã—ã¾ã™ã€‚

-X
--unexport

設定ã™ã‚‹å¤‰æ•°ã‚’エクスãƒãƒ¼ãƒˆå¯¾è±¡ã‹ã‚‰å¤–ã—ã¾ã™ã€‚

オペランド

変数

出力ã¾ãŸã¯è¨­å®šã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚

å¤‰æ•°ãŒæ—¢ã«å­˜åœ¨ã™ã‚‹å ´åˆã€å¤‰æ•°ã®å€¤ã¯å¤‰ã‚りã¾ã›ã‚“。存在ã—ãªã„変数を指定ã—ãŸå ´åˆã€å¤‰æ•°ã¯å­˜åœ¨ã™ã‚‹ãŒãã®å€¤ã¯å­˜åœ¨ã—ãªã„状態ã«ãªã‚Šã¾ã™ (ã“ã®ã‚ˆã†ãªå¤‰æ•°ã¯ãƒ‘ラメータ展開ã§ã¯å­˜åœ¨ã—ãªã„変数ã¨ã—ã¦æ‰±ã„ã¾ã™)。

変数=値

設定ã™ã‚‹å¤‰æ•°ã®åå‰ã¨ãã®å€¤ã§ã™ã€‚

指定ã—ãŸå€¤ãŒå¤‰æ•°ã®å€¤ã¨ã—ã¦è¨­å®šã•れã¾ã™ã€‚ã“ã®å½¢å¼ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ã¯ã€-p (--print) オプションを指定ã—ãŸã¨ãã§ã‚‚ã“ã®å¤‰æ•°ã¯å‡ºåŠ›ã§ã¯ãªã設定ã•れã¾ã™ã€‚

関数

出力ã¾ãŸã¯è¨­å®šã™ã‚‹é–¢æ•°ã®åå‰ã§ã™ã€‚存在ã—ãªã„関数を指定ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

終了ステータス

エラーãŒãªã„é™ã‚Š typeset コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

æ—¢ã«ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒå­˜åœ¨ã™ã‚‹å ´åˆã€ãれを無視ã—ã¦ã‚°ãƒ­ãƒ¼ãƒãƒ«å¤‰æ•°ã‚’æ–°ã—ã作るã“ã¨ã¯ã§ãã¾ã›ã‚“ (-g (--global) オプションを指定ã—ã¦ã„ã¦ã‚‚既存ã®ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒå†è¨­å®šã•れã¾ã™)。

POSIX ã«ã¯ typeset コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。</p>

Export コマンド㯠typeset コマンド㫠-gx オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚Readonly コマンド㯠typeset コマンド㫠-gr オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚

yash-2.35/doc/ja/_fc.txt0000644000175000017500000001135312154557026015200 0ustar magicantmagicant= Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:interact.html#history[コマンド履歴]ã«è¨˜éŒ²ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œãƒ»è¡¨ç¤ºã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +fc [-qr] [-e {{エディタ}}] [{{始点}} [{{終点}}]]+ - +fc -s[q] [{{å‰}}={{後}}] [{{始点}}]+ - +fc -l[nrv] [{{始点}} [{{終点}}]]+ [[description]] == 説明 +-l+ (+--list+) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€fc コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸlink:interact.html#history[コマンド履歴]ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ã¾ã™ã€‚+-s+ (+--silent+) オプションを付ã‘ã¦ã„ãªã„å ´åˆã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã™ã‚‹å‰ã«ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã§ãるよã†ã«ã—ã¾ã™ã€‚エディタãŒçµ‚了ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç·¨é›†å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚+-s+ (+--silent+) オプションを付ã‘ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã›ãšç›´æŽ¥ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ã¾ã™ã€‚ã„ãšã‚Œã®å ´åˆã‚‚ã€å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯æ¨™æº–出力ã«å‡ºåŠ›ã—コマンド履歴ã«è¿½åŠ ã•れã¾ã™ã€‚ +-l+ (+--list+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€fc コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸç¯„囲ã®ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚標準ã§ã¯å±¥æ­´å†…ã®ã‚³ãƒžãƒ³ãƒ‰ã®å†…容を履歴番å·ã¨ã¨ã‚‚ã«è¡¨ç¤ºã—ã¾ã™ãŒã€+-n+ (+--no-numbers+) ãŠã‚ˆã³ +-v+ (+--verbose+) オプションã«ã‚ˆã‚Šå‡ºåЛ形å¼ã‚’変更ã§ãã¾ã™ã€‚ [[options]] == オプション +-e {{エディタ}}+:: +--editor={{エディタ}}+:: コマンドã®ç·¨é›†ã«ç”¨ã„るエディタ。 + ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€link:params.html#sv-fcedit[+FCEDIT+ 変数]ã®å€¤ã‚’エディタã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚+FCEDIT+ 変数も設定ã•れã¦ã„ãªã„å ´åˆã¯ã€vi をエディタã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚ +-l+:: +--list+:: コマンド履歴ã®å†…容を表示ã—ã¾ã™ã€‚ +-n+:: +--no-numbers+:: コマンド履歴ã®å†…容を表示ã™ã‚‹éš›ã€å±¥æ­´ç•ªå·ã‚’çœã„ã¦ã‚³ãƒžãƒ³ãƒ‰ã®ã¿è¡¨ç¤ºã—ã¾ã™ã€‚ +-q+:: +--quiet+:: コマンドを実行ã™ã‚‹å‰ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’出力ã—ãªã„よã†ã«ã—ã¾ã™ã€‚ +-r+:: +--reverse+:: {{始点}}ã¨{{終点}}を入れ替ãˆã¾ã™ã€‚ +-s+:: +--silent+:: コマンドを編集ã›ãšã«ç›´æŽ¥å†å®Ÿè¡Œã—ã¾ã™ã€‚ +-v+:: +--verbose+:: コマンド履歴ã®å†…容を表示ã™ã‚‹éš›ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ™‚刻も表示ã—ã¾ã™ã€‚ [[operands]] == オペランド {{始点}}ã¨{{終点}}:: {{始点}}ã¨{{終点}}ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€å†å®Ÿè¡Œã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ç¯„囲を指定ã—ã¾ã™ã€‚{{始点}}ã‚ã‚‹ã„ã¯{{終点}}ã«æ•´æ•°ã‚’指定ã™ã‚‹ã¨ã€ãれã¯å±¥æ­´ç•ªå·ã¨ã¿ãªã—ã¾ã™ã€‚è² ã®æ•´æ•°ã¯æœ€æ–°ã®å±¥æ­´ã‹ã‚‰æ•°ãˆãŸç•ªå·ã¨ãªã‚Šã¾ã™ã€‚例ãˆã° +-2+ ã¯æœ€å¾Œã‹ã‚‰äºŒç•ªç›®ã«å±¥æ­´ã«ç™»éŒ²ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’表ã—ã¾ã™ã€‚æ•´æ•°ä»¥å¤–ã®æ–‡å­—列を{{始点}}ã‚ã‚‹ã„ã¯{{終点}}ã«æŒ‡å®šã™ã‚‹ã¨ã€ãã®æ–‡å­—列ã§å§‹ã¾ã‚‹æœ€æ–°ã®å±¥æ­´ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ + Fc コマンドãŒå†å®Ÿè¡Œã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã€{{始点}}ã¨{{終点}}ã§æŒ‡å®šã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¨ãã®é–“ã«ã‚る履歴ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚{{始点}}ãŒ{{終点}}より後ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’指ã—ã¦ã„ã‚‹å ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®é †åºã¯é€†ã«ãªã‚Šã¾ã™ã€‚ + {{始点}}ã¾ãŸã¯{{終点}}ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã®ãƒ‡ãƒ•ォルト値ã¯ä»¥ä¸‹ã®è¡¨ã®ã¨ãŠã‚Šã§ã™ã€‚ + [width="50%",options="header"] |=== | |+-l+ ã‚り |+-l+ ãªã— |{{始点}} |-16 |-1 |{{終点}} |-16 |{{始点}}ã«åŒã˜ |=== {{å‰}}={{後}}:: {{å‰}}={{後}}ã®å½¢å¼ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®ä¸€éƒ¨ã‚’æ›¸ãæ›ãˆã‚‹ã“ã¨ã‚’指示ã—ã¾ã™ã€‚å†å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ä¸­ã«{{å‰}}ã¨åŒã˜æ–‡å­—列ãŒã‚ã‚‹å ´åˆã¯ã€ãã®éƒ¨åˆ†ã‚’{{後}}ã«ç½®ãæ›ãˆã¦å®Ÿè¡Œã—ã¾ã™ã€‚該当部分ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ã€æœ€åˆã®ã‚‚ã®ã ã‘ã‚’ç½®ãæ›ãˆã¾ã™ã€‚ [[exitstatus]] == 終了ステータス コマンドを正ã—ãå†å®Ÿè¡Œã§ããŸå ´åˆã€fc コマンドã®çµ‚了ステータスã¯å†å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚+-l+ (+--list+) オプションを指定ã—ãŸå ´åˆã¯ã€å±¥æ­´ãŒæ­£ã—ã出力ã§ãれã°çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Fc コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ +-q+ (+--quiet+) ãŠã‚ˆã³ +-v+ (+--verbose+) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“れらã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 link:lineedit.html[行編集]ã®å‹•作中ã¯å±¥æ­´ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/lineedit.html0000644000175000017500000024166212154557026016403 0ustar magicantmagicant 行編集

行編集機能ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã™ã‚‹éš›ã«ä½¿ãˆã‚‹ã€ã‚³ãƒžãƒ³ãƒ‰ã®ç°¡æ˜“編集機能ã§ã™ã€‚行編集機能ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã™ã‚‹ãŸã‚ã®ç°¡å˜ãªã‚¨ãƒ‡ã‚£ã‚¿ã¨ã—ã¦åƒãã¾ã™ã€‚行編集機能ã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã¨ã‚‚連æºã—ã¦ãŠã‚Šã€fc コマンドを使ã£ã¦ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã™ã‚‹ä»£ã‚りã«è¡Œç·¨é›†ã§ç›´æŽ¥ã‚³ãƒžãƒ³ãƒ‰ã‚’編集・å†å®Ÿè¡Œã§ãã¾ã™ã€‚

行編集ã«ã¯è¤‡æ•°ã®ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ãŒã‚りã€ãƒ¢ãƒ¼ãƒ‰ã”ã¨ã«ã‚­ãƒ¼æ“作ã®å‰²ã‚Šå½“ã¦ãŒç•°ãªã‚Šã¾ã™ã€‚è¡Œç·¨é›†ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’åˆ‡ã‚Šæ›¿ãˆãŸã‚Šãƒ¢ãƒ¼ãƒ‰ã‚’é¸æŠžã—ãŸã‚Šã™ã‚‹ã«ã¯ã€set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ—ションを設定ã—ã¾ã™ã€‚ã‚るモードã«å¯¾å¿œã™ã‚‹ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãã®ãƒ¢ãƒ¼ãƒ‰ã®è¡Œç·¨é›†ãŒæœ‰åйã«ãªã‚Šã¾ã™ (åŒæ™‚ã«ä»–ã®ãƒ¢ãƒ¼ãƒ‰ã®ã‚ªãƒ—ションã¯è‡ªå‹•çš„ã«ç„¡åйã«ãªã‚Šã¾ã™)。ç¾åœ¨æœ‰åйã«ãªã£ã¦ã„るモードã®ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã¨ã€è¡Œç·¨é›†ã¯ç„¡åйã«ãªã‚Šã¾ã™ã€‚ç¾åœ¨ yash ãŒæ­è¼‰ã—ã¦ã„る編集モード㯠vi 風㨠emacs 風ã®äºŒç¨®é¡žã§ã€ãれãžã‚Œå¯¾å¿œã™ã‚‹ã‚ªãƒ—ション㯠-o vi 㨠-o emacs ã§ã™ã€‚

シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§èµ·å‹•ã—ãŸã¨ãã€æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ãªã‚‰ã°ã€vi 風行編集ãŒè‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚

行編集ã¯ã€æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ã®ã¨ãã ã‘使ãˆã¾ã™ã€‚ã“ã®æ¡ä»¶ãŒæº€ãŸã•れã¦ã„ãªã„ã¨ãã¯ã€è¡Œç·¨é›†ã¯åƒãã¾ã›ã‚“。行編集ãŒåƒãã¨ãã€ã‚·ã‚§ãƒ«ã¯ termios インタフェースを使用ã—ã¦ç«¯æœ«ã®å…¥å‡ºåŠ›ãƒ¢ãƒ¼ãƒ‰ã‚’ä¸€æ™‚çš„ã«å¤‰æ›´ã—ã€terminfo インタフェースを使用ã—ã¦å…¥åŠ›ã•れãŸã‚­ãƒ¼ã®åˆ¤åˆ¥ãªã©ã‚’行ã„ã¾ã™ã€‚

行編集ã®ã‚ªãƒ—ション

行編集を有効ã«ã—ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’é¸æŠžã™ã‚‹ã‚ªãƒ—ションã¨ã—ã¦ã€ä»¥ä¸‹ã®ã‚ªãƒ—ション㌠set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§è¨­å®šã§ãã¾ã™ã€‚

vi

Vi 風編集モードを有効ã«ã—ã¾ã™

emacs

Emacs 風編集モードを有効ã«ã—ã¾ã™

ã“ã®ä»–ã«ã€è¡Œç·¨é›†ã«é–¢ã‚ã‚‹ã‚‚ã®ã¨ã—ã¦ä»¥ä¸‹ã®ã‚ªãƒ—ションãŒè¨­å®šã§ãã¾ã™ã€‚

le-always-rp

ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã¯ã€é•·ã„コマンドを入力ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ãŒå³ãƒ—ロンプトã«é”ã™ã‚‹ã¨ã€å³ãƒ—ロンプトã¯è¦‹ãˆãªããªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€å³ãƒ—ロンプトã¯è¦‹ãˆãªããªã‚‹ä»£ã‚りã«ä¸‹ã«ç§»å‹•ã—ã¾ã™ã€‚

le-comp-debug

補完を行ã†éš›ã«ãƒ‡ãƒãƒƒã‚°ç”¨ã®æƒ…報を出力ã—ã¾ã™

le-conv-meta

Terminfo データベースã§å¾—ã‚‰ã‚ŒãŸæƒ…報を無視ã—ã€å…¥åŠ›ã® 8 ビット目を常㫠meta-key フラグã¨ã¿ãªã—ã¾ã™ã€‚

le-no-conv-meta

Terminfo データベースã§å¾—ã‚‰ã‚ŒãŸæƒ…報を無視ã—ã€å…¥åŠ›ã® 8 ビット目を他ã®ãƒ“ットã¨åŒæ§˜ã«æ‰±ã„ã¾ã™ã€‚

Le-conv-meta オプション㨠le-no-conv-meta オプションã¯ç‰‡æ–¹ã—ã‹æœ‰åйã«ã§ãã¾ã›ã‚“ (片方を有効ã«ã™ã‚‹ã¨ã‚‚ã†ç‰‡æ–¹ã¯è‡ªå‹•çš„ã«ç„¡åйã«ãªã‚Šã¾ã™)。ã©ã¡ã‚‰ã‚‚ç„¡åŠ¹ãªæ™‚㯠terminfo ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®æƒ…å ±ã«å¾“ã£ã¦ 8 ビット目を meta-key ã¨ã¿ãªã™ã‹ã©ã†ã‹åˆ¤æ–­ã—ã¾ã™ã€‚

le-prompt-sp

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出力ã™ã‚‹å‰ã«ã€ãƒ—ロンプトãŒå¿…ãšè¡Œé ­ã«æ¥ã‚‹ã‚ˆã†ã«ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã™ã‚‹ãŸã‚ã®ç‰¹æ®Šãªæ–‡å­—列を出力ã—ã¾ã™ã€‚

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã¯æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚

le-visible-bell

シェルãŒè­¦å‘Šã‚’発ã™ã‚‹éš›ã€è­¦å‘ŠéŸ³ã‚’鳴らã™ä»£ã‚りã«ç«¯æœ«ã‚’点滅ã•ã›ã¾ã™ã€‚

編集モード

Vi 風編集モード㯠vi ã«ä¼¼ãŸã‚­ãƒ¼æ“作ã§ç·¨é›†ã‚’行ã†ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚Vi 風編集モードã§ã¯ã€æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã¨ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã®äºŒã¤ã®ãƒ¢ãƒ¼ãƒ‰ã‚’é©å®œåˆ‡ã‚Šæ›¿ãˆã¦ç·¨é›†ã‚’行ã„ã¾ã™ã€‚編集ãŒå§‹ã¾ã‚‹ã¨ãã¯ãƒ¢ãƒ¼ãƒ‰ã¯å¿…ãšæŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«ãªã£ã¦ã„ã¾ã™ã€‚挿入モードã§ã¯å…¥åŠ›ã—ãŸæ–‡å­—ãŒåŸºæœ¬çš„ã«ãã®ã¾ã¾ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã•れã¾ã™ã€‚コマンドモードã§ã¯å…¥åŠ›ã—ãŸæ–‡å­—ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã—ãŸã‚Šæ–‡å­—を消去ã—ãŸã‚Šã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚

Emacs 風編集モード㯠emacs ã«ä¼¼ãŸã‚­ãƒ¼æ“作ã§ç·¨é›†ã‚’行ã†ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚入力ã—ãŸæ–‡å­—ã¯åŸºæœ¬çš„ã«ãã®ã¾ã¾ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã•れã¾ã™ãŒã€ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れる一部ã®ã‚­ãƒ¼æ“作㌠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã¨ç•°ãªã‚Šã¾ã™ã€‚

ã“れらã®ãƒ¢ãƒ¼ãƒ‰ã®ä»–ã«ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã®éš›ã«ç”¨ã„る検索モード㌠vi 風㨠emacs 風ã¨ãれãžã‚Œã«ã‚りã¾ã™ã€‚

行編集コマンド

行編集中ã«å…¥åŠ›ã•ã‚ŒãŸæ–‡å­—ã¯å…¨ã¦ä»¥ä¸‹ã®è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®ã„ãšã‚Œã‹ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚コマンドã¨ã‚­ãƒ¼ã®å¯¾å¿œã¯ bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¤‰æ›´ã§ãã¾ã™ (検索モードを除ã)。

以下ã®ä¸€è¦§ã«ã¯å„コマンドã«å¯¾å¿œã™ã‚‹ã‚­ãƒ¼å…¥åŠ›ã®åˆæœŸè¨­å®šã‚‚示ã—ã¦ã‚りã¾ã™ã€‚ãªãŠã€ 『vi-insert〠㯠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã‚’〠『vi-command〠㯠vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã‚’〠『vi-search〠㯠vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã‚’〠『emacs〠㯠emacs 風編集モードを〠『emacs-search〠㯠emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã‚’示ã—ã¾ã™ã€‚

コマンドã®ä¸­ã«ã¯å¼•数を指定ã™ã‚‹ã“ã¨ã§ãã®å‹•作を変更ã§ãã‚‹ã‚‚ã®ãŒã‚りã¾ã™ã€‚例ãˆã° forward-char コマンドã¯é€šå¸¸ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’一文字分å‰ã«ç§»å‹•ã—ã¾ã™ãŒã€å¼•数を指定ã™ã‚‹ã¨ãã®å¼•æ•°ã®æ–‡å­—数分ã ã‘カーソルを移動ã—ã¾ã™ã€‚引数ã¯ã€ç›®çš„ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å‰ã« digit-argument コマンドを使ã†ã“ã¨ã§æŒ‡å®šã§ãã¾ã™ã€‚

基本的ãªç·¨é›†ã‚³ãƒžãƒ³ãƒ‰

noop

何も行ã„ã¾ã›ã‚“。

vi-command

\^[

alert

警告音を発ã—ã¾ãŸã¯ç«¯æœ«ã‚’点滅ã•ã›ã¾ã™ã€‚

self-insert

入力ã—ãŸæ–‡å­—ã‚’ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚(エスケープシーケンスã«ã‚ˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã®å¯¾è±¡ã¨ãªã‚‹æ–‡å­—ã¯æŒ¿å…¥ã§ãã¾ã›ã‚“)

vi-insert
emacs

\\

insert-tab

タブをç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚

emacs

\^[\^I

expect-verbatim

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã™ã‚‹ä¸€æ–‡å­—ã‚’ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã†ã¨ self-insert コマンドã§å…¥åŠ›ã§ããªã„文字も入力ã§ãã¾ã™ (ナル文字 '\0' を除ã)。

vi-insert
vi-search
emacs-search

\^V

emacs

\^Q, \^V

digit-argument

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ•°å­—ã¾ãŸã¯ãƒã‚¤ãƒ•ンã®å…¥åŠ›ã«å¯¾ã—ã¦ã®ã¿æœ‰åйã§ã™ã€‚入力ã—ãŸæ•°å­—を次ã®ã‚³ãƒžãƒ³ãƒ‰ã¸ã®å¼•æ•°ã¨ã—ã¦å—ã‘付ã‘ã¾ã™ (ãƒã‚¤ãƒ•ンã®å ´åˆã¯ç¬¦å·ã‚’å転ã—ã¾ã™)。

Digit-argument コマンドを連続ã—ã¦ä½¿ã†ã“ã¨ã§è¤‡æ•°æ¡ã®å¼•数を指定ã§ãã¾ã™ã€‚例ãˆã° vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã§ 12l ã¨å…¥åŠ›ã™ã‚‹ã¨ã€forward-char コマンドã«å¼•æ•° 12 を与ãˆãŸã“ã¨ã«ãªã‚Šã¾ã™ (ã™ãªã‚ã¡ã‚«ãƒ¼ã‚½ãƒ«ãŒå·¦ã« 12 文字分移動ã—ã¾ã™)。

vi-command

1, 2, 3, 4, 5, 6, 7, 8, 9

emacs

\^[0, \^[1, \^[2, \^[3, \^[4, \^[5, \^[6, \^[7, \^[8, \^[9, \^[-

bol-or-digit

引数ãŒãªã„å ´åˆã¯ beginning-of-line コマンドã¨åŒã˜ã‚ˆã†ã«ã€å¼•æ•°ãŒã‚ã‚‹å ´åˆã¯ digit-argument コマンドã¨åŒã˜ã‚ˆã†ã«å‹•作ã—ã¾ã™ã€‚

vi-command

0

accept-line

行編集を終了ã—ã€ç¾åœ¨ã®ãƒãƒƒãƒ•ã‚¡ã®å†…容をシェルã¸ã®å…¥åŠ›ã¨ã—ã¦ä¸Žãˆã¾ã™ã€‚è¡Œã®æœ«å°¾ã«ã¯è‡ªå‹•çš„ã«æ”¹è¡ŒãŒä»˜ã‘加ã‚りã¾ã™ã€‚

vi-insert
vi-command
emacs
emacs-search

\^J, \^M

abort-line

行編集を中止ã—ã€ç©ºã®å…¥åŠ›ã‚’ã‚·ã‚§ãƒ«ã«ä¸Žãˆã¾ã™ã€‚

vi-insert
vi-command
vi-search
emacs
emacs-search

\!, \^C

eof

シェルã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。

eof-if-empty

ãƒãƒƒãƒ•ã‚¡ãŒç©ºãªã‚‰ã°ã€è¡Œç·¨é›†ã‚’終了ã—ã€ã‚·ã‚§ãƒ«ã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。ãƒãƒƒãƒ•ã‚¡ãŒç©ºã§ãªã‘れã°ã€alert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-insert
vi-command

\#, \^D

eof-or-delete

ãƒãƒƒãƒ•ã‚¡ãŒç©ºãªã‚‰ã°ã€è¡Œç·¨é›†ã‚’終了ã—ã€ã‚·ã‚§ãƒ«ã«å…¥åŠ›ã®çµ‚ã‚りを知らã›ã¾ã™ (ã“れã«ã‚ˆã‚Šã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™)。ãƒãƒƒãƒ•ã‚¡ãŒç©ºã§ãªã‘れã°ã€delete-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

emacs

\#, \^D

accept-with-hash

引数ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã‹ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã®æ–‡å­—㌠# ã§ãªã‘れã°ã€ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã« # を挿入ã—ã¾ã™ã€‚ãã†ã§ãªã‘れã°ãƒãƒƒãƒ•ã‚¡ã®æœ€åˆã® # を削除ã—ã¾ã™ã€‚ã„ãšã‚Œã®å ´åˆã‚‚ã€ãã®å¾Œ accept-line コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-command

#

emacs

\^[#

setmode-viinsert

編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

i, \I

setmode-vicommand

編集モードを vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-insert

\^[

setmode-emacs

編集モードを emacs 風編集モードã«å¤‰æ›´ã—ã¾ã™ã€‚

expect-char
abort-expect-char

ã“れ㯠find-char コマンドãªã©ã‚’実装ã™ã‚‹ãŸã‚ã« yash 内部ã§ä½¿ã‚れã¦ã„るコマンドã§ã€ç›´æŽ¥ä½¿ç”¨ã—ã¦ã‚‚æ„味ã¯ã‚りã¾ã›ã‚“。

redraw-all

行編集ã®ãƒ—ロンプトやãƒãƒƒãƒ•ァを端末ã«è¡¨ç¤ºã—ãªãŠã—ã¾ã™ã€‚

vi-insert
vi-command
vi-search
emacs
emacs-search

\^L

clear-and-redraw-all

端末ã®è¡¨ç¤ºã‚’クリアã—ã€è¡Œç·¨é›†ã®ãƒ—ロンプトやãƒãƒƒãƒ•ァを端末ã«è¡¨ç¤ºã—ãªãŠã—ã¾ã™ã€‚

移動コマンド

移動コマンドã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’移動ã•ã›ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ã»ã¨ã‚“ã©ã®ç§»å‹•コマンドã¯å¼•数を与ãˆã‚‹ã“ã¨ã§ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’引数ã®å›žæ•°ã ã‘実行ã™ã‚‹ã®ã¨åŒã˜ã‚ˆã†ã«å‹•作ã•ã›ã‚‰ã‚Œã¾ã™ã€‚例ãˆã° forward-char コマンドã«å¼•æ•° 4 を与ãˆã‚‹ã¨ã€ã‚«ãƒ¼ã‚½ãƒ«ã‚’ 4 文字先ã«é€²ã‚ã¾ã™ã€‚

以下ã€bigword ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸç©ºç™½ã§ãªã„文字をã„ã„ã€semiword ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸç©ºç™½ã§ã‚‚å¥èª­ç‚¹ã§ã‚‚ãªã„文字をã„ã„ã€emacsword ã¨ã¯ä¸€æ–‡å­—以上ã®é€£ç¶šã—ãŸè‹±æ•°å­—ã‚’ã„ã„ã¾ã™ã€‚ã¾ãŸ viword ã¨ã¯ä»¥ä¸‹ã®ã„ãšã‚Œã‹ã‚’ã„ã„ã¾ã™

  • 一文字以上ã®é€£ç¶šã—ãŸè‹±æ•°å­—ã¾ãŸã¯ä¸‹ç·š (_)

  • 一文字以上ã®é€£ç¶šã—ãŸã€è‹±æ•°å­—ã§ã‚‚下線ã§ã‚‚空白ã§ã‚‚ãªã„文字

以下ã«ç§»å‹•コマンドã®ä¸€è¦§ã‚’示ã—ã¾ã™ã€‚

forward-char

ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-insert

\R

vi-command

l, (空白文字), \R

emacs

\R, \^F

backward-char

カーソルをå‰ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-insert

\L

vi-command

h, \B, \L, \?, \^H,

emacs

\L, \^B

forward-bigword

カーソルを次㮠bigword ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

W

end-of-bigword

カーソルを bigword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚

vi-command

E

backward-bigword

カーソルをå‰ã® bigword ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

B

forward-semiword

カーソルを次㮠semiword ã«ç§»å‹•ã—ã¾ã™ã€‚

end-of-semiword

カーソルを semiword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚

backward-semiword

カーソルをå‰ã® semiword ã«ç§»å‹•ã—ã¾ã™ã€‚

forward-viword

カーソルを次㮠viword ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

w

end-of-viword

カーソルを viword ã®çµ‚ã‚りã¾ã§ç§»å‹•ã—ã¾ã™ã€‚

vi-command

e

backward-viword

カーソルをå‰ã® viword ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

b

forward-emacsword

カーソルを次㮠emacsword ã«ç§»å‹•ã—ã¾ã™ã€‚

emacs

\^[f, \^[F

backward-emacsword

カーソルをå‰ã® emacsword ã«ç§»å‹•ã—ã¾ã™ã€‚

emacs

\^[b, \^[B

beginning-of-line

カーソルをãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-insert
vi-command

\H

emacs

\H, \^A

end-of-line

カーソルをãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-insert

\E

vi-command

$, \E

emacs

\E, \^E

go-to-column

カーソルをãƒãƒƒãƒ•ァ内㮠n 文字目ã«ç§»å‹•ã—ã¾ã™ã€‚ãŸã ã— n ã¯å¼•æ•°ã§ã™ (引数ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ 1)。

vi-command

|

first-nonblank

カーソルをãƒãƒƒãƒ•ã‚¡å†…ã®æœ€åˆã®ç©ºç™½ã§ãªã„文字ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

^

find-char

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’進ã‚ã¾ã™ã€‚

vi-command

f

emacs

\^]

find-char-rev

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’戻ã—ã¾ã™ã€‚

vi-command

F

emacs

\^[\^]

till-char

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã®ç›´å‰ã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’進ã‚ã¾ã™ã€‚

vi-command

t

till-char-rev

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ãŒã‚ã‚‹ä½ç½®ã®ç›´å¾Œã¾ã§ã‚«ãƒ¼ã‚½ãƒ«ã‚’戻ã—ã¾ã™ã€‚

vi-command

T

refind-char

å‰å›žå®Ÿè¡Œã—㟠find-char, find-char-rev, till-char, till-char-rev コマンドをå†å®Ÿè¡Œã—ã¾ã™ã€‚

vi-command

;

refind-char-rev

å‰å›žå®Ÿè¡Œã—㟠find-char, find-char-rev, till-char, till-char-rev コマンドをã€ã‚«ãƒ¼ã‚½ãƒ«ã®é€²ã‚€å‘ãを逆ã«ã—ã¦å†å®Ÿè¡Œã—ã¾ã™ã€‚

vi-command

,

編集コマンド

編集コマンドã¯ãƒãƒƒãƒ•ã‚¡ã®å†…容を変更ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ã»ã¨ã‚“ã©ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¯å¼•数を与ãˆã‚‹ã“ã¨ã§ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’引数ã®å›žæ•°ã ã‘実行ã™ã‚‹ã®ã¨åŒã˜ã‚ˆã†ã«å‹•作ã•ã›ã‚‰ã‚Œã¾ã™ã€‚

åå‰ã« 『kill〠ãŒä»˜ãコマンドã§å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã¨ã„ã†å ´æ‰€ã«ä¿ç®¡ã•れã€å¾Œã§ put ãªã©ã®ã‚³ãƒžãƒ³ãƒ‰ã§ãƒãƒƒãƒ•ã‚¡ã«æˆ»ã™ã“ã¨ãŒã§ãã¾ã™ã€‚

以下ã«ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®ä¸€è¦§ã‚’示ã—ã¾ã™ã€‚

delete-char

カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-insert
emacs

\X

delete-bigword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ bigword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-bigword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

delete-semiword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ semiword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-semiword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

delete-viword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ viword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-viword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

delete-emacsword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ emacsword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ kill-emacsword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

backward-delete-char

カーソルã®å‰ã«ã‚る文字を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-char コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-insert
emacs

\B, \?, \^H

backward-delete-bigword

カーソルã®å‰ã«ã‚ã‚‹ bigword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-bigword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

backward-delete-semiword

カーソルã®å‰ã«ã‚ã‚‹ semiword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-semiword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-insert

\^W

backward-delete-viword

カーソルã®å‰ã«ã‚ã‚‹ viword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-viword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

backward-delete-emacsword

カーソルã®å‰ã«ã‚ã‚‹ emacsword を削除ã—ã¾ã™ã€‚引数を与ãˆãŸå ´åˆã¯ backward-kill-emacsword コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

delete-line

ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã¾ã™ã€‚

forward-delete-line

カーソル以é™ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã¾ã™ã€‚

backward-delete-line

カーソルよりå‰ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã¾ã™ã€‚

vi-insert

\$, \^U

kill-char

カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

vi-command

x, \X

kill-bigword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ bigword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

kill-semiword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ semiword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

kill-viword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ viword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

kill-emacsword

カーソルã®ã¨ã“ã‚ã«ã‚ã‚‹ emacsword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

emacs

\^[d, \^[D

backward-kill-char

カーソルã®å‰ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

vi-command

X

backward-kill-bigword

カーソルã®å‰ã«ã‚ã‚‹ bigword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

emacs

\^W

backward-kill-semiword

カーソルã®å‰ã«ã‚ã‚‹ semiword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

backward-kill-viword

カーソルã®å‰ã«ã‚ã‚‹ viword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

backward-kill-emacsword

カーソルã®å‰ã«ã‚ã‚‹ emacsword を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

emacs

\^[\B, \^[\?, \^[\^H

kill-line

ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

forward-kill-line

カーソル以é™ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

emacs

\^K

backward-kill-line

カーソルよりå‰ã®å…¨ã¦ã®æ–‡å­—を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

emacs

\$, \^U, \^X\B, \^X\?

put-before

最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å‰ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—åˆ—ã®æœ€å¾Œã®æ–‡å­—ã®ã¨ã“ã‚ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

P

put

最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å¾Œã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—åˆ—ã®æœ€å¾Œã®æ–‡å­—ã®ã¨ã“ã‚ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

p

put-left

最後ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列をカーソルã®ç›´å‰ã«æŒ¿å…¥ã—ã¾ã™ã€‚ã‚«ãƒ¼ã‚½ãƒ«ã¯æŒ¿å…¥ã—ãŸæ–‡å­—列ã®ç›´å¾Œã«ç§»å‹•ã—ã¾ã™ã€‚

emacs

\^Y

put-pop

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ put-before, put, put-left, put-pop コマンドã®ç›´å¾Œã«ã ã‘使ãˆã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã‚­ãƒ«ãƒªãƒ³ã‚°ã‹ã‚‰æŒ¿å…¥ã—ãŸæ–‡å­—列を削除ã—ã€ä»£ã‚りã«ãã®æ–‡å­—列ã®å‰ã«ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ãŸæ–‡å­—列を挿入ã—ã¾ã™ã€‚

emacs

\^[y, \^[Y

undo

ç›´å‰ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容をå‰ã®çŠ¶æ…‹ã«æˆ»ã—ã¾ã™ã€‚

vi

u

emacs

\^_, \^X\$, \^X\^U

undo-all

å…¨ã¦ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…å®¹ã‚’åˆæœŸçŠ¶æ…‹ã«æˆ»ã—ã¾ã™ã€‚

vi

U

emacs

\^[\^R, \^[r, \^[R

cancel-undo

undo, undo-all ã«ã‚ˆã‚‹ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®å–り消ã—ã‚’å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を復元ã—ã¾ã™ã€‚

vi

\^R

cancel-undo-all

undo, undo-all ã«ã‚ˆã‚‹ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®å–り消ã—ã‚’å…¨ã¦å–り消ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を復元ã—ã¾ã™ã€‚

redo

ç›´å‰ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã‚’繰り返ã—ã¾ã™ã€‚

vi-command

.

補完コマンド

complete

ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã¾ã™ã€‚補完候補ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãã®ä¸€è¦§ã‚’表示ã—ã¾ã™ã€‚

complete-next-candidate

補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-insert
emacs

\^I

complete-prev-candidate

補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-insert
emacs

\bt

complete-next-column

補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®åˆ—ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

complete-prev-column

補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®åˆ—ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

complete-next-page

補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰æ¬¡ã®ãƒšãƒ¼ã‚¸ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

complete-prev-page

補完候補ã®ä¸€è¦§ã‚’æ—¢ã«è¡¨ç¤ºã—ã¦ã„ã‚‹å ´åˆã¯ä¸€è¦§ã®ä¸­ã‹ã‚‰å‰ã®ãƒšãƒ¼ã‚¸ã®æœ€åˆã®å€™è£œã‚’é¸æŠžã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ complete コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

complete-list

ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã¾ã™ã€‚引数を指定ã—ãªã„å ´åˆã€è£œå®Œå€™è£œã®ä¸€è¦§ã‚’表示ã—ã¾ã™ã€‚引数を指定ã™ã‚‹ã¨ã€ãã®ç•ªå·ã®å€™è£œã§è£œå®Œå†…容を確定ã—ã¾ã™ã€‚

emacs

\^[?, \^[=

complete-all

ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã€ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã«ã‚ã‚‹å˜èªžã‚’ã™ã¹ã¦ã®è£œå®Œå€™è£œã§ç½®ãæ›ãˆã¾ã™ã€‚

emacs

\^[*

complete-max

ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã§è£œå®Œã‚’行ã„ã€å„è£œå®Œå€™è£œã®æœ€é•·å…±é€šå…ˆé ­éƒ¨åˆ†ã‚’カーソルä½ç½®ã«æŒ¿å…¥ã—ã¾ã™ã€‚

clear-candidates

補完候補ã®ä¸€è¦§ã‚’消去ã—ã¾ã™ã€‚

Vi 固有ã®ã‚³ãƒžãƒ³ãƒ‰

vi-replace-char

カーソルã®ã¨ã“ã‚ã«ã‚る文字をã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ã«ç½®ãæ›ãˆã¾ã™ã€‚

vi-command

r

vi-insert-beginning

カーソルをãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-command

I

vi-append

ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-command

I

vi-append-to-eol

カーソルをãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ãŸã®ã¡ã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-command

A

vi-replace

Setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ãŒã€åŒæ™‚ã«ä¸Šæ›¸ãモードを有効ã«ã—ã¾ã™ã€‚上書ãモードã§ã¯ã€self-insert ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—を挿入ã™ã‚‹ä»£ã‚りã«ã‚«ãƒ¼ã‚½ãƒ«ã®ã¨ã“ã‚ã«ã‚ã‚‹æ–‡å­—ã‚’ç½®ãæ›ãˆã¾ã™ã€‚上書ãモードã¯ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’変更ã™ã‚‹ã¾ã§æœ‰åйã§ã™ã€‚

vi-command

R

vi-switch-case

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字ã®å¤§æ–‡å­—ã¨å°æ–‡å­—を入れ替ãˆã¾ã™ã€‚

vi-switch-case-char

カーソルã®ã¨ã“ã‚ã«ã‚る文字ã®å¤§æ–‡å­—ã¨å°æ–‡å­—を入れ替ãˆã¦ã€ã‚«ãƒ¼ã‚½ãƒ«ã‚’æ¬¡ã®æ–‡å­—ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

~

vi-yank

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字をキルリングã«ä¿ç®¡ã—ã¾ã™ã€‚

vi-command

y

vi-yank-to-eol

カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字をキルリングã«ä¿ç®¡ã—ã¾ã™ã€‚

vi-command

Y

vi-delete

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

vi-command

d

vi-delete-to-eol

カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字を削除ã—ã€ã‚­ãƒ«ãƒªãƒ³ã‚°ã«ä¿ç®¡ã—ã¾ã™ã€‚

vi-command

D

vi-change

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«ã¯ç§»å‹•コマンドを入力ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚移動コマンドãŒå‹•ã‹ã—ãŸã‚«ãƒ¼ã‚½ãƒ«ã®ç¯„囲ã«ã‚る文字を削除ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

c

vi-change-to-eol

カーソルã®ä½ç½®ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã¾ã§ã«ã‚る文字を削除ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚ Delete the characters from the current cursor position to the end of the line and switch to the vi insert mode.

vi-command

C

vi-change-line

ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã€ãã®å¾Œç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

S

vi-yank-and-change

Vi-change コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚

vi-yank-and-change-to-eol

Vi-change-to-eol コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚

vi-yank-and-change-line

Vi-change-line コマンドã¨åŒæ§˜ã§ã™ãŒã€å‰Šé™¤ã—ãŸæ–‡å­—列ã¯ã‚­ãƒ«ãƒªãƒ³ã‚°ã«è£œå®Œã•れã¾ã™ã€‚

vi-substitute

カーソルã®ã¨ã“ã‚ã«ã‚る文字を削除ã—キルリングã«ä¿ç®¡ã—ãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

s

vi-append-last-bigword

コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ãŠã‘る最後㮠bigword ã‚’ã€ç©ºç™½æ–‡å­—ã«ç¶šã‘ã¦ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã®ç›´å¾Œã«æŒ¿å…¥ã—ã¾ã™ã€‚引数 n を与ãˆãŸã¨ãã¯æœ€å¾Œã® bigword ã®ä»£ã‚り㫠n 番目㮠bigword を挿入ã—ã¾ã™ã€‚ãã®å¾Œã€setmode-viinsert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-command

_

vi-exec-alias

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã«å…¥åŠ›ã—ãŸæ–‡å­—ã‚’ c ã¨ã™ã‚‹ã¨ã€_c ã¨ã„ã†åå‰ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®å†…容をシェルã¸ã®å…¥åŠ›ã¨ã¿ãªã—ã¦è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚

vi-command

@

vi-edit-and-accept

エディタã¨ã—㦠vi ã‚’èµ·å‹•ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å†…容を編集ã•ã›ã¾ã™ã€‚エディタãŒçµ‚了ã™ã‚‹ã¨ç·¨é›†å¾Œã®å†…容をãƒãƒƒãƒ•ã‚¡ã«å映ã—ãŸå¾Œ accept-line コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚ãŸã ã—エディタã®çµ‚了ステータス㌠0 ã§ãªã„ã¨ãã¯ä½•も行ã„ã¾ã›ã‚“。

vi-command

v

vi-complete-list

Complete-list コマンドã¨åŒæ§˜ã§ã™ãŒã€å€™è£œã‚’確定ã—ãŸã¨ã編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

=

vi-complete-all

Complete-all コマンドã¨åŒæ§˜ã§ã™ãŒã€å˜èªžã‚’ç½®ãæ›ãˆãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

*

vi-complete-max

Complete-max コマンドã¨åŒæ§˜ã§ã™ãŒã€å€™è£œã‚’挿入ã—ãŸå¾Œã€ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã‚’ vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

\\

vi-search-forward

順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

?

vi-search-backward

逆方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

vi-command

/

Emacs 固有ã®ã‚³ãƒžãƒ³ãƒ‰

emacs-transpose-chars

カーソルã®å‰ã«ã‚る文字をå³ã«ç§»å‹•ã—ã¾ã™ã€‚

emacs

\^T

emacs-transpose-words

カーソルã®å‰ã«ã‚ã‚‹ emacsword ã‚’å³ã«ç§»å‹•ã—ã¾ã™ã€‚

emacs

\^[t, \^[T

emacs-downcase-word

カーソルã®å¾Œã«ã‚ã‚‹ emacsword ã‚’å°æ–‡å­—ã«å¤‰æ›ã—ã¾ã™ã€‚

emacs

\^[l, \^[L

emacs-upcase-word

カーソルã®å¾Œã«ã‚ã‚‹ emacsword を大文字ã«å¤‰æ›ã—ã¾ã™ã€‚

emacs

\^[u, \^[U

emacs-capitalize-word

カーソルã®å¾Œã«ã‚ã‚‹ emacsword をキャピタライズã—ã¾ã™ (å„å˜èªžã®é ­æ–‡å­—ã ã‘大文字ã«ã™ã‚‹)。

emacs

\^[c, \^[C

emacs-delete-horizontal-space

カーソルã®å‰å¾Œã«ã‚る空白を削除ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ã‚«ãƒ¼ã‚½ãƒ«ã®å‰ã«ã‚る空白を削除ã—ã¾ã™ã€‚

emacs

\^[\\

emacs-just-one-space

カーソルã®å‰å¾Œã«ã‚る空白ã®å€‹æ•°ã‚’一ã¤ã«èª¿æ•´ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãã®å¼•æ•°ã®æ•°ã ã‘空白を残ã—ã¾ã™ã€‚

emacs

\^[ (エスケープã®å¾Œã«ç©ºç™½æ–‡å­—)

emacs-search-forward

順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

emacs

\^S

emacs-search-backward

順方å‘ã®å±¥æ­´æ¤œç´¢ã‚’é–‹å§‹ã—ã¾ã™ã€‚編集モードを emacs é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æ¤œç´¢ãƒ¢ãƒ¼ãƒ‰ã«å¤‰æ›´ã—ã¾ã™ã€‚

emacs

\^R

コマンド履歴関連ã®ã‚³ãƒžãƒ³ãƒ‰

oldest-history

コマンド履歴ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。

newest-history

コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。

return-history

コマンド履歴ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。

oldest-history-bol

コマンド履歴ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

G

newest-history-bol

コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚

return-history-bol

コマンド履歴ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™ã€‚

vi-command

g

oldest-history-eol

コマンド履歴ã®ä¸­ã§æœ€ã‚‚å¤ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚

emacs

\^[<

newest-history-eol

コマンド履歴ã®ä¸­ã§æœ€ã‚‚æ–°ã—ã„コマンドã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚

return-history-eol

コマンド履歴ã®ã©ã®ã‚³ãƒžãƒ³ãƒ‰ã«ã‚‚対応ã—ãªã„æ–°è¦ãƒãƒƒãƒ•ã‚¡ã«ç§»å‹•ã—ã¾ã™ã€‚引数を与ãˆã‚‹ã¨ãれを履歴番å·ã¨ã¿ãªã—ã¦ãã®ç•ªå·ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™ã€‚

emacs

\^[>

next-history

コマンド履歴ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。

prev-history

コマンド履歴ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã®ä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。

next-history-bol

コマンド履歴ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™

vi-command

j, +, \D, \^N

prev-history-bol

コマンド履歴ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã«ç§»å‹•ã—ã¾ã™

vi-command

k, -, \U, \^P

next-history-eol

コマンド履歴ã®ä¸­ã§æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™

vi-insert
emacs

\D, \^N

prev-history-eol

コマンド履歴ã®ä¸­ã§å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルã¯ãƒãƒƒãƒ•ã‚¡ã®æœ«å°¾ã«ç§»å‹•ã—ã¾ã™

vi-insert
emacs

\U, \^P

search-again

最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚

vi-command

n

search-again-rev

最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’æ–¹å‘を逆ã«ã—ã¦ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚

vi-command

N

search-again-forward

最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’順方å‘ã«ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚

search-again-backward

最後ã«è¡Œã£ãŸã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ¤œç´¢ã‚’逆方å‘ã«ã‚‚ã†ä¸€åº¦è¡Œã„ã¾ã™ã€‚

beginning-search-forward

コマンド履歴を順方å‘ã«æ¤œç´¢ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã¾ã§ã®é–“ã«ã‚る文字列ãŒåŒã˜æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。

beginning-search-backward

コマンド履歴を逆方å‘ã«æ¤œç´¢ã—ã€ãƒãƒƒãƒ•ã‚¡ã®å…ˆé ­ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã¾ã§ã®é–“ã«ã‚る文字列ãŒåŒã˜å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã«ç§»å‹•ã—ã¾ã™ã€‚カーソルä½ç½®ã¯å¤‰ã‚りã¾ã›ã‚“。

コマンド履歴検索モードã®ã‚³ãƒžãƒ³ãƒ‰

srch-self-insert

入力ã—ãŸæ–‡å­—を検索用ãƒãƒƒãƒ•ã‚¡ã«æŒ¿å…¥ã—ã¾ã™ã€‚(エスケープシーケンスã«ã‚ˆã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã®å¯¾è±¡ã¨ãªã‚‹æ–‡å­—ã¯æŒ¿å…¥ã§ãã¾ã›ã‚“)

vi-search
emacs-search

\\

srch-backward-delete-char

検索用ãƒãƒƒãƒ•ã‚¡ã®æœ€å¾Œã®ä¸€æ–‡å­—を削除ã—ã¾ã™ã€‚検索用ãƒãƒƒãƒ•ã‚¡ãŒç©ºã®å ´åˆã¯:

  • vi 風編集モードã§ã¯ srch-abort-search コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

  • emacs 風編集モードã§ã¯ alert コマンドã¨åŒã˜å‹•作をã—ã¾ã™ã€‚

vi-search
emacs-search

\B, \?, \^H

srch-backward-delete-line

検索用ãƒãƒƒãƒ•ã‚¡ã®å†…容を全ã¦å‰Šé™¤ã—ã¾ã™ã€‚

vi-search
emacs-search

\$, \^U

srch-continue-forward

ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã®æ¬¡ã®çµæžœã‚’順方å‘ã«æŽ¢ã—ã¾ã™ã€‚

emacs-search

\^S

srch-continue-backward

ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã®æ¬¡ã®çµæžœã‚’逆方å‘ã«æŽ¢ã—ã¾ã™ã€‚

emacs-search

\^R

srch-accept-search

検索を終了ã—ã€ç¾åœ¨è¡¨ç¤ºã—ã¦ã„ã‚‹æš«å®šæ¤œç´¢çµæžœã‚’確定ã—ã¾ã™ã€‚æ¤œç´¢çµæžœã«ç§»å‹•ã—ã¾ã™ã€‚

vi-search

\^J, \^M

emacs-search

\^J, \^[

srch-abort-search

検索を中止ã—ã€æ¤œç´¢ã‚’é–‹å§‹ã™ã‚‹å‰ã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚

vi-search

\^[

emacs-search

\^G

エスケープシーケンス

Bindkey コマンドã§è¡Œç·¨é›†ã®ã‚­ãƒ¼è¨­å®šã‚’表示・設定ã™ã‚‹éš›ã€ãƒ•ァンクションキーãªã©ã®ç‰¹æ®Šãªã‚­ãƒ¼ã¯ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスã§è¡¨ã‚ã—ã¾ã™ã€‚エスケープシーケンスã¯å…¨ã¦ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\) ã§å§‹ã¾ã‚Šã¾ã™ã€‚ã¾ãŸãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãã®ã‚‚ã®ã‚‚エスケープã®å¯¾è±¡ã§ã™ã€‚エスケープシーケンスã«å¯¾ã™ã‚‹ã‚­ãƒ¼ã®å‰²ã‚Šå½“ã¦ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

\\

ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\)

\B

Backspace

\D

↓矢å°ã‚­ãƒ¼

\E

End

\H

Home

\I

Insert (Insert-char, Enter-insert-mode)

\L

â†çŸ¢å°ã‚­ãƒ¼

\N

Page-down (Next-page)

\P

Page-up (Previous-page)

\R

→矢å°ã‚­ãƒ¼

\U

↑矢å°ã‚­ãƒ¼

\X

Delete

\!

INTR

\#

EOF

\$

KILL

\?

ERASE

\^@

Ctrl + @

\^A, \^B, …, \^Z

Ctrl + A, Ctrl + B, …, Ctrl + Z

※ Ctrl + I 㯠Tabã€Ctrl + J 㯠Newlineã€Ctrl + M 㯠Carriage-return ã§ã™ã€‚

\^[

Ctrl + [ (Escape)

\^\

Ctrl + \

\^]

Ctrl + ]

\^^

Ctrl + ^

\^_

Ctrl + _

\^?

Ctrl + ? (Delete)

\F00, \F01, …, \F63

F0, F1, …, F63

\a1

キーパッドã®å·¦ä¸Šã‚­ãƒ¼

\a3

キーパッドã®å³ä¸Šã‚­ãƒ¼

\b2

キーパッドã®ä¸­å¤®ã‚­ãƒ¼

\bg

Beginning

\bt

Back-tab

\c1

キーパッドã®å·¦ä¸‹ã‚­ãƒ¼

\c3

キーパッドã®å³ä¸‹ã‚­ãƒ¼

\ca

Clear-all-tabs

\cl

Close

\cn

Cancel

\co

Command

\cp

Copy

\cr

Create

\cs

Clear-screen ã¾ãŸã¯ erase

\ct

Clear-tab

\dl

Delete-line

\ei

Exit-insert-mode

\el

Clear-to-end-of-line

\es

Clear-to-end-of-screen

\et

Enter (Send)

\ex

Exit

\fd

Find

\hp

Help

\il

Insert-line

\ll

Home-down

\me

Message

\mk

Mark

\ms

マウスイベント

\mv

Move

\nx

Next-object

\on

Open

\op

Options

\pr

Print (Copy)

\pv

Previous-object

\rd

Redo

\re

Resume

\rf

Ref (Reference)

\rh

Refresh

\rp

Replace

\rs

Restart

\sf

Scroll-forward (Scroll-down)

\sl

Select

\sr

Scroll-backward (Scroll-up)

\st

Set-tab

\su

Suspend

\sv

Save

\ud

Undo

\SE

Shift + End

\SH

Shift + Home

\SI

Shift + Insert

\SL

Shift + â†çŸ¢å°ã‚­ãƒ¼

\SR

Shift + →矢å°ã‚­ãƒ¼

\SX

Shift + Delete

\Sbg

Shift + Beginning

\Scn

Shift + Cancel

\Sco

Shift + Command

\Scp

Shift + Copy

\Scr

Shift + Create

\Sdl

Shift + Delete-line

\Sel

Shift + End-of-line

\Sex

Shift + Exit

\Sfd

Shift + Find

\Shp

Shift + Help

\Smg

Shift + Message

\Smv

Shift + Move

\Snx

Shift + Next

\Sop

Shift + Options

\Spr

Shift + Print

\Spv

Shift + Previous

\Srd

Shift + Redo

\Sre

Shift + Resume

\Srp

Shift + Replace

\Ssu

Shift + Suspend

\Ssv

Shift + Save

\Sud

Shift + Undo

INTR, EOF, KILL, ERASE ã®å››ã¤ã¯ stty コマンドãªã©ã§è¨­å®šã•れる端末ã®ç‰¹æ®Šæ–‡å­—ã§ã™ã€‚一般的ãªç’°å¢ƒã§ã¯ã€INTR 㯠Ctrl + C ã«ã€EOF 㯠Ctrl + D ã«ã€KILL 㯠Ctrl + U ã«ã€ERASE 㯠Ctrl + H ã¾ãŸã¯ Ctrl + ? ã«è¨­å®šã•れã¦ã„ã¾ã™ã€‚ã“れら四ã¤ã¯ä»–ã®ã‚­ãƒ¼å…¥åŠ›ã‚ˆã‚Šã‚‚å„ªå…ˆã—ã¦èªè­˜ã•れã¾ã™ã€‚

コマンドライン補完

行編集ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã—ã¦ã„る途中㧠Tab キーを押ã™ã“ã¨ã§ã€ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã‚„オプションã€å¼•数を補完ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚コマンドåやファイルåを途中ã¾ã§æ‰“ã¡è¾¼ã‚“ã ã¨ã“ã‚ã§ Tab キーを押ã™ã¨ã€ãã®åå‰ã«ä¸€è‡´ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰åやファイルåã®ä¸€è¦§ãŒç¾ã‚Œã¾ã™ã€‚ã•らã«ç¶šã‘㦠Tab キーを押ã™ã¨ã€å…¥åŠ›ã—ãŸã„åå‰ã‚’一覧ã®ä¸­ã‹ã‚‰é¸ã¶ã“ã¨ãŒã§ãã¾ã™ã€‚(一致ã™ã‚‹åå‰ãŒä¸€ã¤ã—ã‹ãªã„å ´åˆã¯ã€ä¸€è¦§ã¯ç¾ã‚Œãšã€ç›´æŽ¥åå‰ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å…¥åŠ›ã•れã¾ã™ã€‚)

補完ã®å¯¾è±¡ã¨ãªã‚‹åå‰ã« * ã‚„ ? ãªã©ã®æ–‡å­—ãŒå…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®ãƒ‘ターンã«ä¸€è‡´ã™ã‚‹åå‰å…¨ã¦ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å±•é–‹ã•れã¾ã™ã€‚(一覧ã«ã‚ˆã‚‹é¸æŠžã¯ã§ãã¾ã›ã‚“)

標準状態ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰åを入力ã—ã¦ã„ã‚‹ã¨ãã¯ã‚³ãƒžãƒ³ãƒ‰åãŒã€ã‚³ãƒžãƒ³ãƒ‰ã®å¼•数を入力ã—ã¦ã„ã‚‹ã¨ãã¯ãƒ•ァイルåãŒè£œå®Œã•れã¾ã™ã€‚ã—ã‹ã—補完を行ã†é–¢æ•° (補完関数) を定義ã™ã‚‹ã“ã¨ã§è£œå®Œå†…容を変更ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

補完動作ã®è©³ç´°

シェルを起動ã—ã¦ã‹ã‚‰åˆã‚ã¦è£œå®Œã‚’行ãŠã†ã¨ã—ãŸã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ . -AL completion/INIT を実行ã™ã‚‹ã®ã¨åŒæ§˜ã«ã—ã¦ã€ãƒ•ァイル completion/INIT をロードパスã‹ã‚‰èª­ã¿è¾¼ã¿ã¾ã™ã€‚ファイルãŒè¦‹ã¤ã‹ã‚‰ãªã„å ´åˆã¯ã€ãã®ã¾ã¾è£œå®Œå‹•作を続ã‘ã¾ã™ã€‚(ã“ã®å‡¦ç†ã¯ä¸»ã«ã‚·ã‚§ãƒ«ã«ä»˜å±žã—ã¦ã„る補完関数を読ã¿è¾¼ã‚€ãŸã‚ã®ã‚‚ã®ã§ã™ãŒã€ãƒ­ãƒ¼ãƒ‰ãƒ‘ス内ã«è‡ªåˆ†ã§ç”¨æ„ã—ãŸãƒ•ァイルを置ã„ã¦ãŠãã“ã¨ã§ä»£ã‚りã«ãれを読ã¿è¾¼ã¾ã›ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚)

補完ã¯ã€å¯¾è±¡ã«å¿œã˜ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«è¡Œã„ã¾ã™ã€‚

コマンドå

関数 completion//command ãŒå®šç¾©ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれを補完関数ã¨ã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚定義ã•れã¦ã„ãªã„å ´åˆã¯ã€å…¥åЛ䏭ã®å˜èªžã‚’コマンドåã¨ã—ã¦è£œå®Œã—ã¾ã™ã€‚

コマンドã®å¼•æ•°

関数 completion//argument ãŒå®šç¾©ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれを補完関数ã¨ã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚定義ã•れã¦ã„ãªã„å ´åˆã¯ã€å…¥åЛ䏭ã®å˜èªžã‚’ファイルåã¨ã—ã¦è£œå®Œã—ã¾ã™ã€‚

ã“ã®ä»–ã€ãƒãƒ«ãƒ€å±•é–‹ã«ãŠã‘るユーザåやパラメータ展開ã«ãŠã‘るパラメータåを入力ã—ã¦ã„ã‚‹ã¨ãã¯ã€ãƒ¦ãƒ¼ã‚¶åやパラメータåãŒå¸¸ã«è£œå®Œã•れã¾ã™ã€‚(補完ã®ã—ã‹ãŸã‚’変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“)

è£œå®Œé–¢æ•°ã¯æ™®é€šã®é–¢æ•°ã¨åŒæ§˜ã« (ä½ç½®ãƒ‘ラメータãªã—ã§) 実行ã•れã¾ã™ã€‚ãŸã ã—ã€è£œå®Œé–¢æ•°ã®å®Ÿè¡Œæ™‚ã«ã¯ä»¥ä¸‹ã®ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ãŒè‡ªå‹•çš„ã«è¨­å®šã•れã¾ã™ã€‚

IFS

空白文字・タブ・改行ã®ä¸‰æ–‡å­— (シェル起動時ã®ãƒ‡ãƒ•ォルト)

WORDS

æ—¢ã«å…¥åŠ›ã•れã¦ã„るコマンドåã¨ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã‚’å«ã‚€é…列ã§ã™ã€‚コマンドåを補完ã—よã†ã¨ã—ã¦ã„ã‚‹ã¨ãã¯ã€ã“ã®é…列ã¯ç©ºã«ãªã‚Šã¾ã™ã€‚

TARGETWORD

ç¾åœ¨è£œå®Œã‚’行ãŠã†ã¨ã—ã¦ã„ã‚‹ã€é€”中ã¾ã§å…¥åŠ›ã•れãŸã‚³ãƒžãƒ³ãƒ‰åã¾ãŸã¯ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã§ã™ã€‚

補完関数ã®ä¸­ã§ complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã§ã€è£œå®Œå€™è£œãŒç”Ÿæˆã•れã¾ã™ã€‚シェルã¯è£œå®Œé–¢æ•°å®Ÿè¡Œä¸­ã«ç”Ÿæˆã•れãŸè£œå®Œå€™è£œã‚’用ã„ã¦è£œå®Œã‚’行ã„ã¾ã™ã€‚

補完関数ã®å®Ÿè¡Œä¸­ã¯ã€ç«¯æœ«ã«å¯¾ã—ã¦å…¥å‡ºåŠ›ã‚’è¡Œã£ã¦ã¯ãªã‚Šã¾ã›ã‚“ (端末ã®è¡¨ç¤ºãŒä¹±ã‚Œã¦ã—ã¾ã„ã¾ã™)。スムーズãªè£œå®Œã‚’行ã†ãŸã‚ã«ã€è£œå®Œã®å®Ÿè¡Œä¸­ã«é•·ã„時間ã®ã‹ã‹ã‚‹å‡¦ç†ã‚’行ã†ã®ã¯é¿ã‘ã¦ãã ã•ã„。

補完ã®å®Ÿè¡Œä¸­ã¯ã€POSIX 準拠モードãŒå¼·åˆ¶çš„ã«è§£é™¤ã•れã¾ã™ã€‚ã¾ãŸ errexit オプションã¯ç„¡åйã¨ãªã‚Šã€ãƒˆãƒ©ãƒƒãƒ—ã¯å®Ÿè¡Œã•れã¾ã›ã‚“。

yash-2.35/doc/ja/_bindkey.html0000644000175000017500000001037112154557026016361 0ustar magicantmagicant Bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯​行編集ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰è¨­å®šã‚’表示・設定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • bindkey -aev [キー [コマンド]]

  • bindkey -l

説明

-l (--list) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€bindkey コマンドã¯ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã§åˆ©ç”¨å¯èƒ½ãª​行編集コマンドã®ä¸€è¦§ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

ä»–ã®ã‚ªãƒ—ションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€bindkey コマンドã¯ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã®è¡¨ç¤ºã¾ãŸã¯è¨­å®šã‚’行ã„ã¾ã™ã€‚

  • オペランドã¨ã—ã¦ã‚­ãƒ¼ãƒ»ã‚³ãƒžãƒ³ãƒ‰ã‚’与ãˆãªã„å ´åˆã€ç¾åœ¨ã®ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã®å†…容を (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

  • キーã®ã¿ã‚’与ãˆã‚‹ã¨ã€ãã®ã‚­ãƒ¼ã«å¯¾ã™ã‚‹ç¾åœ¨ã®è¨­å®šã ã‘を出力ã—ã¾ã™ã€‚

  • キーã¨ã‚³ãƒžãƒ³ãƒ‰ã‚’両方与ãˆã‚‹ã¨ã€ãã®ã‚­ãƒ¼ã‚’入力ã—ãŸã¨ãã«å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã«è¨­å®šã—ã¾ã™ã€‚

オプション

-a
--vi-command

Vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚

-e
--emacs

Emacs 風編集モードã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚

-v
--vi-insert

Vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚

オペランド

キー

表示・設定ã™ã‚‹å¯¾è±¡ã®ã‚­ãƒ¼å…¥åŠ›ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã§ã™ã€‚ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å€¤ã«ã¯ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスãŒåˆ©ç”¨ã§ãã¾ã™ã€‚

コマンド

設定ã™ã‚‹è¡Œç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ãƒã‚¤ãƒ•ン一㤠(-) を指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸã‚­ãƒ¼ã«å¯¾ã™ã‚‹è¨­å®šã‚’削除ã—ã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š bindkey コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

POSIX ã«ã¯ bindkey コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/_ulimit.html0000644000175000017500000002046312154557026016242 0ustar magicantmagicant Ulimit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Ulimit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™ã‚’表示・設定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • ulimit -a [-H|-S]

  • ulimit [-H|-S] [-efilnqrstuvx] [値]

説明

Ulimit コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚

-a (--all) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€ulimit コマンドã¯å…¨ã¦ã®ç¨®é¡žã®ãƒªã‚½ãƒ¼ã‚¹ã«ã¤ã„ã¦ç¾åœ¨ã®åˆ¶é™å€¤ã‚’一覧形å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚-a (--all) オプションを付ã‘ãªã„ã§å®Ÿè¡Œã™ã‚‹ã¨ã€ä¸€ç¨®é¡žã®ãƒªã‚½ãƒ¼ã‚¹ã«ã¤ã„ã¦åˆ¶é™å€¤ã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚オペランドã§å€¤ã‚’指定ã—ã¦ã„ã‚‹å ´åˆã€ãã®å€¤ã«åˆ¶é™å€¤ã‚’設定ã—ã¾ã™ã€‚値を指定ã—ã¦ã„ãªã„å ´åˆã¯ç¾åœ¨ã®åˆ¶é™å€¤ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚表示・設定ã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã¯ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ã¾ã™ã€‚設定ã—ãŸãƒªã‚½ãƒ¼ã‚¹ã®åˆ¶é™å€¤ã¯ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å„コマンドã«å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚

リソースã®å„種類ã«ã¤ã„ã¦ã€ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã¨ã‚½ãƒ•トリミットã®äºŒç¨®é¡žã®åˆ¶é™å€¤ãŒã‚りã¾ã™ã€‚ソフトリミットãŒãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’è¶…ãˆã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。ã¾ãŸãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’ç·©ã‚ã‚‹ã«ã¯å°‚ç”¨ã®æ¨©é™ãŒå¿…è¦ã§ã™ã€‚

-H (--hard) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€ulimit コマンドã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚-S (--soft) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€ulimit コマンドã¯ã‚½ãƒ•トリミットを表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ã©ã¡ã‚‰ã®ã‚ªãƒ—ションも指定ã—ã¦ãªã„å ´åˆã€ulimit コマンドã¯ã‚½ãƒ•トリミットã®ã¿ã‚’表示ã™ã‚‹ã‹ã¾ãŸã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã¨ã‚½ãƒ•トリミットã®ä¸¡æ–¹ã‚’設定ã—ã¾ã™ã€‚

オプション

-H
--hard

ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚

-S
--soft

ソフトリミットを表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚

-a
--all

全種類ã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã‚’表示ã—ã¾ã™ã€‚

以下ã®ã‚ªãƒ—ションã¯è¡¨ç¤ºãƒ»è¨­å®šã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã‚’指定ã—ã¾ã™ã€‚ã“れらã®ã‚ªãƒ—ションãŒã©ã‚Œã‚‚与ãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã¯ã€-f ãŒä¸Žãˆã‚‰ã‚ŒãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚(表示・設定å¯èƒ½ãªãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã¯ã‚·ã‚¹ãƒ†ãƒ ã«ã‚ˆã£ã¦ç•°ãªã‚Šã¾ã™)

-c
--core

プロセスãŒå¼·åˆ¶çµ‚了ã•ã›ã‚‰ã‚ŒãŸã¨ãã«ã§ãるコアファイルã®ã‚µã‚¤ã‚ºã®é™ç•Œ (512 ãƒã‚¤ãƒˆå˜ä½)

-d
--data

プロセスãŒä½¿ç”¨ã§ãるデータセグメント領域ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½)

-e
--nice

スケジューリング優先度 (nice 値) ã®é™ç•Œ

-f
--fsize

プロセスãŒä½œæˆã§ãるファイルã®ã‚µã‚¤ã‚ºã®é™ç•Œ (512 ãƒã‚¤ãƒˆå˜ä½)

-i
--sigpending

プロセスã®å‡¦ç†å¾…ã¡ã‚·ã‚°ãƒŠãƒ«ã®å€‹æ•°ã®é™ç•Œ

-l
--memlock

RAM 上ã«ãƒ­ãƒƒã‚¯å¯èƒ½ãªãƒ¡ãƒ¢ãƒªã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½)

-m
--rss

プロセス㮠resident set (RAM 上ã«å­˜åœ¨ã™ã‚‹ä»®æƒ³ãƒšãƒ¼ã‚¸) ã®æ•°ã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½)

-n
--nofile

プロセスãŒä½¿ç”¨ã§ãるファイル記述å­ã®æœ€å¤§å€¤ + 1

-q
--msgqueue

POSIX メッセージキューã®ã‚µã‚¤ã‚ºã®é™ç•Œ

-r
--rtprio

リアルタイムスケジューリングã®å„ªå…ˆåº¦ã®é™ç•Œ

-s
--stack

プロセスãŒä½¿ç”¨ã§ãるスタック領域ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½)

-t
--cpu

プロセスãŒä½¿ç”¨ã§ãã‚‹ CPU 時間ã®é™ç•Œ (ç§’å˜ä½)

-u
--nproc

プロセスãŒèµ·å‹•ã§ãã‚‹å­ãƒ—ロセスã®å€‹æ•°ã®é™ç•Œ

-v
--as

プロセスãŒä½¿ç”¨ã§ãるメモリ領域全体ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½)

-x
--locks

プロセスãŒãƒ­ãƒƒã‚¯ã§ãるファイルã®å€‹æ•°ã®é™ç•Œ

オペランド

値

設定ã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã§ã™ã€‚

値ã¯åŸºæœ¬çš„ã« 0 以上ã®è‡ªç„¶æ•°ã§æŒ‡å®šã—ã¾ã™ãŒã€è‡ªç„¶æ•°ã®ä»£ã‚り㫠hardã€softã€unlimited ã®ã„ãšã‚Œã‹ã®æ–‡å­—列を指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“ã‚Œã‚‰ã®æ–‡å­—列ã¯ãれãžã‚Œç¾åœ¨ã®ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã®å€¤ã€ç¾åœ¨ã®ã‚½ãƒ•トリミットã®å€¤ã€ç„¡åˆ¶é™ã‚’表ã—ã¾ã™ã€‚

終了ステータス

リソース制é™å€¤ãŒæ­£ã—ã出力ã¾ãŸã¯è¨­å®šã§ããŸã¨ãã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

POSIX ãŒè¦å®šã—ã¦ã„るオプション㯠-f ã ã‘ã§ã™ã€‚ã¾ãŸ POSIX ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å€¤ã¨ã—ã¦è‡ªç„¶æ•°ã—ã‹è¦å®šã—ã¦ã„ã¾ã›ã‚“。

yash-2.35/doc/ja/_getopts.txt0000644000175000017500000001205712154557026016277 0ustar magicantmagicant= Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +getopts {{オプションリスト}} {{変数å}} [{{引数}}...]+ [[description]] == 説明 Getopts コマンドã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«å«ã¾ã‚Œã¦ã„ã‚‹link:builtin.html#argsyntax[一文字ã®ã‚ªãƒ—ション]ã‚’è§£æžã—ã¾ã™ã€‚Getopts コマンドを一回呼ã³å‡ºã™ãŸã³ã«ã‚ªãƒ—ションãŒä¸€ã¤è§£æžã•れã€ãã®ã‚ªãƒ—ションを表ã™ä¸€æ–‡å­—ãŒ{{変数å}}ã§æŒ‡å®šã—ãŸlink:params.html#variables[変数]ã«ä»£å…¥ã•れã¾ã™ã€‚ è§£æžã®å¯¾è±¡ã¨ãªã‚‹ã‚ªãƒ—ションã®ç¨®é¡žã‚‚ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ã¾ã™ã€‚{{オプションリスト}}ã«ã¯å—ã‘付ã‘ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—を並ã¹ã¦æŒ‡å®šã—ã¾ã™ã€‚文字ã®å¾Œã«ã‚³ãƒ­ãƒ³ (+:+) を付ã‘ã‚‹ã¨ãã®ã‚ªãƒ—ションã¯å¼•æ•°ã‚’ã¨ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚例ãˆã°ã€+-a+, +-b+, +-c+ ã®ä¸‰ç¨®é¡žã®ã‚ªãƒ—ションをå—ã‘付ã‘ã€ã•らã«ã“れらã®ã†ã¡ +-b+ ãŒå¼•æ•°ã‚’ã¨ã‚‹å ´åˆã€{{オプションリスト}}ã«ã¯ +ab:c+ を指定ã—ã¾ã™ã€‚ 引数をã¨ã‚‹ã‚ªãƒ—ションを解æžã—ãŸã¨ãã€ãã®å¼•æ•°ã®å€¤ãŒ link:params.html#sv-optarg[+OPTARG+ 変数]ã«ä»£å…¥ã•れã¾ã™ã€‚ {{オプションリスト}}ã§ä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„オプションã«å‡ºãã‚ã—ãŸã¨ãã¾ãŸã¯å¼•æ•°ã‚’ã¨ã‚‹ã‚ªãƒ—ションã«å¼•æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã®å‹•作ã¯ã€{{オプションリスト}}ã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ (+:+) ã§ã‚ã‚‹ã‹ã©ã†ã‹ã§æ±ºã¾ã‚Šã¾ã™ã€‚ - {{オプションリスト}}ã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ã®å ´åˆã€ãã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—㌠+OPTARG+ 変数ã«ä»£å…¥ã•れã€{{変数å}}ã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ã¯ +?+ ({{オプションリスト}}ã§ä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„オプションã«å‡ºãã‚ã—ãŸã¨ã) ã¾ãŸã¯ +:+ (引数をã¨ã‚‹ã‚ªãƒ—ションã«å¼•æ•°ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ã) ãŒä»£å…¥ã•れã¾ã™ã€‚ - {{オプションリスト}}ã®æœ€åˆã®æ–‡å­—ãŒã‚³ãƒ­ãƒ³ã§ãªã„å ´åˆã€+OPTARG+ 変数ã¯å‰Šé™¤ã•れã€{{変数å}}ã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ã¯ +?+ ãŒä»£å…¥ã•れã¾ã™ã€‚ã¾ãŸã“ã®ã¨ã標準エラーã«ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒå‡ºåŠ›ã•れã¾ã™ãŒã€ãれã§ã‚‚ getopts コマンドã®çµ‚了ステータス㯠0 ã«ãªã‚Šã¾ã™ã€‚ Getopts コマンドã¯ã€å®Ÿè¡Œã™ã‚‹ãŸã³ã«ä¸€ã¤ãšã¤ã‚ªãƒ—ションを解æžã—ã¾ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã™ã‚‹ã«ã¯ã€æ¯Žå›žåŒã˜{{引数}}ã§ getopts コマンドを繰り返ã—実行ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚シェルã¯ã€ã‚ªãƒ—ションをã©ã“ã¾ã§è§£æžã—ãŸã‹ã‚’覚ãˆã¦ãŠããŸã‚ã«ã€link:params.html#sv-optind[+OPTIND+ 変数]を用ã„ã¾ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã‚‹ã¾ã§ã«ã“ã®å¤‰æ•°ã‚’変更ã—ã¦ã¯ã„ã‘ã¾ã›ã‚“。全ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã‚‹ã¨ã€+OPTIND+ 変数ã«ã¯{{引数}} (ã¾ãŸã¯ä½ç½®ãƒ‘ラメータ) ã®ä¸­ã§æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã«å½“ãŸã‚‹ã‚‚ã®ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒä»£å…¥ã•れã¾ã™ (オペランドãŒãªã„å ´åˆã¯{{引数}}ã¾ãŸã¯ä½ç½®ãƒ‘ラメータã®å€‹æ•° + 1 ã«ãªã‚Šã¾ã™)。 ç•°ãªã‚‹{{引数}}ã‚’è§£æžã•ã›ãŸã„å ´åˆã¯ã€getopts ã‚³ãƒžãƒ³ãƒ‰ã«æ–°ã—ã„{{引数}}を与ãˆã‚‹å‰ã« +OPTIND+ 変数㫠+1+ を代入ã—ã¦ãã ã•ã„。 [[operands]] == オペランド {{オプションリスト}}:: è§£æžã®å¯¾è±¡ã¨ãªã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—ã®ç¾…列ã§ã™ã€‚ {{変数å}}:: è§£æžçµæžœã®å€¤ã‚’代入ã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚ {{引数}}s:: è§£æžã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚ + ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’指定ã—ãªã„å ´åˆã¯ã€link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã‚’è§£æžã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス {{引数}}ã®ä¸­ã«ã‚ªãƒ—ションãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¯ã€(ãれãŒ{{オプションリスト}}ã«å«ã¾ã‚Œã¦ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãš) 終了ステータス㯠0 ã§ã™ã€‚å…¨ã¦ã®ã‚ªãƒ—ションを解æžã—終ã‚ã£ãŸæ™‚ã¯ã€çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[example]] == 使用例 ---- aopt=false bopt= copt=false while getopts ab:c opt do case $opt in a) aopt=true ;; b) bopt=$OPTARG ;; c) copt=true ;; \?) return 2 ;; esac done if $aopt; then echo オプション -a ãŒæŒ‡å®šã•れã¾ã—ãŸ; fi if [ -n "$bopt" ]; then echo オプション -b $bopt ãŒæŒ‡å®šã•れã¾ã—ãŸ; fi if $copt; then echo オプション -c ãŒæŒ‡å®šã•れã¾ã—ãŸ; fi shift $((OPTIND - 1)) echo オペランド㯠$* ---- [[notes]] == 補足 Getopts コマンドãŒè§£æžã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã¯ã€ã‚ªãƒ—ションã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«æŒ‡å®šã—ã¦ã‚ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚最åˆã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒç¾ã‚ŒãŸæ™‚点ã§ã€getopts コマンドã¯è§£æžã‚’終了ã—ã¾ã™ã€‚ Getopts コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã¯ã€+OPTIND+ 変数㫠+1+ 以外ã®å€¤ã‚’代入ã—ãŸå ´åˆã®å‹•作をè¦å®šã—ã¦ã„ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/job.txt0000644000175000017500000001627612154557026015234 0ustar magicantmagicant= ジョブ制御 :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - ジョブ制御 :description: Yash ã®ã‚¸ãƒ§ãƒ–制御ã®å‹•作ã«ã¤ã„㦠dfn:[ジョブ制御]ã¨ã¯ã€è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’åŒæ™‚ã«å®Ÿè¡Œã—ã€å¿…è¦ã«å¿œã˜ã¦ãれらを中断・å†é–‹ã•ã›ã‚‹æ©Ÿèƒ½ã§ã™ã€‚シェルã¯ã€ã‚ªãƒšãƒ¬ãƒ¼ãƒ†ã‚£ãƒ³ã‚°ã‚·ã‚¹ãƒ†ãƒ ãŒæä¾›ã™ã‚‹ç«¯æœ«ã®æ©Ÿèƒ½ã‚„ãƒ—ãƒ­ã‚»ã‚¹ã‚°ãƒ«ãƒ¼ãƒ—ç®¡ç†æ©Ÿæ§‹ãªã©ã‚’用ã„ã¦ã€ã‚¸ãƒ§ãƒ–制御を実ç¾ã—ã¾ã™ã€‚ ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚…… - シェルãŒèµ·å‹•ã™ã‚‹å„プロセスã¯ã€link:syntax.html#pipelines[パイプライン]ã”ã¨ã«å…±é€šã®ä¸€æ„ãªãƒ—ロセスグループã«å±žã—ã¾ã™ã€‚ã™ãªã‚ã¡ã€ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ãれãžã‚Œãƒ‘イプラインã”ã¨ã«dfn:[ジョブ]ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚ - シェルãŒã‚¸ãƒ§ãƒ–ã‚’èµ·å‹•ã—ãã®ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスãŒçµ‚了ã™ã‚‹ã®ã‚’å¾…ã£ã¦ã„ã‚‹é–“ã«ãã®ãƒ—ロセスãŒåœæ­¢ã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã¯ (プロセスãŒå®Ÿéš›ã«çµ‚了ã—ãŸã¨ãã¨åŒæ§˜ã«) 次ã®ã‚³ãƒžãƒ³ãƒ‰ã®å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ã“ã®ã¨ãシェルã¯ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã“ã¨ã‚’覚ãˆã¦ã„ã‚‹ã®ã§ã€å¾Œã§ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ - ジョブãŒlink:syntax.html#async[åŒæœŸçš„]ã«å®Ÿè¡Œã•れる場åˆã€ãã®ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡Œä¸­ã¯ãã®ã‚¸ãƒ§ãƒ–ã®ãƒ—ロセスグループãŒç«¯æœ«ã®ãƒ•ォアグラウンドプロセスグループã«ãªã‚Šã¾ã™ã€‚ジョブã®å®Ÿè¡ŒãŒçµ‚了 (ã¾ãŸã¯åœæ­¢) ã™ã‚‹ã¨ã€å†ã³ã‚·ã‚§ãƒ«ãŒãƒ•ォアグラウンドã«ãªã‚Šã¾ã™ã€‚ - link:expand.html#cmdsub[コマンド置æ›]ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹link:exec.html#subshell[サブシェル]ã‚‚ã¾ãŸç‹¬ç«‹ã—ãŸãƒ—ロセスグループã«å±žã—ã¾ã™ã€‚ã—ã‹ã—シェルã¯ã“れをジョブã¨ã—ã¦ã¯æ‰±ã‚ãªã„ãŸã‚ã€åœæ­¢ãƒ»å†é–‹ã•ã›ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 - シェルãŒlink:interact.html[対話モード]ã®å ´åˆã€ãƒ—ロンプトを出ã™å‰ã«æ¯Žå›žã‚³ãƒžãƒ³ãƒ‰ +link:_jobs.html[jobs] -n+ を実行ã™ã‚‹ã®ã¨åŒæ§˜ã«ã—ã¦ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚ - link:syntax.html#async[éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰]ã®æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れã¾ã›ã‚“。(link:posix.html[POSIX 準拠モード]ã®ã¨ãを除ã) - SIGTSTP シグナルをå—ã‘ã¦ã‚‚ã€ã‚·ã‚§ãƒ«ã¯åœæ­¢ã—ã¾ã›ã‚“。 - link:params.html#sp-hyphen[特殊パラメータ +-+] ã®å€¤ã« +m+ ãŒå«ã¾ã‚Œã¾ã™ã€‚ - link:_wait.html[Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§å¾…ã£ã¦ã„るジョブãŒçµ‚了ã—ãŸã¨ãã€ãã®ã“ã¨ã‚’示ã™ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã¾ã™ã€‚(link:interact.html[対話モード]ã®æ™‚ã®ã¿ã€‚link:posix.html[POSIX 準拠モード]を除ã) ジョブ制御ãŒç„¡åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å„プロセスã¯ã‚·ã‚§ãƒ«ã¨åŒã˜ãƒ—ロセスグループã«å±žã—ã¾ã™ãŒã€å®Ÿè¡Œã—ãŸlink:syntax.html#async[éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰]ã¯ãれãžã‚Œã‚¸ãƒ§ãƒ–制御ã®å¯¾è±¡ã¨ãªã£ã¦ã„ãªã„ジョブã¨ã—ã¦æ‰±ã„ã¾ã™ã€‚ ã“ã“ã§ã‚¸ãƒ§ãƒ–制御ã«é–¢é€£ã™ã‚‹çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’ç°¡å˜ã«ç´¹ä»‹ã—ã¾ã™ã€‚ link:_jobs.html[jobs]:: ç¾åœ¨ã‚·ã‚§ãƒ«ãŒç®¡ç†ã—ã¦ã„るジョブを表示ã—ã¾ã™ã€‚ link:_fg.html[fg] ãŠã‚ˆã³ link:_bg.html[bg]:: ジョブをフォアグラウンドã¾ãŸã¯ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã—ã¾ã™ã€‚主ã«åœæ­¢ã—ãŸã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã•ã›ã‚‹ã®ã«ä½¿ã„ã¾ã™ã€‚ link:_wait.html[wait]:: ジョブãŒçµ‚了 (ã¾ãŸã¯åœæ­¢) ã™ã‚‹ã¾ã§å¾…ã¡ã¾ã™ã€‚ link:_disown.html[disown]:: ジョブã®å­˜åœ¨ã‚’忘れã¾ã™ã€‚ link:_kill.html[kill]:: プロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Šã¾ã™ã€‚ 対話モードã§ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出ã™ç›´å‰ã«ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚ã“れ以外ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¦ã»ã—ã„å ´åˆã¯ã€ä»¥ä¸‹ã®link:_set.html#options[オプション]を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ link:_set.html#so-notify[notify]:: タイミングã«ã‹ã‹ã‚らãšã€ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹ãŒå¤‰åŒ–ã—ãŸã‚‰ç›´ã¡ã«ãれを報告ã—ã¾ã™ã€‚ link:_set.html#so-notifyle[notify-le]:: link:lineedit.html[行編集]を行ã£ã¦ã„る最中ã«ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹ãŒå¤‰åŒ–ã—ãŸã‚‰ç›´ã¡ã«ãれを報告ã—ã¾ã™ã€‚ シェルãŒç®¡ç†ã—ã¦ã„るジョブã¯ä»¥ä¸‹ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§å‰Šé™¤ã•れã¾ã™ã€‚ - ジョブã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸå¾Œã€ãã®ã“ã¨ã‚’ link:_jobs.html[jobs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]やプロンプトå‰ã®è‡ªå‹•報告ã§è¡¨ç¤ºã—ãŸã¨ã - link:_wait.html[Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚¸ãƒ§ãƒ–ã®çµ‚了を待ã£ãŸã¨ã - link:_disown.html[Disown 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚¸ãƒ§ãƒ–を削除ã—ãŸã¨ã [[jobid]] == ジョブ ID ã„ãã¤ã‹ã®link:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã¯ã€æ“作対象ã®ã‚¸ãƒ§ãƒ–を指定ã™ã‚‹ãŸã‚ã«dfn:[ジョブ ID] ã¨ã„ã†ä»¥ä¸‹ã®ã‚ˆã†ãªè¨˜æ³•を用ã„ã¾ã™ã€‚ +%+:: +%%+:: +%++:: ç¾åœ¨ã®ã‚¸ãƒ§ãƒ– +%-+:: å‰ã®ã‚¸ãƒ§ãƒ– +%{{n}}+:: ジョブ番å·ãŒ {{n}} ã®ã‚¸ãƒ§ãƒ– ({{n}} ã¯è‡ªç„¶æ•°) +%{{string}}+:: ジョブåãŒ{{文字列}}ã§å§‹ã¾ã‚‹ã‚¸ãƒ§ãƒ– +%?{{string}}+:: ジョブåãŒ{{文字列}}ã‚’å«ã‚€ã‚¸ãƒ§ãƒ– dfn:[ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–]åŠã³dfn:[å‰ã®ã‚¸ãƒ§ãƒ–]ã¨ã¯ã€ã‚·ã‚§ãƒ«ãŒç‰¹å®šã®æ–¹æ³•ã§é¸ã‚“ã ã‚¸ãƒ§ãƒ–ã®ã“ã¨ã§ã€link:_fg.html[fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãªã©ã§ã‚¸ãƒ§ãƒ–ã‚’é¸æŠžã—ã‚„ã™ãã™ã‚‹ãŸã‚ã«ç”¨æ„ã•れã¦ã„ã¾ã™ã€‚ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¨å‰ã®ã‚¸ãƒ§ãƒ–ã¯ä»¥ä¸‹ã®è¦å‰‡ã‚’満ãŸã™ã‚ˆã†ã«é¸ã°ã‚Œã¾ã™ã€‚ - åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹å ´åˆã¯ã€ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯ãã®ä¸­ã‹ã‚‰é¸ã°ã‚Œã¾ã™ã€‚ - ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–以外ã«åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹å ´åˆã¯ã€å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãã®ä¸­ã‹ã‚‰é¸ã°ã‚Œã¾ã™ã€‚ - ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¨å‰ã®ã‚¸ãƒ§ãƒ–ã¯ç•°ãªã‚‹ã‚¸ãƒ§ãƒ–ã«ãªã‚‹ã‚ˆã†ã«é¸ã°ã‚Œã¾ã™ã€‚ジョブãŒä¸€ã¤ã—ã‹ãªã„ã¨ãã¯ãれãŒç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã€å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãªããªã‚Šã¾ã™ã€‚ - ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ãŒçµ‚了ã—ãŸã¨ãã¯ã€å‰ã®ã‚¸ãƒ§ãƒ–ãŒç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ã“れ以外ã«ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ãŒå¤‰æ›´ã•れる場åˆã¯ã€å…ƒã®ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯å‰ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ - フォアグラウンドã§å®Ÿè¡Œã—ã¦ã„ãŸã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãã¯ã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ Yash ã«ã¯ã€ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã‚’é¸æŠžã™ã‚‹æ–¹é‡ã‚’指示ã™ã‚‹ãŸã‚ã«ã„ãã¤ã‹ã®link:_set.html#options[オプション]ãŒç”¨æ„ã•れã¦ã„ã¾ã™ã€‚ãŸã ã—ã“れらã®ã‚ªãƒ—ションよりも上記ã®è¦å‰‡ã®ã»ã†ãŒå„ªå…ˆã—ã¾ã™ã€‚ link:_set.html#so-curasync[cur-async]:: æ–°ã—ãlink:syntax.html#async[éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰]ã‚’èµ·å‹•ã—ãŸã¨ãã€ãれã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ link:_set.html#so-curbg[cur-bg]:: link:_bg.html[Bg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã—ãŸã¨ãã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ link:_set.html#so-curstop[cur-stop]:: 実行中ã®ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ãŸã¨ãã€ãã®ã‚¸ãƒ§ãƒ–ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã«ãªã‚Šã¾ã™ã€‚ ã“れらã®è¦å‰‡ãƒ»ã‚ªãƒ—ションã«åã—ãªã„é™ã‚Šã€ä¸€åº¦é¸ã°ã‚ŒãŸç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã¯ãšã£ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã®ã¾ã¾ã§ã™ã€‚ POSIX ã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–・å‰ã®ã‚¸ãƒ§ãƒ–ã®é¸æŠžæ–¹æ³•ã‚’ç´°ã‹ã定ã‚ã¦ã„ãªã„ãŸã‚ã€ä»–ã®ã‚·ã‚§ãƒ«ã§ã¯é¸ã³æ–¹ãŒç•°ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_read.html0000644000175000017500000001060312154557026015645 0ustar magicantmagicant Read 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Read 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯æ¨™æº–入力ã‹ã‚‰è¡Œã‚’読ã¿è¾¼ã¿å¤‰æ•°ã«ä»£å…¥ã—ã¾ã™ã€‚

æ§‹æ–‡

  • read [-Ar] 変数å

説明

Read ã‚³ãƒžãƒ³ãƒ‰ã¯æ¨™æº–入力ã‹ã‚‰ä¸€è¡Œã®æ–‡å­—列を読ã¿è¾¼ã¿ã€ãれを変数ã«ä»£å…¥ã—ã¾ã™ã€‚シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ã€è¡Œç·¨é›†ã‚’利用ã™ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã‚‰ã°ã€èª­ã¿è¾¼ã¿ã«è¡Œç·¨é›†ã‚’使用ã—ã¾ã™ã€‚

-r (--raw-mode) オプションを付ã‘ã‚‹ã¨ã€è¡Œå†…ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒæ§˜ã«æ‰±ã‚れã¾ã™ã€‚

-r (--raw-mode) オプションを付ã‘ãªã„å ´åˆã€èª­ã¿è¾¼ã‚“ã æ–‡å­—列ã®ä¸­ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\) ã¯å¼•用符ã¨ã—ã¦åƒãã¾ã™ã€‚ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒè¡Œæœ«ã«ã‚ã‚‹ã¨ãã¯è¡Œã®é€£çµã‚’行ã„ã¾ã™ã€‚対話モードã®ã‚·ã‚§ãƒ«ãŒ 2 行目以é™ã‚’読ã¿è¾¼ã‚€ã¨ãã€æ¨™æº–入力ãŒç«¯æœ«ãªã‚‰ã° PS2 変数ã®å€¤ãŒãƒ—ロンプトã¨ã—ã¦å‡ºåŠ›ã•れã¾ã™ã€‚

読ã¿è¾¼ã‚“ã æ–‡å­—列ã¯ã€å˜èªžåˆ†å‰²ã«ã‚ˆã£ã¦åˆ†å‰²ã—ã¾ã™ã€‚分割後ã®å„文字列ãŒã€ãれãžã‚Œã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã•れãŸå¤‰æ•°ã®å€¤ã«é †ã«è¨­å®šã•れã¾ã™ã€‚指定ã•れãŸå¤‰æ•°ã®æ•°ã‚ˆã‚Šåˆ†å‰²çµæžœã®ã»ã†ãŒå¤šã„å ´åˆã¯ã€æœ€å¾Œã®å¤‰æ•°ã«æ®‹ã‚Šã®åˆ†å‰²çµæžœã®å…¨ã¦ãŒå…¥ã‚Šã¾ã™ã€‚åˆ†å‰²çµæžœã®æ•°ã‚ˆã‚ŠæŒ‡å®šã•れãŸå¤‰æ•°ã®ã»ã†ãŒå¤šã„å ´åˆã¯ã€ä½™ã£ãŸå¤‰æ•°ã«ã¯ç©ºæ–‡å­—列ãŒå…¥ã‚Šã¾ã™ã€‚

オプション

-A
--array

æœ€å¾Œã«æŒ‡å®šã—ãŸå¤‰æ•°ã‚’é…列ã«ã—ã¾ã™ã€‚分割後ã®å„文字列ãŒé…列ã®è¦ç´ ã¨ã—ã¦è¨­å®šã•れã¾ã™ã€‚

-r
--raw-mode

読ã¿è¾¼ã‚“ã æ–‡å­—列ã®ä¸­ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’引用符ã¨ã—ã¦æ‰±ã‚ãªã„よã†ã«ã—ã¾ã™ã€‚

オペランド

変数å

読ã¿è¾¼ã‚“ã æ–‡å­—列を格ç´ã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š read コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Read ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ -A (--array) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/_bindkey.txt0000644000175000017500000000444612154557026016242 0ustar magicantmagicant= Bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Bindkey 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯{zwsp}link:lineedit.html[行編集]ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰è¨­å®šã‚’表示・設定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +bindkey -aev [{{キー}} [{{コマンド}}]]+ - +bindkey -l+ [[description]] == 説明 +-l+ (+--list+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€bindkey コマンドã¯ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã§åˆ©ç”¨å¯èƒ½ãª{zwsp}link:lineedit.html#commands[行編集コマンド]ã®ä¸€è¦§ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ ä»–ã®ã‚ªãƒ—ションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€bindkey コマンドã¯ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã®è¡¨ç¤ºã¾ãŸã¯è¨­å®šã‚’行ã„ã¾ã™ã€‚ - オペランドã¨ã—ã¦{{キー}}・{{コマンド}}を与ãˆãªã„å ´åˆã€ç¾åœ¨ã®ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰è¨­å®šã®å†…容を (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ - {{キー}}ã®ã¿ã‚’与ãˆã‚‹ã¨ã€ãã®ã‚­ãƒ¼ã«å¯¾ã™ã‚‹ç¾åœ¨ã®è¨­å®šã ã‘を出力ã—ã¾ã™ã€‚ - {{キー}}ã¨{{コマンド}}を両方与ãˆã‚‹ã¨ã€ãã®ã‚­ãƒ¼ã‚’入力ã—ãŸã¨ãã«å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã«è¨­å®šã—ã¾ã™ã€‚ [[options]] == オプション +-a+:: +--vi-command+:: Vi 風編集モードã®ã‚³ãƒžãƒ³ãƒ‰ãƒ¢ãƒ¼ãƒ‰ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚ +-e+:: +--emacs+:: Emacs 風編集モードã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚ +-v+:: +--vi-insert+:: Vi é¢¨ç·¨é›†ãƒ¢ãƒ¼ãƒ‰ã®æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã«ãŠã‘るキーãƒã‚¤ãƒ³ãƒ‰ã‚’表示・設定ã—ã¾ã™ã€‚ [[operands]] == オペランド {{キー}}:: 表示・設定ã™ã‚‹å¯¾è±¡ã®ã‚­ãƒ¼å…¥åŠ›ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã§ã™ã€‚ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å€¤ã«ã¯ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹link:lineedit.html#escape[エスケープシーケンス]ãŒåˆ©ç”¨ã§ãã¾ã™ã€‚ {{コマンド}}:: 設定ã™ã‚‹link:lineedit.html#commands[行編集コマンド]ã§ã™ã€‚ãƒã‚¤ãƒ•ン一㤠(+-+) を指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ{{キー}}ã«å¯¾ã™ã‚‹è¨­å®šã‚’削除ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š bindkey コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ bindkey コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_trap.txt0000644000175000017500000000650012154557026015554 0ustar magicantmagicant= Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作を設定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +trap+ - +trap {{動作}} {{シグナル}}...+ - +trap {{シグナル番å·}} [{{シグナル}}...]+ - +trap -p [{{シグナル}}...]+ [[description]] == 説明 Trap コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作 (dfn:[トラップ]) を表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ オペランドã«{{動作}}ã¨{{シグナル}}を指定ã—㦠trap コマンドを実行ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ãŒ{{シグナル}}ã‚’å—ä¿¡ã—ãŸéš›ã«æŒ‡å®šã—ãŸ{{動作}}を行ã†ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ{{シグナル番å·}}ã®å ´åˆã€ãã‚Œã¨æ®‹ã‚Šã®{{シグナル}}ã«å¯¾ã™ã‚‹å‹•作ã¯ã€å‹•作ã¨ã—㦠+-+ ãŒæŒ‡å®šã•れãŸã¨ãã¨åŒæ§˜ã«æ¨™æº–ã®å‹•作ã«è¨­å®šã•れã¾ã™ã€‚ +-p+ (+--print+) オプションを指定ã—ãŸå ´åˆã¾ãŸã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’一ã¤ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€trap コマンドã¯ç¾åœ¨ã®ãƒˆãƒ©ãƒƒãƒ—ã®è¨­å®šçжæ³ã‚’コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚{{シグナル}}ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã«é–¢ã™ã‚‹è¨­å®šã‚’ã€ä¸Žãˆã‚‰ã‚Œã¦ãªã„ã¨ãã¯å…¨ã¦ã®è¨­å®šã‚’出力ã—ã¾ã™ã€‚ [[options]] == オプション +-p+:: +--print+:: ç¾åœ¨ã®ãƒˆãƒ©ãƒƒãƒ—ã®è¨­å®šã‚’表示ã—ã¾ã™ã€‚ [[operands]] == オペランド {{動作}}:: シグナルをå—ä¿¡ã—ãŸéš›ã®å‹•作を指定ã—ã¾ã™ã€‚{{動作}}ãŒãƒã‚¤ãƒ•ン一㤠(+-+) ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ã‚·ã‚¹ãƒ†ãƒ ã§è¦å®šã•ã‚ŒãŸæ¨™æº–ã®å‹•作を行ã„ã¾ã™ã€‚{{動作}}ãŒç©ºæ–‡å­—列ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ã‚·ã‚°ãƒŠãƒ«ã‚’無視ã—ã¾ã™ã€‚ãれ以外ã®å€¤ã‚’指定ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã¿ãªã—ã¦ã€ã‚·ã‚°ãƒŠãƒ«å—信時ã«ã“れを解釈・実行ã—ã¾ã™ (コマンドã®å®Ÿè¡Œä¸­ã«ã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã¯ã€ã‚³ãƒžãƒ³ãƒ‰ãŒçµ‚了ã—ãŸå¾Œã«ãƒˆãƒ©ãƒƒãƒ—を実行ã—ã¾ã™)。 {{シグナル}}:: 動作ã®å¯¾è±¡ã¨ãªã‚‹ã‚·ã‚°ãƒŠãƒ«ã§ã™ã€‚シグナルã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã¨ã‚·ã‚°ãƒŠãƒ«åã®ã©ã¡ã‚‰ã‹ã§æŒ‡å®šã—ã¾ã™ã€‚ + {{シグナル}}ã¨ã—㦠+0+ ã¾ãŸã¯ +EXIT+ を指定ã™ã‚‹ã¨ã€ã“れã¯ã‚·ã‚§ãƒ«ã®çµ‚了時ã«ç™ºç”Ÿã™ã‚‹ä»®æƒ³ã®ã‚·ã‚°ãƒŠãƒ«ã‚’指定ã—ã¦ã„ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚ã“ã®ä»®æƒ³ã®ã‚·ã‚°ãƒŠãƒ«ã«å¯¾ã—ã¦è¨­å®šã•れãŸ{{動作}}ã¯ã€ã‚·ã‚§ãƒ«ãŒæ­£å¸¸çµ‚了ã™ã‚‹ç›´å‰ã«å®Ÿè¡Œã•れã¾ã™ã€‚ {{シグナル番å·}}:: {{シグナル}}ã¨åŒæ§˜ã§ã™ãŒã€ã‚·ã‚°ãƒŠãƒ«ã‚’番å·ã§æŒ‡å®šã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス ãƒˆãƒ©ãƒƒãƒ—ãŒæ­£ã—ã設定ã¾ãŸã¯è¡¨ç¤ºã•れãŸã¨ãã¯çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 Trap コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã¯ã€ã‚·ã‚°ãƒŠãƒ«å㯠+INT+ ã‚„ +QUIT+ ã®ã‚ˆã†ã«æœ€åˆã® SIG を除ã„ãŸå½¢ã§æŒ‡å®šã—ãªã‘れã°ãªã‚‰ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯ã€æ‹¡å¼µã¨ã—㦠SIG を付ã‘ãŸå½¢ã§ã‚‚指定ã§ãã¾ã™ã—ã€ã‚·ã‚°ãƒŠãƒ«åã®å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¾ã›ã‚“ (ã“ã®ã‚ˆã†ãªæ‹¡å¼µã¯ POSIX ã§ã‚‚èªã‚られã¦ã„ã¾ã™)。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_read.txt0000644000175000017500000000507112154557026015523 0ustar magicantmagicant= Read 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Read 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Read 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯æ¨™æº–入力ã‹ã‚‰è¡Œã‚’読ã¿è¾¼ã¿å¤‰æ•°ã«ä»£å…¥ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +read [-Ar] {{変数å}}...+ [[description]] == 説明 Read ã‚³ãƒžãƒ³ãƒ‰ã¯æ¨™æº–入力ã‹ã‚‰ä¸€è¡Œã®æ–‡å­—列を読ã¿è¾¼ã¿ã€ãれをlink:params.html#variables[変数]ã«ä»£å…¥ã—ã¾ã™ã€‚シェルãŒlink:interact.html[対話モード]ã§ã€link:lineedit.html[行編集]を利用ã™ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã‚‰ã°ã€èª­ã¿è¾¼ã¿ã«è¡Œç·¨é›†ã‚’使用ã—ã¾ã™ã€‚ +-r+ (+--raw-mode+) オプションを付ã‘ã‚‹ã¨ã€è¡Œå†…ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒæ§˜ã«æ‰±ã‚れã¾ã™ã€‚ +-r+ (+--raw-mode+) オプションを付ã‘ãªã„å ´åˆã€èª­ã¿è¾¼ã‚“ã æ–‡å­—列ã®ä¸­ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (+\+) ã¯link:syntax.html#quotes[引用符]ã¨ã—ã¦åƒãã¾ã™ã€‚ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒè¡Œæœ«ã«ã‚ã‚‹ã¨ãã¯è¡Œã®é€£çµã‚’行ã„ã¾ã™ã€‚link:interact.html[対話モード]ã®ã‚·ã‚§ãƒ«ãŒ 2 行目以é™ã‚’読ã¿è¾¼ã‚€ã¨ãã€æ¨™æº–入力ãŒç«¯æœ«ãªã‚‰ã° link:params.html#sv-ps2[+PS2+ 変数]ã®å€¤ãŒãƒ—ロンプトã¨ã—ã¦å‡ºåŠ›ã•れã¾ã™ã€‚ 読ã¿è¾¼ã‚“ã æ–‡å­—列ã¯ã€link:expand.html#split[å˜èªžåˆ†å‰²]ã«ã‚ˆã£ã¦åˆ†å‰²ã—ã¾ã™ã€‚分割後ã®å„文字列ãŒã€ãれãžã‚Œã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã•れãŸå¤‰æ•°ã®å€¤ã«é †ã«è¨­å®šã•れã¾ã™ã€‚指定ã•れãŸå¤‰æ•°ã®æ•°ã‚ˆã‚Šåˆ†å‰²çµæžœã®ã»ã†ãŒå¤šã„å ´åˆã¯ã€æœ€å¾Œã®å¤‰æ•°ã«æ®‹ã‚Šã®åˆ†å‰²çµæžœã®å…¨ã¦ãŒå…¥ã‚Šã¾ã™ã€‚åˆ†å‰²çµæžœã®æ•°ã‚ˆã‚ŠæŒ‡å®šã•れãŸå¤‰æ•°ã®ã»ã†ãŒå¤šã„å ´åˆã¯ã€ä½™ã£ãŸå¤‰æ•°ã«ã¯ç©ºæ–‡å­—列ãŒå…¥ã‚Šã¾ã™ã€‚ [[options]] == オプション +-A+:: +--array+:: æœ€å¾Œã«æŒ‡å®šã—ãŸå¤‰æ•°ã‚’link:params.html#arrays[é…列]ã«ã—ã¾ã™ã€‚分割後ã®å„文字列ãŒé…列ã®è¦ç´ ã¨ã—ã¦è¨­å®šã•れã¾ã™ã€‚ +-r+:: +--raw-mode+:: 読ã¿è¾¼ã‚“ã æ–‡å­—列ã®ä¸­ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’引用符ã¨ã—ã¦æ‰±ã‚ãªã„よã†ã«ã—ã¾ã™ã€‚ [[operands]] == オペランド {{変数å}}:: 読ã¿è¾¼ã‚“ã æ–‡å­—列を格ç´ã™ã‚‹å¤‰æ•°ã®åå‰ã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š read コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Read コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ +-A+ (+--array+) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/yash.txt.in0000644000175000017500000000053612154557026016023 0ustar magicantmagicant= YASH(1) 裕貴 渡邊 v{yashversion}, :encoding: UTF-8 :lang: ja == åå‰ yash - POSIX 準拠コマンドラインシェル == æ›¸å¼ +yash [オプション...] [--] [オペランド...]+ :leveloffset: 1 // (Replaced with generated contents list) // :leveloffset: 0 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_kill.html0000644000175000017500000001605112154557026015670 0ustar magicantmagicant Kill 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Kill 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Šã¾ã™ã€‚

æ§‹æ–‡

  • kill [-シグナル|-s シグナル|-n シグナル] プロセス

  • kill -l [-v] [シグナル…]

Kill コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚

説明

-l オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€kill ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã™ã€‚é€ä¿¡ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã®ç¨®é¡žã¯ã‚·ã‚°ãƒŠãƒ«æŒ‡å®šã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ã¾ã™ã€‚シグナルã®ç¨®é¡žã‚’指定ã—ãªã„å ´åˆã¯ SIGTERM シグナルをé€ä¿¡ã—ã¾ã™ã€‚

-l オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€kill ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸã‚·ã‚°ãƒŠãƒ«ã«é–¢ã™ã‚‹æƒ…報を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚シグナルを指定ã—ãªã„å ´åˆã¯å…¨ã¦ã®ã‚·ã‚°ãƒŠãƒ«ã«é–¢ã™ã‚‹æƒ…報を表示ã—ã¾ã™ã€‚

オプション

シグナル指定オプション

-シグナル
-s シグナル
-n シグナル

é€ä¿¡ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã‚’指定ã—ã¾ã™ã€‚シグナルã«ã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã¨ã‚·ã‚°ãƒŠãƒ«åã®ã©ã¡ã‚‰ã‹ã‚’指定ã—ã¾ã™ã€‚シグナル番å·ã¨ã—㦠0 を指定ã™ã‚‹ã¨ã€ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹ã“ã¨ãŒã§ãã‚‹ã‹ã©ã†ã‹ã®åˆ¤å®šã ã‘を行ã„ã€å®Ÿéš›ã«ã¯ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã›ã‚“。シグナルをåå‰ã§æŒ‡å®šã™ã‚‹éš›ã¯ã€å¤§æ–‡å­—ã¨å°æ–‡å­—ã®åŒºåˆ¥ã¯ã‚りã¾ã›ã‚“。

シグナル指定オプションã¯ä¸€åº¦ã«ä¸€ã¤ã¾ã§ã—ã‹ä½¿ãˆã¾ã›ã‚“。

ä»–ã®ã‚ªãƒ—ション

-l

シグナルã«é–¢ã™ã‚‹æƒ…報を表示ã—ã¾ã™ã€‚

-v

シグナルã«é–¢ã™ã‚‹æƒ…報をより詳ã—ã表示ã—ã¾ã™ã€‚-v オプションを指定ã—ã¦ã„ãªã„å ´åˆã¯å˜ã«ã‚·ã‚°ãƒŠãƒ«åを出力ã—ã¾ã™ãŒã€æŒ‡å®šã—ã¦ã„ã‚‹å ´åˆã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ãƒ»ã‚·ã‚°ãƒŠãƒ«å・シグナルã®ç°¡å˜ãªèª¬æ˜Žã‚’出力ã—ã¾ã™ã€‚

ã“ã®ã‚ªãƒ—ションを指定ã—ãŸã¨ãã¯åŒæ™‚ã« -l も指定ã—ã¦ã‚ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚

オペランド

プロセス

シグナルをé€ä¿¡ã™ã‚‹ãƒ—ロセスをプロセス ID・プロセスグループ ID・ジョブ ID ã®ã„ãšã‚Œã‹ã§æŒ‡å®šã—ã¾ã™ã€‚プロセスグループ ID を指定ã™ã‚‹ã¨ãã¯ã€å…ˆé ­ã«è² å· (-) を付ã‘ã¾ã™ã€‚プロセスã¨ã—㦠0 を指定ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ãƒ—ロセスãŒå±žã™ã‚‹ãƒ—ロセスグループを指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚プロセスã¨ã—㦠-1 を指定ã™ã‚‹ã¨ã€å…¨ã¦ã®ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ä¿¡ã—ã¾ã™ã€‚

シグナル

情報を表示ã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ã®åå‰ã¾ãŸã¯ç•ªå·ã§ã™ã€‚シグナルã«ã‚ˆã£ã¦ä¸­æ–­ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š kill コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚一ã¤ä»¥ä¸Šã®ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹ã“ã¨ãŒã§ããŸå ´åˆã€ä»–ã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚Œãªã‹ã£ãŸãƒ—ロセスãŒã‚ã£ãŸã¨ã—ã¦ã‚‚終了ステータス㯠0 ã«ãªã‚Šã¾ã™ã€‚

補足

Kill ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

è² æ•°ã«è¦‹ãˆã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®æ‰±ã„ã«ã¯æ³¨æ„ãŒå¿…è¦ã§ã™ã€‚例ãˆã° kill -1 -2 ã§ã¯ -1 ãŒã‚·ã‚°ãƒŠãƒ«æŒ‡å®šã‚ªãƒ—ションã€-2 ãŒã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ãªã‚‹ã®ã§ã€ç•ªå· 1 ã®ã‚·ã‚°ãƒŠãƒ«ã‚’プロセスグループ 2 ã«é€ä¿¡ã—ã¾ã™ã€‚kill — -1 -2 ã‚„ kill -TERM -1 -2 ã§ã¯ -1 㨠-2 ã¯ã©ã¡ã‚‰ã‚‚オペランドã«ãªã‚Šã¾ã™ã€‚

POSIX ã«ã¯ -v ãŠã‚ˆã³ -n オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“れらã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠-s オプションã®å¼•æ•°ã¨ã—ã¦ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã‚’指定ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。POSIX ã¯ã‚·ã‚°ãƒŠãƒ«ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦ã‚·ã‚°ãƒŠãƒ«ã®åå‰ã‚’指定ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。

POSIX ã¯ã€ã‚·ã‚°ãƒŠãƒ«å㯠INT ã‚„ QUIT ã®ã‚ˆã†ã«æœ€åˆã® SIG を除ã„ãŸå½¢ã§æŒ‡å®šã—ãªã‘れã°ãªã‚‰ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚éž POSIX 準拠モード㮠yash ã§ã¯ã€æ‹¡å¼µã¨ã—㦠SIG を付ã‘ãŸå½¢ã§ã‚‚指定ã§ãã¾ã™ã€‚

yash-2.35/doc/ja/_ulimit.txt0000644000175000017500000001140212154557026016106 0ustar magicantmagicant= Ulimit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Ulimit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Ulimit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™ã‚’表示・設定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +ulimit -a [-H|-S]+ - +ulimit [-H|-S] [-efilnqrstuvx] [{{値}}]+ [[description]] == 説明 Ulimit コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ +-a+ (+--all+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€ulimit コマンドã¯å…¨ã¦ã®ç¨®é¡žã®ãƒªã‚½ãƒ¼ã‚¹ã«ã¤ã„ã¦ç¾åœ¨ã®åˆ¶é™å€¤ã‚’一覧形å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚+-a+ (+--all+) オプションを付ã‘ãªã„ã§å®Ÿè¡Œã™ã‚‹ã¨ã€ä¸€ç¨®é¡žã®ãƒªã‚½ãƒ¼ã‚¹ã«ã¤ã„ã¦åˆ¶é™å€¤ã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚オペランドã§{{値}}を指定ã—ã¦ã„ã‚‹å ´åˆã€ãã®å€¤ã«åˆ¶é™å€¤ã‚’設定ã—ã¾ã™ã€‚{{値}}を指定ã—ã¦ã„ãªã„å ´åˆã¯ç¾åœ¨ã®åˆ¶é™å€¤ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚表示・設定ã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã¯ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ã¾ã™ã€‚設定ã—ãŸãƒªã‚½ãƒ¼ã‚¹ã®åˆ¶é™å€¤ã¯ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹å„コマンドã«å—ã‘ç¶™ãŒã‚Œã¾ã™ã€‚ リソースã®å„種類ã«ã¤ã„ã¦ã€dfn:[ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆ]ã¨dfn:[ソフトリミット]ã®äºŒç¨®é¡žã®åˆ¶é™å€¤ãŒã‚りã¾ã™ã€‚ソフトリミットãŒãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’è¶…ãˆã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。ã¾ãŸãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’ç·©ã‚ã‚‹ã«ã¯å°‚ç”¨ã®æ¨©é™ãŒå¿…è¦ã§ã™ã€‚ +-H+ (+--hard+) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€ulimit コマンドã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚+-S+ (+--soft+) オプションを指定ã—ã¦ã„ã‚‹å ´åˆã€ulimit コマンドã¯ã‚½ãƒ•トリミットを表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ã©ã¡ã‚‰ã®ã‚ªãƒ—ションも指定ã—ã¦ãªã„å ´åˆã€ulimit コマンドã¯ã‚½ãƒ•トリミットã®ã¿ã‚’表示ã™ã‚‹ã‹ã¾ãŸã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã¨ã‚½ãƒ•トリミットã®ä¸¡æ–¹ã‚’設定ã—ã¾ã™ã€‚ [[options]] == オプション +-H+:: +--hard+:: ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚’表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ +-S+:: +--soft+:: ソフトリミットを表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚ +-a+:: +--all+:: 全種類ã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã‚’表示ã—ã¾ã™ã€‚ 以下ã®ã‚ªãƒ—ションã¯è¡¨ç¤ºãƒ»è¨­å®šã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã‚’指定ã—ã¾ã™ã€‚ã“れらã®ã‚ªãƒ—ションãŒã©ã‚Œã‚‚与ãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã¯ã€+-f+ ãŒä¸Žãˆã‚‰ã‚ŒãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚(表示・設定å¯èƒ½ãªãƒªã‚½ãƒ¼ã‚¹ã®ç¨®é¡žã¯ã‚·ã‚¹ãƒ†ãƒ ã«ã‚ˆã£ã¦ç•°ãªã‚Šã¾ã™) +-c+:: +--core+:: プロセスãŒå¼·åˆ¶çµ‚了ã•ã›ã‚‰ã‚ŒãŸã¨ãã«ã§ãるコアファイルã®ã‚µã‚¤ã‚ºã®é™ç•Œ (512 ãƒã‚¤ãƒˆå˜ä½) +-d+:: +--data+:: プロセスãŒä½¿ç”¨ã§ãるデータセグメント領域ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) +-e+:: +--nice+:: スケジューリング優先度 (nice 値) ã®é™ç•Œ +-f+:: +--fsize+:: プロセスãŒä½œæˆã§ãるファイルã®ã‚µã‚¤ã‚ºã®é™ç•Œ (512 ãƒã‚¤ãƒˆå˜ä½) +-i+:: +--sigpending+:: プロセスã®å‡¦ç†å¾…ã¡ã‚·ã‚°ãƒŠãƒ«ã®å€‹æ•°ã®é™ç•Œ +-l+:: +--memlock+:: RAM 上ã«ãƒ­ãƒƒã‚¯å¯èƒ½ãªãƒ¡ãƒ¢ãƒªã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) +-m+:: +--rss+:: プロセス㮠lang:en[resident set] (RAM 上ã«å­˜åœ¨ã™ã‚‹ä»®æƒ³ãƒšãƒ¼ã‚¸) ã®æ•°ã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) +-n+:: +--nofile+:: プロセスãŒä½¿ç”¨ã§ãるファイル記述å­ã®æœ€å¤§å€¤ + 1 +-q+:: +--msgqueue+:: POSIX メッセージキューã®ã‚µã‚¤ã‚ºã®é™ç•Œ +-r+:: +--rtprio+:: リアルタイムスケジューリングã®å„ªå…ˆåº¦ã®é™ç•Œ +-s+:: +--stack+:: プロセスãŒä½¿ç”¨ã§ãるスタック領域ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) +-t+:: +--cpu+:: プロセスãŒä½¿ç”¨ã§ãã‚‹ CPU 時間ã®é™ç•Œ (ç§’å˜ä½) +-u+:: +--nproc+:: プロセスãŒèµ·å‹•ã§ãã‚‹å­ãƒ—ロセスã®å€‹æ•°ã®é™ç•Œ +-v+:: +--as+:: プロセスãŒä½¿ç”¨ã§ãるメモリ領域全体ã®ã‚µã‚¤ã‚ºã®é™ç•Œ (キロãƒã‚¤ãƒˆå˜ä½) +-x+:: +--locks+:: プロセスãŒãƒ­ãƒƒã‚¯ã§ãるファイルã®å€‹æ•°ã®é™ç•Œ [[operands]] == オペランド {{値}}:: 設定ã™ã‚‹ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™å€¤ã§ã™ã€‚ + 値ã¯åŸºæœ¬çš„ã« 0 以上ã®è‡ªç„¶æ•°ã§æŒ‡å®šã—ã¾ã™ãŒã€è‡ªç„¶æ•°ã®ä»£ã‚り㫠++hard++ã€++soft++ã€++unlimited++ ã®ã„ãšã‚Œã‹ã®æ–‡å­—列を指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“ã‚Œã‚‰ã®æ–‡å­—列ã¯ãれãžã‚Œç¾åœ¨ã®ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã®å€¤ã€ç¾åœ¨ã®ã‚½ãƒ•トリミットã®å€¤ã€ç„¡åˆ¶é™ã‚’表ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス リソース制é™å€¤ãŒæ­£ã—ã出力ã¾ãŸã¯è¨­å®šã§ããŸã¨ãã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ãŒè¦å®šã—ã¦ã„るオプション㯠+-f+ ã ã‘ã§ã™ã€‚ã¾ãŸ POSIX ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®{{値}}ã¨ã—ã¦è‡ªç„¶æ•°ã—ã‹è¦å®šã—ã¦ã„ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_popd.txt0000644000175000017500000000277012154557026015555 0ustar magicantmagicant= Popd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Popd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Popd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:_dirs.html[ディレクトリスタック]ã‹ã‚‰ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’削除ã—ã€ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’戻ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +popd [{{インデックス}}]+ [[description]] == 説明 Popd コマンドã¯link:_dirs.html[ディレクトリスタック]ã‹ã‚‰ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®è¦ç´ ã‚’削除ã—ã¾ã™ã€‚インデックス ++0+ ã®è¦ç´ ã‚’削除ã—ãŸå ´åˆã¯ã€æ–°ãŸã«ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ ++0+ ã®è¦ç´ ã¨ãªã£ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ [[operands]] == オペランド {{インデックス}}:: 削除ã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã™ã€‚çœç•¥ã™ã‚‹ã¨ ++0+ を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス ディレクトリスタックã®è¦ç´ ã‚’æ­£ã—ã削除ã—作業ディレクトリを変更ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 ディレクトリスタックã«è¦ç´ ãŒä¸€ã¤ã—ã‹ãªã„å ´åˆã¯ãれ以上è¦ç´ ã‚’削除ã§ããªã„ã®ã§ã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚ POSIX ã«ã¯ popd コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_alias.txt0000644000175000017500000000417312154557026015703 0ustar magicantmagicant= Alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:syntax.html#aliases[エイリアス]を設定・表示ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +alias [-gp] [{{エイリアスå}}[={{値}}]...]+ [[description]] == 説明 Alias コマンドã¯link:syntax.html#aliases[エイリアス]をオペランドã«å¾“ã£ã¦è¨­å®šã¾ãŸã¯è¡¨ç¤ºã—ã¾ã™ã€‚表示ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ (ã®ä¸€éƒ¨) ã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚オペランドを一ã¤ã‚‚与ãˆãªã„å ´åˆã€alias コマンドã¯ç¾åœ¨è¨­å®šã•れã¦ã„ã‚‹å…¨ã¦ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’表示ã—ã¾ã™ã€‚ [[options]] == オプション +-g+:: +--global+:: ã“ã®ã‚ªãƒ—ションを指定ã—ãŸå ´åˆã€è¨­å®šã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ãªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€è¨­å®šã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯é€šå¸¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ãªã‚Šã¾ã™ã€‚ +-p+:: +--prefix+:: ã“ã®ã‚ªãƒ—ションã¯è¡¨ç¤ºã®æ›¸å¼ã‚’é¸æŠžã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãŸå ´åˆã€alias コマンドã¨ãã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°å…¨ã¦ã‚’表示ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€alias ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã ã‘を表示ã—ã¾ã™ã€‚ [[operands]] == オペランド {{エイリアスå}}:: 表示ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã§ã™ã€‚ {{エイリアスå}}={{値}}:: 設定ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã¨ãã®å†…容ã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š alias コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Yash ã§ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã¨ã—ã¦ä½¿ãˆãªã„文字ã¯ã€ç©ºç™½æ–‡å­—・タブ・改行ã€ãŠã‚ˆã³ +=$<>\'"`;&|()#+ ã®å„文字ã§ã™ã€‚エイリアスã®å†…容ã«ã¯ã™ã¹ã¦ã®æ–‡å­—ãŒä½¿ãˆã¾ã™ã€‚ Alias コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_umask.html0000644000175000017500000001734712154557026016066 0ustar magicantmagicant Umask 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Umask 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’表示・設定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • umask マスク

  • umask [-S]

説明

オペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã€umask コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ç¾åœ¨ã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚-S (--symbolic) オプションã§å‡ºåŠ›ã®å½¢å¼ã‚’指定ã§ãã¾ã™ã€‚出力ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦å†åˆ©ç”¨å¯èƒ½ãªå½¢å¼ã«ãªã£ã¦ã„ã¾ã™ã€‚

オペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã€umask コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’与ãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å€¤ã«è¨­å®šã—ã¾ã™ã€‚

オプション

-S
--symbolic

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã¯ã€è¨˜å·å½¢å¼ã§ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’出力ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æ•°å€¤å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚

オペランド

マスク

ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€umask コマンドã¯ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’ã“ã®å€¤ã«è¨­å®šã—ã¾ã™ã€‚値ã¯ä»¥ä¸‹ã«è¿°ã¹ã‚‹æ•°å€¤å½¢å¼ã¨è¨˜å·å½¢å¼ã®ã©ã¡ã‚‰ã‹ã§ä¸Žãˆã¾ã™ã€‚

数値形å¼

数値形å¼ã¯ 0 以上ã®å…«é€²æ•´æ•°ã§ãƒžã‚¹ã‚¯ã‚’指定ã—ã¾ã™ã€‚ã“れã¯ä»¥ä¸‹ã®å„モードを表ã™è‡ªç„¶æ•°ã®ã„ãã¤ã‹ã®å’Œã§ã™ã€‚

0400

ユーザã®èª­ã¿å–り権é™

0200

ãƒ¦ãƒ¼ã‚¶ã®æ›¸ãè¾¼ã¿æ¨©é™

0100

ユーザã®å®Ÿè¡Œæ¨©é™

0040

グループã®èª­ã¿å–り権é™

0020

ã‚°ãƒ«ãƒ¼ãƒ—ã®æ›¸ãè¾¼ã¿æ¨©é™

0010

グループã®å®Ÿè¡Œæ¨©é™

0004

ãã®ä»–ã®èª­ã¿å–り権é™

0002

ãã®ä»–ã®æ›¸ãè¾¼ã¿æ¨©é™

0001

ãã®ä»–ã®å®Ÿè¡Œæ¨©é™

記å·å½¢å¼

記å·å½¢å¼ã¯ä»¥ä¸‹ã®ã‚ˆã†ãªæ›¸å¼ã®è¨˜å·åˆ—ã§ãƒžã‚¹ã‚¯ã—ãªã„権é™ã‚’指定ã—ã¾ã™ã€‚

記å·åˆ—ã¯ä¸€ã¤ä»¥ä¸Šã®ç¯€ã‚’カンマ (,) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚ 節ã¯å¯¾è±¡ã®åˆ—ã¨ä¸€ã¤ä»¥ä¸Šã®å‹•作ã‹ã‚‰ãªã‚Šã¾ã™ã€‚

対象ã«ã¯ä»¥ä¸‹ã®è¨˜å·ã‚’ã„ãã¤ã§ã‚‚指定ã§ãã¾ã™ã€‚

u

ユーザ

g

グループ

o

ãã®ä»–

a

ユーザ・グループ・ãã®ä»–ã®å…¨ã¦

対象ãŒä¸€ã¤ã‚‚指定ã•れã¦ã„ãªã„å ´åˆã¯ a ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

動作ã¯ä»¥ä¸‹ã®æ¼”ç®—å­ã¨æ¨©é™ã®çµ„ã¿åˆã‚ã›ã§ã™ã€‚ 演算å­ã¯ä»¥ä¸‹ã®ã©ã‚Œã‹ã§ã™ã€‚

=

対象ã«å¯¾ã™ã‚‹è¨­å®šã‚’権é™ã«ã—ã¾ã™ã€‚

+

対象ã«å¯¾ã™ã‚‹è¨­å®šã«æ¨©é™ã‚’加ãˆã¾ã™ã€‚

-

対象ã«å¯¾ã™ã‚‹è¨­å®šã‹ã‚‰æ¨©é™ã‚’除ãã¾ã™ã€‚

権é™ã¯ä»¥ä¸‹ã®ã©ã‚Œã‹ã§ã™ã€‚

r

読ã¿å–り権é™

w

書ãè¾¼ã¿æ¨©é™

x

実行権é™

X

å®Ÿè¡Œæ¨©é™ (元々実行権é™ãŒè¨­å®šã•れã¦ã„ãŸå ´åˆã®ã¿)

s

Set-user-ID, Set-group-ID

u

ç¾åœ¨ã®ãƒ¦ãƒ¼ã‚¶ã®å€¤

g

ç¾åœ¨ã®ã‚°ãƒ«ãƒ¼ãƒ—ã®å€¤

o

ç¾åœ¨ã®ãã®ä»–ã®å€¤

r, w, x, X, s ã®è¨˜å·åŒå£«ã¯ä¸€åº¦ã«çµ„ã¿åˆã‚ã›ã¦æŒ‡å®šã§ãã¾ã™ã€‚

例ãˆã° umask u=rwx,go+r-w を実行ã™ã‚‹ã¨ã€ãƒ¦ãƒ¼ã‚¶ã®èª­ã¿å–り権é™ã¨æ›¸ãè¾¼ã¿æ¨©é™ã¨å®Ÿè¡Œæ¨©é™ã‚’マスクã—ãªã„よã†ã«ã—ã€ã‚°ãƒ«ãƒ¼ãƒ—ã¨ãã®ä»–ã®èª­ã¿å–り権é™ã‚’マスクã—ãªã„よã†ã«ã—ã€ã‚°ãƒ«ãƒ¼ãƒ—ã¨ãã®ä»–ã®æ›¸ãè¾¼ã¿æ¨©é™ã‚’マスクã™ã‚‹ã‚ˆã†ã«ã—ã¾ã™ã€‚

終了ステータス

ファイルモード作æˆãƒžã‚¹ã‚¯ãŒæ­£ã—ã出力ã¾ãŸã¯è¨­å®šã§ããŸã¨ãã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

Ulimit ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX 㯠-S オプションを指定ã—ãªã‹ã£ãŸå ´åˆã®å‡ºåЛ形å¼ãŒå¿…ãšã—も数値形å¼ã§ã‚ã‚‹ã¨ã¯è¦å®šã—ã¦ã„ã¾ã›ã‚“。

yash-2.35/doc/ja/fgrammar.html0000644000175000017500000003624112154557026016375 0ustar magicantmagicant æ§‹æ–‡ã®å½¢å¼çš„定義

ã“ã“ã« yash ã®æ–‡æ³•ã®å½¢å¼çš„定義を示ã—ã¾ã™ã€‚Yash ã®æ–‡æ³•ã¯è§£æžè¡¨ç¾æ–‡æ³•ã§å®šç¾©ã•れã¾ã™ã€‚

Yash ã®æ–‡æ³•ã«ãŠã‘る終端記å·ã®é›†åˆã¯ã€yash を実行ã™ã‚‹ç’°å¢ƒãŒæ‰±ãˆã‚‹ä»»æ„ã®æ–‡å­—ã®é›†åˆ (実行文字集åˆ) ã§ã™ (ãŸã ã—ナル文字 '\0' を除ã)。

以下ã¯ã€yash ã®æ–‡æ³•ã‚’æ§‹æˆã™ã‚‹éžçµ‚端記å·ã¨ãれã«å¯¾å¿œã™ã‚‹çµ‚端記å·ã®ä¸€è¦§ã§ã™ã€‚ãŸã ã—ã“ã“ã«æŒ™ã’る文法ã®å®šç¾©ã«ã¯ãƒ’アドキュメントã®å†…容ã¨ãã®çµ‚ã‚りを表ã™è¡Œã®è§£æžã®ãŸã‚ã®è¦å‰‡ã¯å«ã¾ã‚Œã¦ã„ã¾ã›ã‚“。ã¾ãŸ POSIX 準拠モードã§ã¯æ§‹æ–‡ãŒè‹¥å¹²å¤‰ã‚りã¾ã™ãŒã€ã“ã“ã«ã¯ç¤ºã—ã¾ã›ã‚“。

CompleteCommand

Sequence EOF

Sequence

N* List*

List

Pipeline ((&& / ||) N* Pipeline)* ListSeparator

Pipeline

Bang? Command (| N* Command)*

Command

CompoundCommand Redirection* /
!R FunctionDefinition /
!R SimpleCommand

CompoundCommand

Subshell /
Grouping /
IfCommand /
ForCommand /
WhileCommand /
CaseCommand /
FunctionCommand

Subshell

( Sequence ) S*

Grouping

LeftBrace Sequence RightBrace

IfCommand

If Sequence Then Sequence (Elif Sequence Then Sequence)* (Else Sequence)? Fi

ForCommand

For Name S* Separator? (In Word* Separator)? Do Sequence Done

WhileCommand

(While / Until) Sequence Do Sequence Done

CaseCommand

Case Word N* In N* CaseItem* Esac

CaseItem

!Esac (( S*)? Word (| S* Word)* ) Sequence (;; / &Esac)

FunctionCommand

Function Word (( S* ))? N* CompoundCommand Redirection*

FunctionDefinition

Name S* ( S* ) N* CompoundCommand Redirection*

SimpleCommand

&(Word / Redirection) (Assignment / Redirection)* (Word / Redirection)*

Assignment

Name = Word /
Name =( N* (Word N*)* )

Name

![[:digit:]] [[:alnum:] _]+

PortableName

![0-9] [0-9 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+

Word

(WordElement / !SpecialChar .)+ S*

WordElement

\ . /
' (!' .)* ' /
" QuoteElement* " /
Parameter /
Arithmetic /
CommandSubstitution

QuoteElement

\ ([$`"\] / NL) /
Parameter /
Arithmetic /
CommandSubstitution /
![`"\] .

Parameter

$ [@*#?-$! [:digit:]] /
$ PortableName /
$ ParameterBody

ParameterBody

{ ParameterNumber? (ParameterName / ParameterBody / Parameter) ParameterIndex? ParameterMatch? }

ParameterNumber

# ![+=:/%] !([-?#] })

ParameterName

[@*#?-$!] /
[[:alnum:] _]+

ParameterIndex

[ ParameterIndexWord (, ParameterIndexWord)? ]

ParameterIndexWord

(WordElement / !["'],] .)+

ParameterMatch

:? [-+=?] ParameterMatchWord /
(# / ## / % / %%) ParameterMatchWord /
(:/ / / [#%/]?) ParameterMatchWordNoSlash (/ ParameterMatchWord)?

ParameterMatchWord

(WordElement / !["'}] .)*

ParameterMatchWordNoSlash

(WordElement / !["'/}] .)*

Arithmetic

$(( ArithmeticBody* ))

ArithmeticBody

\ . /
Parameter /
Arithmetic /
CommandSubstitution /
( ArithmeticBody ) /
![`()] .

CommandSubstitution

$( Sequence ) /
` CommandSubstitutionBody* `

CommandSubstitutionBody

\ [$`\] /
!` .

Redirection

RedirectionFD RedirectionOperator S* Word /
RedirectionFD <( Sequence ) /
RedirectionFD >( Sequence )

RedirectionFD

[[:digit:]]*

RedirectionOperator

< / <> / > / >| / >> / >>| / <& / >& / << / <<- / <<<

ListSeparator

Separator /
& N* /
&) /
&;;

Separator

; N* /
N+ /
EOF

N

S* NL

S

[[:blank:]] /
Comment

Comment

# (!NL .)*

R

Bang / LeftBrace / RightBrace / Case / Do / Done / Elif / Else / Esac / Fi / For / If / In / Then / Until / While

Bang

! D

LeftBrace

{ D

RightBrace

} D

Case

case D

Do

do D

Done

done D

Elif

elif D

Else

else D

Esac

esac D

Fi

fi D

For

for D

Function

function D

If

if D

In

in D

Then

then D

Until

until D

While

while D

D

!Word S*

SpecialChar

[|&;<>()`\"' [:blank:]] / NL

NL

<newline>

EOF

!.

yash-2.35/doc/ja/_type.html0000644000175000017500000000407112154557026015715 0ustar magicantmagicant Type 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Type 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡žã‚’特定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • type [-abefkp] [コマンド…]

説明

Type コマンド㯠command コマンド㫠-V オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠command コマンドã¨åŒã˜ã§ã™ã€‚

補足

POSIX ã§ã¯ã€type コマンド㨠command コマンドã¨ã®é–¢ä¿‚ã«ã¤ã„ã¦è¦å®šã—ã¦ã„ã¾ã›ã‚“。従ã£ã¦ä»–ã®ã‚·ã‚§ãƒ«ã® type コマンド㯠command コマンド㫠-V オプションを付ã‘ãŸã‚‚ã®ã¨ã¯ç•°ãªã‚‹å‹•作をã™ã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ã¾ãŸ POSIX 㯠type コマンドã®ã‚ªãƒ—ションをè¦å®šã—ã¦ã„ã¾ã›ã‚“。

POSIX 準拠モードã§ã¯å°‘ãªãã¨ã‚‚一ã¤ã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚

yash-2.35/doc/ja/_set.html0000644000175000017500000004237612154557026015541 0ustar magicantmagicant Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ションã®è¨­å®šã¨ä½ç½®ãƒ‘ラメータã®å¤‰æ›´ã‚’行ã„ã¾ã™ã€‚

æ§‹æ–‡

  • set [オプション…] [オペランド…]

  • set -o

  • set +o

Set コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚

説明

コマンドライン引数を一切与ãˆãšã« set コマンドを実行ã™ã‚‹ã¨ã€ç¾åœ¨ã‚·ã‚§ãƒ«ã«è¨­å®šã•れã¦ã„ã‚‹å…¨ã¦ã®å¤‰æ•°ã®ä¸€è¦§ã‚’アルファベット順㧠(コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

-o を唯一ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸ŽãˆãŸå ´åˆã¯ç¾åœ¨ã®ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ション設定を一覧ã«ã—ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚+o を唯一ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸ŽãˆãŸå ´åˆã‚‚åŒæ§˜ã§ã™ãŒã€ã“ã®å ´åˆã¯ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚

ã“れ以外ã®å ´åˆã¯ã€set コマンドã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ションã®è¨­å®šã¨ä½ç½®ãƒ‘ラメータã®å¤‰æ›´ã®ã©ã¡ã‚‰ã‹ã¾ãŸã¯ä¸¡æ–¹ã®å‹•作を行ã„ã¾ã™ã€‚

オプション

オプションãŒä¸€ã¤ä»¥ä¸Šä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã€set コマンドã¯ãã‚Œã‚‰ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’åˆ‡ã‚Šæ›¿ãˆã¾ã™ã€‚通常ã®å½¢å¼ã§ã‚ªãƒ—ションを与ãˆã‚‹ã¨ã€ãã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã¯æœ‰åйã«ãªã‚Šã¾ã™ã€‚オプションã®å…ˆé ­ã®ãƒã‚¤ãƒ•ン (-) ã®ä»£ã‚りã«ãƒ—ラス (+) を付ã‘ã¦æŒ‡å®šã™ã‚‹ã¨ã€ãã®ã‚ªãƒ—ションã¯ç„¡åйã«ãªã‚Šã¾ã™ã€‚例ãˆã° -m ã‚„ -o monitor ã‚„ --monitor ã¯ã‚·ã‚§ãƒ«ã®ã‚¸ãƒ§ãƒ–制御を有効ã«ã—ã€é€†ã« +m ã‚„ +o monitor ã‚„ ++monitor ã¯ã‚¸ãƒ§ãƒ–制御を無効ã«ã—ã¾ã™ã€‚

é•·ã„オプションã®åå‰ã«å«ã¾ã‚Œã‚‹è‹±æ•°å­—ä»¥å¤–ã®æ–‡å­—ã¯ç„¡è¦–ã•れã€å¤§æ–‡å­—ã¨å°æ–‡å­—ã®åŒºåˆ¥ã¯ã‚りã¾ã›ã‚“。例ãˆã° --Le-Comp-Debug 㯠--lecompdebug ã«åŒã˜ã§ã™ã€‚ã¾ãŸé•·ã„オプションã®åå‰ã®å…ˆé ­ã« no を付ã‘ã‚‹ã“ã¨ã§ã€ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’é€†è»¢ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚例ãˆã° --noallexport 㯠++allexport ã«åŒã˜ãã€ã¾ãŸ ++nonotify 㯠--notify ã«åŒã˜ã§ã™ã€‚

オプションã¯ä»¥ä¸‹ã«æŒ™ã’ã‚‹å½¢å¼ã§æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™:

  • é•·ã„オプション (例: --allexport)

  • 引数ã¨ã—ã¦ã‚ªãƒ—ションåを指定ã—㟠-o オプション (例: -o allexport)

  • 一文字ã®ã‚ªãƒ—ション (例: -a)

ãŸã ã—å…¨ã¦ã®ã‚ªãƒ—ションãŒä¸€æ–‡å­—ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã§ãã‚‹ã‚ã‘ã§ã¯ã‚りã¾ã›ã‚“。

利用å¯èƒ½ãªã‚ªãƒ—ションã¯ä»¥ä¸‹ã®ã¨ãŠã‚Šã§ã™:

all-export (-a)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å¤‰æ•°ã«ä»£å…¥ã‚’ã™ã‚‹ã¨ãã®å¤‰æ•°ã¯è‡ªå‹•çš„ã«ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚

brace-expand

ã“ã®ã‚ªãƒ—ションã¯ãƒ–レース展開を有効ã«ã—ã¾ã™ã€‚

case-glob

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã«ãŠã‘るパターンマッãƒãƒ³ã‚°ã¯å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¦è¡Œã„ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚

clobber (+C)

ã“ã®ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã¨ã€ > 演算å­ã«ã‚ˆã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§æ—¢å­˜ã®ãƒ•ァイルを上書ãã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚

cur-async
cur-bg
cur-stop

ã“れらã®ã‚ªãƒ—ションã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã®é¸æŠžã®ä»•æ–¹ã«å½±éŸ¿ã—ã¾ã™ã€‚(ジョブ ID å‚ç…§)。ã“れらã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚

dot-glob

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã«ãŠã„ã¦ãƒ•ァイルåã®å…ˆé ­ã®ãƒ”ãƒªã‚ªãƒ‰ã‚’ç‰¹åˆ¥ã«æ‰±ã„ã¾ã›ã‚“。

emacs

ã“ã®ã‚ªãƒ—ション㯠emacs 風行編集を有効ã«ã—ã¾ã™ã€‚

err-exit (-e)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å®Ÿè¡Œã—ãŸãƒ‘イプラインã®çµ‚了ステータス㌠0 ã§ãªã‘れã°ã€ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ãŸã ã—ã€ä»¥ä¸‹ã®å ´åˆã‚’除ãã¾ã™ã€‚

exec (+n)

ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®è§£é‡ˆã ã‘を行ã„ã€å®Ÿéš›ã«ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã‚¹ã‚¯ãƒªãƒ—ãƒˆã®æ–‡æ³•ãƒã‚§ãƒƒã‚¯ã‚’ã™ã‚‹ã®ã«ä¾¿åˆ©ã§ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚対話モードã§ã¯ã€ã“ã®ã‚ªãƒ—ションã«é–¢ã‚らãšã‚³ãƒžãƒ³ãƒ‰ã¯å¸¸ã«å®Ÿè¡Œã•れã¾ã™ã€‚

extended-glob

ã“ã®ã‚ªãƒ—ションã¯ãƒ‘スå展開ã«ãŠã‘る拡張機能を有効ã«ã—ã¾ã™ã€‚

glob (+f)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãã¯ã‚·ã‚§ãƒ«ã¯ãƒ‘スå展開を行ã„ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚

hash-on-def (-h)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ã関数を定義ã™ã‚‹ã¨ã€ç›´ã¡ã«ãã®é–¢æ•°å†…ã§ä½¿ã‚れるå„コマンド㮠PATH 検索を行ã„コマンドã®ãƒ‘スåを記憶ã—ã¾ã™ã€‚

hist-space

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ç©ºç™½ã§å§‹ã¾ã‚‹è¡Œã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«è‡ªå‹•çš„ã«è¿½åŠ ã—ã¾ã›ã‚“。

ignore-eof

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ã« EOF (入力ã®çµ‚ã‚り) ãŒå…¥åŠ›ã•れã¦ã‚‚シェルã¯ãれを無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã®èª­ã¿è¾¼ã¿ã‚’ç¶šã‘ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€èª¤ã£ã¦ Ctrl-D を押ã—ã¦ã—ã¾ã£ã¦ã‚‚シェルã¯çµ‚了ã—ãªããªã‚Šã¾ã™ã€‚

le-always-rp
le-comp-debug
le-conv-meta
le-no-conv-meta
le-prompt-sp
le-visible-bell

ã“れらã®ã‚ªãƒ—ションã¯è¡Œç·¨é›†ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚行編集ã®ã‚ªãƒ—ションをå‚ç…§ã—ã¦ãã ã•ã„。

mark-dirs

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã®å±•é–‹çµæžœã«ãŠã„ã¦ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表ã™ã‚‚ã®ã®æœ«å°¾ã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’付ã‘ã¾ã™ã€‚

monitor (-m)

ã“ã®ã‚ªãƒ—ションã¯ã‚¸ãƒ§ãƒ–制御を有効ã«ã—ã¾ã™ã€‚シェルを対話モードã§èµ·å‹•ã—ãŸã¨ãã“ã®ã‚ªãƒ—ションã¯è‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚

notify (-b)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã®ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡ŒçŠ¶æ…‹ãŒå¤‰åŒ–ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«ãれを標準エラーã«å ±å‘Šã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ション㯠notifyle オプションより優先ã—ã¾ã™ã€‚

notify-le

ã“ã®ã‚ªãƒ—ション㯠notify オプションã¨ã»ã¼åŒã˜ã§ã™ãŒã€è¡Œç·¨é›†ã‚’行ã£ã¦ã„る最中ã®ã¿ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚

null-glob

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘スå展開ã§ãƒžãƒƒãƒã™ã‚‹ãƒ‘スåãŒãªã„ã¨ãå…ƒã®ãƒ‘ã‚¿ãƒ¼ãƒ³ã¯æ®‹ã‚Šã¾ã›ã‚“。

posixly-correct

ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードを有効ã«ã—ã¾ã™ã€‚

trace-all

ã“ã®ã‚ªãƒ—ションã¯ã€è£œåŠ©ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œä¸­ã‚‚ x-trace オプションを機能ã•ã›ã‚‹ã‹ã©ã†ã‹ã‚’指定ã—ã¾ã™ã€‚補助コマンドã¨ã¯ã€ COMMAND_NOT_FOUND_HANDLER〠PROMPT_COMMANDã€ãŠã‚ˆã³ YASH_AFTER_CD 変数ã®å€¤ã¨ã—ã¦å®šç¾©ã•れã€ç‰¹å®šã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§è§£é‡ˆãƒ»å®Ÿè¡Œã•れるコマンドã§ã™ã€‚ ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚

unset (+u)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ãƒ‘ラメータ展開ã§å­˜åœ¨ã—ãªã„変数を展開ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ã¯ãªã‚‰ãšç©ºæ–‡å­—列ã«å±•é–‹ã•れã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚

verbose (-v)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯èª­ã¿è¾¼ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ã‚’ãã®ã¾ã¾æ¨™æº–エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚

vi

ã“ã®ã‚ªãƒ—ション㯠vi 風行編集を有効ã«ã—ã¾ã™ã€‚å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åŠ¹ã§æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ãªã‚‰ã°ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«è‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚

x-trace (-x)

ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹å‰ã«å±•é–‹ã®çµæžœã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã®å‡ºåŠ›ã¯ã€å„行頭㫠PS4 変数ã®å€¤ã‚’展開ã—ãŸçµæžœã‚’付ã‘ã¦ç¤ºã•れã¾ã™ã€‚ Trace-all オプションもå‚ç…§ã—ã¦ãã ã•ã„。

オペランド

Set コマンドã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã¾ãŸã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’区切るãƒã‚¤ãƒ•ン二㤠(--, コマンドã®å¼•æ•°ã®æ§‹æ–‡å‚ç…§) ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«å…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€ç¾åœ¨ã®ä½ç½®ãƒ‘ラメータã¯å‰Šé™¤ã•れã€ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒãれãžã‚Œæ–°ã—ãä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚ãƒã‚¤ãƒ•ン二ã¤ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã¦ã‹ã¤ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒãªã„å ´åˆã¯ä½ç½®ãƒ‘ラメータã¯ãªããªã‚Šã¾ã™ã€‚

終了ステータス

ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šãŒé–“é•ã£ã¦ã„ã‚‹å ´åˆã‚’除ãã€set コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Set コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX è¦æ ¼ã«å®šç¾©ã•れã¦ã„るオプションã¯é™ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚è¦æ ¼ã®å®šç¾©ã§ã¯ã€

  • --allexport ãªã©ã®é•·ã„オプションã¯ä½¿ãˆã¾ã›ã‚“。

  • オプションåã« no を付ã‘ã¦ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

  • オプションåã«å¤§æ–‡å­—や英字ã§ãªã„記å·ã¯ä½¿ãˆã¾ã›ã‚“。

è¦æ ¼ã«å®šç¾©ã•れã¦ã„るオプションã¯ä»¥ä¸‹ã®ã¨ãŠã‚Šã§ã™:

  • -a, -o allexport

  • -e, -o errexit

  • -m, -o monitor

  • -C, -o noclobber

  • -n, -o noexec

  • -f, -o noglob

  • -b, -o notify

  • -u, -o nounset

  • -v, -o verbose

  • -x, -o xtrace

  • -h

  • -o ignoreeof

  • -o nolog

  • -o vi

POSIX ã§ã¯ã“ã®ã»ã‹ã«ã€é–¢æ•°å®šç¾©ã‚’コマンド履歴ã«ç™»éŒ²ã—ãªã„よã†ã«ã™ã‚‹ -o nolog オプションをè¦å®šã—ã¦ã„ã¾ã™ãŒã€yash ã¯ã“れをサãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã›ã‚“。

yash-2.35/doc/ja/_exec.txt0000644000175000017500000000772012154557026015537 0ustar magicantmagicant= Exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ã®ãƒ—ロセスを別ã®å¤–部コマンドã«ç½®ãæ›ãˆã¾ã™ã€‚ã¾ãŸã‚·ã‚§ãƒ«ã®ãƒ—ロセスã«å¯¾ã—ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚’実行ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +exec [-cf] [-a {{コマンドå}}] [{{コマンド}} [{{引数}}...]]+ Exec コマンドã§ã¯ã€link:posix.html[POSIX 準拠モード]ã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“れ㯠exec コマンドã«å¯¾ã™ã‚‹ã‚ªãƒ—ションã¨{{コマンド}}ã«å¯¾ã™ã‚‹ã‚ªãƒ—ションを区別ã™ã‚‹ãŸã‚ã«é‡è¦ã§ã™ã€‚{{コマンド}}より後ã«ã‚る引数ã¯ã™ã¹ã¦{{引数}}ã¨ã¿ãªã•れã¾ã™ã€‚ [[description]] == 説明 Exec コマンドを{{コマンド}}を指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯link:exec.html#simple[å˜ç´”コマンドã®å®Ÿè¡Œ]ã®æœ€å¾Œã®ã‚¹ãƒ†ãƒƒãƒ—ã¨åŒæ§˜ã«ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã¯å¿…ãšå¤–部コマンドã¨ã—ã¦ã¿ãªã•れã€é–¢æ•°ã‚„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç„¡è¦–ã—ã¾ã™ã€‚ãã—ã¦ãã®å¤–部コマンドã¯ã‚µãƒ–シェルã§ã¯ãªãç¾åœ¨ã®link:exec.html#environment[コマンド実行環境]ã§ exec システムコールを呼ã³å‡ºã™ã“ã¨ã§å®Ÿè¡Œã—ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚·ã‚§ãƒ«ã®ãƒ—ãƒ­ã‚»ã‚¹ã¯æ–°ã—ãèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«ç½®ãæ›ã‚りã¾ã™ã€‚ シェル㌠link:posix.html[POSIX 準拠モード]ã®ã¨ãã¾ãŸã¯link:interact.html[対話モード]ã§ãªã„ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ã®èµ·å‹•ã«å¤±æ•—ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ シェル㌠POSIX 準拠モードã§ã¯ãªãã‹ã¤å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã¨ãã€åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã—ã¾ã›ã‚“。一度 exec ãŒå®Ÿè¡Œã•れるã¨ã€ã‚·ã‚§ãƒ«ãŒæŒã£ã¦ã„ã‚‹ã‚¸ãƒ§ãƒ–ã®æƒ…å ±ã¯å¤±ã‚れるãŸã‚ã€æ‰‹å‹•ã§ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã£ã¦ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã¾ãŸã¯çµ‚了ã•ã›ãªã‘れã°ãªã‚‰ãªããªã‚Šã¾ã™ã€‚警告を無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã™ã‚‹ã«ã¯ +-f+ (+--force+) オプションを付ã‘ã¦ãã ã•ã„。 {{コマンド}}ãªã—ã§å®Ÿè¡Œã—ãŸå ´åˆ exec コマンドã¯ä½•も行ã„ã¾ã›ã‚“ãŒã€ã“ã® exec コマンドを実行ã™ã‚‹éš›ã«è¡Œã£ãŸlink:redir.html[リダイレクト]ã®åŠ¹æžœã¯ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã«æ®‹ã‚Šã¾ã™ã€‚ [[options]] == オプション +-a {{コマンドå}}+:: +--as={{コマンドå}}+:: {{コマンド}}ã®ä»£ã‚りã«{{コマンドå}}をコマンドåã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã—ã¾ã™ã€‚ +-c+:: +--clear+:: 既存ã®link:params.html#variables[環境変数]ã‚’ã™ã¹ã¦å‰Šé™¤ã—ãŸçŠ¶æ…‹ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ãŸã ã—ã“ã® exec コマンドを実行ã™ã‚‹éš›ã«è¡Œã£ãŸå¤‰æ•°ä»£å…¥ã®çµæžœã¯ç’°å¢ƒå¤‰æ•°ã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã—ã¾ã™ã€‚ +-f+:: +--force+:: 警告を無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ [[operands]] == オペランド {{コマンド}}:: 実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ {{引数}}...:: 実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚ [[exitstatus]] == 終了ステータス 指定ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®èµ·å‹•ã«æˆåŠŸã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã¯ãã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセスã«ç½®ãæ›ã‚ã£ã¦ã—ã¾ã†ã®ã§ã€çµ‚了ステータスã¯ã‚りã¾ã›ã‚“。 実行ã—よã†ã¨ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠127 ã§ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã£ãŸãŒå®Ÿè¡Œã§ããªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠126 ã§ã™ã€‚{{コマンド}}を指定ã›ãšã« exec コマンドを実行ã—ãŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Exec コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/interact.html0000644000175000017500000005303112154557026016406 0ustar magicantmagicant 対話モード

対話モードã¯ã€åˆ©ç”¨è€…ãŒç›´æŽ¥ã‚·ã‚§ãƒ«ã‚’æ“作ã™ã‚‹ã“ã¨ã‚’æ„図ã—ãŸãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚シェルã®èµ·å‹•時㫠-i オプションを指定ã—ãŸå ´åˆ (ãã®ä»–å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åйã«ãªã‚‹æ¡ä»¶ãŒæº€ãŸã•れã¦ã„ã‚‹å ´åˆ)ã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚シェルãŒèµ·å‹•ã—ãŸå¾Œã¯ã€ãã®ã‚·ã‚§ãƒ«ã®å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚ªãƒ³ãƒ»ã‚ªãƒ•を切り替ãˆã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åŠ¹ãªæ™‚……

プロンプト

対話モードã§ã¯ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å…¥åŠ›ã‚’èª­ã¿å–ã‚‹ç›´å‰ã«ãƒ—ロンプトを標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚プロンプトã®å†…容㯠PS1 å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚ãŸã ã—ã€è¤‡æ•°è¡Œã«ã‚ãŸã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã‚‹éš›ã€äºŒè¡Œç›®ä»¥é™ã®èª­ã¿å–りã«ã¯ PS1 ã§ã¯ãªã PS2 変数ã®å€¤ãŒãƒ—ロンプトã¨ã—ã¦è¡¨ç¤ºã•れã¾ã™ã€‚

プロンプトã®è¡¨ç¤ºã®éš›ã«ã¯ã€ã¾ãš PS1 (ã¾ãŸã¯ PS2) 変数ã®å€¤ãŒãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ã§å±•é–‹ã•れã¾ã™ (ãŸã ã— POSIX ã«ã‚ˆã‚Œã°ãƒ‘ラメータ展開ã ã‘ãŒè¡Œã‚れるã“ã¨ã«ãªã£ã¦ã„ã¾ã™)。ã“ã®å±•開後ã®å€¤ã¯ä»¥ä¸‹ã®é€šã‚Šè§£é‡ˆã•れã€ãã®çµæžœãŒãƒ—ロンプトã¨ã—ã¦æ¨™æº–エラーã«å‡ºåŠ›ã•れã¾ã™ã€‚

POSIX 準拠モードã§ã¯ã€å€¤ã«å«ã¾ã‚Œã‚‹ ! ã¯ã“れã‹ã‚‰å…¥åŠ›ã—よã†ã¨ã—ã¦ã„るコマンドã®å±¥æ­´ç•ªå·ã«å¤‰æ›ã•れã¾ã™ã€‚感嘆符ãã®ã‚‚ã®ã‚’プロンプトã«è¡¨ç¤ºã•ã›ã‚‹ã«ã¯ !! ã¨äºŒã¤ç¶šã‘ã¦æ›¸ãã¾ã™ã€‚ã“ã‚Œä»¥å¤–ã®æ–‡å­—ã¯ãƒ—ロンプトã«ãã®ã¾ã¾è¡¨ç¤ºã•れã¾ã™ã€‚

POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ä»¥ä¸‹ã®è¨˜æ³•ãŒè§£é‡ˆã•れã¾ã™ã€‚ã“れらã®è¨˜æ³•ä»¥å¤–ã®æ–‡å­—ã¯ãã®ã¾ã¾ãƒ—ロンプトã«è¡¨ç¤ºã•れã¾ã™ã€‚

\a

ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7)

\e

エスケープ文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 27)

\j

ç¾åœ¨ã‚·ã‚§ãƒ«ãŒæŠ±ãˆã¦ã„ã‚‹ã‚¸ãƒ§ãƒ–ã®æ•°

\n

改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10)

\r

復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13)

\!

ã“れã‹ã‚‰å…¥åŠ›ã—よã†ã¨ã—ã¦ã„るコマンドã®å±¥æ­´ç•ªå·

\$

シェルã®å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ㌠0 ã®ã¨ã㯠#ã€ãã‚Œä»¥å¤–ã®æ™‚㯠$。

\\

ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (\)

\[
\]

ã“ã®äºŒã¤ã®è¨˜æ³•ã¯ã€å®Ÿéš›ã«ã¯ç«¯æœ«ã«è¡¨ç¤ºã•れãªã„プロンプトã®ä¸€éƒ¨åˆ†ã‚’指示ã™ã‚‹ã®ã«ä½¿ã„ã¾ã™ã€‚\[ 㨠\] ã§å›²ã‚“ã éƒ¨åˆ†ã¯ã€è¡Œç·¨é›†ãŒãƒ—ãƒ­ãƒ³ãƒ—ãƒˆã®æ–‡å­—数を計算ã™ã‚‹éš›ã«ã€æ–‡å­—æ•°ã«æ•°ãˆã‚‰ã‚Œã¾ã›ã‚“。端末ã«è¡¨ç¤ºã•れãªã„エスケープシーケンスãªã©ã‚’プロンプトã«å«ã‚ã‚‹éš›ã¯ã€ãã®éƒ¨åˆ†ã‚’ \[ 㨠\] ã§å›²ã‚“ã§ãã ã•ã„。ã“ã®æŒ‡å®šã‚’怠るã¨ã€è¡Œç·¨é›†ã®è¡¨ç¤ºãŒä¹±ã‚Œã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚

\fフォント指定.

行編集を使用ã—ã¦ã„ã‚‹å ´åˆã€ã“ã®è¨˜æ³•ã¯ç«¯æœ«ã®ãƒ•ォントã®è¡¨ç¤ºã‚’変更ã™ã‚‹ãŸã‚ã®ç‰¹æ®Šãªæ–‡å­—ã®ç¾…列ã«å¤‰æ›ã•れã¾ã™ (端末ãŒå¯¾å¿œã—ã¦ã„ã‚‹å ´åˆã®ã¿)。行編集を使用ã—ã¦ã„ãªã„å ´åˆã‚„端末ãŒå¯¾å¿œã—ã¦ã„ãªã„å ´åˆã¯ã€ã“ã®è¨˜æ³•ã¯å˜ã«ç„¡è¦–ã•れã¾ã™ã€‚フォント指定ã®éƒ¨åˆ†ã«ã¯ãƒ•ォントã®ç¨®é¡žã‚’指定ã™ã‚‹ãŸã‚ã®ä»¥ä¸‹ã®æ–‡å­—を指定ã—ã¾ã™ã€‚

k

文字ã®è‰²ã‚’é»’ã«ã™ã‚‹

r

文字ã®è‰²ã‚’赤ã«ã™ã‚‹

g

文字ã®è‰²ã‚’ç·‘ã«ã™ã‚‹

y

文字ã®è‰²ã‚’黄ã«ã™ã‚‹

b

文字ã®è‰²ã‚’é’ã«ã™ã‚‹

m

文字ã®è‰²ã‚’マゼンタã«ã™ã‚‹

c

文字ã®è‰²ã‚’シアンã«ã™ã‚‹

w

文字ã®è‰²ã‚’白ã«ã™ã‚‹

K

背景ã®è‰²ã‚’é»’ã«ã™ã‚‹

R

背景ã®è‰²ã‚’赤ã«ã™ã‚‹

G

背景ã®è‰²ã‚’ç·‘ã«ã™ã‚‹

Y

背景ã®è‰²ã‚’黄ã«ã™ã‚‹

B

背景ã®è‰²ã‚’é’ã«ã™ã‚‹

M

背景ã®è‰²ã‚’マゼンタã«ã™ã‚‹

C

背景ã®è‰²ã‚’シアンã«ã™ã‚‹

W

背景ã®è‰²ã‚’白ã«ã™ã‚‹

t

文字ã¾ãŸã¯èƒŒæ™¯ã®è‰²ã‚’明るãã™ã‚‹ (ä¸Šè¨˜ã®æ–‡å­—・背景ã®è‰²ã‚’変更ã™ã‚‹æ–‡å­—ã®ç›´å¾Œã§ã®ã¿æœ‰åй)

d

文字ã¨èƒŒæ™¯ã®è‰²ã‚’æ¨™æº–çŠ¶æ…‹ã«æˆ»ã™

s

文字を目立ãŸã›ã‚‹

u

文字ã«ä¸‹ç·šã‚’引ã

v

文字ã®è‰²ã‚’å転ã•ã›ã‚‹

b

文字を点滅ã•ã›ã‚‹

i

文字ã®è‰²ã‚’æš—ãã™ã‚‹

o

文字を太ã目立ãŸã›ã‚‹

x

文字を見ãˆãªãã™ã‚‹

D

色ã¨è£…é£¾ã‚’æ¨™æº–çŠ¶æ…‹ã«æˆ»ã™

文字ã¨èƒŒæ™¯ã®è‰²ã¯æœ€çµ‚çš„ã«ç«¯æœ«ã«ã‚ˆã£ã¦æ±ºã¾ã‚‹ãŸã‚ã€å®Ÿéš›ã«ã¯ã“ã“ã§æŒ‡å®šã—ãŸè‰²ã¨ç•°ãªã‚‹è‰²ã§è¡¨ç¤ºã•れるã“ã¨ãŒã‚りã¾ã™ã€‚

入力ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®å³å´ã«è¡¨ç¤ºã•れるプロンプトを指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ (å³ãƒ—ロンプト)。PS1/PS2 変数ã«å¯¾å¿œã™ã‚‹å³ãƒ—ロンプト㯠PS1R/PS2R å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚

ã¾ãŸã€ãƒ—ロンプトã®ãƒ•ォントã ã‘ã§ãªãã€å…¥åŠ›ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ォントを変ãˆã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚PS1S (ã¾ãŸã¯ PS2S) 変数ã«ä¸Šè¿°ã®ãƒ•ォントを指定ã™ã‚‹ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã‚’指定ã™ã‚‹ã“ã¨ã§ã€ã‚³ãƒžãƒ³ãƒ‰å…¥åŠ›æ™‚ã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ォントãŒå¤‰ã‚りã¾ã™ã€‚

POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ãƒ—ロンプトを出ã™å‰ã« PROMPT_COMMAND 変数ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œã•れã¾ã™ã€‚

コマンド履歴

コマンド履歴ã¯å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’記録ã—後ã§å†ã³å®Ÿè¡Œã™ã‚‹ã“ã¨ã®ã§ãる機能ã§ã™ã€‚対話モードã§ã‚·ã‚§ãƒ«ãŒèª­ã¿è¾¼ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ã¯è‡ªå‹•çš„ã«ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã™ã€‚履歴ã«è¨˜éŒ²ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯è¡Œç·¨é›†ã§å‘¼ã³å‡ºã—ã¦å†å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸ fc・history 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å±¥æ­´ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ãŸã‚Šç·¨é›†ã—ãŸã‚Šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚

コマンドã¯è¡Œå˜ä½ã§å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã™ã€‚ç©ºç™½ä»¥å¤–ã®æ–‡å­—を一切å«ã¾ãªã„行ã¯å±¥æ­´ã«ã¯è¨˜éŒ²ã•れã¾ã›ã‚“。ã¾ãŸ hist-space ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãã¯ç©ºç™½ã§å§‹ã¾ã‚‹è¡Œã¯å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã›ã‚“。

コマンド履歴ã®å†…容㯠HISTFILE å¤‰æ•°ã§æŒ‡å®šã•れるファイルã«ä¿å­˜ã•れã¾ã™ã€‚対話モードã®ã‚·ã‚§ãƒ«ã®èµ·å‹•後ã«å±¥æ­´é–¢é€£ã®æ©Ÿèƒ½ãŒåˆã‚ã¦ä½¿ç”¨ã•れるã¨ãã€HISTFILE 変数ã®å€¤ã‚’ファイルåã¨ã¿ãªã—ã¦ãƒ•ァイルを開ãã¾ã™ã€‚æ—¢ã«ãƒ•ァイルã«å±¥æ­´ãƒ‡ãƒ¼ã‚¿ãŒä¿å­˜ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれãŒèª­ã¿è¾¼ã¾ã‚Œã¾ã™ã€‚ファイルãŒå­˜åœ¨ã—ãªã„ã‹å†…容ãŒå±¥æ­´ãƒ‡ãƒ¼ã‚¿ã§ã¯ãªã„å ´åˆã¯ã€æ–°ã—ã„履歴ファイルã«åˆæœŸåŒ–ã•れã¾ã™ã€‚HISTFILE 変数ãŒå­˜åœ¨ã—ãªã„å ´åˆã‚„ファイルを開ãã“ã¨ãŒã§ããªã„å ´åˆã¯å±¥æ­´ã¯ãƒ•ァイルã«ä¿å­˜ã•れã¾ã›ã‚“ãŒã€å±¥æ­´æ©Ÿèƒ½è‡ªä½“ã¯ä½¿ç”¨ã§ãã¾ã™ã€‚

シェルãŒè¨˜éŒ²ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®æ•°ã¯ HISTSIZE å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚履歴ã®ä»¶æ•°ãŒã“ã®å¤‰æ•°ã®å€¤ã‚’è¶…ãˆã‚‹ã¨é †æ¬¡å¤ã„データã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒå­˜åœ¨ã—ãªã„å ´åˆã¾ãŸã¯å€¤ãŒè‡ªç„¶æ•°ã§ãªã„å ´åˆã¯ã€å±¥æ­´ã¯ 500 ä»¶ã¾ã§è¨˜éŒ²ã•れã¾ã™ã€‚

HISTFILE ãŠã‚ˆã³ HISTSIZE 変数ã¯å±¥æ­´æ©Ÿèƒ½ãŒåˆã‚ã¦ä½¿ç”¨ã•れるã¨ãã«ã®ã¿å‚ç…§ã•れã€ãれ以é™ã¯å¤‰æ•°ã‚’å†è¨­å®šã—ã¦ã‚‚履歴機能ã®å‹•作ã«å½±éŸ¿ã—ã¾ã›ã‚“。履歴機能ãŒåˆ©ç”¨ã•れるã¨ãã¨ã„ã†ã®ã¯ã€å…·ä½“çš„ã«ã¯ä»¥ä¸‹ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§ã™ã€‚

  • Fc ã¾ãŸã¯ history 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ã

  • 行編集を使用ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã™ã‚‹ã¨ã (履歴データを行編集ã®ä¸­ã§ä½¿ã‚ãªãã¦ã‚‚履歴機能ã¯ä½¿ã‚れã¾ã™)

  • 入力ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒå±¥æ­´ã«ç™»éŒ²ã•れるã¨ã

ã“ã®ãŸã‚ HISTFILE ãŠã‚ˆã³ HISTSIZE 変数ã¯åŽŸå‰‡ã¨ã—ã¦ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«èª­ã¿è¾¼ã¾ã‚Œã‚‹åˆæœŸåŒ–スクリプトã®ä¸­ã§è¨­å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚

複数ã®ã‚·ã‚§ãƒ«ãƒ—ロセスãŒåŒã˜å±¥æ­´ãƒ•ァイルを使用ã—ã¦ã„ã‚‹å ´åˆã€ã“れらã®ã‚·ã‚§ãƒ«ã¯ä¸€ã¤ã®å±¥æ­´ãƒ‡ãƒ¼ã‚¿ã‚’共有ã—ã¾ã™ã€‚ã“ã®ã¨ã例ãˆã°ã‚るシェルプロセスã§å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’別ã®ã‚·ã‚§ãƒ«ãƒ—ロセスã§å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚åŒã˜å±¥æ­´ã‚’使用ã—ã¦ã„るシェルã®é–“ã§ HISTSIZE ãŒç•°ãªã£ã¦ã„ã‚‹ã¨å±¥æ­´ãŒæ­£ã—ã共有ã•れãªã„ã®ã§ã€HISTSIZE ã®å€¤ã¯çµ±ä¸€ã™ã‚‹ã‚ˆã†ã«ã—ã¦ãã ã•ã„。

Yash ã¯ç‹¬è‡ªã®å½¢å¼ã®å±¥æ­´ãƒ•ァイルを使用ã—ã¦ã„ã‚‹ãŸã‚ã€å±¥æ­´ãƒ•ァイルを他ã®ç¨®é¡žã®ã‚·ã‚§ãƒ«ã¨å…±ç”¨ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

履歴ã«åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’記録ã™ã‚‹ç„¡é§„を解消ã™ã‚‹ãŸã‚ã€HISTRMDUP 変数を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚æ–°ã—ãコマンドを履歴ã«è¨˜éŒ²ã—よã†ã¨ã™ã‚‹éš›ã€ã™ã§ã«åŒã˜ã‚³ãƒžãƒ³ãƒ‰ãŒæœ€è¿‘ã® $HISTRMDUP ä»¶ã®å±¥æ­´ãƒ‡ãƒ¼ã‚¿ã®ä¸­ã«è¨˜éŒ²ã•れã¦ã„れã°ã€ãã®æ—¢ã«è¨˜éŒ²ã•れã¦ã„るコマンドã¯å±¥æ­´ã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚

メールãƒã‚§ãƒƒã‚¯

対話モードã®ã‚·ã‚§ãƒ«ã«ã¯ã€é›»å­ãƒ¡ãƒ¼ãƒ«ãŒå±Šã„ãŸã‚‰ãれを知らã›ã‚‹æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚ã“ã‚Œã¯æ‰€å®šã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚を調ã¹ã¦ã€æ›´æ–°æ—¥æ™‚ãŒå¤‰ã‚ã£ã¦ã„ãŸã‚‰ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’表示ã™ã‚‹ã¨ã„ã†ã‚‚ã®ã§ã™ã€‚å—ä¿¡ã—ãŸãƒ¡ãƒ¼ãƒ«ã®ãƒ‡ãƒ¼ã‚¿ãŒä¿å­˜ã•れるファイルをãƒã‚§ãƒƒã‚¯å¯¾è±¡ã¨ã—ã¦æŒ‡å®šã—ã¦ãŠãã“ã¨ã§ã€ãƒ¡ãƒ¼ãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒè¡¨ç¤ºã•れるよã†ã«ãªã‚Šã¾ã™ã€‚

ファイル更新ã®ãƒã‚§ãƒƒã‚¯ã¯ã‚·ã‚§ãƒ«ãŒãƒ—ロンプトを出ã™ç›´å‰ã«è¡Œã„ã¾ã™ã€‚ãƒã‚§ãƒƒã‚¯ã‚’行ã†é–“隔を MAILCHECK å¤‰æ•°ã§æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã§æŒ‡å®šã—ãŸç§’æ•°ãŒçµŒéŽã™ã‚‹ã”ã¨ã«ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出ã™ç›´å‰ã«ãƒã‚§ãƒƒã‚¯ã‚’行ã„ã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ãŒ 0 ã«ãªã£ã¦ã„ã‚‹å ´åˆã¯ã€ãƒ—ロンプトを出ã™ç›´å‰ã«æ¯Žå›žãƒã‚§ãƒƒã‚¯ã‚’行ã„ã¾ã™ã€‚ã¾ãŸå¤‰æ•°ã®å€¤ãŒ 0 ä»¥ä¸Šã®æ•´æ•°ã§ãªã„å ´åˆã¯ã€ãƒã‚§ãƒƒã‚¯ã¯ä¸€åˆ‡è¡Œã„ã¾ã›ã‚“。

更新日時をãƒã‚§ãƒƒã‚¯ã™ã‚‹å¯¾è±¡ã®ãƒ•ァイル㯠MAIL å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã«ãƒã‚§ãƒƒã‚¯ã—ãŸã„ファイルã®ãƒ‘スåを指定ã—ã¦ãŠãã¨ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚ãŒå‰å›žãƒã‚§ãƒƒã‚¯ã—ãŸã¨ãã¨å¤‰ã‚ã£ã¦ã„ãŸã‚‰ã€æ–°ç€ãƒ¡ãƒ¼ãƒ«ã‚’知らã›ã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚(ãŸã ã—ファイルãŒç©ºã®ã¨ãã¯ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¯å‡ºã¾ã›ã‚“ (POSIX 準拠モードã®ã¨ãを除ã))

複数ã®ãƒ•ァイルをãƒã‚§ãƒƒã‚¯ã®å¯¾è±¡ã«ã—ãŸã„å ´åˆã‚„ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’è‡ªåˆ†ã§æŒ‡å®šã—ãŸã„å ´åˆã¯ã€MAIL 変数ã®ä»£ã‚り㫠MAILPATH 変数を使ã†ã“ã¨ãŒã§ãã¾ã™ã€‚MAILPATH 変数ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€MAIL 変数ã®è¨­å®šã¯ç„¡è¦–ã•れã¾ã™ã€‚MAILPATH 変数ã®å€¤ã«ã¯ã€ä¸€ã¤ä»¥ä¸Šã®ãƒ•ァイルã®ãƒ‘スåをコロン (:) ã§åŒºåˆ‡ã£ã¦æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚·ã‚§ãƒ«ã¯æ¯Žå›žã®ãƒã‚§ãƒƒã‚¯ã§ãれãžã‚Œã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚を調ã¹ã€ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ›´æ–°ã•れã¦ã„ãŸã‚‰ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’表示ã—ã¾ã™ã€‚ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’è‡ªåˆ†ã§æŒ‡å®šã™ã‚‹ã«ã¯ã€ãƒ‘スåã®ç›´å¾Œã«ãƒ‘ーセント (%) ã‚’ç½®ãã€ç¶šã‘ã¦è¡¨ç¤ºã•ã›ãŸã„メッセージを置ãã¾ã™ã€‚ãれãžã‚Œã®ãƒ•ァイルã”ã¨ã«ç•°ãªã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚(パーセントをパスåã¨ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¨ã®åŒºåˆ‡ã‚Šã§ã¯ãªãパスåã®ä¸€éƒ¨ã¨ã—ãŸã„å ´åˆã¯ãƒ‘ーセントをãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã—ã¦ãã ã•ã„) パーセントã®å¾Œã«æŒ‡å®šã•れãŸãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¯ã€è¡¨ç¤ºã®å‰ã«ãƒ‘ラメータ展開ã•れã¾ã™ã€‚

例ãˆã° MAILPATH 変数ã®å€¤ãŒ /foo/mail%New mail!:/bar/mailbox%You've got mail:/baz/mail\%data ã ã¨ã™ã‚‹ã¨ã€ãƒ•ァイル /foo/mail ãŒæ›´æ–°ã•れãŸã¨ã㯠New mail! ãŒã€/bar/mailbox ãŒæ›´æ–°ã•れãŸã¨ã㯠You've got mail ãŒã€/baz/mail%data ãŒæ›´æ–°ã•れãŸã¨ãã¯ãƒ‡ãƒ•ォルトã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒè¡¨ç¤ºã•れã¾ã™ã€‚

yash-2.35/doc/ja/_fg.html0000644000175000017500000000621312154557026015330 0ustar magicantmagicant Fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Fg 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚¸ãƒ§ãƒ–をフォアグラウンドã§å®Ÿè¡Œã—ã¾ã™ã€‚

æ§‹æ–‡

  • fg [ジョブ…]

説明

Fg コマンドã¯ã‚¸ãƒ§ãƒ–をフォアグラウンドã«ç§»å‹•ã— SIGCONT シグナルをé€ã‚Šã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚¸ãƒ§ãƒ–ãŒåœæ­¢ã—ã¦ã„ãŸå ´åˆã¯ãƒ•ォアグラウンドã§å®Ÿè¡ŒãŒå†é–‹ã•れã¾ã™ã€‚Fg コマンドã¯ã‚¸ãƒ§ãƒ–ã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã¾ã§å¾…機ã—ã€ã‚¸ãƒ§ãƒ–ã®çµ‚了ステータスを返ã—ã¾ã™ã€‚

ジョブã®å®Ÿè¡Œã‚’å†é–‹ã™ã‚‹å‰ã« fg コマンドã¯ã‚¸ãƒ§ãƒ–ã®åå‰ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

Fg コマンドã¯ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åŠ¹ãªæ™‚ã—ã‹ä½¿ãˆã¾ã›ã‚“。

オペランド

ジョブ

実行ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®ã‚¸ãƒ§ãƒ– ID。

複数指定ã™ã‚‹ã¨æŒ‡å®šã—ãŸé †ã«ä¸€ã¤ãšã¤ã‚¸ãƒ§ãƒ–をフォアグラウンドã§å®Ÿè¡Œã—ã¾ã™ã€‚何も指定ã—ãªã„ã¨ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–を実行ã—ã¾ã™ã€‚

éž POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ– ID ã®å…ˆé ­ã® % ã¯çœç•¥ã§ãã¾ã™ã€‚

終了ステータス

ジョブを正ã—ã実行ã§ããŸå ´åˆã€fg コマンドã®çµ‚了ステータス㯠(最後ã«) 実行ã—ãŸã‚¸ãƒ§ãƒ–ã®çµ‚了ステータスã§ã™ã€‚エラーãŒç™ºç”Ÿã—ãŸå ´åˆã¯çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

Fg ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ–ã¯ä¸€ã¤ã¾ã§ã—ã‹æŒ‡å®šã§ãã¾ã›ã‚“。

yash-2.35/doc/ja/_set.txt0000644000175000017500000002771212154557026015411 0ustar magicantmagicant= Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ションã®è¨­å®šã¨link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã®å¤‰æ›´ã‚’行ã„ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +set [{{オプション}}...] [{{オペランド}}...]+ - +set -o+ - +set +o+ Set コマンドã§ã¯ã€link:posix.html[POSIX 準拠モード]ã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚ [[description]] == 説明 コマンドライン引数を一切与ãˆãšã« set コマンドを実行ã™ã‚‹ã¨ã€ç¾åœ¨ã‚·ã‚§ãƒ«ã«è¨­å®šã•れã¦ã„ã‚‹å…¨ã¦ã®link:params.html#variables[変数]ã®ä¸€è¦§ã‚’アルファベット順㧠(コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ +-o+ を唯一ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸ŽãˆãŸå ´åˆã¯ç¾åœ¨ã®ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ション設定を一覧ã«ã—ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚++o+ を唯一ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸ŽãˆãŸå ´åˆã‚‚åŒæ§˜ã§ã™ãŒã€ã“ã®å ´åˆã¯ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ ã“れ以外ã®å ´åˆã¯ã€set コマンドã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ã‚·ã‚§ãƒ«ã®ã‚ªãƒ—ションã®è¨­å®šã¨link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã®å¤‰æ›´ã®ã©ã¡ã‚‰ã‹ã¾ãŸã¯ä¸¡æ–¹ã®å‹•作を行ã„ã¾ã™ã€‚ [[options]] == オプション オプションãŒä¸€ã¤ä»¥ä¸Šä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã€set コマンドã¯ãã‚Œã‚‰ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’åˆ‡ã‚Šæ›¿ãˆã¾ã™ã€‚通常ã®å½¢å¼ã§ã‚ªãƒ—ションを与ãˆã‚‹ã¨ã€ãã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã¯æœ‰åйã«ãªã‚Šã¾ã™ã€‚オプションã®å…ˆé ­ã®ãƒã‚¤ãƒ•ン (+-+) ã®ä»£ã‚りã«ãƒ—ラス (+++) を付ã‘ã¦æŒ‡å®šã™ã‚‹ã¨ã€ãã®ã‚ªãƒ—ションã¯ç„¡åйã«ãªã‚Šã¾ã™ã€‚例ãˆã° +-m+ ã‚„ +-o monitor+ ã‚„ +--monitor+ ã¯ã‚·ã‚§ãƒ«ã®ã‚¸ãƒ§ãƒ–制御を有効ã«ã—ã€é€†ã« ++m+ ã‚„ ++o monitor+ ã‚„ +++monitor+ ã¯ã‚¸ãƒ§ãƒ–制御を無効ã«ã—ã¾ã™ã€‚ link:builtin.html#argsyntax[é•·ã„オプション]ã®åå‰ã«å«ã¾ã‚Œã‚‹è‹±æ•°å­—ä»¥å¤–ã®æ–‡å­—ã¯ç„¡è¦–ã•れã€å¤§æ–‡å­—ã¨å°æ–‡å­—ã®åŒºåˆ¥ã¯ã‚りã¾ã›ã‚“。例ãˆã° +--Le-Comp-Debug+ 㯠+--lecompdebug+ ã«åŒã˜ã§ã™ã€‚ã¾ãŸé•·ã„オプションã®åå‰ã®å…ˆé ­ã« +no+ を付ã‘ã‚‹ã“ã¨ã§ã€ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’é€†è»¢ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚例ãˆã° +--noallexport+ 㯠+++allexport+ ã«åŒã˜ãã€ã¾ãŸ +++nonotify+ 㯠+--notify+ ã«åŒã˜ã§ã™ã€‚ オプションã¯ä»¥ä¸‹ã«æŒ™ã’ã‚‹å½¢å¼ã§æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™: - é•·ã„オプション (例: +--allexport+) - 引数ã¨ã—ã¦ã‚ªãƒ—ションåを指定ã—㟠+-o+ オプション (例: +-o allexport+) - 一文字ã®ã‚ªãƒ—ション (例: +-a+) ãŸã ã—å…¨ã¦ã®ã‚ªãƒ—ションãŒä¸€æ–‡å­—ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã§ãã‚‹ã‚ã‘ã§ã¯ã‚りã¾ã›ã‚“。 利用å¯èƒ½ãªã‚ªãƒ—ションã¯ä»¥ä¸‹ã®ã¨ãŠã‚Šã§ã™: [[so-allexport]]all-export (+-a+):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€link:params.html#variables[変数]ã«ä»£å…¥ã‚’ã™ã‚‹ã¨ãã®å¤‰æ•°ã¯è‡ªå‹•çš„ã«link:params.html#variables[エクスãƒãƒ¼ãƒˆ]対象ã«ãªã‚Šã¾ã™ã€‚ [[so-braceexpand]]brace-expand:: ã“ã®ã‚ªãƒ—ションã¯link:expand.html#brace[ブレース展開]を有効ã«ã—ã¾ã™ã€‚ [[so-caseglob]]case-glob:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€link:expand.html#glob[パスå展開]ã«ãŠã‘るパターンマッãƒãƒ³ã‚°ã¯å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¦è¡Œã„ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ [[so-clobber]]clobber (`+C`):: ã“ã®ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã¨ã€ +>+ 演算å­ã«ã‚ˆã‚‹link:redir.html[リダイレクト]ã§æ—¢å­˜ã®ãƒ•ァイルを上書ãã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ [[so-curasync]]cur-async:: [[so-curbg]]cur-bg:: [[so-curstop]]cur-stop:: ã“れらã®ã‚ªãƒ—ションã¯ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã®é¸æŠžã®ä»•æ–¹ã«å½±éŸ¿ã—ã¾ã™ã€‚(link:job.html#jobid[ジョブ ID] å‚ç…§)。ã“れらã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ [[so-dotglob]]dot-glob:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€link:expand.html#glob[パスå展開]ã«ãŠã„ã¦ãƒ•ァイルåã®å…ˆé ­ã®ãƒ”ãƒªã‚ªãƒ‰ã‚’ç‰¹åˆ¥ã«æ‰±ã„ã¾ã›ã‚“。 [[so-emacs]]emacs:: ã“ã®ã‚ªãƒ—ション㯠emacs 風link:lineedit.html[行編集]を有効ã«ã—ã¾ã™ã€‚ [[so-errexit]]err-exit (+-e+):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å®Ÿè¡Œã—ãŸlink:syntax.html#pipelines[パイプライン]ã®çµ‚了ステータス㌠0 ã§ãªã‘れã°ã€ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚ãŸã ã—ã€ä»¥ä¸‹ã®å ´åˆã‚’除ãã¾ã™ã€‚ - ãã®ã‚³ãƒžãƒ³ãƒ‰ãŒ link:syntax.html#if[if æ–‡]ã®åˆ†å²ã‚„ link:syntax.html#while-until[while/until æ–‡]ã®ãƒ«ãƒ¼ãƒ—æ¡ä»¶ã®åˆ¤å®šã«ä½¿ã‚ã‚Œã‚‹å ´åˆ - パイプラインã®å…ˆé ­ã« +!+ ãŒä»˜ã„ã¦ã„ã‚‹å ´åˆ - パイプラインãŒã‚µãƒ–シェルlink:syntax.html#grouping[グルーピング]以外ã®å˜ç‹¬ã®link:syntax.html#compound[複åˆã‚³ãƒžãƒ³ãƒ‰]ã‹ã‚‰æ§‹æˆã•ã‚Œã‚‹å ´åˆ [[so-exec]]exec (`+n`):: ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®è§£é‡ˆã ã‘を行ã„ã€å®Ÿéš›ã«ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã‚¹ã‚¯ãƒªãƒ—ãƒˆã®æ–‡æ³•ãƒã‚§ãƒƒã‚¯ã‚’ã™ã‚‹ã®ã«ä¾¿åˆ©ã§ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚link:interact.html[対話モード]ã§ã¯ã€ã“ã®ã‚ªãƒ—ションã«é–¢ã‚らãšã‚³ãƒžãƒ³ãƒ‰ã¯å¸¸ã«å®Ÿè¡Œã•れã¾ã™ã€‚ [[so-extendedglob]]extended-glob:: ã“ã®ã‚ªãƒ—ションã¯link:expand.html#glob[パスå展開]ã«ãŠã‘る拡張機能を有効ã«ã—ã¾ã™ã€‚ [[so-glob]]glob (`+f`):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãã¯ã‚·ã‚§ãƒ«ã¯link:expand.html#glob[パスå展開]を行ã„ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ [[so-hashondef]]hash-on-def (+-h+):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãlink:exec.html#function[関数]を定義ã™ã‚‹ã¨ã€ç›´ã¡ã«ãã®é–¢æ•°å†…ã§ä½¿ã‚れるå„コマンド㮠link:exec.html#search[PATH 検索]を行ã„コマンドã®ãƒ‘スåを記憶ã—ã¾ã™ã€‚ [[so-histspace]]hist-space:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ç©ºç™½ã§å§‹ã¾ã‚‹è¡Œã¯link:interact.html#history[コマンド履歴]ã«è‡ªå‹•çš„ã«è¿½åŠ ã—ã¾ã›ã‚“。 [[so-ignoreeof]]ignore-eof:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€link:interact.html[対話モード]ã®ã‚·ã‚§ãƒ«ã« EOF (入力ã®çµ‚ã‚り) ãŒå…¥åŠ›ã•れã¦ã‚‚シェルã¯ãれを無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã®èª­ã¿è¾¼ã¿ã‚’ç¶šã‘ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€èª¤ã£ã¦ Ctrl-D を押ã—ã¦ã—ã¾ã£ã¦ã‚‚シェルã¯çµ‚了ã—ãªããªã‚Šã¾ã™ã€‚ [[so-lealwaysrp]]le-always-rp:: [[so-lecompdebug]]le-comp-debug:: [[so-leconvmeta]]le-conv-meta:: [[so-lenoconvmeta]]le-no-conv-meta:: [[so-lepromptsp]]le-prompt-sp:: [[so-levisiblebell]]le-visible-bell:: ã“れらã®ã‚ªãƒ—ションã¯link:lineedit.html[行編集]ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚link:lineedit.html#options[行編集ã®ã‚ªãƒ—ション]ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 [[so-markdirs]]mark-dirs:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€link:expand.html#glob[パスå展開]ã®å±•é–‹çµæžœã«ãŠã„ã¦ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表ã™ã‚‚ã®ã®æœ«å°¾ã«ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’付ã‘ã¾ã™ã€‚ [[so-monitor]]monitor (+-m+):: ã“ã®ã‚ªãƒ—ションã¯link:job.html[ジョブ制御]を有効ã«ã—ã¾ã™ã€‚シェルをlink:interact.html[対話モード]ã§èµ·å‹•ã—ãŸã¨ãã“ã®ã‚ªãƒ—ションã¯è‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚ [[so-notify]]notify (+-b+):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã®link:job.html[ジョブ]ã®å®Ÿè¡ŒçŠ¶æ…‹ãŒå¤‰åŒ–ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«ãれを標準エラーã«å ±å‘Šã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ション㯠notifyle オプションより優先ã—ã¾ã™ã€‚ [[so-notifyle]]notify-le:: ã“ã®ã‚ªãƒ—ション㯠notify オプションã¨ã»ã¼åŒã˜ã§ã™ãŒã€link:lineedit.html[行編集]を行ã£ã¦ã„る最中ã®ã¿ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚’å ±å‘Šã—ã¾ã™ã€‚ [[so-nullglob]]null-glob:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€link:expand.html#glob[パスå展開]ã§ãƒžãƒƒãƒã™ã‚‹ãƒ‘スåãŒãªã„ã¨ãå…ƒã®ãƒ‘ã‚¿ãƒ¼ãƒ³ã¯æ®‹ã‚Šã¾ã›ã‚“。 [[so-posixlycorrect]]posixly-correct:: ã“ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]を有効ã«ã—ã¾ã™ã€‚ [[so-traceall]]trace-all:: ã“ã®ã‚ªãƒ—ションã¯ã€è£œåŠ©ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œä¸­ã‚‚ <>を機能ã•ã›ã‚‹ã‹ã©ã†ã‹ã‚’指定ã—ã¾ã™ã€‚補助コマンドã¨ã¯ã€ link:params.html#sv-command_not_found_handler[+COMMAND_NOT_FOUND_HANDLER+]〠link:params.html#sv-prompt_command[+PROMPT_COMMAND+]ã€ãŠã‚ˆã³ link:params.html#sv-yash_after_cd[+YASH_AFTER_CD+] 変数ã®å€¤ã¨ã—ã¦å®šç¾©ã•れã€ç‰¹å®šã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§è§£é‡ˆãƒ»å®Ÿè¡Œã•れるコマンドã§ã™ã€‚ ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ [[so-unset]]unset (`+u`):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€link:expand.html#params[パラメータ展開]ã§å­˜åœ¨ã—ãªã„変数を展開ã™ã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ã¯ãªã‚‰ãšç©ºæ–‡å­—列ã«å±•é–‹ã•れã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰æœ‰åйã«ãªã£ã¦ã„ã¾ã™ã€‚ [[so-verbose]]verbose (+-v+):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚·ã‚§ãƒ«ã¯èª­ã¿è¾¼ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ã‚’ãã®ã¾ã¾æ¨™æº–エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚ [[so-vi]]vi:: ã“ã®ã‚ªãƒ—ション㯠vi 風link:lineedit.html[行編集]を有効ã«ã—ã¾ã™ã€‚link:interact.html[対話モード]ãŒæœ‰åŠ¹ã§æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã¨ã‚‚ã«ç«¯æœ«ãªã‚‰ã°ã“ã®ã‚ªãƒ—ションã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«è‡ªå‹•çš„ã«æœ‰åйã«ãªã‚Šã¾ã™ã€‚ [[so-xtrace]]x-trace (+-x+):: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹å‰ã«link:expand.html[展開]ã®çµæžœã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚ã“ã®å‡ºåŠ›ã¯ã€å„行頭㫠link:params.html#sv-ps4[+PS4+ 変数]ã®å€¤ã‚’link:expand.html[展開]ã—ãŸçµæžœã‚’付ã‘ã¦ç¤ºã•れã¾ã™ã€‚ <>ã‚‚å‚ç…§ã—ã¦ãã ã•ã„。 [[operands]] == オペランド Set コマンドã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹å ´åˆã¾ãŸã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’区切るãƒã‚¤ãƒ•ン二㤠(+--+, link:builtin.html#argsyntax[コマンドã®å¼•æ•°ã®æ§‹æ–‡]å‚ç…§) ãŒã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«å…¥ã£ã¦ã„ã‚‹å ´åˆã¯ã€ç¾åœ¨ã®link:params.html#positional[ä½ç½®ãƒ‘ラメータ]ã¯å‰Šé™¤ã•れã€ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒãれãžã‚Œæ–°ã—ãä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚ãƒã‚¤ãƒ•ン二ã¤ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã¦ã‹ã¤ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒãªã„å ´åˆã¯ä½ç½®ãƒ‘ラメータã¯ãªããªã‚Šã¾ã™ã€‚ [[exitstatus]] == 終了ステータス ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šãŒé–“é•ã£ã¦ã„ã‚‹å ´åˆã‚’除ãã€set コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Set コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX è¦æ ¼ã«å®šç¾©ã•れã¦ã„るオプションã¯é™ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚è¦æ ¼ã®å®šç¾©ã§ã¯ã€ - +--allexport+ ãªã©ã®é•·ã„オプションã¯ä½¿ãˆã¾ã›ã‚“。 - オプションåã« +no+ を付ã‘ã¦ã‚ªãƒ—ションを無効ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 - オプションåã«å¤§æ–‡å­—や英字ã§ãªã„記å·ã¯ä½¿ãˆã¾ã›ã‚“。 è¦æ ¼ã«å®šç¾©ã•れã¦ã„るオプションã¯ä»¥ä¸‹ã®ã¨ãŠã‚Šã§ã™: - +-a+, +-o allexport+ - +-e+, +-o errexit+ - +-m+, +-o monitor+ - +-C+, +-o noclobber+ - +-n+, +-o noexec+ - +-f+, +-o noglob+ - +-b+, +-o notify+ - +-u+, +-o nounset+ - +-v+, +-o verbose+ - +-x+, +-o xtrace+ - +-h+ - +-o ignoreeof+ - +-o nolog+ - +-o vi+ POSIX ã§ã¯ã“ã®ã»ã‹ã«ã€link:syntax.html#funcdef[関数定義]ã‚’link:interact.html#history[コマンド履歴]ã«ç™»éŒ²ã—ãªã„よã†ã«ã™ã‚‹ +-o nolog+ オプションをè¦å®šã—ã¦ã„ã¾ã™ãŒã€yash ã¯ã“れをサãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_trap.html0000644000175000017500000001246412154557026015707 0ustar magicantmagicant Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作を設定ã—ã¾ã™ã€‚

æ§‹æ–‡

  • trap

  • trap 動作 シグナル

  • trap ã‚·ã‚°ãƒŠãƒ«ç•ªå· [シグナル…]

  • trap -p [シグナル…]

説明

Trap コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作 (トラップ) を表示ã¾ãŸã¯è¨­å®šã—ã¾ã™ã€‚

オペランドã«å‹•作ã¨ã‚·ã‚°ãƒŠãƒ«ã‚’指定ã—㦠trap コマンドを実行ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ãŒã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸéš›ã«æŒ‡å®šã—ãŸå‹•作を行ã†ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒã‚·ã‚°ãƒŠãƒ«ç•ªå·ã®å ´åˆã€ãã‚Œã¨æ®‹ã‚Šã®ã‚·ã‚°ãƒŠãƒ«ã«å¯¾ã™ã‚‹å‹•作ã¯ã€å‹•作ã¨ã—㦠- ãŒæŒ‡å®šã•れãŸã¨ãã¨åŒæ§˜ã«æ¨™æº–ã®å‹•作ã«è¨­å®šã•れã¾ã™ã€‚

-p (--print) オプションを指定ã—ãŸå ´åˆã¾ãŸã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’一ã¤ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€trap コマンドã¯ç¾åœ¨ã®ãƒˆãƒ©ãƒƒãƒ—ã®è¨­å®šçжæ³ã‚’コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚シグナルãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ãã®ã‚·ã‚°ãƒŠãƒ«ã«é–¢ã™ã‚‹è¨­å®šã‚’ã€ä¸Žãˆã‚‰ã‚Œã¦ãªã„ã¨ãã¯å…¨ã¦ã®è¨­å®šã‚’出力ã—ã¾ã™ã€‚

オプション

-p
--print

ç¾åœ¨ã®ãƒˆãƒ©ãƒƒãƒ—ã®è¨­å®šã‚’表示ã—ã¾ã™ã€‚

オペランド

動作

シグナルをå—ä¿¡ã—ãŸéš›ã®å‹•作を指定ã—ã¾ã™ã€‚動作ãŒãƒã‚¤ãƒ•ン一㤠(-) ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ã‚·ã‚¹ãƒ†ãƒ ã§è¦å®šã•ã‚ŒãŸæ¨™æº–ã®å‹•作を行ã„ã¾ã™ã€‚動作ãŒç©ºæ–‡å­—列ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯ã‚·ã‚°ãƒŠãƒ«ã‚’無視ã—ã¾ã™ã€‚ãれ以外ã®å€¤ã‚’指定ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã¿ãªã—ã¦ã€ã‚·ã‚°ãƒŠãƒ«å—信時ã«ã“れを解釈・実行ã—ã¾ã™ (コマンドã®å®Ÿè¡Œä¸­ã«ã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã¯ã€ã‚³ãƒžãƒ³ãƒ‰ãŒçµ‚了ã—ãŸå¾Œã«ãƒˆãƒ©ãƒƒãƒ—を実行ã—ã¾ã™)。

シグナル

動作ã®å¯¾è±¡ã¨ãªã‚‹ã‚·ã‚°ãƒŠãƒ«ã§ã™ã€‚シグナルã¯ã‚·ã‚°ãƒŠãƒ«ç•ªå·ã¨ã‚·ã‚°ãƒŠãƒ«åã®ã©ã¡ã‚‰ã‹ã§æŒ‡å®šã—ã¾ã™ã€‚

シグナルã¨ã—㦠0 ã¾ãŸã¯ EXIT を指定ã™ã‚‹ã¨ã€ã“れã¯ã‚·ã‚§ãƒ«ã®çµ‚了時ã«ç™ºç”Ÿã™ã‚‹ä»®æƒ³ã®ã‚·ã‚°ãƒŠãƒ«ã‚’指定ã—ã¦ã„ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚ã“ã®ä»®æƒ³ã®ã‚·ã‚°ãƒŠãƒ«ã«å¯¾ã—ã¦è¨­å®šã•れãŸå‹•作ã¯ã€ã‚·ã‚§ãƒ«ãŒæ­£å¸¸çµ‚了ã™ã‚‹ç›´å‰ã«å®Ÿè¡Œã•れã¾ã™ã€‚

シグナル番å·

シグナルã¨åŒæ§˜ã§ã™ãŒã€ã‚·ã‚°ãƒŠãƒ«ã‚’番å·ã§æŒ‡å®šã—ã¾ã™ã€‚

終了ステータス

ãƒˆãƒ©ãƒƒãƒ—ãŒæ­£ã—ã設定ã¾ãŸã¯è¡¨ç¤ºã•れãŸã¨ãã¯çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

Trap コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã¯ã€ã‚·ã‚°ãƒŠãƒ«å㯠INT ã‚„ QUIT ã®ã‚ˆã†ã«æœ€åˆã® SIG を除ã„ãŸå½¢ã§æŒ‡å®šã—ãªã‘れã°ãªã‚‰ãªã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯ã€æ‹¡å¼µã¨ã—㦠SIG を付ã‘ãŸå½¢ã§ã‚‚指定ã§ãã¾ã™ã—ã€ã‚·ã‚°ãƒŠãƒ«åã®å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¾ã›ã‚“ (ã“ã®ã‚ˆã†ãªæ‹¡å¼µã¯ POSIX ã§ã‚‚èªã‚られã¦ã„ã¾ã™)。

yash-2.35/doc/ja/_alias.html0000644000175000017500000000752312154557026016032 0ustar magicantmagicant Alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’設定・表示ã—ã¾ã™ã€‚

æ§‹æ–‡

  • alias [-gp] [エイリアスå[=値]…]

説明

Alias コマンドã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’オペランドã«å¾“ã£ã¦è¨­å®šã¾ãŸã¯è¡¨ç¤ºã—ã¾ã™ã€‚表示ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ (ã®ä¸€éƒ¨) ã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚オペランドを一ã¤ã‚‚与ãˆãªã„å ´åˆã€alias コマンドã¯ç¾åœ¨è¨­å®šã•れã¦ã„ã‚‹å…¨ã¦ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã‚’表示ã—ã¾ã™ã€‚

オプション

-g
--global

ã“ã®ã‚ªãƒ—ションを指定ã—ãŸå ´åˆã€è¨­å®šã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ãªã‚Šã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€è¨­å®šã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯é€šå¸¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ãªã‚Šã¾ã™ã€‚

-p
--prefix

ã“ã®ã‚ªãƒ—ションã¯è¡¨ç¤ºã®æ›¸å¼ã‚’é¸æŠžã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãŸå ´åˆã€alias コマンドã¨ãã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°å…¨ã¦ã‚’表示ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションを指定ã—ãªã„å ´åˆã€alias ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã ã‘を表示ã—ã¾ã™ã€‚

オペランド

エイリアスå

表示ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã§ã™ã€‚

エイリアスå=値

設定ã™ã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã¨ãã®å†…容ã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š alias コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Yash ã§ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã¨ã—ã¦ä½¿ãˆãªã„文字ã¯ã€ç©ºç™½æ–‡å­—・タブ・改行ã€ãŠã‚ˆã³ =$<>\'"`;&|()# ã®å„文字ã§ã™ã€‚エイリアスã®å†…容ã«ã¯ã™ã¹ã¦ã®æ–‡å­—ãŒä½¿ãˆã¾ã™ã€‚

Alias ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/expand.html0000644000175000017500000011711712154557026016062 0ustar magicantmagicant å˜èªžã®å±•é–‹

コマンドを構æˆã™ã‚‹å„å˜èªžã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã¨ãã«å±•é–‹ã•れã¾ã™ã€‚展開ã¨ã¯å˜èªžã«å«ã¾ã‚Œã‚‹ãƒ‘ラメータやパターンを処ç†ã—ã¦å…·ä½“çš„ãªæ–‡å­—列値ã«ç½®ãæ›ãˆã‚‹ã“ã¨ã§ã™ã€‚展開ã«ã¯ä»¥ä¸‹ã®ä¸ƒç¨®é¡žãŒã‚りã¾ã™ã€‚

ã“れらã®å±•é–‹ã¯ä¸Šã«æŒ™ã’ãŸé †åºã§è¡Œã‚れã¾ã™ã€‚ç‰¹ã«æœ€åˆã®å››ã¤ (ãƒãƒ«ãƒ€å±•開・パラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹) を四種展開ã¨ã„ã„ã¾ã™ã€‚

ãƒãƒ«ãƒ€å±•é–‹

ãƒãƒ«ãƒ€å±•é–‹ã¯ã€~ ã§å§‹ã¾ã‚‹å˜èªžã‚’特定ã®ãƒ‘スåã«ç½®ãæ›ãˆã‚‹å±•é–‹ã§ã™ã€‚å˜èªžã®å…ˆé ­ã«ã‚ã‚‹ ~ ã‹ã‚‰æœ€åˆã® / ã¾ã§ (/ ãŒãªã„å ´åˆã¯å˜èªžå…¨ä½“) ãŒæŒ‡å®šã•れãŸãƒ‘スåã«å¤‰æ›ã•れã¾ã™ã€‚ãŸã ã—ã€ç½®ãæ›ãˆã‚‰ã‚Œã‚‹éƒ¨åˆ†ãŒä¸€æ–‡å­—ã§ã‚‚クォートã•れã¦ã„ã‚‹å ´åˆã¯ã€ãƒãƒ«ãƒ€å±•é–‹ã¯è¡Œã‚れã¾ã›ã‚“。

展開ã•れる内容ã¯ã€ç½®ãæ›ãˆã‚‰ã‚Œã‚‹éƒ¨åˆ†ã®æ›¸å¼ã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«æ±ºã¾ã‚Šã¾ã™ã€‚

~

å˜ãªã‚‹ ~ ã¯ã€HOME 変数ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚

~username

~ ã®å¾Œã«ãƒ¦ãƒ¼ã‚¶åãŒæ›¸ã‹ã‚Œã¦ã„ã‚‹å ´åˆã¯ã€ãã®ãƒ¦ãƒ¼ã‚¶ã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スåã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚

~+

~+ ã¯ã€PWD 変数ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚

~-

~- ã¯ã€OLDPWD 変数ã®å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚

~+n
~-n

ã“ã® n 㯠0 ä»¥ä¸Šã®æ•´æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®å½¢å¼ã®ãƒãƒ«ãƒ€å±•é–‹ã¯ã€+n ã¾ãŸã¯ -n ã§æŒ‡å®šã•れるディレクトリスタック内ã®ãƒ‘スã®ä¸€ã¤ã«å±•é–‹ã•れã¾ã™ã€‚(dirs 組込ã¿ã‚³ãƒžãƒ³ãƒ‰å‚ç…§)

変数代入ã®å€¤ã«å¯¾ã—ã¦ãƒãƒ«ãƒ€å±•é–‹ãŒè¡Œã‚れる際ã€å€¤ãŒã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦ã‚ã‚‹å ´åˆã¯ã€ã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦ã‚ã‚‹å„部分をãれãžã‚Œå˜èªžã¨ã¿ãªã—ã¦ãƒãƒ«ãƒ€å±•é–‹ã—ã¾ã™ã€‚例ãˆã° HOME 変数ã®å€¤ãŒ /home/foo ã®ã¨ãã€

VAR=~/a:~/b:~/c

ã¯

VAR=/home/foo/a:/home/foo/b:/home/foo/c

ã¨ç­‰ä¾¡ã§ã™ã€‚

ãƒãƒ«ãƒ€å±•é–‹ã«å¤±æ•—ã—ãŸå ´åˆ (指定ã•れãŸãƒ‘スåãŒä½•らã‹ã®åŽŸå› ã§å¾—られãªã‹ã£ãŸå ´åˆ) ã®å‹•作㯠POSIX ã§ã¯è¦å®šã•れã¦ã„ã¾ã›ã‚“ãŒã€yash ã§ã¯ä½•事もãªã‹ã£ãŸã‹ã®ã‚ˆã†ã«å‡¦ç†ã‚’続行ã—ã¾ã™ (ç½®ãæ›ãˆã‚‰ã‚Œã‚‹ã¯ãšã ã£ãŸéƒ¨åˆ†ã¯ãã®ã¾ã¾æ®‹ã•れã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãªã©ã¯å‡ºã¾ã›ã‚“)。

POSIX 準拠モードã§ã¯ ~ 㨠~ユーザå ã®å½¢å¼ã®å±•é–‹ã®ã¿ãŒæœ‰åйã§ã™ã€‚

パラメータ展開

パラメータ展開ã¯ã€å˜èªžã®ä¸€éƒ¨ã‚’パラメータã®å€¤ã«ç½®ãæ›ãˆã‚‹å±•é–‹ã§ã™ã€‚

よã使ã‚れるå˜ç´”ãªãƒ‘ラメータ展開ã®å½¢å¼ã¯ ${パラメータå} ã§ã™ã€‚ã“れã¯ãƒ‘ラメータåã§æŒ‡å®šã•れãŸãƒ‘ラメータã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚ã•らã«ã€ä»¥ä¸‹ã®å ´åˆã«ã¯ãƒ‘ラメータåを囲む括弧をçœç•¥ã—㦠$パラメータå ã®ã‚ˆã†ã«æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ã€‚

  • パラメータåãŒç‰¹æ®Šãƒ‘ラメータã®å ´åˆ

  • パラメータåãŒä¸€æ¡ã®ä½ç½®ãƒ‘ラメータã®å ´åˆ

  • パラメータåãŒå¤‰æ•°åã§ã€ç›´å¾Œã«å¤‰æ•°åã®ä¸€éƒ¨ã¨ã—ã¦èª¤è§£ã•れるæã‚Œã®ã‚る文字ãŒãªã„å ´åˆã€‚例ãˆã° ${path}-name ã¨ã„ã†å˜èªžã¯ $path-name ã¨æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ãŒã€ ${path}name ã‚’ $pathname ã¨æ›¸ãã“ã¨ã¯ã§ãã¾ã›ã‚“。

パラメータåã¨ã—ã¦ç‰¹æ®Šãƒ‘ラメータã§ã‚‚ä½ç½®ãƒ‘ラメータã§ã‚‚変数åã§ã‚‚ãªã„ã‚‚ã®ã‚’指定ã—ãŸå ´åˆã¯ã€æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚(Yash 以外ã®ã‚·ã‚§ãƒ«ã§ã¯æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã§ã¯ãªã展開エラーã«ãªã‚‹ã‚‚ã®ã‚‚ã‚りã¾ã™)

シェル㮠unset オプションãŒç„¡åйãªå ´åˆã€ãƒ‘ラメータåã«å­˜åœ¨ã—ãªã„変数を指定ã™ã‚‹ã¨å±•開エラーã«ãªã‚Šã¾ã™ã€‚Unset ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªå ´åˆã¯ã€å­˜åœ¨ã—ãªã„変数ã¯ç©ºæ–‡å­—列ã«å±•é–‹ã•れã¾ã™ã€‚

より複雑ãªãƒ‘ラメータ展開ã®å½¢å¼ã§ã¯ã€ãƒ‘ラメータã®å€¤ã‚’加工ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚パラメータ展開ã®ä¸€èˆ¬å½¢ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

パラメータ展開

${ å‰ç½®è©ž パラメータå インデックス 加工指定 }

ã“ã“ã§ã¯ä¾¿å®œä¸Šãƒ‘ラメータåやインデックスã®å‘¨ã‚Šã«ç©ºç™½ã‚’入れã¾ã—ãŸãŒã€å®Ÿéš›ã«ã¯ç©ºç™½ã‚’入れã¦ã¯ã„ã‘ã¾ã›ã‚“。パラメータå以外ã®éƒ¨åˆ†ã¯ã„ãšã‚Œã‚‚çœç•¥å¯èƒ½ã§ã™ã€‚

å‰ç½®è©ž

å‰ç½®è©žã¨ã—ã¦ãƒ‘ラメータåã®ç›´å‰ã«è¨˜å· # ã‚’ç½®ãã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚展開ã—よã†ã¨ã—ã¦ã„ã‚‹ã®ãŒé…列変数ã®å ´åˆã€å„è¦ç´ ãŒãれãžã‚Œæ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚

パラメータå

パラメータåã«ã¯ã€ç‰¹æ®Šãƒ‘ラメータ・ä½ç½®ãƒ‘ラメータ・変数を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿å±•é–‹ã¯æŒ‡å®šã•れãŸãƒ‘ラメータã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚指定ã—ãŸãƒ‘ラメータåãŒé…列変数ã®å ´åˆã€é…列ã®å„è¦ç´ ãŒç‰¹æ®Šãƒ‘ラメータ @ ã®å ´åˆã¨åŒæ§˜ã«å˜èªžåˆ†å‰²ã•れã¾ã™ (インデックス [*] ãŒæŒ‡å®šã•れãŸå ´åˆã‚’除ã)。

パラメータåã¨ã—ã¦ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•開を指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“れã¯ç‰¹ã«å±•é–‹ã®å…¥ã‚Œå­ã¨è¨€ã„ã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘ラメータ展開ã¯å†…å´ã®å±•é–‹ã®å±•é–‹çµæžœã«å±•é–‹ã•れã¾ã™ã€‚ãªãŠã€å†…å´ã®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿å±•é–‹ã®æ‹¬å¼§ { } ã¯çœç•¥ã§ãã¾ã›ã‚“。ã¾ãŸå±•é–‹ã®å…¥ã‚Œå­ã¯ POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

インデックス

インデックスã¯å±•é–‹ã™ã‚‹å€¤ã®ä¸€éƒ¨ã‚’抜ã出ã™ã®ã«ä½¿ã„ã¾ã™ã€‚インデックスã¯ä»¥ä¸‹ã®æ›¸å¼ã‚’ã—ã¦ã„ã¾ã™ã€‚

インデックス

[å˜èªž1]

[å˜èªž1,å˜èªž2]

ã“ã“ã§ã®å˜èªž1ãŠã‚ˆã³å˜èªž2ã¯é€šå¸¸ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨åŒæ§˜ã«è§£é‡ˆã•れã¾ã™ãŒã€, 㨠] ã§å¼·åˆ¶çš„ã«åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ã¾ãŸç©ºç™½ã‚„タブã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ã¯ã¿ãªã—ã¾ã›ã‚“。

インデックスã¯ã€ä»¥ä¸‹ã®ã‚ˆã†ã«è§£é‡ˆã•れã¾ã™ã€‚

  1. ã¾ãšã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«å«ã¾ã‚Œã‚‹å˜èªž1・å˜èªž2ã«å¯¾ã—ã¦ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•開を行ã„ã¾ã™ã€‚

  2. インデックス㌠[å˜èªž1] ã®æ›¸å¼ã‚’ã—ã¦ã„ã¦ã€å˜èªž1ã®ä¸Šè¨˜å±•é–‹çµæžœãŒ *ã€@ã€# ã®ã„ãšã‚Œã‹ã®å ´åˆã¯ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®è§£é‡ˆã¯çµ‚了ã§ã™ã€‚

  3. å˜èªž1ã¨å˜èªž2ã®ä¸Šè¨˜å±•é–‹çµæžœã‚’æ•°å¼ã¨ã¿ãªã—ã¦ã€æ•°å¼å±•é–‹ã¨åŒæ§˜ã«è¨ˆç®—ã—ã¾ã™ã€‚計算ã®çµæžœå¾—られる整数ãŒã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¨ãªã‚Šã¾ã™ã€‚æ•°å¼å±•é–‹ã®çµæžœãŒæ•´æ•°ã§ãªã„å ´åˆã¯å±•開エラーã§ã™ã€‚å˜èªž2ãŒãªã„å½¢å¼ã§ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’指定ã—ã¦ã„ã‚‹å ´åˆã¯ã€å˜èªž2ã¯å˜èªž1ã¨åŒã˜æ•´æ•°ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚

パラメータåãŒé…列変数ã®å ´åˆã¾ãŸã¯ç‰¹æ®Šãƒ‘ラメータ * ã¾ãŸã¯ @ ã®å ´åˆã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯é…列ã®è¦ç´ ã¾ãŸã¯ä½ç½®ãƒ‘ラメータã®ä¸€éƒ¨ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚パラメータåãŒä¸Šè¨˜ä»¥å¤–ã®å ´åˆã¯ã€ãƒ‘ラメータã®å€¤ã®ä¸€éƒ¨ã‚’指定ã—ã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚インデックスã§é¸æŠžã•れãŸé…列ã®è¦ç´ ã¾ãŸã¯ãƒ‘ラメータã®å€¤ã®ä¸€éƒ¨ã®ã¿ãŒã€ãƒ‘ラメータ展開ã®çµæžœã¨ã—ã¦å±•é–‹çµæžœã«æ®‹ã‚Šã¾ã™ã€‚インデックスã«ã‚ˆã‚‹é¸æŠžã«ã¤ã„ã¦ä»¥ä¸‹ã®è¦å‰‡ãŒé©ç”¨ã•れã¾ã™ã€‚

  • ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ãŒè² æ•°ã®ã¨ãã¯ã€è¦ç´ ã¾ãŸã¯æ–‡å­—を最後ã‹ã‚‰æ•°ãˆã‚‹ã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚例ãˆã°ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ [-2,-1] ã¯é…åˆ—ã®æœ€å¾Œã®äºŒã¤ã®è¦ç´  (ã¾ãŸã¯ãƒ‘ラメータã®å€¤ã®æœ€å¾Œã® 2 文字) ã‚’é¸æŠžã—ã¾ã™ã€‚

  • ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ãŒå­˜åœ¨ã—ãªã„è¦ç´ ã¾ãŸã¯æ–‡å­—を指示ã—ã¦ã„ã‚‹å ´åˆã§ã‚‚ã€ã‚¨ãƒ©ãƒ¼ã«ã¯ãªã‚Šã¾ã›ã‚“。例ãˆã°é…列ã®è¦ç´ æ•°ãŒ 4 ã®ã¨ãã«ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ [3,5] ãŒä¸Žãˆã‚‰ã‚ŒãŸã¨ã㯠3 番目以é™ã®å…¨ã¦ã®è¦ç´ ãŒé¸æŠžã•れã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ [5,7] ãŒä¸Žãˆã‚‰ã‚ŒãŸæ™‚ã¯ã©ã®è¦ç´ ã‚‚é¸æŠžã•れã¾ã›ã‚“。

  • ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®æ•´æ•°ã®ä¸€æ–¹ãŒ 0 ãªã‚‰ã°ã€(ã‚‚ã†ä¸€æ–¹ãŒä½•ã§ã‚れ) å±•é–‹çµæžœã«ã¯ä½•も残りã¾ã›ã‚“。

インデックス㌠[å˜èªž1] ã®æ›¸å¼ã‚’ã—ã¦ã„ã¦ã€å˜èªž1ã®å±•é–‹çµæžœãŒ *ã€@ã€# ã®ã„ãšã‚Œã‹ã ã£ãŸå ´åˆã¯ã€ãƒ‘ラメータã¯ä»¥ä¸‹ã®ã‚ˆã†ã«å‡¦ç†ã•れã¾ã™ã€‚

*

パラメータåãŒé…列変数ã®å ´åˆã€é…列ã®å…¨è¦ç´ ã‚’連çµã—一ã¤ã®æ–‡å­—列ã«ã—ã¾ã™ã€‚パラメータåãŒç‰¹æ®Šãƒ‘ラメータ * ã¾ãŸã¯ @ ã®å ´åˆã€å…¨ã¦ã®ä½ç½®ãƒ‘ラメータを連çµã—一ã¤ã®æ–‡å­—列ã«ã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ [1,-1] ã¨åŒæ§˜ã§ã™ã€‚(連çµã®ä»•æ–¹ã¯ç‰¹æ®Šãƒ‘ラメータ * ã®ä½ç½®ãƒ‘ラメータã®é€£çµã®ä»•æ–¹ã¨åŒã˜ã§ã™)

@

インデックス [1,-1] ã¨åŒæ§˜ã§ã™ã€‚

#

パラメータåãŒé…列変数ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯é…列ã®è¦ç´ æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚パラメータåãŒç‰¹æ®Šãƒ‘ラメータ * ã¾ãŸã¯ @ ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚ãれ以外ã®å ´åˆã€ã“ã®ãƒ‘ラメータ展開ã¯ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æ–‡å­—æ•°ã‚’è¡¨ã™æ•´æ•°ã«å±•é–‹ã•れã¾ã™ã€‚

パラメータ展開ã«ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¨ã—㦠[@] ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã•れã¾ã™ã€‚インデックスã¯POSIX 準拠モードã§ã¯ä¸€åˆ‡ä½¿ãˆã¾ã›ã‚“。

例 1. 通常ã®å¤‰æ•°ã®å±•é–‹

以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 ABC を出力ã—ã¾ã™:

var='123ABC789'
echo "${var[4,6]}"
例 2. ä½ç½®ãƒ‘ラメータã®å±•é–‹

以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 2 3 4 を出力ã—ã¾ã™:

set 1 2 3 4 5
echo "${*[2,-2]}"
例 3. é…列ã®å±•é–‹

以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–‡å­—列 2 3 4 を出力ã—ã¾ã™:

array=(1 2 3 4 5)
echo "${array[2,-2]}"

加工指定

加工指定ã¯ãƒ‘ラメータã®å€¤ã‚’加工ã—ã¾ã™ã€‚加工ã•れãŸå¾Œã®å€¤ãŒãƒ‘ラメータ展開ã®çµæžœã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚加工指定ã«ã¯ä»¥ä¸‹ã®å½¢å¼ãŒã‚りã¾ã™ã€‚

-å˜èªž

パラメータåãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã“ã®ãƒ‘ラメータ展開ã¯å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚(Unset オプションãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“)

+å˜èªž

パラメータåãŒå­˜åœ¨ã™ã‚‹å¤‰æ•°ã‚’指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã“ã®ãƒ‘ラメータ展開ã¯å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚(Unset オプションãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“)

=å˜èªž

パラメータåãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€å˜èªžã®å±•é–‹çµæžœãŒãã®å¤‰æ•°ã«ä»£å…¥ã•れãŸå¾Œã€ã“ã®ãƒ‘ラメータ展開ã¯ãã®å€¤ã«å±•é–‹ã•れã¾ã™ã€‚変数以外ã®ã‚‚ã®ã«å¯¾ã—ã¦ä»£å…¥ã—よã†ã¨ã™ã‚‹ã¨å±•開エラーã«ãªã‚Šã¾ã™ã€‚(Unset オプションãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚エラーã«ãªã‚Šã¾ã›ã‚“)

?å˜èªž

パラメータåãŒå­˜åœ¨ã—ãªã„変数を指示ã—ã¦ã„ã‚‹å ´åˆã¯ã€ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¨ã—ã¦å˜èªžã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚(å˜èªžãŒãªã„å ´åˆã¯ãƒ‡ãƒ•ォルトã®ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒå‡ºã¾ã™)

:-å˜èªž
:+å˜èªž
:=å˜èªž
:?å˜èªž

ã“れらã¯ä¸Šè¨˜ã® -ã€+ã€=ã€? ã¨å˜èªžã®çµ„ã¿åˆã‚ã›ã®åŠ å·¥æŒ‡å®šã¨åŒæ§˜ã§ã™ãŒã€å˜èªžã‚’使用ã™ã‚‹æ¡ä»¶ãŒç•°ãªã‚Šã¾ã™ã€‚先頭㫠: ãŒä»˜ã‹ãªã„ã‚‚ã®ã§ã¯ 『変数ãŒå­˜åœ¨ã™ã‚‹ã‹ã©ã†ã‹ã€ ã§åˆ¤å®šã•れã¾ã™ãŒã€: ãŒä»˜ãã‚‚ã®ã§ã¯ 『変数ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºæ–‡å­—列ã§ãªã„ã‹ã©ã†ã‹ã€ ã§åˆ¤å®šã•れã¾ã™ã€‚

#å˜èªž

å˜èªžã‚’パターンã¨ã—ã¦è¦‹ãŸã¨ãã€ãれãŒã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®å…ˆé ­éƒ¨åˆ†ã«ãƒžãƒƒãƒã™ã‚‹ãªã‚‰ã°ã€ãã®ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã‚’削除ã—ã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã“ã®ãƒ‘ラメータ展開ã¯ãƒžãƒƒãƒã—ãªã‹ã£ãŸæ®‹ã‚Šã®éƒ¨åˆ†ã«å±•é–‹ã•れã¾ã™ã€‚マッãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘短ãマッãƒã•ã›ã¾ã™ã€‚

##å˜èªž

ã“ã®åŠ å·¥æŒ‡å®šã¯ #å˜èªž ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚

%å˜èªž

ã“ã®åŠ å·¥æŒ‡å®šã¯ #å˜èªž ã¨åŒæ§˜ã§ã™ãŒã€å€¤ã®å…ˆé ­éƒ¨åˆ†ã§ã¯ãªã末尾部分ã«ãƒžãƒƒãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚

%%å˜èªž

ã“ã®åŠ å·¥æŒ‡å®šã¯ %å˜èªž ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚

/å˜èªž1/å˜èªž2

å˜èªž1をパターンã¨ã—ã¦è¦‹ãŸã¨ãã€ãれãŒã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®ä¸€éƒ¨ã«ãƒžãƒƒãƒã™ã‚‹ãªã‚‰ã°ã€ãã®ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã‚’å˜èªž2ã«ç½®ãæ›ãˆã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã“ã®ãƒ‘ラメータ展開ã¯ãƒžãƒƒãƒã—ãŸéƒ¨åˆ†ã‚’å˜èªž2ã«ç½®ãæ›ãˆãŸå€¤ã«å±•é–‹ã•れã¾ã™ã€‚マッãƒã™ã‚‹ç®‡æ‰€ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ã€æœ€åˆã®ç®‡æ‰€ãŒé¸ã°ã‚Œã¾ã™ã€‚マッãƒã®ä»•æ–¹ãŒè¤‡æ•°é€šã‚Šã‚ã‚‹å ´åˆã¯ã§ãã‚‹ã ã‘é•·ãマッãƒã•ã›ã¾ã™ã€‚

ã“ã®åŠ å·¥æŒ‡å®šã¯ POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

/#å˜èªž1/å˜èªž2

ã“ã®åŠ å·¥æŒ‡å®šã¯ /å˜èªž1/å˜èªž2 ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値ã®å…ˆé ­éƒ¨åˆ†ã«ã—ã‹ãƒžãƒƒãƒã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚

/%å˜èªž1/å˜èªž2

ã“ã®åŠ å·¥æŒ‡å®šã¯ /å˜èªž1/å˜èªž2 ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„ã‚‹å€¤ã®æœ«å°¾éƒ¨åˆ†ã«ã—ã‹ãƒžãƒƒãƒã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚

//å˜èªž1/å˜èªž2

ã“ã®åŠ å·¥æŒ‡å®šã¯ /å˜èªž1/å˜èªž2 ã¨åŒæ§˜ã§ã™ãŒã€ãƒžãƒƒãƒã™ã‚‹ç®‡æ‰€ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯æœ€åˆã®ç®‡æ‰€ã ã‘ã§ã¯ãªãå…¨ã¦ã®ç®‡æ‰€ã‚’å˜èªž2ã«ç½®ãæ›ãˆã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚

:/å˜èªž1/å˜èªž2

ã“ã®åŠ å·¥æŒ‡å®šã¯ /å˜èªž1/å˜èªž2 ã¨åŒæ§˜ã§ã™ãŒã€ã„ã¾å±•é–‹ã—よã†ã¨ã—ã¦ã„る値全体ã«ãƒžãƒƒãƒã™ã‚‹å ´åˆã—ã‹å¯¾è±¡ã¨ã—ãªã„点ãŒç•°ãªã‚Šã¾ã™ã€‚

ã„ãšã‚Œã®å½¢å¼ã«ãŠã„ã¦ã‚‚ã€åŠ å·¥æŒ‡å®šã«å«ã¾ã‚Œã‚‹å˜èªžã¯ (ãれãŒä½¿ç”¨ã•れるã¨ãã®ã¿) 四種展開ã•れã¾ã™ã€‚

展開ã—よã†ã¨ã—ã¦ã„るパラメータåãŒé…列変数ã¾ãŸã¯ç‰¹æ®Šãƒ‘ラメータ @ ã¾ãŸã¯ * ã®å ´åˆã€åŠ å·¥æŒ‡å®šã¯é…列ã®å„è¦ç´ ã¾ãŸã¯å„ä½ç½®ãƒ‘ラメータã«å¯¾ã—ã¦ãれãžã‚Œä½œç”¨ã—ã¾ã™ã€‚

コマンド置æ›

コマンド置æ›ã¯ã€æŒ‡å®šã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ãã®å‡ºåŠ›ã‚’ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ã«å±•é–‹ã—ã¾ã™ã€‚コマンド置æ›ã®æ›¸å¼ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

コマンド置æ›

$(コマンド)

`コマンド`

コマンド置æ›ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ãŒã‚µãƒ–シェルã§å®Ÿè¡Œã•れã¾ã™ã€‚ã“ã®ã¨ãã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ãŒãƒ‘イプを通ã˜ã¦ã‚·ã‚§ãƒ«ã«é€ã‚‰ã‚Œã¾ã™ã€‚çµæžœã¨ã—ã¦ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å‡ºåŠ›çµæžœã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã®å‡ºåŠ›ã®æœ«å°¾ã«ã‚る改行ã¯é™¤ãã¾ã™ã€‚

$( 㨠) ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®å…¥ã‚Œå­ã‚„リダイレクトãªã©ã‚’考慮ã—ã¦äºˆã‚è§£æžã•れã¾ã™ã€‚従ã£ã¦ã€$( 㨠) ã®é–“ã«ã¯åŸºæœ¬çš„ã«é€šå¸¸é€šã‚Šã‚³ãƒžãƒ³ãƒ‰ã‚’書ãã“ã¨ãŒã§ãã¾ã™ã€‚ãŸã ã—ã€æ•°å¼å±•é–‹ã¨ã®æ··åŒã‚’é¿ã‘ã‚‹ãŸã‚ã€ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ãŒ ( ã§å§‹ã¾ã‚‹å ´åˆã¯ã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã«ç©ºç™½ã‚’æŒ¿ã—æŒŸã‚“ã§ãã ã•ã„。

` ã§å›²ã‚€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®å…¥ã‚Œå­ãªã©ã¯è€ƒæ…®ã›ãšã«ã€ã‚³ãƒžãƒ³ãƒ‰ã®ä¸­ã«æœ€åˆã« (ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã—ã¦ã„ãªã„) ` ãŒç¾ã‚ŒãŸã¨ã“ã‚ã§ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®çµ‚ã‚りã¨ã¿ãªã•れã¾ã™ã€‚` ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã« ` ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚’書ãå ´åˆã¯ã€å†…å´ã® ` ã‚’ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ãã®ä»–ã€ã‚³ãƒžãƒ³ãƒ‰ã®ä¸€éƒ¨ã¨ã—㦠` を入れãŸã„ã¨ãã¯ã€(ãれãŒã‚³ãƒžãƒ³ãƒ‰å†…部ã§ä¸€é‡ã¾ãŸã¯äºŒé‡å¼•用符ã§ã‚¯ã‚©ãƒ¼ãƒˆã•れã¦ã„ã¦ã‚‚) ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚

$( 㨠) ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚’å«ã‚€ã‚³ãƒžãƒ³ãƒ‰ã‚’è§£æžã™ã‚‹æ™‚ã«ä¸€ç·’ã«è§£æžã•れã¾ã™ (POSIX 準拠モードを除ã)。` ã§å›²ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«é–¢ã‚らãšã€ãã®ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒå®Ÿè¡Œã•ã‚Œã‚‹æ™‚ã«æ¯Žå›žè§£æžã•れã¾ã™ã€‚

æ•°å¼å±•é–‹

æ•°å¼å±•é–‹ã¯ã€æ–‡å­—列を数å¼ã¨ã—ã¦è§£é‡ˆã—ã¦ã€ãã®è¨ˆç®—çµæžœã‚’è¡¨ã™æ•°å€¤ã«å±•é–‹ã—ã¾ã™ã€‚æ•°å¼å±•é–‹ã®æ›¸å¼ã¯ä»¥ä¸‹ã®é€šã‚Šã§ã™ã€‚

æ•°å¼å±•é–‹

$((å¼))

æ•°å¼å±•é–‹ã§ã¯ã€ã¾ãšå¼ã«å¯¾ã—ã¦ãƒ‘ラメータ展開・コマンド置æ›ãƒ»(入れå­ã®) æ•°å¼å±•é–‹ãŒè¡Œã‚れã¾ã™ã€‚ãã®çµæžœå¾—ã‚‰ã‚ŒãŸæ–‡å­—列を以下ã®ã‚ˆã†ã«æ•°å¼ã¨ã—ã¦è§£é‡ˆã—ã€ãã®è¨ˆç®—çµæžœã‚’è¡¨ã™æ•°å€¤ã«å±•é–‹ã•れã¾ã™ã€‚

Yash ã§ã¯ã€æ•°å¼ã®ä¸­ã§æ•´æ•° (C 言語㮠long åž‹) ã¨æµ®å‹•å°æ•°ç‚¹æ•° (C 言語㮠double åž‹) を扱ã†ã“ã¨ãŒã§ãã¾ã™ã€‚ãŸã ã— POSIX 準拠モードã§ã¯æµ®å‹•å°æ•°ç‚¹æ•°ã¯ä½¿ãˆã¾ã›ã‚“。整数åŒå£«ã®æ¼”ç®—ã®çµæžœã¯æ•´æ•°ã«ã€æµ®å‹•å°æ•°ç‚¹æ•°ã‚’å«ã‚€æ¼”ç®—ã®çµæžœã¯æµ®å‹•å°æ•°ç‚¹æ•°ã«ãªã‚Šã¾ã™ã€‚

æ•°å¼ã§ã¯ C 言語㨠(ã»ã¼) åŒæ§˜ã«ä»¥ä¸‹ã®æ¼”ç®—å­ãŒä½¿ãˆã¾ã™ã€‚

  1. ( )

  2. ++ -- (後置演算å­)

  3. ++ -- + - ~ ! (å‰ç½®æ¼”ç®—å­)

  4. * / %

  5. + - (二項演算å­)

  6. << >>

  7. < <= > >=

  8. == !=

  9. &

  10. ^

  11. |

  12. &&

  13. ||

  14. ? : (三項演算å­)

  15. = *= /= %= += -= <<= >>= &= ^= |=

++ ãŠã‚ˆã³ -- 演算å­ã¯ POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

原å­å¼ã¨ã—ã¦ã¯æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ãƒ»æµ®å‹•å°æ•°ç‚¹æ•°ãƒªãƒ†ãƒ©ãƒ«ãƒ»å¤‰æ•°ãŒä½¿ç”¨ã§ãã¾ã™ã€‚æ•°ãƒªãƒ†ãƒ©ãƒ«ã®æ›¸å¼ã¯ C è¨€èªžã«æº–ã˜ã¾ã™ã€‚0 ã§å§‹ã¾ã‚‹æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ã¯å…«é€²æ•°ã€0x ã§å§‹ã¾ã‚‹æ•´æ•°ãƒªãƒ†ãƒ©ãƒ«ã¯å六進数ã¨ã¿ãªã•れã¾ã™ã€‚æµ®å‹•å°æ•°ç‚¹æ•°ãƒªãƒ†ãƒ©ãƒ«ã§ã¯æŒ‡æ•°è¡¨è¨˜ã‚‚使ãˆã¾ã™ (例ãˆã° 1.23×106 㯠1.23e+6)。変数ã¯ã€ãã®å€¤ãŒæ•°å€¤ã§ãªã„å ´åˆã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚

ブレース展開

ブレース展開ã¯ã€ãƒ–レース ({ }) ã§å›²ã‚“ã éƒ¨åˆ†ã‚’ã„ãã¤ã‹ã®å˜èªžã«åˆ†å‰²ã—ã¾ã™ã€‚ブレース展開㯠brace-expand ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã®ã¿è¡Œã‚れã¾ã™ã€‚ブレース展開ã«ã¯äºŒç¨®é¡žã®å½¢å¼ãŒã‚りã¾ã™ã€‚

カンマ区切りã®ãƒ–レース展開

{å˜èªž1,å˜èªž2,…,å˜èªžn}

連続ã—ãŸæ•°å€¤ã®ãƒ–レース展開

{始点..終点}

{始点..終点..差分}

一ã¤ç›®ã®å½¢å¼ã¯ã€ãƒ–レースã§å›²ã‚“ã éƒ¨åˆ†ã‚’一ã¤ä»¥ä¸Šã®ã‚«ãƒ³ãƒž (,) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚区切られãŸãれãžã‚Œã®éƒ¨åˆ†ãŒãƒ–レース展開ã®å‰å¾Œã®éƒ¨åˆ†ã¨çµåˆã•れã¦ã€ãれãžã‚Œå˜èªžã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚例ãˆã° a{1,2,3}b 㯠a1bã€a2bã€a3b ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚

二ã¤ç›®ã®å½¢å¼ã¯ {始点..終点} ã¾ãŸã¯ {始点..終点..差分} ã§ã™ã€‚始点・終点・差分ã¯å…¨ã¦æ•´æ•°ã§ã‚ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ã“ã®å½¢å¼ã®ãƒ–レース展開ã§ã¯ã€å§‹ç‚¹ã‹ã‚‰çµ‚点ã¾ã§ã®å„æ•´æ•°ãŒãƒ–レース展開ã®å‰å¾Œã®éƒ¨åˆ†ã¨çµåˆã•れã¦ã€ãれãžã‚Œå˜èªžã¨ã—ã¦å±•é–‹ã•れã¾ã™ã€‚å·®åˆ†ã¯æ•´æ•°ã®é–“隔を指定ã—ã¾ã™ã€‚例ãˆã° a{1..3}b 㯠a1bã€a2bã€a3b ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã€a{1..7..2}b 㯠a1bã€a3bã€a5bã€a7b ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚始点ãŒçµ‚点より大ãã„å ´åˆã¯æ•´æ•°ã¯é™é †ã«å±•é–‹ã•れã¾ã™ã€‚

複数ã®ãƒ–レース展開を組ã¿åˆã‚ã›ãŸã‚Šã€å…¥ã‚Œå­ã«ã—ãŸã‚Šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ブレースをブレース展開ã¨ã—ã¦ã§ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã«ã¯ã€ãƒ–レースをクォートã—ã¦ãã ã•ã„。ã¾ãŸã‚«ãƒ³ãƒžã‚’区切りã¨ã—ã¦ã§ãªãé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦æ‰±ã†ã«ã¯ã€ã‚«ãƒ³ãƒžã‚’クォートã—ã¦ãã ã•ã„。

ブレース展開ã§ã¯å±•開エラーã¯ç™ºç”Ÿã—ã¾ã›ã‚“ã€‚ãƒ–ãƒ¬ãƒ¼ã‚¹å±•é–‹ãŒæ­£ã—ãã§ããªã„å ´åˆã¯ã€å˜ã«ãれã¯ãƒ–レース展開ã§ã¯ãªã‹ã£ãŸã‚‚ã®ã¨ã—ã¦ã€ãã®ã¾ã¾æ®‹ã•れã¾ã™ã€‚

å˜èªžåˆ†å‰²

å˜èªžåˆ†å‰²ã¯ã€å±•é–‹ã®çµæžœã‚’ã„ãã¤ã‹ã®å˜èªžã«åˆ†å‰²ã—ã¾ã™ã€‚

å˜èªžåˆ†å‰²ã§åˆ†å‰²ã®å¯¾è±¡ã¨ãªã‚‹ã®ã¯ã€ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ã§å±•é–‹ã•れãŸçµæžœã®éƒ¨åˆ†ã ã‘ã§ã™ã€‚ã¾ãŸã€äºŒé‡å¼•用符ã«ã‚ˆã‚‹ã‚¯ã‚©ãƒ¼ãƒˆã®ä¸­ã§å±•é–‹ã•れãŸéƒ¨åˆ†ã¯ã€(特殊パラメータ @ ã®å±•開を除ã„ã¦) 分割ã®å¯¾è±¡ã¨ãªã‚Šã¾ã›ã‚“。

å˜èªžåˆ†å‰²ã¯ IFS 変数ã®å€¤ã«å¾“ã£ã¦è¡Œã‚れã¾ã™ã€‚IFS 変数ãŒå­˜åœ¨ã—ãªã„å ´åˆã¯ã€ç©ºç™½æ–‡å­—・タブ・改行ã®ä¸‰æ–‡å­—㌠IFS 変数ã®å€¤ã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚

IFS 変数ã®å€¤ã«å«ã¾ã‚Œã¦ã„る文字を IFS 文字ã¨ã„ã„ã¾ã™ã€‚IFS 文字ã®ã†ã¡ç©ºç™½æ–‡å­—ã¾ãŸã¯ã‚¿ãƒ–ã¾ãŸã¯æ”¹è¡Œã§ã‚ã‚‹ã‚‚ã®ã‚’ IFS 空白類ã¨ã„ã„ã¾ã™ã€‚IFS 空白類以外㮠IFS 文字を IFS éžç©ºç™½é¡žã¨ã„ã„ã¾ã™ã€‚

分割ã¯ä»¥ä¸‹ã®è¦å‰‡ã«å¾“ã£ã¦è¡Œã‚れã¾ã™ã€‚

  1. 分割ã¯ã€åˆ†å‰²ã®å¯¾è±¡ã¨ãªã‚‹å±•é–‹çµæžœã®éƒ¨åˆ†ã®ä¸­ã§ã€IFS 文字ãŒç¾ã‚Œã‚‹ç®‡æ‰€ã§è¡Œã‚れã¾ã™ã€‚以下ã“ã®ã‚ˆã†ãªç®‡æ‰€ã‚’分割点ã¨å‘¼ã³ã¾ã™ã€‚複数㮠IFS 文字ãŒé€£ç¶šã—ã¦ç¾ã‚Œã‚‹å ´åˆã¯ã€ãれらをã¾ã¨ã‚ã¦ä¸€ã¤ã®åˆ†å‰²ç‚¹ã¨ã—ã¾ã™ã€‚

  2. 分割点㫠IFS éžç©ºç™½é¡žãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ãã®åˆ†å‰²ç‚¹ã«å«ã¾ã‚Œã‚‹ IFS 空白類ã¯ã™ã¹ã¦ç„¡è¦–ã•れã¾ã™ã€‚ãã—ã¦åˆ†å‰²ç‚¹ã«å«ã¾ã‚Œã‚‹å„ IFS éžç©ºç™½é¡žã®å‰å¾Œã§å˜èªžãŒåˆ†å‰²ã•れã¾ã™ã€‚

  3. 分割点㫠IFS éžç©ºç™½é¡žãŒå«ã¾ã‚Œã¦ã„ãªã„ (分割点㌠IFS 空白類ã ã‘ã‹ã‚‰ãªã‚‹) å ´åˆã€ãã®åˆ†å‰²ç‚¹ã®å‰å¾Œã§å˜èªžãŒåˆ†å‰²ã•れã¾ã™ã€‚ãŸã ã—ã€ã“ã®ã‚ˆã†ãªåˆ†å‰²ç‚¹ãŒå…ƒã®å˜èªžã®å…ˆé ­ã¾ãŸã¯æœ«å°¾ã«ã‚ã‚‹å ´åˆã‚’除ãã¾ã™ã€‚

  4. ã„ãšã‚Œã®å ´åˆã‚‚ã€åˆ†å‰²ç‚¹ã¯å˜èªžåˆ†å‰²å¾Œã®å˜èªžã«ã¯æ®‹ã‚Šã¾ã›ã‚“。

注
IFS 変数ã®å€¤ãŒç©ºæ–‡å­—列ã®å ´åˆã¯ã€å˜èªžã¯ä¸€åˆ‡åˆ†å‰²ã•れã¾ã›ã‚“。

パスå展開

パスå展開ã¯ã€å˜èªžã‚’パターンã¨ã¿ãªã—ã¦ãƒ•ァイルを検索ã—ã€ãƒ‘ターンã«ãƒžãƒƒãƒã™ã‚‹å®Ÿåœ¨ã®ãƒ•ァイルã¸ã®ãƒ‘スåã«å±•é–‹ã—ã¾ã™ã€‚ パスå展開㯠glob オプションãŒç„¡åŠ¹ãªæ™‚ã¯è¡Œã‚れã¾ã›ã‚“。

パスå展開ã«ãŠã„ã¦ãƒ‘ターンãŒãƒžãƒƒãƒã™ã‚‹ã«ã¯ã€æ¤œç´¢ã®å¯¾è±¡ã¨ãªã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®èª­ã¿è¾¼ã¿æ¨©é™ãŒå¿…è¦ã§ã™ã€‚検索ã—よã†ã¨ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒã‚·ã‚§ãƒ«ã«ã¨ã£ã¦èª­ã¿è¾¼ã¿å¯èƒ½ã§ãªã‘れã°ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯ç©ºã§ã‚ã‚‹ã¨ã¿ãªã—ã¾ã™ã€‚

以下ã®ã‚ªãƒ—ションãŒãƒ‘スå展開ã®çµæžœã«å½±éŸ¿ã—ã¾ã™ã€‚

null-glob

マッãƒã™ã‚‹ãƒ•ァイルãŒãªã„時ã€é€šå¸¸ (ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚) ã¯ãƒ‘ターンã¯ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ãƒ‘ターンã¯å‰Šé™¤ã•れ何も残りã¾ã›ã‚“。

case-glob

通常 (ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚) ã¯ã€å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã—ã¦ãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚ã¯å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã›ãšãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ã€‚

dot-glob

通常 (ã“ã®ã‚ªãƒ—ションãŒç„¡åŠ¹ãªæ™‚) ã¯ã€* ã‚„ ? ãªã©ã®ãƒ¯ã‚¤ãƒ«ãƒ‰ã‚«ãƒ¼ãƒ‰ã‚„ブラケット記法ã§å§‹ã¾ã‚‹ãƒ‘ターンã¯ãƒ”リオドã§å§‹ã¾ã‚‹ãƒ•ァイルåã«ãƒžãƒƒãƒã—ã¾ã›ã‚“。ã—ã‹ã—ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã“ã®ã‚ˆã†ãªåˆ¶ç´„ã¯è§£é™¤ã•れã¾ã™ã€‚

mark-dirs

ã“ã®ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãƒžãƒƒãƒã—ãŸãƒ•ァイルã®ç¨®é¡žãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®å ´åˆã«å±•é–‹ã•れるパスåã®æœ€å¾Œã« / ãŒä»˜ãã¾ã™ã€‚

extended-glob

ã“ã®ã‚ªãƒ—ションを有効ã«ã™ã‚‹ã¨ã€ãƒ‘スå展開ã«ãŠã‘る拡張機能ãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚

パスå展開ã§ã¯ã‚¨ãƒ©ãƒ¼ã¯ç™ºç”Ÿã—ã¾ã›ã‚“。マッãƒã™ã‚‹ãƒ•ァイルãŒãªã„å ´åˆã¾ãŸã¯ãƒ‘ターンãŒä¸æ­£ãªå ´åˆã¯ã€å±•é–‹ã¯è¡Œã‚れãšãƒ‘ターンã¯ãã®ã¾ã¾æ®‹ã‚Šã¾ã™ (null-glob ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚を除ã)。

ãƒ•ã‚¡ã‚¤ãƒ«ã®æ¤œç´¢ã¨ãƒ‘ターンマッãƒãƒ³ã‚°ã¯ / ã§åŒºåˆ‡ã‚‰ã‚ŒãŸãƒ‘スåã®æ§‹æˆè¦ç´ ã”ã¨ã«è¡Œã‚れã¾ã™ã€‚ワイルドカードやブラケット記法を全ãå«ã¾ãªã„æ§‹æˆè¦ç´ ã¯ãƒ‘ターンã¨ã¯ã¿ãªã•れãšã€æ¤œç´¢ã¨ãƒžãƒƒãƒãƒ³ã‚°ã¯è¡Œã‚れã¾ã›ã‚“。従ã£ã¦ã€case-glob オプションãŒç„¡åŠ¹ãªæ™‚ã€/*/foo 㨠/*/fo[o] ã®å±•é–‹çµæžœãŒç•°ãªã‚‹å¯èƒ½æ€§ãŒã‚りã¾ã™ (å‰è€…ã§ã¯ foo ã®éƒ¨åˆ†ãŒãƒ‘ターンã¨ã¯ã¿ãªã•れãªã„ã®ã§ã€ä¾‹ãˆã° /bar/FOO ã¨ã„ã†ãƒ•ァイルãŒã‚ã£ã¦ã‚‚マッãƒã—ã¾ã›ã‚“。)。

パスåå±•é–‹ã®æ‹¡å¼µæ©Ÿèƒ½

Extended-glob ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã¯ã€ä»¥ä¸‹ã®ç‰¹æ®Šãªãƒ‘ターンãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚

**

指定ã•れãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ„リーã«å¯¾ã—å†å¸°çš„ã«æ¤œç´¢ã‚’行ã„ã¾ã™ã€‚ã™ãªã‚ã¡ã€æŒ‡å®šã•れãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¨ã€ãã®ã‚µãƒ–ディレクトリã€ã•らã«ãã®ã‚µãƒ–ディレクトリãªã©ã«å¯¾ã—検索を行ã„ã¾ã™ã€‚ãŸã ã—åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯æ¤œç´¢ã®å¯¾è±¡ã«ãªã‚Šã¾ã›ã‚“。例ãˆã° dir/**/file ã¨ã„ã†ãƒ‘ターンã¯ã€dir/file ã‚„ dir/foo/file ã‚„ dir/a/b/c/file ãªã©ã€dir ディレクトリã®ä¸­ã«ã‚ã‚‹å…¨ã¦ã® file ファイルã¸ã®ãƒ‘スã«å±•é–‹ã•れã¾ã™ã€‚

ã“ã®ç‰¹æ®Šãªãƒ‘ターンã¯ã€ foo/bar/** ã®ã‚ˆã†ã«ãƒ‘ã‚¿ãƒ¼ãƒ³å…¨ä½“ã®æœ€å¾Œã«ã‚ã‚‹å ´åˆã«ã¯åŠ¹æžœãŒã‚りã¾ã›ã‚“。

.**

** パターンã¨åŒæ§˜ã§ã™ãŒã€åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚‚å«ã‚ã¦æ¤œç´¢ã™ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚

***

** パターンã¨åŒæ§˜ã§ã™ãŒã€æ¤œç´¢ã®ä¸­ã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¸ã®ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ä¸­ã‚‚検索ã®å¯¾è±¡ã«å«ã‚る点ãŒç•°ãªã‚Šã¾ã™ã€‚

.***

*** パターンã¨åŒæ§˜ã§ã™ãŒã€åå‰ãŒãƒ”リオドã§å§‹ã¾ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚‚å«ã‚ã¦æ¤œç´¢ã™ã‚‹ç‚¹ãŒç•°ãªã‚Šã¾ã™ã€‚

yash-2.35/doc/ja/_exit.txt0000644000175000017500000000564112154557026015564 0ustar magicantmagicant= Exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]コマンドã¯ã‚·ã‚§ãƒ«ã®å®Ÿè¡Œã‚’終了ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +exit [-f] [{{終了ステータス}}]+ [[description]] == 説明 Exit コマンドã¯ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã‚·ã‚§ãƒ« (ã¾ãŸã¯link:exec.html#subshell[サブシェル]) を終了ã—ã¾ã™ã€‚ åœæ­¢ã—ã¦ã„ã‚‹link:job.html[ジョブ]ã®ã‚ã‚‹link:interact.html[対話モード]ã®ã‚·ã‚§ãƒ«ã‚’終了ã—よã†ã¨ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€çµ‚了ã—ã¾ã›ã‚“。+-f+ (+--force+) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã‹ exit コマンドを二連続ã§å®Ÿè¡Œã™ã‚‹ã¨è­¦å‘Šã‚’無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’終了ã—ã¾ã™ã€‚ シェル終了時ã®link:_trap.html[トラップ]ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ãŒçµ‚了ã™ã‚‹å‰ã«ãれãŒå®Ÿè¡Œã•れã¾ã™ã€‚ [[options]] == オプション +-f+:: +--force+:: 警告を無視ã—ã¦ã‚·ã‚§ãƒ«ã‚’終了ã—ã¾ã™ã€‚ [[operands]] == オペランド {{終了ステータス}}:: 終了ã™ã‚‹ã‚·ã‚§ãƒ«ã®çµ‚了ステータスを指定ã™ã‚‹ 0 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚ + ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€exit コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスを用ã„ã¾ã™ (ãŸã ã—link:_trap.html[トラップ]を実行中ã®å ´åˆã¯ãƒˆãƒ©ãƒƒãƒ—ã«å…¥ã‚‹ç›´å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス)。 + 終了ã™ã‚‹ã‚·ã‚§ãƒ«ã®å®Ÿéš›ã®çµ‚了ステータスã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§ä¸Žãˆã‚‰ã‚ŒãŸæ•°ã‚’ 256 ã§å‰²ã£ãŸä½™ã‚Šã«ãªã‚Šã¾ã™ã€‚ [[exitstatus]] == 終了ステータス Exit コマンドã¯ã‚·ã‚§ãƒ«ã‚’終了ã™ã‚‹ã®ã§ã€exit コマンドãã®ã‚‚ã®ã®çµ‚了ステータスã¯ã‚りã¾ã›ã‚“。 例外ã¨ã—ã¦ã€exit コマンドãŒè­¦å‘Šã‚’表示ã—ã¦ã€ã‚·ã‚§ãƒ«ã‚’終了ã—ãªã‹ã£ãŸå ´åˆã€exit コマンドã®çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 Exit コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã§ã¯ã€{{終了ステータス}}ã®å€¤ã¯ 0 以上 256 未満ã§ãªã‘れã°ãªã‚‰ãªã„ã¨ã—ã¦ã„ã¾ã™ã€‚Yash ã§ã¯æ‹¡å¼µã¨ã—㦠256 以上ã®å€¤ã‚‚å—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ POSIX ã«ã¯ +-f+ (+--force+) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。 シェル終了時ã®ãƒˆãƒ©ãƒƒãƒ—ã®å®Ÿè¡Œä¸­ã« exit コマンドを実行ã™ã‚‹ã¨ã€å†ã³ãƒˆãƒ©ãƒƒãƒ—ãŒå®Ÿè¡Œã•れるã“ã¨ã¯ãªããã®ã¾ã¾ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚ã“ã®ã¨ã exit コマンドã«{{終了ステータス}}ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€ã‚‚ã—終了時ã®ãƒˆãƒ©ãƒƒãƒ—ãŒè¨­å®šã•れã¦ã„ãªã‹ã£ãŸå ´åˆã«ã‚·ã‚§ãƒ«ãŒè¿”ã—ãŸã‚ã†çµ‚了ステータスã§ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚(link:exec.html#exit[シェルã®çµ‚了]ã‚‚å‚ç…§) // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_true.txt0000644000175000017500000000153212154557026015565 0ustar magicantmagicant= True 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - True 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[True 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ä½•も行ã‚ãšã« 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +true+ [[description]] == 説明 True コマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス True コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 True コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ link:_colon.html[コロンコマンド]㯠true コマンドã¨åŒæ§˜ã«ä½•も行ã„ã¾ã›ã‚“ãŒã€true ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ã‚‹ã®ã«å¯¾ã—コロンコマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_pwd.html0000644000175000017500000000553612154557026015535 0ustar magicantmagicant Pwd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Pwd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表示ã—ã¾ã™ã€‚

æ§‹æ–‡

  • pwd [-L|-P]

説明

Pwd コマンドã¯ã‚·ã‚§ãƒ«ã®ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’çµ¶å¯¾ãƒ‘ã‚¹ã§æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

オプション

-L
--logical

PWD 変数ã®å€¤ãŒç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スã§ã€ä¸­ã« . ã‚„ .. ã‚’å«ã‚“ã§ã„ãªã‘れã°ã€ãれを出力ã—ã¾ã™ã€‚ãれ以外ã®å ´åˆã¯ -P を指定ã—ãŸå ´åˆã¨åŒæ§˜ã«å‡ºåŠ›ã—ã¾ã™ã€‚

-P
--physical

ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スをã€ä¸­ã«ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’å«ã¾ãªã„ã‹ãŸã¡ã§å‡ºåŠ›ã—ã¾ã™ã€‚

-L (--logical) オプション㨠-P (--physical) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€-L を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š pwd コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Pwd ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

yash-2.35/doc/ja/_unset.html0000644000175000017500000000662412154557026016100 0ustar magicantmagicant Unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’削除ã—ã¾ã™ã€‚

æ§‹æ–‡

  • unset [-fv] [å剅]

説明

Unset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸåå‰ã®å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’削除ã—ã¾ã™ã€‚

元々存在ã—ãªã„変数・関数を削除ã—よã†ã¨ã—ã¦ã‚‚ã€ä½•ã‚‚èµ·ã“りã¾ã›ã‚“ (エラーã«ã¯ãªã‚Šã¾ã›ã‚“)。

オプション

-f
--functions

関数を削除ã—ã¾ã™ã€‚

-v
--variables

変数を削除ã—ã¾ã™ã€‚

-f (--functions) オプション㨠-v (--variables) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€-v を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

オペランド

åå‰

削除ã™ã‚‹å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã®åå‰ã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š unset コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Unset コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã§ã¯ã€-f 㨠-v ã®ã©ã¡ã‚‰ã®ã‚ªãƒ—ションも指定ã•れã¦ã„ãªã„å ´åˆã€æŒ‡å®šã—ãŸåå‰ã®å¤‰æ•°ãŒãªã„å ´åˆã¯ã‹ã‚りã«ãã®åå‰ã®é–¢æ•°ã‚’削除ã—ã¦ã‚ˆã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚

POSIX 準拠モードã§ã¯å°‘ãªãã¨ã‚‚一ã¤åå‰ã‚’指定ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚

yash-2.35/doc/ja/_colon.html0000644000175000017500000000417312154557026016051 0ustar magicantmagicant コロン組込ã¿ã‚³ãƒžãƒ³ãƒ‰

コロン組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ä½•も行ã‚ãªã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

æ§‹æ–‡

  • : [引数…]

説明

コロンコマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚

終了ステータス

コロンコマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

コロンコマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

引数ã®å±•é–‹ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«è¡Œã„ã¾ã™ã€‚

True コマンドã¯ã‚³ãƒ­ãƒ³ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«ä½•も行ã„ã¾ã›ã‚“ãŒã€ã‚³ãƒ­ãƒ³ã‚³ãƒžãƒ³ãƒ‰ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ã‚‹ã®ã«å¯¾ã— true ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

yash-2.35/doc/ja/intro.html0000644000175000017500000000430612154557026015731 0ustar magicantmagicant ã¯ã˜ã‚ã«

Yet another shell (yash) 㯠Unix ç³» OS 用コマンドラインシェルã§ã™ã€‚POSIX.1-2008 è¦æ ¼ã« (一部ã®ä¾‹å¤–を除ã„ã¦) 準拠ã—ã¦ã„ã¾ã™ã€‚POSIX 準拠を謳ã†ä»–ã®ã‚·ã‚§ãƒ«ã‚ˆã‚Šã‚‚ç²¾ç¢ºãªæº–拠を目指ã—ã¦ã„ã¾ã™ã€‚ã¾ãŸã€ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚„コマンドライン編集ãªã©ã€å¯¾è©±ã‚·ã‚§ãƒ«ã¨ã—ã¦æ¨™æº–çš„ãªæ©Ÿèƒ½ã‚‚å‚™ãˆã¦ã„ã¾ã™ã€‚

ã“ã®ãƒ—ログラム㯠GNU General Public License (Version 2) ã®å…ƒã§è‡ªç”±ã«å†é…布・変更ãªã©ãŒã§ãã¾ã™ã€‚ãŸã ã—ã€ãƒ—ログラムã®åˆ©ç”¨ã¯å…¨ã¦å„自ã®è‡ªå·±è²¬ä»»ã®ä¸‹ã§è¡Œã£ã¦ã„ãŸã ãã“ã¨ã«ãªã‚Šã¾ã™ã€‚作者ã¯ãƒ—ログラムã®ç‘•ç–µã«å¯¾ã—ã¦ä¸€åˆ‡è²¬ä»»ã‚’å–りã¾ã›ã‚“。ã¾ãŸã€ã“ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã¯ã‚¯ãƒªã‚¨ã‚¤ãƒ†ã‚£ãƒ–・コモンズã®è¡¨ç¤º-継承 2.1 日本ライセンスã®ä¸‹ã§è‡ªç”±ã«å†é…布・変更ãªã©ãŒã§ãã¾ã™ã€‚

Yash ã¯æ¸¡é‚Šè£•è²´ (通称ã¾ã˜ã‹ã‚“ã¨) ã¨ã„ã†ä¸€äººã®é–‹ç™ºè€…ã«ã‚ˆã£ã¦é–‹ç™ºã•れã¦ã„ã¾ã™ã€‚Yash ã®é–‹ç™ºãƒ—ロジェクトãŠã‚ˆã³ ホームページ㯠SourceForge.jp ãŒãƒ›ã‚¹ãƒˆã—ã¦ã„ã¾ã™ã€‚

yash-2.35/doc/ja/builtin.txt0000644000175000017500000001666312154557026016130 0ustar magicantmagicant= 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :description: Yash ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«é–¢ã™ã‚‹å…±é€šã®äº‹æŸ„ã«ã¤ã„㦠dfn:[組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¨ã¯ã‚·ã‚§ãƒ«ã«å†…蔵ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¤–部ã®ãƒ—ログラムを起動ã™ã‚‹ã“ã¨ãªãシェル自身ã«ã‚ˆã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ [[types]] == 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ç¨®é¡ž Yash ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãƒ»é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ä¸‰ç¨®é¡žã«åˆ†ã‘られã¾ã™ã€‚ dfn:[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ä»–ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚ˆã‚Šã‚‚特ã«é‡è¦ãªã‚³ãƒžãƒ³ãƒ‰ã§ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã¯ç•°ãªã‚‹æ€§è³ªã‚’ã„ãã¤ã‹æŒã£ã¦ã„ã¾ã™ã€‚ã¾ãšã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¯¾å¿œã™ã‚‹å¤–部コマンドã®å­˜åœ¨ã«é–¢ä¿‚ãªã常ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã¾ãŸç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã‘る変数代入ã®çµæžœã¯ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã‚‚残りã¾ã™ã€‚ã•ら㫠link:posix.html[POSIX 準拠モード]ã§ã¯ã€ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚¨ãƒ©ãƒ¼ã¾ãŸã¯ä»£å…¥ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã‚ã‚‹ã„ã¯ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションやオペランドã®ä½¿ã„æ–¹ãŒé–“é•ã£ã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ãŒlink:interact.html[対話モード]ã§ãªã‘れã°ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«éž 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚ dfn:[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«æ¬¡ã„ã§é‡è¦ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã€å¯¾å¿œã™ã‚‹å¤–部コマンドã®å­˜åœ¨ã«é–¢ä¿‚ãªã常ã«å®Ÿè¡Œã•れã¾ã™ã€‚ãã®ä»–ã®ç‚¹ã§ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨åŒã˜ã§ã™ã€‚ 外部コマンドã¨ã—ã¦å®Ÿè£…å¯èƒ½ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„ POSIX ã«è¦å®šã•れã¦ã„ãªã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’å«ã‚€ã€é‡è¦åº¦ã®ä½Žã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯dfn:[通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚POSIX 準拠モードã§ã¯ã€é€šå¸¸ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å¯¾å¿œã™ã‚‹å¤–部コマンド㌠link:exec.html#search[+PATH+ å¤‰æ•°ã®æ¤œç´¢]ã§è¦‹ã¤ã‹ã£ãŸå ´åˆã®ã¿å®Ÿè¡Œã•れã¾ã™ã€‚ [[argsyntax]] == コマンドã®å¼•æ•°ã®æ§‹æ–‡ ã“ã“ã§ã¯çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã«é–¢ã™ã‚‹ä¸€èˆ¬çš„ãªè¦å‰‡ã«ã¤ã„ã¦èª¬æ˜Žã—ã¾ã™ã€‚Yash ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã®æŒ‡å®šãƒ»è§£é‡ˆã®ä»•æ–¹ã¯ã€ä»–ã«æ–­ã‚ŠãŒãªã„é™ã‚Šã“ã®è¦å‰‡ã«å¾“ã„ã¾ã™ã€‚ コマンドã®å¼•æ•°ã¯ã€ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®äºŒç¨®é¡žã«åˆ†ã‘られã¾ã™ã€‚dfn:[オプション]ã¯ãƒã‚¤ãƒ•ン (+-+) ã§å§‹ã¾ã‚‹å¼•æ•°ã§ã€ä¸»ã«ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作を変更ã™ã‚‹ã®ã«ä½¿ã‚れã¾ã™ã€‚オプションã®ä¸­ã«ã¯ãれã«å¯¾å¿œã™ã‚‹å¼•æ•°ã‚’ã¨ã‚‹ã‚‚ã®ã‚‚ã‚りã¾ã™ã€‚dfn:[オペランド]ã¯ã‚ªãƒ—ション以外ã®å¼•æ•°ã§ã€ä¸»ã«ã‚³ãƒžãƒ³ãƒ‰ãŒå‡¦ç†ã‚’行ã†å¯¾è±¡ã‚’指定ã™ã‚‹ã®ã«ä½¿ã‚れã¾ã™ã€‚ 一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ã‚ªãƒ—ションを与ãˆã‚‹å ´åˆã€åŽŸå‰‡ã¨ã—ã¦ãれらã®ã‚ªãƒ—ションã®é †åºã¯ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作ã«å½±éŸ¿ã—ã¾ã›ã‚“。ã—ã‹ã—オペランドã®é †åºã«ã¯æ„味ãŒã‚りã¾ã™ã€‚ オプションã«ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã¨é•·ã„オプションã¨ãŒã‚りã¾ã™ã€‚dfn:[一文字ã®ã‚ªãƒ—ション]ã¯è‹±æ•°å­—一文字ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるオプションã§ã™ã€‚dfn:[é•·ã„オプション]ã¯ã‚‚ã£ã¨é•·ã„文字列ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるオプションã§ã™ã€‚POSIX è¦æ ¼ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã«ã¤ã„ã¦ã—ã‹è¦å®šã—ã¦ã„ãªã„ãŸã‚ã€link:posix.html[POSIX 準拠モード]ã§ã¯é•·ã„オプションã¯ä½¿ãˆã¾ã›ã‚“。 一文字ã®ã‚ªãƒ—ションã¯ã€ä¸€ã¤ã®ãƒã‚¤ãƒ•ンã¨ä¸€æ–‡å­—ã®è‹±æ•°å­—ã‹ã‚‰ãªã‚Šã¾ã™ã€‚例ãˆã° +-a+ ã¯ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã§ã™ã€‚引数をã¨ã‚‹ã‚ªãƒ—ションã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã«ä¸Žãˆã‚‰ã‚ŒãŸå¼•æ•°ã®ä¸¦ã³ã®ä¸­ã§ãã®ã‚ªãƒ—ションã®ç›´å¾Œã«ä½ç½®ã—ã¦ã„る引数ãŒãã®ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ã¿ãªã•れã¾ã™ã€‚ .Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨ä¸€æ–‡å­—ã®ã‚ªãƒ—ション ==== Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ã€+-m+ ã¯å¼•æ•°ã‚’ã¨ã‚‰ãªã„一文字ã®ã‚ªãƒ—ションã€+-o+ ã¯å¼•æ•°ã‚’ã¨ã‚‹ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã§ã™ã€‚ - +set -o errexit -m+ - +set -oerrexit -m+ ã“ã®äºŒã¤ã®ä¾‹ã§ã¯ã€+errexit+ ㌠+-o+ オプションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ãªã‚Šã¾ã™ã€‚ ==== 上ã®äºŒã¤ç›®ã®ä¾‹ã§ã¯ã€+-o+ オプションã¨ãれã«å¯¾ã™ã‚‹å¼•æ•°ãŒä¸€ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«ãªã£ã¦ã„ã¾ã™ã€‚POSIX ã¯ã“ã®ã‚ˆã†ãªæ›¸ãæ–¹ã¯é¿ã‘ãªã‘れã°ãªã‚‰ãªã„ã¨å®šã‚ã¦ãŠã‚Šã€POSIX ã«å¾“ã†ã‚¢ãƒ—リケーションã¯å¿…ãšä¸€ã¤ç›®ã®ä¾‹ã®ã‚ˆã†ã«ã‚ªãƒ—ションã¨ãれã«å¯¾ã™ã‚‹å¼•数を別々ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¨ã—ã¦ä¸Žãˆãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã—ã‹ã— yash ã¯ã©ã¡ã‚‰ã®æŒ‡å®šã®ä»•方もå—ã‘付ã‘るよã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ 引数をã¨ã‚‰ãªã„複数ã®ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã¯ã€ä¸€ã¤ã«ã¾ã¨ã‚ã¦æ›¸ãã“ã¨ãŒã§ãã¾ã™ã€‚例ãˆã° +-a+, +-b+, +-c+ ã¨ã„ã†ä¸‰ã¤ã®ã‚ªãƒ—ション㯠+-abc+ ã¨æ›¸ã‘ã¾ã™ã€‚ é•·ã„オプションã¯ã€äºŒã¤ã®ãƒã‚¤ãƒ•ンã¨ã‚ªãƒ—ションåã‚’è¡¨ã™æ–‡å­—列ã‹ã‚‰ãªã‚Šã¾ã™ã€‚例ãˆã° +--long-option+ ã¯é•·ã„オプションã§ã™ã€‚オプションåã¯ä»–ã¨ç´›ã‚‰ã‚ã—ããªã„é™ã‚Šæœ«å°¾ã‚’çœç•¥ã§ãã¾ã™ã€‚例ãˆã°ä»–ã« +--long+ ã§å§‹ã¾ã‚‹é•·ã„オプションãŒãªã‘れã°ã€+--long-option+ 㯠+--long+ ã¨çœç•¥ã§ãã¾ã™ã€‚引数をã¨ã‚‹ã‚ªãƒ—ションã§ã¯ã€ä¸€æ–‡å­—ã®ã‚ªãƒ—ションã®å ´åˆã¨åŒæ§˜ã«ã€ã‚ªãƒ—ションã®ç›´å¾Œã«ã‚るコマンドライン引数ãŒãã®ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ã¿ãªã•れã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã€ã‚ªãƒ—ションåã®å¾Œã«ç­‰å· (+=+) ã§åŒºåˆ‡ã£ã¦ç›´æŽ¥å¼•数を与ãˆã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¨é•·ã„オプション ==== Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ãŠã„ã¦ã€+--quiet+ ã¯å¼•æ•°ã‚’ã¨ã‚‰ãªã„é•·ã„オプションã€+--editor+ ã¯å¼•æ•°ã‚’ã¨ã‚‹é•·ã„オプションã§ã™ã€‚ - +fc --editor vi --quiet+ - +fc --editor=vi --quiet+ ã“ã®äºŒã¤ã®ä¾‹ã§ã¯ã€+vi+ ㌠+--editor+ オプションã«å¯¾ã™ã‚‹å¼•æ•°ã¨ãªã‚Šã¾ã™ã€‚ ==== オプション (ãŠã‚ˆã³ã‚ªãƒ—ションã«å¯¾ã™ã‚‹å¼•æ•°) 以外ã®å¼•æ•°ã¯ã€å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã¿ãªã•れã¾ã™ã€‚POSIX ã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯å…¨ã¦ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚ˆã‚Šå¾Œã«æ›¸ã‹ãªã‘れã°ãªã‚‰ãªã„ã¨å®šã‚ã¦ã„ã¾ã™ã€‚ãã®ãŸã‚ link:posix.html[POSIX 準拠モード]ã§ã¯ã€æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚る引数㯠(ãŸã¨ãˆãれãŒã‚ªãƒ—ションã§ã‚るよã†ã«è¦‹ãˆã¦ã‚‚) å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å¾Œã«ã‚ªãƒ—ションを書ã„ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€ãƒã‚¤ãƒ•ン二ã¤ã‹ã‚‰ãªã‚‹å¼•æ•° (+--+) ã¯ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã®åŒºåˆ‡ã‚Šã¨ã—ã¦ä½¿ãˆã¾ã™ã€‚ã“ã®åŒºåˆ‡ã‚Šä»¥é™ã®å…¨ã¦ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れるãŸã‚ã€ãƒã‚¤ãƒ•ンã§å§‹ã¾ã‚‹ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’æ­£ã—ãæŒ‡å®šã§ãã¾ã™ã€‚ .Set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ ==== - `set -a -b -- -c -d` ã“ã®ä¾‹ã§ã¯ã€+-a+ 㨠+-b+ ãŒã‚ªãƒ—ションã§ã€+-c+ 㨠+-d+ ãŒã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ãªã‚Šã¾ã™ã€‚区切り (+--+) 自体ã¯ã‚ªãƒ—ションã§ã‚‚オペランドã§ã‚‚ã‚りã¾ã›ã‚“。 ==== POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€ãƒã‚¤ãƒ•ン一ã¤ã‹ã‚‰ãªã‚‹å¼•æ•° (+-+) ã¯å¸¸ã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã¿ãªã•れã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_umask.txt0000644000175000017500000000775712154557026015745 0ustar magicantmagicant= Umask 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Umask 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Umask 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’表示・設定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +umask {{マスク}}+ - +umask [-S]+ [[description]] == 説明 オペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„ã¨ãã€umask コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ç¾åœ¨ã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚+-S+ (+--symbolic+) オプションã§å‡ºåŠ›ã®å½¢å¼ã‚’指定ã§ãã¾ã™ã€‚出力ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦å†åˆ©ç”¨å¯èƒ½ãªå½¢å¼ã«ãªã£ã¦ã„ã¾ã™ã€‚ オペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã€umask コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã®ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’与ãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®å€¤ã«è¨­å®šã—ã¾ã™ã€‚ [[options]] == オプション +-S+:: +--symbolic+:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã¯ã€è¨˜å·å½¢å¼ã§ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’出力ã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æ•°å€¤å½¢å¼ã§å‡ºåŠ›ã—ã¾ã™ã€‚ [[operands]] == オペランド {{マスク}}:: ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã‚‹ã¨ãã¯ã€umask コマンドã¯ãƒ•ァイルモード作æˆãƒžã‚¹ã‚¯ã‚’ã“ã®å€¤ã«è¨­å®šã—ã¾ã™ã€‚値ã¯ä»¥ä¸‹ã«è¿°ã¹ã‚‹æ•°å€¤å½¢å¼ã¨è¨˜å·å½¢å¼ã®ã©ã¡ã‚‰ã‹ã§ä¸Žãˆã¾ã™ã€‚ === æ•°å€¤å½¢å¼ æ•°å€¤å½¢å¼ã¯ 0 以上ã®å…«é€²æ•´æ•°ã§ãƒžã‚¹ã‚¯ã‚’指定ã—ã¾ã™ã€‚ã“れã¯ä»¥ä¸‹ã®å„モードを表ã™è‡ªç„¶æ•°ã®ã„ãã¤ã‹ã®å’Œã§ã™ã€‚ 0400:: ユーザã®èª­ã¿å–ã‚Šæ¨©é™ 0200:: ãƒ¦ãƒ¼ã‚¶ã®æ›¸ãè¾¼ã¿æ¨©é™ 0100:: ユーザã®å®Ÿè¡Œæ¨©é™ 0040:: グループã®èª­ã¿å–ã‚Šæ¨©é™ 0020:: ã‚°ãƒ«ãƒ¼ãƒ—ã®æ›¸ãè¾¼ã¿æ¨©é™ 0010:: グループã®å®Ÿè¡Œæ¨©é™ 0004:: ãã®ä»–ã®èª­ã¿å–ã‚Šæ¨©é™ 0002:: ãã®ä»–ã®æ›¸ãè¾¼ã¿æ¨©é™ 0001:: ãã®ä»–ã®å®Ÿè¡Œæ¨©é™ === 記å·å½¢å¼ 記å·å½¢å¼ã¯ä»¥ä¸‹ã®ã‚ˆã†ãªæ›¸å¼ã®è¨˜å·åˆ—ã§ãƒžã‚¹ã‚¯**ã—ãªã„**権é™ã‚’指定ã—ã¾ã™ã€‚ 記å·åˆ—ã¯ä¸€ã¤ä»¥ä¸Šã®{{節}}をカンマ (+,+) ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚ {{節}}ã¯{{対象}}ã®åˆ—ã¨ä¸€ã¤ä»¥ä¸Šã®{{動作}}ã‹ã‚‰ãªã‚Šã¾ã™ã€‚ {{対象}}ã«ã¯ä»¥ä¸‹ã®è¨˜å·ã‚’ã„ãã¤ã§ã‚‚指定ã§ãã¾ã™ã€‚ +u+:: ユーザ +g+:: グループ +o+:: ãã®ä»– +a+:: ユーザ・グループ・ãã®ä»–ã®å…¨ã¦ {{対象}}ãŒä¸€ã¤ã‚‚指定ã•れã¦ã„ãªã„å ´åˆã¯ +a+ ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ {{動作}}ã¯ä»¥ä¸‹ã®{{演算å­}}ã¨{{権é™}}ã®çµ„ã¿åˆã‚ã›ã§ã™ã€‚ {{演算å­}}ã¯ä»¥ä¸‹ã®ã©ã‚Œã‹ã§ã™ã€‚ +=+:: {{対象}}ã«å¯¾ã™ã‚‹è¨­å®šã‚’{{権é™}}ã«ã—ã¾ã™ã€‚ +++:: {{対象}}ã«å¯¾ã™ã‚‹è¨­å®šã«{{権é™}}を加ãˆã¾ã™ã€‚ +-+:: {{対象}}ã«å¯¾ã™ã‚‹è¨­å®šã‹ã‚‰{{権é™}}を除ãã¾ã™ã€‚ {{権é™}}ã¯ä»¥ä¸‹ã®ã©ã‚Œã‹ã§ã™ã€‚ +r+:: 読ã¿å–ã‚Šæ¨©é™ +w+:: 書ãè¾¼ã¿æ¨©é™ +x+:: å®Ÿè¡Œæ¨©é™ +X+:: å®Ÿè¡Œæ¨©é™ (元々実行権é™ãŒè¨­å®šã•れã¦ã„ãŸå ´åˆã®ã¿) +s+:: Set-user-ID, Set-group-ID +u+:: ç¾åœ¨ã®ãƒ¦ãƒ¼ã‚¶ã®å€¤ +g+:: ç¾åœ¨ã®ã‚°ãƒ«ãƒ¼ãƒ—ã®å€¤ +o+:: ç¾åœ¨ã®ãã®ä»–ã®å€¤ +r+, +w+, +x+, +X+, +s+ ã®è¨˜å·åŒå£«ã¯ä¸€åº¦ã«çµ„ã¿åˆã‚ã›ã¦æŒ‡å®šã§ãã¾ã™ã€‚ 例ãˆã° +umask u=rwx,go+r-w+ を実行ã™ã‚‹ã¨ã€ãƒ¦ãƒ¼ã‚¶ã®èª­ã¿å–り権é™ã¨æ›¸ãè¾¼ã¿æ¨©é™ã¨å®Ÿè¡Œæ¨©é™ã‚’マスクã—ãªã„よã†ã«ã—ã€ã‚°ãƒ«ãƒ¼ãƒ—ã¨ãã®ä»–ã®èª­ã¿å–り権é™ã‚’マスクã—ãªã„よã†ã«ã—ã€ã‚°ãƒ«ãƒ¼ãƒ—ã¨ãã®ä»–ã®æ›¸ãè¾¼ã¿æ¨©é™ã‚’マスクã™ã‚‹ã‚ˆã†ã«ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス ファイルモード作æˆãƒžã‚¹ã‚¯ãŒæ­£ã—ã出力ã¾ãŸã¯è¨­å®šã§ããŸã¨ãã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚ [[notes]] == 補足 Ulimit コマンドã¯link:builtin.html#types[準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX 㯠+-S+ オプションを指定ã—ãªã‹ã£ãŸå ´åˆã®å‡ºåЛ形å¼ãŒå¿…ãšã—も数値形å¼ã§ã‚ã‚‹ã¨ã¯è¦å®šã—ã¦ã„ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/invoke.html0000644000175000017500000002202512154557026016067 0ustar magicantmagicant シェルã®èµ·å‹•

Yash ãŒãƒ—ログラムã¨ã—ã¦èµ·å‹•ã•れるã¨ã€yash ã¯ã„ãã¤ã‹ã®åˆæœŸåŒ–処ç†ã‚’行ã£ãŸå¾Œã€ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦å®Ÿè¡Œã™ã‚‹å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ã“れらã®å‡¦ç†ã®å†…容ã¯ã€ä¸»ã«èµ·å‹•時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã«ã‚ˆã£ã¦æ±ºã¾ã‚Šã¾ã™ã€‚

起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°

Yash ã®èµ·å‹•時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数㯠POSIX ã«æº–æ‹ ã—ã¦ã„ã¾ã™ã€‚POSIX ã§å®šã‚られã¦ã„ã‚‹ã¨ãŠã‚Šã€å¼•数㯠オプション 㨠オペランド ã«åˆ†é¡žã•れã¾ã™ã€‚å¼•æ•°ã®æ›¸å¼ã«é–¢ã™ã‚‹ä¸€èˆ¬çš„ãªèª¬æ˜Žã«ã¤ã„ã¦ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å¼•æ•°ã®æ§‹æ–‡ã‚’å‚ç…§ã—ã¦ãã ã•ã„。オプションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå‰ã«æŒ‡å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚

オプション㫠-c (--cmdline) オプションãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’å°‘ãªãã¨ã‚‚一ã¤ä¸Žãˆã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚シェルã¯ã€ã“ã®æœ€åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚二ã¤ç›®ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ç‰¹æ®Šãƒ‘ラメータ 0 ãŒãれã«åˆæœŸåŒ–ã•れã¾ã™ã€‚三ã¤ç›®ä»¥é™ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€ä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚ -c (--cmdline) オプションを指定ã—ãŸå ´åˆã¯ã€ãƒ•ァイルや標準入力ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€ã“ã¨ã¯ã‚りã¾ã›ã‚“ (ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã—ãŸã¨ãを除ã)。

オプション㫠-s (--stdin) オプションãŒå«ã¾ã‚Œã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯æ¨™æº–入力ã‹ã‚‰ä¸€è¡Œãšã¤ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦ã€è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚オペランドã¯ã™ã¹ã¦ä½ç½®ãƒ‘ラメータã®åˆæœŸåŒ–ã«ä½¿ã‚れã¾ã™ã€‚特殊パラメータ 0 ã¯ã“ã®ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã«å…ƒã®ãƒ—ログラムã‹ã‚‰å—ã‘å–ã£ãŸæœ€åˆã®å¼•æ•°ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

-c (--cmdline) オプションも -s (--stdin) オプションも指定ã•れãªã‹ã£ãŸå ´åˆã¯ã€ã‚·ã‚§ãƒ«ã¯ãƒ•ァイルã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã£ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒèª­ã¿è¾¼ã‚€ãƒ•ァイルåã¨è¦‹ãªã•れã€ç‰¹æ®Šãƒ‘ラメータ 0 ã®å€¤ã¨ãªã‚Šã¾ã™ã€‚残りã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ä½ç½®ãƒ‘ラメータã«ãªã‚Šã¾ã™ã€‚オペランドãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¯ã€ -s (--stdin) オプションを指定ã—ãŸã¨ãã¨åŒæ§˜ã«æ¨™æº–入力ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã¿ã¾ã™ã€‚

-c (--cmdline) オプション㨠-s (--stdin) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

--help オプションã¾ãŸã¯ --version ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€é€šå¸¸ã®åˆæœŸåŒ–処ç†ã‚„コマンドã®è§£é‡ˆãƒ»å®Ÿè¡Œã¯ä¸€åˆ‡è¡Œã„ã¾ã›ã‚“。ãれãžã‚Œã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã®ç°¡å˜ãªèª¬æ˜Žã¨ãƒãƒ¼ã‚¸ãƒ§ãƒ³æƒ…報を標準出力ã«å‡ºåŠ›ã—ãŸå¾Œã€ãã®ã¾ã¾ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚ --version オプションを --verbose オプションã¨å…±ã«ä½¿ç”¨ã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã§åˆ©ç”¨å¯èƒ½ãªæ©Ÿèƒ½ã®ä¸€è¦§ã‚‚出力ã•れã¾ã™ã€‚

-i (--interactive) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚逆㫠+i (++interactive) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã›ã‚“。

-l (--login) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã¯ãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¾ã™ã€‚

--noprofile, --norcfile, --profile, --rcfile å„オプションã¯ã€ã‚·ã‚§ãƒ«ã®åˆæœŸåŒ–処ç†ã®å‹•作を指定ã—ã¾ã™ (後述)。

ãã®ä»–ã®ã‚ªãƒ—ションã¨ã—ã¦ã€set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§æŒ‡å®šå¯èƒ½ãªå„種オプションをシェルã®èµ·å‹•æ™‚ã«æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚(+ ã§å§‹ã¾ã‚‹ã‚ªãƒ—ションをå«ã‚€)

最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ - ã§ã‚りã€ã‹ã¤ã‚ªãƒ—ションã¨ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒ -- ã§åŒºåˆ‡ã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€ãã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ç‰¹åˆ¥ã«ç„¡è¦–ã•れã¾ã™ã€‚

シェルã®åˆæœŸåŒ–処ç†

シェルã®åˆæœŸåŒ–処ç†ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«è¡Œã‚れã¾ã™ã€‚

  1. Yash ã¯ã¾ãšã€(コマンドライン引数ã®å‰ã«æ¸¡ã•れる) ãれ自身ã®èµ·å‹•時ã®åå‰ã‚’è§£æžã—ã¾ã™ã€‚ãã®åå‰ãŒ - ã§å§‹ã¾ã‚‹å ´åˆã¯ã€ã‚·ã‚§ãƒ«ã¯ãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¾ã™ã€‚ã¾ãŸåå‰ãŒ sh ã§ã‚ã‚‹å ´åˆ (/bin/sh ã®ã‚ˆã†ã« sh ã§çµ‚ã‚ã‚‹å ´åˆã‚’å«ã‚€) ã¯ã€ã‚·ã‚§ãƒ«ã¯ POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚

  2. オペランドãŒä¸€ã¤ã‚‚ãªãã€ã‹ã¤æ¨™æº–å…¥åŠ›ã¨æ¨™æº–エラーãŒã©ã¡ã‚‰ã‚‚端末ãªã‚‰ã°ã€ã‚·ã‚§ãƒ«ã¯è‡ªå‹•çš„ã«å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚ãŸã ã— +i (++interactive) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ãã¡ã‚‰ã‚’優先ã—ã¾ã™ã€‚

  3. 対話モードã®ã‚·ã‚§ãƒ«ã§ã¯è‡ªå‹•çš„ã«ã‚¸ãƒ§ãƒ–åˆ¶å¾¡ãŒæœ‰åйã«ãªã‚Šã¾ã™ã€‚ãŸã ã— +m (++monitor) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã¯ãã¡ã‚‰ã‚’優先ã—ã¾ã™ã€‚

  4. シェルã¯ä»¥ä¸‹ã®åˆæœŸåŒ–スクリプトを読ã¿è¾¼ã‚“ã§è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã—シェルプロセスã®å®Ÿãƒ¦ãƒ¼ã‚¶ ID ã¨å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ãŒç•°ãªã£ã¦ã„ã‚‹ã‹ã€å®Ÿã‚°ãƒ«ãƒ¼ãƒ— ID ã¨å®ŸåŠ¹ã‚°ãƒ«ãƒ¼ãƒ— ID ãŒç•°ãªã£ã¦ã„ã‚‹å ´åˆã‚’除ã)

    1. シェルãŒãƒ­ã‚°ã‚¤ãƒ³ã‚·ã‚§ãƒ«ã¨ã—ã¦å‹•作ã—ã¦ã„ã‚‹å ´åˆã¯ã€ --profile=ファイルå ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸãƒ•ァイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã— --noprofile ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã‹ POSIX 準拠モードã®å ´åˆã‚’除ã)
      --profile=ファイルå ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€ ~/.yash_profile ãŒãƒ‡ãƒ•ォルトã®ãƒ•ァイルã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚

    2. シェルãŒå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®å ´åˆã¯ã€ --rcfile=ファイルå ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸãƒ•ァイルを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚(ãŸã ã— --norcfile ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã‚’除ã)
      --rcfile ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„å ´åˆã¯ã€éž POSIX 準拠モードã§ã¯ãƒ•ァイル ~/.yashrc ãŒãƒ‡ãƒ•ォルトã®ãƒ•ァイルã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚POSIX 準拠モードã§ã¯ã€ ENV 環境変数ã®å€¤ãŒãƒ‘ラメータ展開ã•れã€ãã®çµæžœã‚’ファイルåã¨è¦‹ãªã—ã¦ãƒ•ァイルを読ã¿è¾¼ã¿ã¾ã™ã€‚

注
Yash 㯠/etc/profile ã‚„ /etc/yashrc ã‚„ ~/.profile を自動的ã«èª­ã‚€ã“ã¨ã¯ã‚りã¾ã›ã‚“。
yash-2.35/doc/ja/_help.txt0000644000175000017500000000254212154557026015540 0ustar magicantmagicant= Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«é–¢ã™ã‚‹èª¬æ˜Žã‚’表示ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +help [{{コマンド}}...]+ [[description]] == 説明 Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«é–¢ã™ã‚‹èª¬æ˜Žã‚’出力ã—ã¾ã™ã€‚ ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€+man yash+ ã®å‡ºåŠ›ã®ä¸€éƒ¨ã‚’抜ã出ã—ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚従ã£ã¦ã€ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ãƒšãƒ¼ã‚¸ãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•れã¦ã„ãªã‘ã‚Œã°æ­£ã—ã動作ã—ã¾ã›ã‚“。ã¾ãŸã€man コマンドã®å‡ºåŠ›ã®å½¢å¼ã«ã‚ˆã£ã¦ã¯æ­£ã—ã説明を抜ã出ã›ãªã„ã“ã¨ãŒã‚りã¾ã™ã€‚ [[operands]] == オペランド {{コマンド}}:: 説明を表示ã™ã‚‹çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š help コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ The exit status of the help built-in is zero unless there is any error. [[notes]] == 補足 POSIX ã«ã¯ help コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 Yash ã®å¤šãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã€+--help+ オプションを与ãˆã‚‹ã“ã¨ã§ help コマンドã®å‡ºåŠ›ã¨åŒæ§˜ã®èª¬æ˜Žã‚’表示ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_eval.html0000644000175000017500000001055112154557026015663 0ustar magicantmagicant Eval 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Eval 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コマンドã¨ã—ã¦è§£é‡ˆã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚

æ§‹æ–‡

  • eval [-i] [コマンド…]

Eval コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。最åˆã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå¾Œã«ã‚るコマンドライン引数ã¯å…¨ã¦ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã¾ã™ã€‚

説明

Eval コマンドã¯ã€ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’シェルã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã—ã€ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã§å®Ÿè¡Œã—ã¾ã™ã€‚

-i (--iteration) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’ã¾ã¨ã‚ã¦ä¸€åº¦ã«è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚複数ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ãれらを順ã«é€£çµã—ã¦ä¸€ã¤ã«ã—ã¦ã‹ã‚‰è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ (連çµã®éš›ã€å„オペランド間ã«ç©ºç™½æ–‡å­—を一ã¤ãšã¤åŒºåˆ‡ã‚Šã¨ã—ã¦æŒ¿å…¥ã—ã¾ã™)。

-i (--iteration) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã¨ãã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’é †ã«ä¸€ã¤ãšã¤è§£é‡ˆãƒ»å®Ÿè¡Œã—ã¾ã™ã€‚ã“れをå復実行ã¨ã„ã„ã¾ã™ã€‚å復実行ã®é€”中㧠continue コマンドを -i オプション付ãã§å®Ÿè¡Œã—ãŸå ´åˆã€ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã¯ä¸­æ–­ã•れã€eval コマンドã«ä¸Žãˆã‚‰ã‚ŒãŸæ¬¡ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®è§£é‡ˆãƒ»å®Ÿè¡Œã«ç§»ã‚Šã¾ã™ã€‚å復実行ã®é€”中㧠break コマンドを -i オプション付ãã§å®Ÿè¡Œã—ãŸå ´åˆã€å復実行ã¯ä¸­æ–­ã•れã€ã“ã® eval コマンドã®å®Ÿè¡Œã¯çµ‚了ã—ã¾ã™ã€‚

オプション

-i
--iteration

与ãˆã‚‰ã‚ŒãŸã‚³ãƒžãƒ³ãƒ‰ã‚’é †ã«å復実行ã—ã¾ã™ã€‚

オペランド

コマンド

コマンドã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã™ã‚‹æ–‡å­—列ã§ã™ã€‚

終了ステータス

オペランドãŒä¸€ã¤ã‚‚ãªã„å ´åˆã¾ãŸã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®ä¸­ã«ã‚³ãƒžãƒ³ãƒ‰ãŒä¸€ã¤ã‚‚å«ã¾ã‚Œã¦ã„ãªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚コマンドãŒä¸€ã¤ä»¥ä¸Šè§£é‡ˆãƒ»å®Ÿè¡Œã•れãŸå ´åˆã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠eval コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

補足

Eval コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/params.html0000644000175000017500000006736412154557026016076 0ustar magicantmagicant パラメータã¨å¤‰æ•°

パラメータã¨ã¯ã€ãƒ‘ラメータ展開ã§å€¤ã«ç½®ãæ›ãˆã‚‰ã‚Œã‚‹ãƒ‡ãƒ¼ã‚¿ã‚’言ã„ã¾ã™ã€‚パラメータã«ã¯ä½ç½®ãƒ‘ラメータ・特殊パラメータ・変数ã®ä¸‰ç¨®é¡žãŒã‚りã¾ã™ã€‚

ä½ç½®ãƒ‘ラメータ

ä½ç½®ãƒ‘ラメータ㯠1 以上ã®è‡ªç„¶æ•°ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるパラメータã§ã™ã€‚例ãˆã°ä½ç½®ãƒ‘ラメータãŒä¸‰ã¤ã‚ã‚‹å ´åˆã€ãれらã¯é †ã« 1, 2, 3 ã¨ã„ã†åç§°ã§è­˜åˆ¥ã•れã¾ã™ã€‚ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã¯ç‰¹æ®Šãƒ‘ラメータ # ã§å–å¾—ã§ãã¾ã™ã€‚ã¾ãŸå…¨ã¦ã®ä½ç½®ãƒ‘ラメータを表ã™ç‰¹æ®Šãƒ‘ラメータã¨ã—㦠* 㨠@ ãŒã‚りã¾ã™ã€‚

ä½ç½®ãƒ‘ラメータã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã€ã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã‚’å…ƒã«åˆæœŸåŒ–ã•れã¾ã™ (起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°å‚ç…§)。引数ã®ã†ã¡ã€ä½ç½®ãƒ‘ラメータã®å€¤ã¨ã—ã¦ä¸Žãˆã‚‰ã‚ŒãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒé †ã«ä¸€ã¤ãšã¤ä½ç½®ãƒ‘ラメータã¨ãªã‚Šã¾ã™ã€‚

シェルã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œä¸­ã«é–¢æ•°ãŒå‘¼ã³å‡ºã•れるã¨ãã€ä½ç½®ãƒ‘ラメータã¯ãã®é–¢æ•°ã®å‘¼ã³å‡ºã—ã«å¯¾ã™ã‚‹å¼•æ•°ã«å¤‰æ›´ã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€é–¢æ•°ã®å®Ÿè¡Œä¸­ã¯ä½ç½®ãƒ‘ラメータã«ã‚ˆã£ã¦é–¢æ•°ã®å¼•æ•°ã‚’å‚ç…§ã§ãã¾ã™ã€‚関数呼ã³å‡ºã—ã®ç›´å‰ã®ä½ç½®ãƒ‘ラメータã®å€¤ã¯ä¿å­˜ã•れã¦ãŠã‚Šã€é–¢æ•°ã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹éš›ã«å…ƒã®å€¤ã«æˆ»ã‚Šã¾ã™ã€‚

ä½ç½®ãƒ‘ラメータã¯ã€set ã‚„ shift ãªã©ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«ã‚ˆã£ã¦å¤‰æ›´ã§ãã¾ã™ã€‚

0 ã¯ä½ç½®ãƒ‘ラメータã¨ã¯è¦‹ãªã•れã¾ã›ã‚“ (特殊パラメータã®ä¸€ã¤ã§ã™)。

特殊パラメータ

特殊パラメータã¯ä¸€æ–‡å­—ã®è¨˜å·ã«ã‚ˆã£ã¦è­˜åˆ¥ã•れるパラメータã§ã™ã€‚特殊パラメータã«ã¯ãƒ¦ãƒ¼ã‚¶ãŒæ˜Žç¤ºçš„ã«å€¤ã‚’代入ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

Yash ã§ã¯ä»¥ä¸‹ã®ç‰¹æ®Šãƒ‘ラメータãŒåˆ©ç”¨å¯èƒ½ã§ã™ã€‚

0

ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ä¸Žãˆã‚‰ã‚ŒãŸã‚·ã‚§ãƒ«ã®å®Ÿè¡Œãƒ•ァイルã®åç§°ã¾ãŸã¯ã‚¹ã‚¯ãƒªãƒ—トファイルã®åç§°ã§ã™ã€‚(起動時ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°å‚ç…§)

#

ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã®ä½ç½®ãƒ‘ラメータã®å€‹æ•°ã‚’表㙠0 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚

$

ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ã‚·ã‚§ãƒ«è‡ªèº«ã®ãƒ—ロセス ID ã‚’è¡¨ã™æ­£ã®æ•´æ•°ã§ã™ã€‚ã“ã®å€¤ã¯ã‚µãƒ–シェルã«ãŠã„ã¦ã‚‚変ã‚りã¾ã›ã‚“。

-

ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã‚·ã‚§ãƒ«ã§æœ‰åŠŸã«ãªã£ã¦ã„ã‚‹ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æ–‡å­—ã‚’ã¤ãªã’ãŸã‚‚ã®ã§ã™ã€‚ã“ã®å€¤ã«ã¯ã€ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§æŒ‡å®šã§ãる一文字ã®ã‚ªãƒ—ションã®ã†ã¡ç¾åœ¨æœ‰åйã«ãªã£ã¦ã„ã‚‹ã‚‚ã®ãŒå…¨ã¦å«ã¾ã‚Œã¾ã™ã€‚set 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ªãƒ—ションを変更ã—ãŸå ´åˆã¯ã€ãã®å¤‰æ›´ãŒã“ã®ãƒ‘ラメータã®å€¤ã«ã‚‚åæ˜ ã•れã¾ã™ã€‚

?

ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€æœ€å¾Œã«çµ‚了ã—ãŸãƒ‘イプラインã®çµ‚了ステータスを表㙠0 ä»¥ä¸Šã®æ•´æ•°ã§ã™ã€‚

!

ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸéžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID ã§ã™ã€‚

*

ã“ã®ãƒ‘ラメータã®å€¤ã¯ã€ç¾åœ¨ã®ä½ç½®ãƒ‘ラメータã®å€¤ã§ã™ã€‚ä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã“ã®ãƒ‘ラメータã®å€¤ã¯ç©ºæ–‡å­—列ã§ã™ã€‚ä½ç½®ãƒ‘ラメータãŒè¤‡æ•°ã‚ã‚‹å ´åˆã€ã“ã®ãƒ‘ラメータã®å€¤ã¯å…¨ã¦ã®ä½ç½®ãƒ‘ラメータã®å€¤ã‚’連çµã—ãŸã‚‚ã®ã§ã™ã€‚å„ä½ç½®ãƒ‘ラメータã®å€¤ã®é–“ã¯ä»¥ä¸‹ã«å¾“ã£ã¦åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚

  • 変数 IFS ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºã§ãªã„å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯å¤‰æ•° IFS ã®å€¤ã®æœ€åˆã®æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚

  • 変数 IFS ãŒå­˜åœ¨ã—ã€ãã®å€¤ãŒç©ºã®å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯é–“ã«ä½•ã‚‚ç½®ã‹ãšã«é€£çµã•れã¾ã™ã€‚

  • 変数 IFS ãŒå­˜åœ¨ã—ãªã„å ´åˆã€å„ä½ç½®ãƒ‘ラメータã¯ç©ºç™½æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚

@

ã“ã®ãƒ‘ラメータã¯ã€ãƒ‘ラメータ * ã¨åŒæ§˜ã«ç¾åœ¨ã®å…¨ã¦ã®ä½ç½®ãƒ‘ラメータを表ã—ã¾ã™ã€‚ãŸã ã—ã€ã“ã®ãƒ‘ラメータãŒäºŒé‡å¼•用符ã«ã‚ˆã‚‹ã‚¯ã‚©ãƒ¼ãƒˆã®ä¸­ã§å±•é–‹ã•れる場åˆã®æ‰±ã„ãŒãƒ‘ラメータ * ã¨ç•°ãªã‚Šã¾ã™ã€‚ã“ã®å ´åˆã€å„ä½ç½®ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã¯æ–‡å­—ã§åŒºåˆ‡ã‚‰ã‚Œã‚‹ã®ã§ã¯ãªãã€(クォートã®å†…部ã§ã‚ã‚‹ã«ã‚‚ã‹ã‹ã‚らãš) å˜èªžåˆ†å‰²ã•れã¾ã™ã€‚ã¾ãŸä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã“ã®ãƒ‘ラメータã¯å±•開後ã®å˜èªžã«ã¯æ®‹ã‚Šã¾ã›ã‚“。

例ãˆã°ä½ç½®ãƒ‘ラメータãŒä¸€ã¤ã‚‚ãªã„ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ echo 1 "$@" 2 㯠echoã€1ã€2 ã¨ã„ã†ä¸‰ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚ä½ç½®ãƒ‘ラメータ㌠1ã€2 2ã€3 ã®ä¸‰ã¤ã®ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ echo "$@" 㯠echoã€1ã€2 2ã€3 ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ echo "a$@b" 㯠echoã€a1ã€2 2ã€3b ã¨ã„ã†å››ã¤ã®å˜èªžã«å±•é–‹ã•れã¾ã™ã€‚

変数

変数ã¨ã¯ãƒ¦ãƒ¼ã‚¶ãŒè‡ªç”±ã«ä»£å…¥å¯èƒ½ãªãƒ‘ラメータã§ã™ã€‚å„変数ã¯åå‰ã§åŒºåˆ¥ã•れã€ãれãžã‚ŒãŒæ–‡å­—列ã®å€¤ã‚’æŒã¡ã¾ã™ã€‚

変数ã®åå‰ã¯ã€è‹±æ•°å­—ã¨ä¸‹ç·š (_) ã‹ã‚‰æ§‹æˆã•れã¾ã™ã€‚ãŸã ã—変数åã®é ­æ–‡å­—ã‚’æ•°å­—ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。環境ã«ã‚ˆã£ã¦ã¯ã“ã‚Œä»¥å¤–ã®æ–‡å­—も変数åã«ä½¿ç”¨ã§ãã¾ã™ã€‚

ã‚·ã‚§ãƒ«ãŒæ‰±ã†å¤‰æ•°ã®ã†ã¡ã€ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã®å¯¾è±¡ã¨ãªã£ã¦ã„ã‚‹ã‚‚ã®ã¯ç’°å¢ƒå¤‰æ•°ã¨ã„ã„ã¾ã™ã€‚ã“れらã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ãŒå¤–部コマンドを起動ã™ã‚‹éš›ã«å¤–éƒ¨ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚シェルãŒèµ·å‹•ã•れãŸã¨ãã«ã‚·ã‚§ãƒ«ã‚’èµ·å‹•ã—ãŸãƒ—ログラムã‹ã‚‰æ¸¡ã•れãŸå¤‰æ•°ã¯è‡ªå‹•çš„ã«ç’°å¢ƒå¤‰æ•°ã«ãªã‚Šã¾ã™ã€‚

変数ã¯ã€å˜ç´”コマンドã«ã‚ˆã£ã¦ä»£å…¥ã§ãã¾ã™ã€‚ã¾ãŸ typeset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ã‚‚変数ã«ä»£å…¥ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚変数を削除ã™ã‚‹ã«ã¯ unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã„ã¾ã™ã€‚

シェルãŒä½¿ç”¨ã™ã‚‹å¤‰æ•°

以下ã®åå‰ã®å¤‰æ•°ã¯ã€yash ã®å®Ÿè¡Œã«ãŠã„ã¦ç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚

CDPATH

ã“ã®å¤‰æ•°ã¯ cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ç§»å‹•先ディレクトリを検索ã™ã‚‹ãŸã‚ã«ä½¿ã‚れã¾ã™ã€‚

COLUMNS

ã“ã®å¤‰æ•°ã¯ç«¯æœ«ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®æ¨ªå¹… (文字数) を指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã€ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã®æ¨ªå¹…ã§ã¯ãªãã“ã®å¤‰æ•°ã®å€¤ã§æŒ‡å®šã•ã‚ŒãŸæ¨ªå¹…ãŒè¡Œç·¨é›†ã§ä½¿ã‚れã¾ã™ã€‚

COMMAND_NOT_FOUND_HANDLER

シェルãŒå®Ÿè¡Œã—よã†ã¨ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œã•れã¾ã™ã€‚䏿˜Žãªã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ãã«ä½•ã‹åˆ¥ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã•ã›ãŸã„時ã«ä¾¿åˆ©ã§ã™ã€‚å˜ç´”コマンドã®å®Ÿè¡Œã‚’å‚照。

ã“ã®æ©Ÿèƒ½ã¯ POSIX 準拠モードã§ã¯åƒãã¾ã›ã‚“。

DIRSTACK

ã“ã®é…列変数ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å®Ÿè£…ã«ä½¿ã‚れã¦ã„ã¾ã™ã€‚pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’移動ã—ãŸã¨ãã€å‰ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’覚ãˆã¦ãŠããŸã‚ã«ãã®ãƒ‘スåãŒã“ã®é…列ã«å…¥ã‚Œã‚‰ã‚Œã¾ã™ã€‚ã“ã®é…列ã®å†…容を変更ã™ã‚‹ã“ã¨ã¯ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®å†…容を直接変更ã™ã‚‹ã“ã¨ã«ãªã‚Šã¾ã™ã€‚

ECHO_STYLE

ã“ã®å¤‰æ•°ã¯ echo 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®æŒ™å‹•を指定ã—ã¾ã™ã€‚

ENV

POSIX 準拠モードã§å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã•れãŸã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ã§ç¤ºã•れるパスã®ãƒ•ァイルãŒåˆæœŸåŒ–スクリプトã¨ã—ã¦èª­ã¿è¾¼ã¾ã‚Œã¾ã™ (シェルã®åˆæœŸåŒ–処ç†å‚ç…§)。

FCEDIT

Fc 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’編集ã™ã‚‹éš›ã€ã“ã®å¤‰æ•°ã®å€¤ã§ç¤ºã•れãŸã‚¨ãƒ‡ã‚£ã‚¿ãŒã‚³ãƒžãƒ³ãƒ‰ã®ç·¨é›†ã«ä½¿ã‚れã¾ã™ã€‚

HANDLED

ã“ã®å¤‰æ•°ã¯ COMMAND_NOT_FOUND_HANDLER 変数ã®å€¤ãŒå®Ÿè¡Œã•れãŸå¾Œã«ã€ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã“ã¨ã‚’エラーã¨ã™ã‚‹ã‹ã©ã†ã‹ã‚’指示ã—ã¾ã™ã€‚å˜ç´”コマンドã®å®Ÿè¡Œã‚’å‚照。

HISTFILE

コマンド履歴をä¿å­˜ã™ã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚

HISTRMDUP

コマンド履歴ã®é‡è¤‡ã‚’ãƒã‚§ãƒƒã‚¯ã™ã‚‹å€‹æ•°ã‚’指定ã—ã¾ã™ã€‚履歴ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’追加ã™ã‚‹éš›ã€æ—¢ã«å±¥æ­´ã«ã‚るコマンドã®ã†ã¡ã“ã“ã§æŒ‡å®šã—ãŸå€‹æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ãŒæ–°ã—ã追加ã•れるコマンドã¨åŒã˜ã‹ã©ã†ã‹ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚åŒã˜ã‚³ãƒžãƒ³ãƒ‰ãŒæ—¢ã«å±¥æ­´ã«ã‚れã°ã€ãれã¯å±¥æ­´ã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚

例ãˆã°ã“ã®å¤‰æ•°ã®å€¤ãŒ 1 ã®ã¨ãã¯ã€å±¥æ­´ã«è¿½åŠ ã•れるコマンドãŒä¸€ã¤å‰ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒã˜ãªã‚‰ã°ãれã¯å‰Šé™¤ã•れã¾ã™ã€‚ãれよりå¤ã„履歴ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€(履歴ã«è¿½åŠ ã•れるコマンドã¨åŒã˜ã§ã‚‚) 削除ã•れã¾ã›ã‚“。もã—ã“ã®å¤‰æ•°ã®å€¤ãŒ HISTSIZE 変数ã®å€¤ã¨åŒã˜ãªã‚‰ã€å±¥æ­´ã®ä¸­ã§é‡è¤‡ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¯ã™ã¹ã¦å‰Šé™¤ã•れã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã‚‚ã—ã“ã®å¤‰æ•°ã®å€¤ãŒ 0 ãªã‚‰ã€é‡è¤‡ã™ã‚‹å±¥æ­´ã¯ä¸€åˆ‡å‰Šé™¤ã•れã¾ã›ã‚“。

HISTSIZE

コマンド履歴ã«ä¿å­˜ã•れる履歴項目ã®å€‹æ•°ã‚’指定ã—ã¾ã™ã€‚

HOME

ユーザã®ãƒ›ãƒ¼ãƒ ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ãƒ‘スを指定ã—ã¾ã™ã€‚ãƒãƒ«ãƒ€å±•é–‹ã‚„ cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®å‹•作ã«å½±éŸ¿ã—ã¾ã™ã€‚

IFS

ã“ã®å¤‰æ•°ã¯å˜èªžåˆ†å‰²ã®åŒºåˆ‡ã‚Šã‚’指定ã—ã¾ã™ã€‚シェルã®èµ·å‹•時ã«ã“ã®å¤‰æ•°ã®å€¤ã¯ç©ºç™½æ–‡å­—・タブ・改行ã®ä¸‰æ–‡å­—ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

LANG
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MESSAGES
LC_MONETARY
LC_NUMERIC
LC_TIME

ã“れらã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ãŒå‹•作ã™ã‚‹ãƒ­ã‚±ãƒ¼ãƒ«ã‚’指定ã—ã¾ã™ã€‚シェルãŒèª­ã¿æ›¸ãã™ã‚‹ãƒ•ァイルã®ã‚¨ãƒ³ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°ã‚„エラーメッセージã®å†…容ãªã©ã¯ã“ã®å¤‰æ•°ã§æŒ‡å®šã•れãŸãƒ­ã‚±ãƒ¼ãƒ«ã«å¾“ã„ã¾ã™ã€‚

LC_CTYPE 変数ã®å€¤ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã®ã¿å映ã•れã¾ã™ã€‚シェルã®å®Ÿè¡Œä¸­ã«ã“ã®å¤‰æ•°ã‚’変更ã—ã¦ã‚‚シェルã®ãƒ­ã‚±ãƒ¼ãƒ«ã¯å¤‰ã‚りã¾ã›ã‚“ (シェルãŒéž POSIX 準拠モードã§å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®å ´åˆã‚’除ã)。

LINENO

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€ç¾åœ¨ã‚·ã‚§ãƒ«ãŒèª­ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¦ã„るファイルã«ãŠã‘ã‚‹ã€ç¾åœ¨å®Ÿè¡Œä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã®ã‚る行番å·ã‚’示ã—ã¾ã™ã€‚(対話モードã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã—ã¦å®Ÿè¡Œã™ã‚‹ãŸã³ã«è¡Œç•ªå·ã¯ 1 ã«æˆ»ã‚Šã¾ã™)

一度ã“ã®å¤‰æ•°ã«ä»£å…¥ã—ãŸã‚Šå¤‰æ•°ã‚’削除ã—ãŸã‚Šã™ã‚‹ã¨ã€ã“ã®å¤‰æ•°ã‚’用ã„ã¦è¡Œç•ªå·ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚

LINES

ã“ã®å¤‰æ•°ã¯ç«¯æœ«ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®è¡Œæ•°ã‚’指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã€ãƒ‡ãƒ•ォルトã®è¡Œæ•°ã§ã¯ãªãã“ã®å¤‰æ•°ã®å€¤ã§æŒ‡å®šã•れãŸè¡Œæ•°ãŒè¡Œç·¨é›†ã§ä½¿ã‚れã¾ã™ã€‚

MAIL

ã“ã®å¤‰æ•°ã¯ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã®å¯¾è±¡ã¨ãªã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚

MAILCHECK

ã“ã®å¤‰æ•°ã¯ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã‚’行ã†é–“隔を秒å˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠600 ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

MAILPATH

ã“ã®å¤‰æ•°ã¯ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã®å¯¾è±¡ã¨ãªã‚‹ãƒ•ァイルã®ãƒ‘スを指定ã—ã¾ã™ã€‚

NLSPATH

POSIX ã«ã‚ˆã‚‹ã¨ã“ã®å¤‰æ•°ã®å€¤ã¯ãƒ­ã‚±ãƒ¼ãƒ«ä¾å­˜ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒ‡ãƒ¼ã‚¿ãƒ•ァイルã®ãƒ‘スを指示ã™ã‚‹ã“ã¨ã«ãªã£ã¦ã„ã¾ã™ãŒã€yash ã§ã¯ä½¿ç”¨ã—ã¦ã„ã¾ã›ã‚“。

OLDPWD

Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ãŸã¨ãã«ã€å¤‰æ›´å‰ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãƒ‘スãŒã“ã®å¤‰æ•°ã«è¨­å®šã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ãƒ‡ãƒ•ォルトã§ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚

OPTARG

Getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¼•数付ãã®ã‚ªãƒ—ションを読ã¿è¾¼ã‚“ã ã¨ãã€ãã®å¼•æ•°ã®å€¤ãŒã“ã®å¤‰æ•°ã«è¨­å®šã•れã¾ã™ã€‚

OPTIND

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€getopts 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§æ¬¡ã«èª­ã¿è¾¼ã‚€ã‚ªãƒ—ションã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’表ã—ã¾ã™ã€‚シェルã®èµ·å‹•時ã«ã“ã®å¤‰æ•°ã¯ 1 ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

PATH

ã“ã®å¤‰æ•°ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢æ™‚ã«ã‚³ãƒžãƒ³ãƒ‰ã®ã‚りã‹ã‚’示ã™ãƒ‘スを指定ã—ã¾ã™ã€‚

PPID

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€ã‚·ã‚§ãƒ«ã®è¦ªãƒ—ロセスã®ãƒ—ロセス ID ã‚’è¡¨ã™æ­£ã®æ•´æ•°ã§ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ã‚µãƒ–シェルã«ãŠã„ã¦ã‚‚変ã‚りã¾ã›ã‚“。

PROMPT_COMMAND

POSIX 準拠モードã§ãªã„対話モードã®ã‚·ã‚§ãƒ«ã«ãŠã„ã¦ã€ã‚·ã‚§ãƒ«ãŒå„コマンドã®ãƒ—ロンプトを出ã™ç›´å‰ã«ã€ã“ã®å¤‰æ•°ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ã€‚ã“れã¯ã€ãƒ—ロンプトを出ã™ç›´å‰ã«æ¯Žå›ž eval -i -- "${PROMPT_COMMAND-}" ã¨ã„ã†ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã®ã¨åŒã˜ã§ã™ãŒã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œçµæžœã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã® ? 特殊パラメータã®å€¤ã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。

PS1

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‡ºåŠ›ã™ã‚‹æ¨™æº–ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ—ロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。

ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠\$ ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚(POSIX 準拠モード ãªã‚‰å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ㌠0 ã‹ã©ã†ã‹ã«ã‚ˆã£ã¦ $ 㨠# ã®ã©ã¡ã‚‰ã‹)

PS1R

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€éš›ã«ã€å…¥åŠ›ã•れるコマンドã®å³å´ã«è¡¨ç¤ºã•れるプロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。

PS1S

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚€éš›ã«ã€å…¥åŠ›ã•れるコマンドを表示ã™ã‚‹ãƒ•ã‚©ãƒ³ãƒˆã®æ›¸å¼ã‚’指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。

PS2

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‡ºåŠ›ã™ã‚‹è£œåŠ©çš„ãªã‚³ãƒžãƒ³ãƒ‰ãƒ—ロンプトを指定ã—ã¾ã™ã€‚ã“ã®å€¤ã®æ›¸å¼ã«ã¤ã„ã¦ã¯ãƒ—ロンプトã®é …ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠> ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

PS2R

ã“ã®å¤‰æ•°ã¯ PS1R 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠PS1 変数ã§ã¯ãªã PS2 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚

PS2S

ã“ã®å¤‰æ•°ã¯ PS1S 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠PS1 変数ã§ã¯ãªã PS2 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚

PS4

Xtrace ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã¨ãã€ã“ã®å¤‰æ•°ã®å€¤ãŒå„トレース出力ã®å‰ã«å‡ºåŠ›ã•れã¾ã™ã€‚ãŸã ã—出力ã®å‰ã«ã“ã®å¤‰æ•°ã®å€¤ã«å¯¾ã—ã¦ãƒ‘ラメータ展開ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã€æ•°å¼å±•開を行ã„ã¾ã™ã€‚ã¾ãŸ POSIX 準拠モードã§ãªã‘れã°ã€PS1 変数ã¨åŒæ§˜ã«ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ç‰¹æ®Šãªè¨˜æ³•ãŒåˆ©ç”¨ã§ãã¾ã™ã€‚

ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時㫠+ ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

PS4S

ã“ã®å¤‰æ•°ã¯ PS1S 変数ã¨åŒæ§˜ã§ã™ãŒã€ãƒ—ロンプトã¨ã—㦠PS1 変数ãŒä½¿ç”¨ã•れるã¨ãã§ã¯ãªãã€ãƒˆãƒ¬ãƒ¼ã‚¹å‡ºåŠ›ã®éš›ã« PS4 変数ã®å€¤ãŒä½¿ç”¨ã•れるã¨ãã«ä½¿ç”¨ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã‚’使ã†ã¨ãƒˆãƒ¬ãƒ¼ã‚¹å‡ºåŠ›ã®ãƒ•ã‚©ãƒ³ãƒˆã®æ›¸å¼ã‚’変更ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

PWD

ã“ã®å¤‰æ•°ã®å€¤ã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®çµ¶å¯¾ãƒ‘スを表ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æ­£ã—ã„パスã«åˆæœŸåŒ–ã•れã€cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã™ã‚‹åº¦ã«å†è¨­å®šã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ãƒ‡ãƒ•ォルトã§ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆå¯¾è±¡ã«ãªã‚Šã¾ã™ã€‚

RANDOM

ã“ã®å¤‰æ•°ã¯ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ã¯ 0 以上 32768 未満ã®ä¸€æ§˜åˆ†å¸ƒä¹±æ•°ã«ãªã£ã¦ã„ã¾ã™ã€‚

ã“ã®å¤‰æ•°ã«éžè² æ•´æ•°ã‚’代入ã™ã‚‹ã¨ä¹±æ•°ã‚’生æˆã™ã‚‹ç¨®ã‚’å†è¨­å®šã§ãã¾ã™ã€‚

一度ã“ã®å¤‰æ•°ã‚’削除ã™ã‚‹ã¨ã€ã“ã®å¤‰æ•°ã‚’用ã„ã¦ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ããªããªã‚Šã¾ã™ã€‚ã¾ãŸã‚·ã‚§ãƒ«ãŒ POSIX 準拠モードã§èµ·å‹•ã•れãŸå ´åˆã€ã“ã®å¤‰æ•°ã§ä¹±æ•°ã‚’å–å¾—ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。

TERM

ã“ã®å¤‰æ•°ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒå‹•作ã—ã¦ã„る端末ã®ç¨®é¡žã‚’指定ã—ã¾ã™ã€‚ã“ã“ã§æŒ‡å®šã•れãŸç«¯æœ«ã®ç¨®é¡žã«å¾“ã£ã¦è¡Œç·¨é›†æ©Ÿèƒ½ã¯ç«¯æœ«ã‚’制御ã—ã¾ã™ã€‚

YASH_AFTER_CD

ã“ã®å¤‰æ•°ã®å€¤ã¯ã€cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚„ pushd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒå¤‰æ›´ã•れãŸå¾Œã«ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ã€‚ã“れã¯ã€ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒå¤‰ã‚ã£ãŸå¾Œã«æ¯Žå›ž eval -i -- "${YASH_AFTER_CD-}" ã¨ã„ã†ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•れるã®ã¨åŒã˜ã§ã™ã€‚

YASH_LOADPATH

ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§èª­ã¿è¾¼ã‚€ã‚¹ã‚¯ãƒªãƒ—トファイルã®ã‚るディレクトリを指定ã—ã¾ã™ã€‚PATH 変数ã¨åŒæ§˜ã«ã€ã‚³ãƒ­ãƒ³ã§åŒºåˆ‡ã£ã¦è¤‡æ•°ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’指定ã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã€yash ã«ä»˜å±žã—ã¦ã„る共通スクリプトã®ã‚るディレクトリåã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

YASH_LE_TIMEOUT

ã“ã®å¤‰æ•°ã¯è¡Œç·¨é›†æ©Ÿèƒ½ã§æ›–æ˜§ãªæ–‡å­—シーケンスãŒå…¥åŠ›ã•れãŸã¨ãã«ã€å…¥åŠ›æ–‡å­—ã‚’ç¢ºå®šã•ã›ã‚‹ãŸã‚ã«ã‚·ã‚§ãƒ«ãŒå¾…ã¤æ™‚間をミリ秒å˜ä½ã§æŒ‡å®šã—ã¾ã™ã€‚行編集を行ã†éš›ã«ã“ã®å¤‰æ•°ãŒå­˜åœ¨ã—ãªã‘れã°ã€ãƒ‡ãƒ•ォルトã¨ã—㦠100 ãƒŸãƒªç§’ãŒæŒ‡å®šã•れã¾ã™ã€‚

YASH_VERSION

ã“ã®å¤‰æ•°ã¯ã‚·ã‚§ãƒ«ã®èµ·å‹•時ã«ã‚·ã‚§ãƒ«ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ã«åˆæœŸåŒ–ã•れã¾ã™ã€‚

é…列

é…列ã¨ã¯ã€ä¸€ã¤ã®å¤‰æ•°ã«è¤‡æ•°ã®å€¤ (文字列) ã‚’æŒãŸã›ãŸã‚‚ã®ã§ã™ã€‚一ã¤ã®é…列ã®è¤‡æ•°ã®å€¤ã¯ä½ç½®ãƒ‘ラメータã¨åŒæ§˜ã« 1 以上ã®è‡ªç„¶æ•°ã§è­˜åˆ¥ã•れã¾ã™ã€‚

é…列ã¯ã€å˜ç´”コマンドã«ã‚ˆã£ã¦ä»£å…¥ã§ãã¾ã™ã€‚ã¾ãŸ array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãªã©ã§ã‚‚é…列ã«ä»£å…¥ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚é…列を削除ã™ã‚‹ã«ã¯å¤‰æ•°ã¨åŒæ§˜ã« unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’使ã„ã¾ã™ã€‚

é…列をé…列ã®ã¾ã¾ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。é…列をエクスãƒãƒ¼ãƒˆã—よã†ã¨ã™ã‚‹ã¨ã€é…列ã®å„値をコロンã§åŒºåˆ‡ã£ã¦ç¹‹ã„ã ä¸€ã¤ã®æ–‡å­—列ã®å€¤ã‚’æŒã¤å¤‰æ•°ã¨ã—ã¦ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã•れã¾ã™ã€‚

POSIX 準拠モードã§ã¯é…列ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/syntax.txt0000644000175000017500000005541012154557026016001 0ustar magicantmagicant= ã‚³ãƒžãƒ³ãƒ‰ã®æ–‡æ³• :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - ã‚³ãƒžãƒ³ãƒ‰ã®æ–‡æ³• :description: Yash ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ–‡æ³•ã¨ãã®æ„味論ã®èª¬æ˜Ž シェルã¯ã‚³ãƒžãƒ³ãƒ‰ã‚’一行ãšã¤èª­ã¿è¾¼ã‚“ã§è§£é‡ˆã—ã€å®Ÿè¡Œã—ã¾ã™ã€‚一行ã«è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ãŒã‚ã‚‹å ´åˆã¯ã€ãれら全ã¦ã‚’解釈ã—ã¦ã‹ã‚‰å®Ÿè¡Œã—ã¾ã™ã€‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãŒè¤‡æ•°è¡Œã«ã¾ãŸãŒã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®ã‚³ãƒžãƒ³ãƒ‰ã‚’解釈ã—終ãˆã‚‹ã®ã«å¿…è¦ãªã ã‘後続ã®è¡ŒãŒèª­ã¿è¾¼ã¾ã‚Œã¾ã™ã€‚コマンドを正ã—ã解釈ã§ããªã„å ´åˆã¯ã€æ–‡æ³•エラーã¨ãªã‚Šã€ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œã•れã¾ã›ã‚“。 éžlink:interact.html[対話モード]ã§æ–‡æ³•エラーãŒç™ºç”Ÿã—ãŸæ™‚ã¯ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®èª­ã¿è¾¼ã¿ã‚’中止ã™ã‚‹ãŸã‚ã€ãれ以é™ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ä¸€åˆ‡èª­ã¿è¾¼ã¾ã‚Œã¾ã›ã‚“。 [[tokens]] == トークンã®è§£æžã¨äºˆç´„語 コマンドã¯ã€ã„ãã¤ã‹ã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã‚ˆã£ã¦æ§‹æˆã•れã¾ã™ã€‚dfn:[トークン]ã¨ã¯ã€ã‚·ã‚§ãƒ«ã®æ–‡æ³•ã«ãŠã‘る一ã¤ä¸€ã¤ã®å˜èªžã®ã“ã¨ã‚’言ã„ã¾ã™ã€‚トークンã¯åŽŸå‰‡ã¨ã—ã¦ç©ºç™½ (空白文字ã¾ãŸã¯ã‚¿ãƒ–文字) ã«ã‚ˆã£ã¦åŒºåˆ‡ã‚‰ã‚Œã¾ã™ã€‚ãŸã ã—コマンド置æ›ãªã©ã«å«ã¾ã‚Œã‚‹ç©ºç™½ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ã¯è¦‹ãªã—ã¾ã›ã‚“。 以下ã®è¨˜å·ã¯ã€ã‚·ã‚§ãƒ«ã®æ–‡æ³•ã«ãŠã„ã¦ç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚ã“れらã®è¨˜å·ã‚‚多ãã®å ´åˆä»–ã®é€šå¸¸ã®ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã¨ãªã‚Šã¾ã™ã€‚ ; & | < > ( ) [newline] 以下ã®è¨˜å·ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®åŒºåˆ‡ã‚Šã«ã¯ãªã‚Šã¾ã›ã‚“ãŒã€æ–‡æ³•ä¸Šç‰¹åˆ¥ãªæ„味をæŒã£ã¦ã„ã¾ã™ã€‚ $ ` \ " ' * ? [ # ~ = % 以下ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ç‰¹å®šã®å ´é¢ã«ãŠã„ã¦dfn:[予約語]ã¨è¦‹ãªã•れã¾ã™ã€‚予約語ã¯è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ãªã©ã‚’æ§‹æˆã™ã‚‹ä¸€éƒ¨ã¨ãªã‚Šã¾ã™ã€‚ ! { } case do done elif else esac fi for function if in then until while ã“れらã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ä»¥ä¸‹ã®å ´é¢ã«ãŠã„ã¦äºˆç´„語ã¨ãªã‚Šã¾ã™ã€‚ * ãれãŒã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã®ã¨ã * ãれãŒä»–ã®äºˆç´„語 (+case+, +for+, +in+ を除ã) ã®ç›´å¾Œã®ãƒˆãƒ¼ã‚¯ãƒ³ã®ã¨ã * ãれãŒã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã§ã¯ãªã„ãŒã€è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã®ä¸­ã§äºˆç´„語ã¨ã—ã¦æ‰±ã‚れるã¹ãトークンã§ã‚ã‚‹ã¨ã トークン㌠`#` ã§å§‹ã¾ã‚‹å ´åˆã€ãã® `#` ã‹ã‚‰è¡Œæœ«ã¾ã§ã¯dfn:[コメント]ã¨è¦‹ãªã•れã¾ã™ã€‚コマンドã®è§£é‡ˆã«ãŠã„ã¦ã‚³ãƒ¡ãƒ³ãƒˆã¯å®Œå…¨ã«ç„¡è¦–ã•れã¾ã™ã€‚ [[quotes]] == クォート 空白や上記ã®åŒºåˆ‡ã‚Šè¨˜å·ãƒ»äºˆç´„語ãªã©ã‚’é€šå¸¸ã®æ–‡å­—ã¨åŒã˜ã‚ˆã†ã«æ‰±ã†ã«ã¯ã€é©åˆ‡ãªå¼•用符ã§ã‚¯ã‚©ãƒ¼ãƒˆã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚引用符ã¯ã€ãれ自体をクォートã—ãªã„é™ã‚Šé€šå¸¸ã®æ–‡å­—ã¨ã—ã¦ã¯æ‰±ã‚れã¾ã›ã‚“。シェルã§ã¯ä»¥ä¸‹ã®ä¸‰ç¨®é¡žã®å¼•用符ãŒä½¿ãˆã¾ã™ã€‚ * ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (+\+) ã¯ç›´å¾Œã®ä¸€æ–‡å­—をクォートã—ã¾ã™ã€‚ + 例外ã¨ã—ã¦ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã®ç›´å¾Œã«æ”¹è¡ŒãŒã‚ã‚‹å ´åˆã€ãã‚Œã¯æ”¹è¡Œã‚’クォートã—ã¦ã„ã‚‹ã®ã§ã¯ãªãã€dfn:[行ã®é€£çµ]ã¨è¦‹ãªã•れã¾ã™ã€‚ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¨æ”¹è¡ŒãŒå‰Šé™¤ã•れã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒã‚ã£ãŸè¡Œã¨ãã®æ¬¡ã®è¡ŒãŒå…ƒã€…一ã¤ã®è¡Œã§ã‚ã£ãŸã‹ã®ã‚ˆã†ã«æ‰±ã‚れã¾ã™ã€‚ * 二ã¤ã®ä¸€é‡å¼•用符 (+'+) ã§å›²ã‚“ã éƒ¨åˆ†ã§ã¯ã€å…¨ã¦ã®æ–‡å­—ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒã˜ã‚ˆã†ã«æ‰±ã‚れã¾ã™ã€‚改行を一é‡å¼•用符ã§å›²ã‚€ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ãŸã ã—ã€ä¸€é‡å¼•用符を一é‡å¼•用符ã§å›²ã‚€ã“ã¨ã¯ã§ãã¾ã›ã‚“。 * 二ã¤ã®äºŒé‡å¼•用符 (+"+) ã§å›²ã‚“ã éƒ¨åˆ†ã‚‚一é‡å¼•用符ã§å›²ã‚“ã éƒ¨åˆ†ã¨åŒæ§˜ã«ã‚¯ã‚©ãƒ¼ãƒˆã•れã¾ã™ãŒã€ã„ãã¤ã‹ä¾‹å¤–ãŒã‚りã¾ã™ã€‚二é‡å¼•用符ã§å›²ã‚“ã éƒ¨åˆ†ã§ã¯ã€ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ãŒé€šå¸¸é€šã‚Šè§£é‡ˆã•れã¾ã™ã€‚ã¾ãŸãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯ +$+, +`+, +"+, +\+ ã®ç›´å‰ã«ã‚ã‚‹å ´åˆãŠã‚ˆã³è¡Œã®é€£çµã‚’行ã†å ´åˆã«ã®ã¿å¼•用符ã¨ã—ã¦æ‰±ã‚れã€ãれ以外ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯é€šå¸¸ã®æ–‡å­—ã¨åŒæ§˜ã«æ‰±ã‚れã¾ã™ã€‚ [[aliases]] == エイリアス コマンドを構æˆã™ã‚‹å„トークンã¯ã€ãれãŒäºˆã‚登録ã•れãŸã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®åå‰ã«ä¸€è‡´ã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã‚‰ã‚Œã¾ã™ã€‚一致ã™ã‚‹ã‚‚ã®ãŒã‚れã°ã€ãã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ãã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®å†…容ã«ç½®ãæ›ãˆã‚‰ã‚Œã¦ã€ãã®å¾Œã‚³ãƒžãƒ³ãƒ‰ã®è§£æžãŒç¶šã‘られã¾ã™ã€‚ã“れをdfn:[エイリアス置æ›]ã¨ã„ã„ã¾ã™ã€‚ エイリアスã®åå‰ã«å¼•用符をå«ã‚ã‚‹ã“ã¨ã¯ã§ããªã„ã®ã§ã€å¼•用符をå«ã‚€ãƒˆãƒ¼ã‚¯ãƒ³ã¯ã‚¨ã‚¤ãƒªã‚¢ã‚¹ç½®æ›ã•れã¾ã›ã‚“。ã¾ãŸã€äºˆç´„語やコマンドを区切る記å·ã‚‚エイリアス置æ›ã•れã¾ã›ã‚“。 エイリアスã«ã¯é€šå¸¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¨ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®äºŒç¨®é¡žãŒã‚りã¾ã™ã€‚dfn:[通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹]ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã®æœ€åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã®ã¿ä¸€è‡´ã—ã¾ã™ã€‚dfn:[グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹]ã¯ã‚³ãƒžãƒ³ãƒ‰å†…ã®å…¨ã¦ã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒä¸€è‡´ã®å¯¾è±¡ã§ã™ã€‚グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ POSIX è¦æ ¼ã«ã¯ãªã„拡張機能ã§ã™ã€‚ 通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã§ç½®æ›ã•れãŸéƒ¨åˆ†ã®æœ€å¾Œã®æ–‡å­—ãŒç©ºç™½ã®å ´åˆã€ç‰¹ä¾‹ã¨ã—ã¦ãã®ç›´å¾Œã®ãƒˆãƒ¼ã‚¯ãƒ³ã«ã‚‚通常ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®ç½®æ›ãŒè¡Œã‚れã¾ã™ã€‚ エイリアス置æ›ã®çµæžœãŒã•らã«åˆ¥ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«ä¸€è‡´ã—ã¦ç½®æ›ã•れる場åˆã‚‚ã‚りã¾ã™ã€‚ã—ã‹ã—ã€åŒã˜ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã«å†ã³ä¸€è‡´ã™ã‚‹ã“ã¨ã¯ã‚りã¾ã›ã‚“。 エイリアスを登録ã™ã‚‹ã«ã¯ link:_alias.html[alias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã‚’ã€ç™»éŒ²ã‚’削除ã™ã‚‹ã«ã¯ link:_unalias.html[unalias 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]を使用ã—ã¾ã™ã€‚ [[simple]] == å˜ç´”コマンド 最åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒäºˆç´„語ã§ãªã„コマンドã¯ã€dfn:[å˜ç´”コマンド]ã§ã™ã€‚å˜ç´”コマンドã¯link:exec.html#simple[å˜ç´”コマンドã®å®Ÿè¡Œ]ã®ã—ã‹ãŸã«å¾“ã£ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ å˜ç´”コマンドã®åˆã‚ã®ãƒˆãƒ¼ã‚¯ãƒ³ãŒ {{åå‰}}={{値}} ã®å½¢å¼ã«ãªã£ã¦ã„ã‚‹å ´åˆã¯ã€ãれã¯link:params.html#variables[変数]代入ã¨è¦‹ãªã•れã¾ã™ã€‚ãŸã ã—ã“ã“ã§ã®{{åå‰}}ã¯ã€ä¸€æ–‡å­—以上ã®ã‚¢ãƒ«ãƒ•ァベット・数字ã¾ãŸã¯ä¸‹ç·š (+_+) ã§ã€ã‹ã¤æœ€åˆãŒæ•°å­—ã§ãªã„ã‚‚ã®ã§ã™ã€‚変数代入ã§ã¯ãªã„最åˆã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã¨è§£é‡ˆã•れã¾ã™ã€‚ãれ以é™ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ (ãŸã¨ãˆå¤‰æ•°ä»£å…¥ã®å½¢å¼ã‚’ã—ã¦ã„ãŸã¨ã—ã¦ã‚‚) コマンドã®å¼•æ•°ã¨è§£é‡ˆã•れã¾ã™ã€‚ {{åå‰}}=({{トークン列}}) ã®å½¢ã«ãªã£ã¦ã„る変数代入ã¯ã€link:params.html#arrays[é…列]ã®ä»£å…¥ã¨ãªã‚Šã¾ã™ã€‚括弧内ã«ã¯ä»»æ„ã®å€‹æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’書ãã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸã“れらã®ãƒˆãƒ¼ã‚¯ãƒ³ã¯ç©ºç™½ãƒ»ã‚¿ãƒ–ã ã‘ã§ãªã改行ã§åŒºåˆ‡ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ [[pipelines]] == パイプライン dfn:[パイプライン]ã¯ã€ä¸€ã¤ä»¥ä¸Šã®ã‚³ãƒžãƒ³ãƒ‰ (<>ã€<>ã€ã¾ãŸã¯<>) ã‚’è¨˜å· +|+ ã§ç¹‹ã„ã ã‚‚ã®ã§ã™ã€‚ 二ã¤ä»¥ä¸Šã®ã‚³ãƒžãƒ³ãƒ‰ã‹ã‚‰ãªã‚‹ãƒ‘イプラインã®å®Ÿè¡Œã¯ã€ãƒ‘イプラインã«å«ã¾ã‚Œã‚‹å„コマンドをãれãžã‚Œç‹¬ç«‹ã—ãŸlink:exec.html#subshell[サブシェル]ã§åŒæ™‚ã«å®Ÿè¡Œã™ã‚‹ã“ã¨ã§è¡Œã‚れã¾ã™ã€‚ã“ã®æ™‚ã€å„ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å‡ºåŠ›ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力ã«ãƒ‘イプã§å—ã‘æ¸¡ã•れã¾ã™ã€‚最åˆã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å…¥åŠ›ã¨æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ã¯å…ƒã®ã¾ã¾ã§ã™ã€‚最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒãƒ‘イプラインã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ パイプラインã®å…ˆé ­ã«ã¯ã€è¨˜å· +!+ を付ã‘ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å ´åˆã€ãƒ‘イプラインã®çµ‚了ステータスãŒ__逆転__ã—ã¾ã™ã€‚ã¤ã¾ã‚Šã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ã®ã¨ãã¯ãƒ‘イプラインã®çµ‚了ステータス㯠1 ã«ãªã‚Šã€ãれ以外ã®å ´åˆã¯ 0 ã«ãªã‚Šã¾ã™ã€‚ [NOTE] 最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスãŒãƒ‘イプラインã®çµ‚了ステータスã«ãªã‚‹ãŸã‚ã€ãƒ‘イプラインã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã®ã¯å°‘ãªãã¨ã‚‚最後ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸå¾Œã§ã™ã€‚ã—ã‹ã—ãã®ã¨ãä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ã¦ã„ã‚‹ã¨ã¯é™ã‚Šã¾ã›ã‚“。ã¾ãŸã€æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚了ã—ãŸã‚‰ã™ãã«ãƒ‘イプラインã®å®Ÿè¡ŒãŒçµ‚了ã™ã‚‹ã¨ã‚‚é™ã‚Šã¾ã›ã‚“。(シェルã¯ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã‚‹ã¾ã§å¾…ã¤å ´åˆãŒã‚りã¾ã™) [NOTE] POSIX è¦æ ¼ã§ã¯ã€ãƒ‘イプライン内ã®å„コマンドã¯ã‚µãƒ–シェルã§ã¯ãªãç¾åœ¨ã®ã‚·ã‚§ãƒ«ã§å®Ÿè¡Œã—ã¦ã‚‚よã„ã“ã¨ã«ãªã£ã¦ã„ã¾ã™ã€‚ [[and-or]] == And/or リスト dfn:[And/or リスト]ã¯ä¸€ã¤ä»¥ä¸Šã®<>ã‚’è¨˜å· +&&+ ã¾ãŸã¯ +||+ ã§ç¹‹ã„ã ã‚‚ã®ã§ã™ã€‚ And/or リストã®å®Ÿè¡Œã¯ã€and/or リストã«å«ã¾ã‚Œã‚‹å„パイプラインをæ¡ä»¶ä»˜ãã§å®Ÿè¡Œã™ã‚‹ã“ã¨ã§è¡Œã‚れã¾ã™ã€‚最åˆã®ãƒ‘イプラインã¯å¸¸ã«å®Ÿè¡Œã•れã¾ã™ã€‚ãれ以é™ã®ãƒ‘イプラインã®å®Ÿè¡Œã¯ã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータスã«ã‚ˆã‚Šã¾ã™ã€‚ - 二ã¤ã®ãƒ‘イプライン㌠+&&+ ã§ç¹‹ãŒã‚Œã¦ã„ã‚‹å ´åˆã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータス㌠0 ãªã‚‰ã°å¾Œã®ãƒ‘イプラインãŒå®Ÿè¡Œã•れã¾ã™ã€‚ - 二ã¤ã®ãƒ‘イプライン㌠+||+ ã§ç¹‹ãŒã‚Œã¦ã„ã‚‹å ´åˆã€å‰ã®ãƒ‘イプラインã®çµ‚了ステータス㌠0 ã§ãªã‘れã°å¾Œã®ãƒ‘イプラインãŒå®Ÿè¡Œã•れã¾ã™ã€‚ - ãれ以外ã®å ´åˆã¯ã€and/or リストã®å®Ÿè¡Œã¯ãã“ã§çµ‚了ã—ã€ãれ以é™ã®ãƒ‘イプラインã¯å®Ÿè¡Œã•れã¾ã›ã‚“。 最後ã«å®Ÿè¡Œã—ãŸãƒ‘イプラインã®çµ‚了ステータス㌠and/or リストã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ 構文上ã€and/or リストã®ç›´å¾Œã«ã¯åŽŸå‰‡ã¨ã—ã¦è¨˜å· +;+ ã¾ãŸã¯ +&+ ãŒå¿…è¦ã§ã™ (<>å‚ç…§)。 [[async]] == コマンドã®åŒºåˆ‡ã‚Šã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ シェルãŒå—ã‘å–るコマンドã®å…¨ä½“ã¯ã€<>ã‚’ +;+ ã¾ãŸã¯ +&+ ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã§ã™ã€‚行末〠+;;+ ã¾ãŸã¯ +)+ ã®ç›´å‰ã«ã‚ã‚‹ +;+ ã¯çœç•¥ã§ãã¾ã™ãŒã€ãれ以外ã®å ´åˆã¯ and/or リストã®ç›´å¾Œã«ã¯å¿…ãš +;+ 㨠+&+ ã®ã©ã¡ã‚‰ã‹ãŒå¿…è¦ã§ã™ã€‚ And/or リストã®ç›´å¾Œã« +;+ ãŒã‚ã‚‹å ´åˆã¯ã€ãã® and/or リストã¯åŒæœŸçš„ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã® and/or リストã®å®Ÿè¡ŒãŒçµ‚ã‚ã£ãŸå¾Œã«æ¬¡ã® and/or リストãŒå®Ÿè¡Œã•れã¾ã™ã€‚And/or リストã®ç›´å¾Œã« +&+ ãŒã‚ã‚‹å ´åˆã¯ã€ãã® and/or リストã¯éžåŒæœŸçš„ã«å®Ÿè¡Œã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã® and/or リストã®å®Ÿè¡Œã‚’é–‹å§‹ã—ãŸå¾Œã€çµ‚了を待ãŸãšã«ã€ã™ãã•ã¾æ¬¡ã® and/or リストã®å®Ÿè¡Œã«ç§»ã‚Šã¾ã™ã€‚éžåŒæœŸãª and/or リストã¯å¸¸ã«link:exec.html#subshell[サブシェル]ã§å®Ÿè¡Œã•れã¾ã™ã€‚ã¾ãŸçµ‚了ステータスã¯å¸¸ã« 0 ã§ã™ã€‚ link:job.html[ジョブ制御]を行ã£ã¦ã„ãªã„シェルã«ãŠã‘ã‚‹éžåŒæœŸãª and/or リストã§ã¯ã€æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れるã¨ã¨ã‚‚ã«ã€SIGINT 㨠SIGQUIT ã‚’å—ä¿¡ã—ãŸã¨ãã®å‹•作㌠``無視'' ã«è¨­å®šã•れã“れらã®ã‚·ã‚°ãƒŠãƒ«ã‚’å—ã‘ã¦ã‚‚プログラムãŒçµ‚了ã—ãªã„よã†ã«ã—ã¾ã™ã€‚(link:posix.html[POSIX 準拠モード]ã§ã¯ã€æ¨™æº–入力を /dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã™ã‚‹ã®ã¯ã‚¸ãƒ§ãƒ–制御を行ã£ã¦ã„ãªã„シェルã§ã¯ãªãlink:interact.html[対話モード]ã®ã‚·ã‚§ãƒ«ã§ã™ã€‚ã¾ãŸ POSIX 準拠モードã§ã¯ã‚¸ãƒ§ãƒ–制御を行ã£ã¦ã„ã¦ã‚‚ SIGINT 㨠SIGQUIT ㌠``無視'' ã«è¨­å®šã•れã¾ã™) ジョブ制御を行ã£ã¦ã„ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã€éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ãã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID を記憶ã—ã¾ã™ã€‚link:params.html#sp-exclamation[特殊パラメータ +!+] ã‚’å‚ç…§ã™ã‚‹ã¨éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセス ID を知るã“ã¨ãŒã§ãã¾ã™ã€‚éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã®çŠ¶æ…‹ã‚„çµ‚äº†ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ã¯ link:_jobs.html[jobs] ã‚„ link:_wait.html[wait] 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§çŸ¥ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ [[compound]] == 複åˆã‚³ãƒžãƒ³ãƒ‰ 複åˆã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚ˆã‚Šè¤‡é›‘ãªãƒ—ログラムã®åˆ¶å¾¡ã‚’è¡Œã†æ‰‹æ®µã‚’æä¾›ã—ã¾ã™ã€‚ [[grouping]] === グルーピング グルーピングを使ã†ã¨ã€è¤‡æ•°ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦æ‰±ã†ã“ã¨ãŒã§ãã¾ã™ã€‚ 通常ã®ã‚°ãƒ«ãƒ¼ãƒ”ãƒ³ã‚°ã®æ§‹æ–‡:: +{ {{コマンド}}...; }+ サブシェルã®ã‚°ãƒ«ãƒ¼ãƒ”ãƒ³ã‚°ã®æ§‹æ–‡:: +({{コマンド}}...)+ +{+ 㨠+}+ ã¯äºˆç´„語ãªã®ã§ã€ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‘ã¦æ›¸ã„ã¦ã¯ã„ã‘ã¾ã›ã‚“。一方 +(+ 㨠+)+ ã¯ç‰¹æ®ŠãªåŒºåˆ‡ã‚Šè¨˜å·ã¨è¦‹ãªã•れるã®ã§ã€ä»–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‘ã¦æ›¸ãã“ã¨ãŒã§ãã¾ã™ã€‚ 通常ã®ã‚°ãƒ«ãƒ¼ãƒ”ング構文 (+{+ 㨠+}+ ã§å›²ã‚€) ã§ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ (ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«) ç¾åœ¨ã®ã‚·ã‚§ãƒ«ã§å®Ÿè¡Œã•れã¾ã™ã€‚サブシェルã®ã‚°ãƒ«ãƒ¼ãƒ”ング構文 (+(+ 㨠+)+ ã§å›²ã‚€) ã§ã¯ã€æ‹¬å¼§å†…ã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ–°ãŸãª{zwsp}link:exec.html#subshell[サブシェル]ã§å®Ÿè¡Œã•れã¾ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ã¯æ‹¬å¼§å†…ã«å°‘ãªãã¨ã‚‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ãŒå¿…è¦ã§ã™ãŒã€éž POSIX 準拠モードã§ã¯ã‚³ãƒžãƒ³ãƒ‰ã¯ä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 グルーピングã®çµ‚了ステータスã¯ã€ã‚°ãƒ«ãƒ¼ãƒ”ングã®ä¸­ã§å®Ÿè¡Œã•ã‚ŒãŸæœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã§ã™ã€‚グルーピング内ã«ã‚³ãƒžãƒ³ãƒ‰ãŒä¸€ã¤ã‚‚ãªã„å ´åˆã€ã‚°ãƒ«ãƒ¼ãƒ”ングã®çµ‚了ステータスã¯ã‚°ãƒ«ãƒ¼ãƒ”ングã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ [[if]] === If æ–‡ If æ–‡ã¯æ¡ä»¶åˆ†å²ã‚’行ã„ã¾ã™ã€‚分å²ã®è¤‡é›‘ã•ã«å¿œã˜ã¦ã„ãã¤ã‹æ§‹æ–‡ã®ãƒãƒªã‚¨ãƒ¼ã‚·ãƒ§ãƒ³ãŒã‚りã¾ã™ã€‚ If æ–‡ã®åŸºæœ¬æ§‹æ–‡:: +if {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; then {{内容コマンド}}...; fi+ Else ãŒã‚ã‚‹å ´åˆ:: +if {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; then {{内容コマンド}}...; else {{内容コマンド}}...; fi+ Elif ãŒã‚ã‚‹å ´åˆ:: +if {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; then {{内容コマンド}}...; elif {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; then {{内容コマンド}}...; fi+ Elif 㨠else ãŒã‚ã‚‹å ´åˆ:: +if {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; then {{内容コマンド}}...; elif {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; then {{内容コマンド}}...; else {{内容コマンド}}...; fi+ If æ–‡ã®å®Ÿè¡Œã§ã¯ã€ã©ã®æ§‹æ–‡ã®å ´åˆã§ã‚‚ã€+if+ ã®ç›´å¾Œã«ã‚ã‚‹{{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}ãŒã¾ãšå®Ÿè¡Œã•れã¾ã™ã€‚æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ãªã‚‰ã°ã€æ¡ä»¶ãŒçœŸã§ã‚ã‚‹ã¨è¦‹ãªã•れ㦠+then+ ã®ç›´å¾Œã«ã‚ã‚‹{{内容コマンド}}ãŒå®Ÿè¡Œã•れã€if æ–‡ã®å®Ÿè¡Œã¯ãれã§çµ‚了ã—ã¾ã™ã€‚終了ステータス㌠0 ã§ãªã‘れã°ã€æ¡ä»¶ãŒå½ã§ã‚ã‚‹ã¨è¦‹ãªã•れã¾ã™ã€‚ã“ã“ã§ +else+ ã‚‚ +elif+ ã‚‚ãªã‘れã°ã€if æ–‡ã®å®Ÿè¡Œã¯ã“れã§çµ‚ã‚りã§ã™ã€‚+else+ ãŒã‚ã‚‹å ´åˆã¯ã€+else+ ã®ç›´å¾Œã®{{内容コマンド}}ãŒå®Ÿè¡Œã•れã¾ã™ã€‚+elif+ ãŒã‚ã‚‹å ´åˆã¯ã€+elif+ ã®ç›´å¾Œã®{{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}ãŒå®Ÿè¡Œã•れã€ãã®çµ‚了ステータス㌠0 ã§ã‚ã‚‹ã‹ã©ã†ã‹åˆ¤å®šã•れã¾ã™ã€‚ãã®å¾Œã¯å…ˆç¨‹ã¨åŒæ§˜ã«æ¡ä»¶åˆ†å²ã‚’行ã„ã¾ã™ã€‚ +elif …; then …;+ ã¯ä¸€ã¤ã® if 文内ã«è¤‡æ•°ã‚ã£ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 If 文全体ã®çµ‚了ステータスã¯ã€å®Ÿè¡Œã•れãŸå†…容コマンドã®çµ‚了ステータスã§ã™ã€‚内容コマンドãŒå®Ÿè¡Œã•れãªã‹ã£ãŸå ´åˆ (ã©ã®æ¡ä»¶ã‚‚å½ã§ã€+else+ ãŒãªã„å ´åˆ) 㯠0 ã§ã™ã€‚ [[while-until]] === While ãŠã‚ˆã³ until ループ While ループ㨠until ループã¯å˜ç´”ãªãƒ«ãƒ¼ãƒ—æ§‹æ–‡ã§ã™ã€‚ While ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡:: +while {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; do {{内容コマンド}}...; done+ Until ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡:: +until {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}...; do {{内容コマンド}}...; done+ éž link:posix.html[POSIX 準拠モード]ã§ã¯ +{{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}…;+ ãŠã‚ˆã³ +{{内容コマンド}}…;+ ã¯çœç•¥å¯èƒ½ã§ã™ã€‚ While ループã®å®Ÿè¡Œã§ã¯ã¾ãš{{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ãã®ã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠0 ãªã‚‰ã°ã€{{内容コマンド}}ãŒå®Ÿè¡Œã•れãŸã®ã¡ã€å†ã³{{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}ã®å®Ÿè¡Œã«æˆ»ã‚Šã¾ã™ã€‚ã“ã®ç¹°ã‚Šè¿”ã—ã¯{{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}ã®çµ‚了ステータス㌠0 ã§ãªããªã‚‹ã¾ã§ç¶šãã¾ã™ã€‚ [NOTE] {{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}ã®çµ‚äº†ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ãŒæœ€åˆã‹ã‚‰ 0 ã§ãªã„ã¨ãã¯ã€{{内容コマンド}}ã¯ä¸€åº¦ã‚‚実行ã•れã¾ã›ã‚“。 Until ループã¯ã€ãƒ«ãƒ¼ãƒ—を続行ã™ã‚‹æ¡ä»¶ãŒé€†ã«ãªã£ã¦ã„る以外㯠while ループã¨åŒã˜ã§ã™ã€‚ã™ãªã‚ã¡ã€{{æ¡ä»¶ã‚³ãƒžãƒ³ãƒ‰}}ã®çµ‚了ステータス㌠0 ã§ãªã‘れã°{{内容コマンド}}ãŒå®Ÿè¡Œã•れã¾ã™ã€‚ While/until ループ全体ã®çµ‚了ステータスã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸ{{内容コマンド}}ã®çµ‚了ステータスã§ã™ã€‚({{内容コマンド}}ãŒå­˜åœ¨ã—ãªã„ã‹ã€ä¸€åº¦ã‚‚実行ã•れãªã‹ã£ãŸã¨ã㯠0) [[for]] === For ループ For ãƒ«ãƒ¼ãƒ—ã¯æŒ‡å®šã•れãŸãれãžã‚Œã®å˜èªžã«ã¤ã„ã¦åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ For ãƒ«ãƒ¼ãƒ—ã®æ§‹æ–‡:: +for {{変数å}} in {{å˜èªž}}...; do {{コマンド}}...; done+ + +for {{変数å}} do {{コマンド}}...; done+ +in+ ã®ç›´å¾Œã®{{å˜èªž}}ã¯ä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“ãŒã€+do+ ã®ç›´å‰ã® +;+ (ã¾ãŸã¯æ”¹è¡Œ) ã¯å¿…è¦ã§ã™ã€‚ã“れらã®å˜èªžãƒˆãƒ¼ã‚¯ãƒ³ã¯äºˆç´„語ã¨ã—ã¦ã¯èªè­˜ã•れã¾ã›ã‚“ãŒã€+&+ ãªã©ã®è¨˜å·ã‚’å«ã‚ã‚‹ã«ã¯é©åˆ‡ãª<>ãŒå¿…è¦ã§ã™ã€‚+in …;+ ã‚’çœç•¥ã™ã‚‹å ´åˆã¯ã€æœ¬æ¥ã¯å¤‰æ•°å㨠+do+ ã®é–“ã« +;+ を入れã¦ã¯ã„ã‘ã¾ã›ã‚“ãŒã€éž link:posix.html[POSIX 準拠モード]ã§ã¯ +;+ ãŒã‚ã£ã¦ã‚‚許容ã•れã¾ã™ã€‚ã¾ãŸéž POSIX 準拠モードã§ã¯ +{{コマンド}}…;+ ãŒãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 For ループã®å®Ÿè¡Œã§ã¯ã¾ãš{{å˜èªž}}ãŒ<>実行時ã®å˜èªžã®å±•é–‹ã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ (+in …;+ ãŒãªã„構文を使用ã—ã¦ã„ã‚‹å ´åˆã¯ã€+in "$@";+ ãŒçœç•¥ã•れã¦ã„ã‚‹ã‚‚ã®ã¨è¦‹ãªã•れã¾ã™)。続ã„ã¦ã€å±•é–‹ã§ç”Ÿæˆã•れãŸãれãžã‚Œã®å˜èªžã«ã¤ã„ã¦é †ç•ªã«ä¸€åº¦ãšã¤ä»¥ä¸‹ã®å‡¦ç†ã‚’行ã„ã¾ã™ã€‚ . å˜èªžã‚’{{変数å}}ã§æŒ‡å®šã—ãŸå¤‰æ•°ã«ä»£å…¥ã™ã‚‹ . {{コマンド}}を実行ã™ã‚‹ å˜èªžã¯link:exec.html#localvar[ローカル変数]ã¨ã—ã¦ä»£å…¥ã•れã¾ã™ (link:posix.html[POSIX 準拠モード]ã®ã¨ãを除ã)。展開ã®çµæžœå˜èªžãŒä¸€ã¤ã‚‚生æˆã•れãªã‹ã£ãŸå ´åˆã¯ã€{{コマンド}}ã¯ä¸€åˆ‡å®Ÿè¡Œã•れã¾ã›ã‚“。 For ループ全体ã®çµ‚了ステータスã¯ã€æœ€å¾Œã«å®Ÿè¡Œã—ãŸ{{コマンド}}ã®çµ‚了ステータスã§ã™ã€‚{{コマンド}}ãŒã‚ã‚‹ã®ã«ä¸€åº¦ã‚‚実行ã•れãªã‹ã£ãŸã¨ã㯠0 ã§ã™ã€‚{{コマンド}}ãŒãªã„å ´åˆã€for ループã®çµ‚了ステータス㯠for ループã®ä¸€ã¤å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ [[case]] === Case æ–‡ Case æ–‡ã¯å˜èªžã«å¯¾ã—ã¦ãƒ‘ターンマッãƒãƒ³ã‚°ã‚’行ã„ã€ãã®çµæžœã«å¯¾å¿œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ Case æ–‡ã®æ§‹æ–‡:: +case {{å˜èªž}} in {{caseitem}}... esac+ Caseitem ã®æ§‹æ–‡:: +({{パターン}}) {{コマンド}}...;;+ +case+ 㨠+in+ ã®é–“ã®å˜èªžã¯ã¡ã‚‡ã†ã©ä¸€ãƒˆãƒ¼ã‚¯ãƒ³ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®å˜èªžãƒˆãƒ¼ã‚¯ãƒ³ã¯äºˆç´„語ã¨ã—ã¦ã¯èªè­˜ã•れã¾ã›ã‚“ãŒã€+&+ ãªã©ã®è¨˜å·ã‚’å«ã‚ã‚‹ã«ã¯é©åˆ‡ãª<>ãŒå¿…è¦ã§ã™ã€‚+in+ 㨠+esac+ ã®é–“ã«ã¯ä»»æ„ã®å€‹æ•°ã® caseitem ã‚’ç½®ãã¾ã™ (0 個ã§ã‚‚よã„)。Caseitem ã®æœ€åˆã® +(+ 㨠+esac+ ã®ç›´å‰ã® +;;+ ã¯çœç•¥ã§ãã¾ã™ã€‚ã¾ãŸ{{コマンド}}㌠+;+ ã§çµ‚ã‚ã‚‹å ´åˆã¯ãã® +;+ ã‚‚çœç•¥ã§ãã¾ã™ã€‚Caseitem ã® +)+ 㨠+;;+ ã¨ã®é–“ã«{{コマンド}}ãŒä¸€ã¤ã‚‚ãªãã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。 Caseitem ã®{{パターン}}ã«ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã‚’指定ã—ã¾ã™ã€‚å„トークンを +|+ ã§åŒºåˆ‡ã‚‹ã“ã¨ã§è¤‡æ•°ã®ãƒˆãƒ¼ã‚¯ãƒ³ã‚’パターンã¨ã—ã¦æŒ‡å®šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ Case æ–‡ã®å®Ÿè¡Œã§ã¯ã€ã¾ãš{{å˜èªž}}ãŒlink:expand.html[四種展開]ã•れã¾ã™ã€‚ãã®å¾Œã€å„ caseitem ã«å¯¾ã—ã¦é †ã«ä»¥ä¸‹ã®å‹•作を行ã„ã¾ã™ã€‚ . {{パターン}}トークンを{{å˜èªž}}ã¨åŒæ§˜ã«å±•é–‹ã—ã€å±•é–‹ã—ãŸãƒ‘ターンãŒå±•é–‹ã—ãŸå˜èªžã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ (link:pattern.html[パターンマッãƒãƒ³ã‚°è¨˜æ³•]å‚ç…§)。{{パターン}}ã¨ã—ã¦æŒ‡å®šã•れãŸãƒˆãƒ¼ã‚¯ãƒ³ãŒè¤‡æ•°ã‚ã‚‹å ´åˆã¯ãれらå„トークンã«å¯¾ã—ã¦ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ (ã©ã‚Œã‹ã®ãƒ‘ターントークンãŒãƒžãƒƒãƒã—ãŸã‚‰ãれ以é™ã®ãƒ‘ターントークンã¯å±•é–‹ã•れã¾ã›ã‚“。Yash ã¯ãƒˆãƒ¼ã‚¯ãƒ³ãŒæ›¸ã‹ã‚Œã¦ã„る順番ã«ãƒžãƒƒãƒã™ã‚‹ã‹ã©ã†ã‹ã‚’調ã¹ã¾ã™ãŒã€ä»–ã®ã‚·ã‚§ãƒ«ã‚‚ã“ã®é †åºã§èª¿ã¹ã‚‹ã¨ã¯é™ã‚Šã¾ã›ã‚“)。 . マッãƒã—ãŸå ´åˆã¯ã€ç›´å¾Œã®{{コマンド}}を実行ã—ã€ãれã§ã“ã® case æ–‡ã®å®Ÿè¡Œã¯çµ‚了ã§ã™ã€‚マッãƒã—ãªã‹ã£ãŸå ´åˆã¯ã€æ¬¡ã® caseitem ã®å‡¦ç†ã«ç§»ã‚Šã¾ã™ã€‚ Case 文全体ã®çµ‚了ステータスã¯ã€å®Ÿè¡Œã—ãŸ{{コマンド}}ã®çµ‚了ステータスã§ã™ã€‚{{コマンド}}ãŒå®Ÿè¡Œã•れãªã‹ã£ãŸå ´åˆ (ã©ã®ãƒ‘ターンもマッãƒã—ãªã‹ã£ãŸã‹ã€caseitem ãŒä¸€ã¤ã‚‚ãªã„ã‹ã€ãƒžãƒƒãƒã—ãŸãƒ‘ターンã®å¾Œã«ã‚³ãƒžãƒ³ãƒ‰ãŒãªã„å ´åˆ) ã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ã¯ã€(+|+ ã§åŒºåˆ‡ã‚‰ã‚ŒãŸæœ€åˆã®) {{パターン}}トークンを +esac+ ã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 [[funcdef]] == 関数定義 関数定義コマンドã¯ã€link:exec.html#function[関数]を定義ã—ã¾ã™ã€‚ é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã®æ§‹æ–‡:: +{{関数å}} ( ) {{複åˆã‚³ãƒžãƒ³ãƒ‰}}+ + +function {{関数å}} {{複åˆã‚³ãƒžãƒ³ãƒ‰}}+ + +function {{関数å}} ( ) {{複åˆã‚³ãƒžãƒ³ãƒ‰}}+ 予約語 +function+ を用ã„ãªã„一ã¤ç›®ã®å½¢å¼ã§ã¯ã€{{関数å}}ã«ã¯å¼•用符ãªã©ã®ç‰¹æ®Šãªè¨˜å·ã‚’å«ã‚ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。予約語 +function+ を用ã„る二ã¤ç›®ã¾ãŸã¯ä¸‰ã¤ç›®ã®å½¢å¼ã§ã¯ã€{{関数å}}ã¯å®Ÿè¡Œæ™‚ã«link:expand.html[四種展開]ã•れã¾ã™ã€‚(link:posix.html[POSIX 準拠モード]ã§ã¯äºˆç´„語 +function+ を用ã„ã‚‹å½¢å¼ã®é–¢æ•°å®šç¾©ã¯ä½¿ãˆã¾ã›ã‚“。) 関数定義コマンドを実行ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ{{関数å}}ã®é–¢æ•°ãŒ{{複åˆã‚³ãƒžãƒ³ãƒ‰}}を内容ã¨ã—ã¦å®šç¾©ã•れã¾ã™ã€‚ 関数定義コマンドã«å¯¾ã—ã¦ç›´æŽ¥link:redir.html[リダイレクト]を行ã†ã“ã¨ã¯ã§ãã¾ã›ã‚“ã€‚é–¢æ•°å®šç¾©ã‚³ãƒžãƒ³ãƒ‰ã®æœ€å¾Œã«ã‚るリダイレクトã¯ã€é–¢æ•°ã®å†…容ã§ã‚ã‚‹{{複åˆã‚³ãƒžãƒ³ãƒ‰}}ã«å¯¾ã™ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¨è¦‹ãªã•れã¾ã™ã€‚例ãˆã° +func() { cat; } >/dev/null+ ã¨æ›¸ã„ãŸå ´åˆã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れるã®ã¯ +func() { cat; }+ ã§ã¯ãªã +{ cat; }+ ã§ã™ã€‚ 関数定義コマンドã®çµ‚了ステータスã¯ã€é–¢æ•°ãŒæ­£ã—ã定義ã•れãŸå ´åˆã¯ 0ã€ãã†ã§ãªã‘れã°éž 0 ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_readonly.txt0000644000175000017500000000216212154557026016423 0ustar magicantmagicant= Readonly 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Readonly 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Readonly 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯èª­ã¿å–り専用ã®link:params.html#variables[変数]ã¾ãŸã¯link:exec.html#function[関数]を表示・設定ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +readonly [-pxX] [{{変数}}[={{値}}]...]+ - +readonly -f[p] [{{変数}}...]+ [[description]] == 説明 Readonly コマンド㯠link:_typeset.html[typeset コマンド]ã« +-gr+ オプションを付ã‘ãŸã‚‚ã®ã¨åŒã˜ã§ã™ã€‚ãã®ä»–オプション・オペランド・終了ステータス㯠typeset コマンドã¨åŒæ§˜ã§ã™ã€‚ [[notes]] == 補足 readonly コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã«ã¯ readonly コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã™ãŒã€ã‚ªãƒ—ション㯠+-p+ ã—ã‹è¦å®šãŒã‚りã¾ã›ã‚“。ãã®ä»–ã®ã‚ªãƒ—ション㯠link:posix.html[POSIX 準拠モード]ã§ã¯ä½¿ãˆã¾ã›ã‚“。ã¾ãŸ POSIX 㯠+-p+ オプションをオペランドã¨ã¨ã‚‚ã«ä½¿ã†ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/posix.html0000644000175000017500000001622612154557026015744 0ustar magicantmagicant POSIX 準拠モード

Yash ã¯åŸºæœ¬çš„ã« POSIX.1-2008 ã®ã‚·ã‚§ãƒ«ã®è¦å®šã«å¾“ã£ã¦å‹•作ã—ã¾ã™ãŒã€åˆ©ä¾¿æ€§ã‚„分ã‹ã‚Šã‚„ã™ã•ã®ãŸã‚ã« POSIX ã®è¦å®šã¨ã¯ç•°ãªã‚‹å‹•作をã™ã‚‹ç‚¹ã‚‚ã‚りã¾ã™ã€‚ãã®ãŸã‚標準状態㮠yash 㯠POSIX ã®è¦å®šã™ã‚‹ã‚·ã‚§ãƒ«ã¨ã—ã¦ä¾›ã™ã‚‹ã«ã¯å‘ãã¾ã›ã‚“。POSIX 準拠モードを有効ã«ã™ã‚‹ã¨ã€yash ã¯ã§ãã‚‹é™ã‚Š POSIX ã®è¦å®šé€šã‚Šã«å‹•作ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚POSIX 準拠シェルã¨ã—ã¦ã®äº’æ›æ€§ãŒå¿…è¦ãªå ´é¢ã§ã¯ã€POSIX 準拠モードを有効ã«ã—ã¦ãã ã•ã„。

シェルã®èµ·å‹•時ã®èµ·å‹•時ã®åå‰ãŒ sh ãªã‚‰ã°ã‚·ã‚§ãƒ«ã¯è‡ªå‹•的㫠POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚ã¾ãŸèµ·å‹•時㫠-o posixlycorrect ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã‚‹å ´åˆã‚‚ POSIX 準拠モードã«ãªã‚Šã¾ã™ã€‚ã¾ãŸèµ·å‹•後ã¯ã€set -o posixlycorrect を実行ã™ã‚‹ã“ã¨ã§ POSIX 準拠モードを有効ã«ã§ãã¾ã™ã€‚

POSIX 準拠モードを有効ã«ã™ã‚‹ã¨ã€yash 㯠POSIX ã®è¦å®šã«ã§ãã‚‹ã ã‘従ã†ã‚ˆã†ã«ãªã‚‹ã ã‘ã§ãªãã€POSIX ãŒæœªå®šç¾©ã‚„未è¦å®šã¨å®šã‚ã¦ã„ã‚‹å ´åˆã®ã»ã¨ã‚“ã©ã‚’エラーã«ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ã™ãªã‚ã¡ã€yash ç‹¬è‡ªã®æ‹¡å¼µæ©Ÿèƒ½ã®å¤šãã¯ä½¿ãˆãªããªã‚Šã¾ã™ã€‚具体的ã«ã¯ã€POSIX 準拠モードを有効ã«ã™ã‚‹ã¨ä»¥ä¸‹ã®ã‚ˆã†ãªæŒ™å‹•ã®å¤‰åŒ–ãŒã‚りã¾ã™ã€‚

yash-2.35/doc/ja/interact.txt0000644000175000017500000003755712154557026016300 0ustar magicantmagicant= 対話モード :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - 対話モード :description: Yash ã®å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ã¤ã„㦠dfn:[対話モード]ã¯ã€åˆ©ç”¨è€…ãŒç›´æŽ¥ã‚·ã‚§ãƒ«ã‚’æ“作ã™ã‚‹ã“ã¨ã‚’æ„図ã—ãŸãƒ¢ãƒ¼ãƒ‰ã§ã™ã€‚link:invoke.html[シェルã®èµ·å‹•]時㫠+-i+ オプションを指定ã—ãŸå ´åˆ (ãã®ä»–å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åйã«ãªã‚‹æ¡ä»¶ãŒæº€ãŸã•れã¦ã„ã‚‹å ´åˆ)ã€ã‚·ã‚§ãƒ«ã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚シェルãŒèµ·å‹•ã—ãŸå¾Œã¯ã€ãã®ã‚·ã‚§ãƒ«ã®å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚ªãƒ³ãƒ»ã‚ªãƒ•を切り替ãˆã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ãŒæœ‰åŠ¹ãªæ™‚…… - link:invoke.html#init[シェルã®åˆæœŸåŒ–]時ã«åˆæœŸåŒ–スクリプトを読ã¿è¾¼ã‚“ã§å®Ÿè¡Œã—ã¾ã™ã€‚ - コマンドを読ã¿è¾¼ã‚€éš›ã«<>を行ã„ã€<>を表示ã—ã¾ã™ã€‚link:job.html[ジョブ制御]ãŒæœ‰åйãªã‚‰ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹å¤‰åŒ–ã‚‚è¡¨ç¤ºã—ã¾ã™ã€‚端末ã®ç¨®é¡žã«ã‚ˆã£ã¦ã¯link:lineedit.html[行編集]ãŒä½¿ãˆã¾ã™ã€‚ - 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯è‡ªå‹•çš„ã«<>ã«ç™»éŒ²ã•れã¾ã™ã€‚ - 実行ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒ SIGINT/SIGPIPE 以外ã®ã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦ä¸­æ–­ã•れãŸã¨ãã€ã‚·ã‚§ãƒ«ã¯ãã®ã“ã¨ã‚’示ã™è­¦å‘Šãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚ - link:redir.html#file[ファイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ]ã®å¯¾è±¡ãƒ•ァイルを指示ã™ã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã«å¯¾ã—ã¦link:expand.html#glob[パスå展開]を行ã„ã¾ã™ã€‚ - link:syntax.html#async[éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰]ã®æ¨™æº–入力ãŒè‡ªå‹•的㫠/dev/null ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れã¾ã›ã‚“。(link:posix.html[POSIX 準拠モード]ã®ã¿) - ã‚³ãƒžãƒ³ãƒ‰è§£é‡ˆãƒ»å®Ÿè¡Œæ™‚ã«æ–‡æ³•エラーや展開エラーãŒç™ºç”Ÿã—ã¦ã‚‚シェルã¯çµ‚了ã—ã¾ã›ã‚“。(link:exec.html#exit[シェルã®çµ‚了]ã‚’å‚ç…§) - SIGINT, SIGTERM, SIGQUIT シグナルをå—ã‘ã¦ã‚‚ã€ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã›ã‚“。 - シグナルå—ä¿¡æ™‚ã®æŒ™å‹•ãŒã‚·ã‚§ãƒ«ã®èµ·å‹•æ™‚ã«æœ€åˆã‹ã‚‰ ``無視'' ã«è¨­å®šã•れã¦ã„ã¦ã‚‚ link:_trap.html[trap 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚·ã‚°ãƒŠãƒ«å—ä¿¡æ™‚ã®æŒ™å‹•を変更ã§ãã¾ã™ã€‚ - link:params.html#special[特殊パラメータ] +-+ ã®å€¤ã« +i+ ãŒå«ã¾ã‚Œã¾ã™ã€‚ - シェル実行中㫠link:params.html#sv-lc_ctype[+LC_CTYPE+ 変数]ã®å€¤ãŒå¤‰ã‚ã£ãŸæ™‚ã€ãれを直ã¡ã«ã‚·ã‚§ãƒ«ã®ãƒ­ã‚±ãƒ¼ãƒ«æƒ…å ±ã«å映ã—ã¾ã™ã€‚(link:posix.html[POSIX 準拠モード]を除ã) - link:_set.html#so-exec[Exec オプション]ãŒç„¡åŠ¹ãªæ™‚ã§ã‚‚コマンドを実行ã—ã¾ã™ã€‚ - link:_set.html#so-ignoreeof[Ignore-eof オプション]ãŒåŠ¹æžœã‚’ç™ºæ®ã—ã¾ã™ã€‚ - link:_exit.html[Exit 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚·ã‚§ãƒ«ã‚’終了ã—よã†ã¨ã—ãŸæ™‚ã€åœæ­¢ã—ã¦ã„ã‚‹link:job.html[ジョブ]ãŒã‚れã°ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã¦ã™ãã«ã¯çµ‚了ã—ã¾ã›ã‚“。ã“ã®ã¨ãã¯ç¶šã‘ã–ã¾ã«ã‚‚ã†ä¸€åº¦ exit コマンドを実行ã™ã‚‹ã¨æœ¬å½“ã«ã‚·ã‚§ãƒ«ã‚’終了ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚シェルã¸ã®å…¥åŠ›ãŒçµ‚ã‚りã«é”ã—ãŸå ´åˆã‚‚åŒæ§˜ã§ã™ã€‚ - link:_suspend.html[Suspend 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚·ã‚§ãƒ«ã‚’åœæ­¢ã•ã›ã‚ˆã†ã¨ã—ãŸæ™‚ã€ã‚·ã‚§ãƒ«ãŒã‚»ãƒƒã‚·ãƒ§ãƒ³ãƒªãƒ¼ãƒ€ãƒ¼ãªã‚‰ã‚¨ãƒ©ãƒ¼ã‚’出力ã—ã¦åœæ­¢ã—ã¾ã›ã‚“。 - link:_dot.html[ドット組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§èª­ã¿è¾¼ã‚€ã‚¹ã‚¯ãƒªãƒ—トファイルãŒè¦‹ã¤ã‹ã‚‰ãªãã¦ã‚‚ã€ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã›ã‚“。 - link:_exec.html[Exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã«å¤±æ•—ã—ãŸã¨ãã§ã‚‚シェルã¯çµ‚了ã—ã¾ã›ã‚“。(link:posix.html[POSIX 準拠モード]ã®ã¨ãを除ã) - link:_wait.html[Wait 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§å¾…ã£ã¦ã„るジョブãŒçµ‚了ã—ãŸã¨ãã€ãã®ã“ã¨ã‚’示ã™ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã¾ã™ã€‚(link:job.html[ジョブ制御]ãŒæœ‰åŠ¹ãªæ™‚ã®ã¿ã€‚link:posix.html[POSIX 準拠モード]を除ã) - link:_read.html[Read 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ãŒäºŒè¡Œç›®ä»¥é™ã‚’読むã¨ãプロンプトを出ã—ã¾ã™ã€‚ [[prompt]] == プロンプト 対話モードã§ã¯ã€ã‚·ã‚§ãƒ«ã¯ã‚³ãƒžãƒ³ãƒ‰ã®å…¥åŠ›ã‚’èª­ã¿å–ã‚‹ç›´å‰ã«dfn:[プロンプト]を標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚プロンプトã®å†…容㯠link:params.html#sv-ps1[+PS1+ 変数]ã§æŒ‡å®šã—ã¾ã™ã€‚ãŸã ã—ã€è¤‡æ•°è¡Œã«ã‚ãŸã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿å–ã‚‹éš›ã€äºŒè¡Œç›®ä»¥é™ã®èª­ã¿å–りã«ã¯ +PS1+ ã§ã¯ãªã link:params.html#sv-ps2[+PS2+ 変数]ã®å€¤ãŒãƒ—ロンプトã¨ã—ã¦è¡¨ç¤ºã•れã¾ã™ã€‚ プロンプトã®è¡¨ç¤ºã®éš›ã«ã¯ã€ã¾ãš +PS1+ (ã¾ãŸã¯ +PS2+) 変数ã®å€¤ãŒlink:expand.html#params[パラメータ展開]・link:expand.html#cmdsub[コマンド置æ›]・link:expand.html#arith[æ•°å¼å±•é–‹]ã§å±•é–‹ã•れã¾ã™ (ãŸã ã— POSIX ã«ã‚ˆã‚Œã°ãƒ‘ラメータ展開ã ã‘ãŒè¡Œã‚れるã“ã¨ã«ãªã£ã¦ã„ã¾ã™)。ã“ã®å±•開後ã®å€¤ã¯ä»¥ä¸‹ã®é€šã‚Šè§£é‡ˆã•れã€ãã®çµæžœãŒãƒ—ロンプトã¨ã—ã¦æ¨™æº–エラーã«å‡ºåŠ›ã•れã¾ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ã¯ã€å€¤ã«å«ã¾ã‚Œã‚‹ +!+ ã¯ã“れã‹ã‚‰å…¥åŠ›ã—よã†ã¨ã—ã¦ã„るコマンドã®<>番å·ã«å¤‰æ›ã•れã¾ã™ã€‚感嘆符ãã®ã‚‚ã®ã‚’プロンプトã«è¡¨ç¤ºã•ã›ã‚‹ã«ã¯ +!!+ ã¨äºŒã¤ç¶šã‘ã¦æ›¸ãã¾ã™ã€‚ã“ã‚Œä»¥å¤–ã®æ–‡å­—ã¯ãƒ—ロンプトã«ãã®ã¾ã¾è¡¨ç¤ºã•れã¾ã™ã€‚ POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§å§‹ã¾ã‚‹ä»¥ä¸‹ã®è¨˜æ³•ãŒè§£é‡ˆã•れã¾ã™ã€‚ã“れらã®è¨˜æ³•ä»¥å¤–ã®æ–‡å­—ã¯ãã®ã¾ã¾ãƒ—ロンプトã«è¡¨ç¤ºã•れã¾ã™ã€‚ +\a+:: ベル文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 7) +\e+:: エスケープ文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 27) +\j+:: ç¾åœ¨ã‚·ã‚§ãƒ«ãŒæŠ±ãˆã¦ã„ã‚‹link:job.html[ジョブ]ã®æ•° +\n+:: 改行文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 10) +\r+:: 復帰文字 (ASCII ã‚³ãƒ¼ãƒ‰ç•ªå· 13) +\!+:: ã“れã‹ã‚‰å…¥åŠ›ã—よã†ã¨ã—ã¦ã„るコマンドã®<>ç•ªå· +\$+:: シェルã®å®ŸåŠ¹ãƒ¦ãƒ¼ã‚¶ ID ㌠0 ã®ã¨ã㯠++#++ã€ãã‚Œä»¥å¤–ã®æ™‚㯠++$++。 +\\+:: ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ (+\+) +\[+:: +\]+:: ã“ã®äºŒã¤ã®è¨˜æ³•ã¯ã€å®Ÿéš›ã«ã¯ç«¯æœ«ã«è¡¨ç¤ºã•れãªã„プロンプトã®ä¸€éƒ¨åˆ†ã‚’指示ã™ã‚‹ã®ã«ä½¿ã„ã¾ã™ã€‚+\[+ 㨠+\]+ ã§å›²ã‚“ã éƒ¨åˆ†ã¯ã€link:lineedit.html[行編集]ãŒãƒ—ãƒ­ãƒ³ãƒ—ãƒˆã®æ–‡å­—数を計算ã™ã‚‹éš›ã«ã€æ–‡å­—æ•°ã«æ•°ãˆã‚‰ã‚Œã¾ã›ã‚“。端末ã«è¡¨ç¤ºã•れãªã„エスケープシーケンスãªã©ã‚’プロンプトã«å«ã‚ã‚‹éš›ã¯ã€ãã®éƒ¨åˆ†ã‚’ +\[+ 㨠+\]+ ã§å›²ã‚“ã§ãã ã•ã„。ã“ã®æŒ‡å®šã‚’怠るã¨ã€è¡Œç·¨é›†ã®è¡¨ç¤ºãŒä¹±ã‚Œã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ +\f{{フォント指定}}.+:: link:lineedit.html[行編集]を使用ã—ã¦ã„ã‚‹å ´åˆã€ã“ã®è¨˜æ³•ã¯ç«¯æœ«ã®ãƒ•ォントã®è¡¨ç¤ºã‚’変更ã™ã‚‹ãŸã‚ã®ç‰¹æ®Šãªæ–‡å­—ã®ç¾…列ã«å¤‰æ›ã•れã¾ã™ (端末ãŒå¯¾å¿œã—ã¦ã„ã‚‹å ´åˆã®ã¿)。行編集を使用ã—ã¦ã„ãªã„å ´åˆã‚„端末ãŒå¯¾å¿œã—ã¦ã„ãªã„å ´åˆã¯ã€ã“ã®è¨˜æ³•ã¯å˜ã«ç„¡è¦–ã•れã¾ã™ã€‚{{フォント指定}}ã®éƒ¨åˆ†ã«ã¯ãƒ•ォントã®ç¨®é¡žã‚’指定ã™ã‚‹ãŸã‚ã®ä»¥ä¸‹ã®æ–‡å­—を指定ã—ã¾ã™ã€‚ + -- +k+:: 文字ã®è‰²ã‚’é»’ã«ã™ã‚‹ +r+:: 文字ã®è‰²ã‚’赤ã«ã™ã‚‹ +g+:: 文字ã®è‰²ã‚’ç·‘ã«ã™ã‚‹ +y+:: 文字ã®è‰²ã‚’黄ã«ã™ã‚‹ +b+:: 文字ã®è‰²ã‚’é’ã«ã™ã‚‹ +m+:: 文字ã®è‰²ã‚’マゼンタã«ã™ã‚‹ +c+:: 文字ã®è‰²ã‚’シアンã«ã™ã‚‹ +w+:: 文字ã®è‰²ã‚’白ã«ã™ã‚‹ +K+:: 背景ã®è‰²ã‚’é»’ã«ã™ã‚‹ +R+:: 背景ã®è‰²ã‚’赤ã«ã™ã‚‹ +G+:: 背景ã®è‰²ã‚’ç·‘ã«ã™ã‚‹ +Y+:: 背景ã®è‰²ã‚’黄ã«ã™ã‚‹ +B+:: 背景ã®è‰²ã‚’é’ã«ã™ã‚‹ +M+:: 背景ã®è‰²ã‚’マゼンタã«ã™ã‚‹ +C+:: 背景ã®è‰²ã‚’シアンã«ã™ã‚‹ +W+:: 背景ã®è‰²ã‚’白ã«ã™ã‚‹ +t+:: 文字ã¾ãŸã¯èƒŒæ™¯ã®è‰²ã‚’明るãã™ã‚‹ (ä¸Šè¨˜ã®æ–‡å­—・背景ã®è‰²ã‚’変更ã™ã‚‹æ–‡å­—ã®ç›´å¾Œã§ã®ã¿æœ‰åй) +d+:: 文字ã¨èƒŒæ™¯ã®è‰²ã‚’æ¨™æº–çŠ¶æ…‹ã«æˆ»ã™ +s+:: 文字を目立ãŸã›ã‚‹ +u+:: 文字ã«ä¸‹ç·šã‚’引ã +v+:: 文字ã®è‰²ã‚’å転ã•ã›ã‚‹ +b+:: 文字を点滅ã•ã›ã‚‹ +i+:: 文字ã®è‰²ã‚’æš—ãã™ã‚‹ +o+:: 文字を太ã目立ãŸã›ã‚‹ +x+:: 文字を見ãˆãªãã™ã‚‹ +D+:: 色ã¨è£…é£¾ã‚’æ¨™æº–çŠ¶æ…‹ã«æˆ»ã™ -- + 文字ã¨èƒŒæ™¯ã®è‰²ã¯æœ€çµ‚çš„ã«ç«¯æœ«ã«ã‚ˆã£ã¦æ±ºã¾ã‚‹ãŸã‚ã€å®Ÿéš›ã«ã¯ã“ã“ã§æŒ‡å®šã—ãŸè‰²ã¨ç•°ãªã‚‹è‰²ã§è¡¨ç¤ºã•れるã“ã¨ãŒã‚りã¾ã™ã€‚ 入力ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®å³å´ã«è¡¨ç¤ºã•れるプロンプトを指定ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ (dfn:[å³ãƒ—ロンプト])。+PS1+/+PS2+ 変数ã«å¯¾å¿œã™ã‚‹å³ãƒ—ロンプト㯠link:params.html#sv-ps1r[+PS1R+]/link:params.html#sv-ps2r[+PS2R+] å¤‰æ•°ã§æŒ‡å®šã—ã¾ã™ã€‚ ã¾ãŸã€ãƒ—ロンプトã®ãƒ•ォントã ã‘ã§ãªãã€å…¥åŠ›ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ォントを変ãˆã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚link:params.html#sv-ps1s[+PS1S+] (ã¾ãŸã¯ link:params.html#sv-ps2s[+PS2S+]) 変数ã«ä¸Šè¿°ã®ãƒ•ォントを指定ã™ã‚‹ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã‚’指定ã™ã‚‹ã“ã¨ã§ã€ã‚³ãƒžãƒ³ãƒ‰å…¥åŠ›æ™‚ã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ォントãŒå¤‰ã‚りã¾ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ãªã„ã¨ãã¯ã€ãƒ—ロンプトを出ã™å‰ã« link:params.html#sv-prompt_command[+PROMPT_COMMAND+ 変数]ã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®Ÿè¡Œã•れã¾ã™ã€‚ [[history]] == コマンド履歴 dfn:[コマンド履歴]ã¯å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’記録ã—後ã§å†ã³å®Ÿè¡Œã™ã‚‹ã“ã¨ã®ã§ãる機能ã§ã™ã€‚対話モードã§ã‚·ã‚§ãƒ«ãŒèª­ã¿è¾¼ã‚“ã ã‚³ãƒžãƒ³ãƒ‰ã¯è‡ªå‹•çš„ã«ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã™ã€‚履歴ã«è¨˜éŒ²ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã¯link:lineedit.html[行編集]ã§å‘¼ã³å‡ºã—ã¦å†å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸ link:_fc.html[fc]・link:_history.html[history] 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å±¥æ­´ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ãŸã‚Šç·¨é›†ã—ãŸã‚Šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ コマンドã¯è¡Œå˜ä½ã§å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã™ã€‚ç©ºç™½ä»¥å¤–ã®æ–‡å­—を一切å«ã¾ãªã„行ã¯å±¥æ­´ã«ã¯è¨˜éŒ²ã•れã¾ã›ã‚“。ã¾ãŸ link:_set.html#so-histspace[hist-space オプション]ãŒæœ‰åйãªã¨ãã¯ç©ºç™½ã§å§‹ã¾ã‚‹è¡Œã¯å±¥æ­´ã«è¨˜éŒ²ã•れã¾ã›ã‚“。 コマンド履歴ã®å†…容㯠link:params.html#sv-histfile[+HISTFILE+ 変数]ã§æŒ‡å®šã•れるファイルã«ä¿å­˜ã•れã¾ã™ã€‚対話モードã®ã‚·ã‚§ãƒ«ã®èµ·å‹•後ã«å±¥æ­´é–¢é€£ã®æ©Ÿèƒ½ãŒåˆã‚ã¦ä½¿ç”¨ã•れるã¨ãã€+HISTFILE+ 変数ã®å€¤ã‚’ファイルåã¨ã¿ãªã—ã¦ãƒ•ァイルを開ãã¾ã™ã€‚æ—¢ã«ãƒ•ァイルã«å±¥æ­´ãƒ‡ãƒ¼ã‚¿ãŒä¿å­˜ã•れã¦ã„ã‚‹å ´åˆã¯ã€ãれãŒèª­ã¿è¾¼ã¾ã‚Œã¾ã™ã€‚ファイルãŒå­˜åœ¨ã—ãªã„ã‹å†…容ãŒå±¥æ­´ãƒ‡ãƒ¼ã‚¿ã§ã¯ãªã„å ´åˆã¯ã€æ–°ã—ã„履歴ファイルã«åˆæœŸåŒ–ã•れã¾ã™ã€‚+HISTFILE+ 変数ãŒå­˜åœ¨ã—ãªã„å ´åˆã‚„ファイルを開ãã“ã¨ãŒã§ããªã„å ´åˆã¯å±¥æ­´ã¯ãƒ•ァイルã«ä¿å­˜ã•れã¾ã›ã‚“ãŒã€å±¥æ­´æ©Ÿèƒ½è‡ªä½“ã¯ä½¿ç”¨ã§ãã¾ã™ã€‚ シェルãŒè¨˜éŒ²ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®æ•°ã¯ link:params.html#sv-histsize[+HISTSIZE+ 変数]ã§æŒ‡å®šã—ã¾ã™ã€‚履歴ã®ä»¶æ•°ãŒã“ã®å¤‰æ•°ã®å€¤ã‚’è¶…ãˆã‚‹ã¨é †æ¬¡å¤ã„データã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®å¤‰æ•°ãŒå­˜åœ¨ã—ãªã„å ´åˆã¾ãŸã¯å€¤ãŒè‡ªç„¶æ•°ã§ãªã„å ´åˆã¯ã€å±¥æ­´ã¯ 500 ä»¶ã¾ã§è¨˜éŒ²ã•れã¾ã™ã€‚ +HISTFILE+ ãŠã‚ˆã³ +HISTSIZE+ 変数ã¯å±¥æ­´æ©Ÿèƒ½ãŒåˆã‚ã¦ä½¿ç”¨ã•れるã¨ãã«ã®ã¿å‚ç…§ã•れã€ãれ以é™ã¯å¤‰æ•°ã‚’å†è¨­å®šã—ã¦ã‚‚履歴機能ã®å‹•作ã«å½±éŸ¿ã—ã¾ã›ã‚“。履歴機能ãŒåˆ©ç”¨ã•れるã¨ãã¨ã„ã†ã®ã¯ã€å…·ä½“çš„ã«ã¯ä»¥ä¸‹ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã§ã™ã€‚ - link:_fc.html[Fc] ã¾ãŸã¯ link:_history.html[history] 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ãŸã¨ã - link:lineedit.html[行編集]を使用ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’入力ã™ã‚‹ã¨ã (履歴データを行編集ã®ä¸­ã§ä½¿ã‚ãªãã¦ã‚‚履歴機能ã¯ä½¿ã‚れã¾ã™) - 入力ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒå±¥æ­´ã«ç™»éŒ²ã•れるã¨ã ã“ã®ãŸã‚ +HISTFILE+ ãŠã‚ˆã³ +HISTSIZE+ 変数ã¯åŽŸå‰‡ã¨ã—ã¦link:invoke.html#init[シェルã®èµ·å‹•時]ã«èª­ã¿è¾¼ã¾ã‚Œã‚‹åˆæœŸåŒ–スクリプトã®ä¸­ã§è¨­å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ 複数ã®ã‚·ã‚§ãƒ«ãƒ—ロセスãŒåŒã˜å±¥æ­´ãƒ•ァイルを使用ã—ã¦ã„ã‚‹å ´åˆã€ã“れらã®ã‚·ã‚§ãƒ«ã¯ä¸€ã¤ã®å±¥æ­´ãƒ‡ãƒ¼ã‚¿ã‚’共有ã—ã¾ã™ã€‚ã“ã®ã¨ã例ãˆã°ã‚るシェルプロセスã§å®Ÿè¡Œã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’別ã®ã‚·ã‚§ãƒ«ãƒ—ロセスã§å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚åŒã˜å±¥æ­´ã‚’使用ã—ã¦ã„るシェルã®é–“ã§ +HISTSIZE+ ãŒç•°ãªã£ã¦ã„ã‚‹ã¨å±¥æ­´ãŒæ­£ã—ã共有ã•れãªã„ã®ã§ã€+HISTSIZE+ ã®å€¤ã¯çµ±ä¸€ã™ã‚‹ã‚ˆã†ã«ã—ã¦ãã ã•ã„。 Yash ã¯ç‹¬è‡ªã®å½¢å¼ã®å±¥æ­´ãƒ•ァイルを使用ã—ã¦ã„ã‚‹ãŸã‚ã€å±¥æ­´ãƒ•ァイルを他ã®ç¨®é¡žã®ã‚·ã‚§ãƒ«ã¨å…±ç”¨ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。 履歴ã«åŒã˜ã‚³ãƒžãƒ³ãƒ‰ã‚’記録ã™ã‚‹ç„¡é§„を解消ã™ã‚‹ãŸã‚ã€link:params.html#sv-histrmdup[+HISTRMDUP+ 変数]を使用ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚æ–°ã—ãコマンドを履歴ã«è¨˜éŒ²ã—よã†ã¨ã™ã‚‹éš›ã€ã™ã§ã«åŒã˜ã‚³ãƒžãƒ³ãƒ‰ãŒæœ€è¿‘ã® {{$HISTRMDUP}} ä»¶ã®å±¥æ­´ãƒ‡ãƒ¼ã‚¿ã®ä¸­ã«è¨˜éŒ²ã•れã¦ã„れã°ã€ãã®æ—¢ã«è¨˜éŒ²ã•れã¦ã„るコマンドã¯å±¥æ­´ã‹ã‚‰å‰Šé™¤ã•れã¾ã™ã€‚ [[mailcheck]] == メールãƒã‚§ãƒƒã‚¯ 対話モードã®ã‚·ã‚§ãƒ«ã«ã¯ã€é›»å­ãƒ¡ãƒ¼ãƒ«ãŒå±Šã„ãŸã‚‰ãれを知らã›ã‚‹æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚ã“ã‚Œã¯æ‰€å®šã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚を調ã¹ã¦ã€æ›´æ–°æ—¥æ™‚ãŒå¤‰ã‚ã£ã¦ã„ãŸã‚‰ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’表示ã™ã‚‹ã¨ã„ã†ã‚‚ã®ã§ã™ã€‚å—ä¿¡ã—ãŸãƒ¡ãƒ¼ãƒ«ã®ãƒ‡ãƒ¼ã‚¿ãŒä¿å­˜ã•れるファイルをãƒã‚§ãƒƒã‚¯å¯¾è±¡ã¨ã—ã¦æŒ‡å®šã—ã¦ãŠãã“ã¨ã§ã€ãƒ¡ãƒ¼ãƒ«ã‚’å—ä¿¡ã—ãŸã¨ãã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒè¡¨ç¤ºã•れるよã†ã«ãªã‚Šã¾ã™ã€‚ ファイル更新ã®ãƒã‚§ãƒƒã‚¯ã¯ã‚·ã‚§ãƒ«ãŒãƒ—ロンプトを出ã™ç›´å‰ã«è¡Œã„ã¾ã™ã€‚ãƒã‚§ãƒƒã‚¯ã‚’行ã†é–“隔を link:params.html#sv-mailcheck[+MAILCHECK+ 変数]ã§æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã®å¤‰æ•°ã§æŒ‡å®šã—ãŸç§’æ•°ãŒçµŒéŽã™ã‚‹ã”ã¨ã«ã€ã‚·ã‚§ãƒ«ã¯ãƒ—ロンプトを出ã™ç›´å‰ã«ãƒã‚§ãƒƒã‚¯ã‚’行ã„ã¾ã™ã€‚ã“ã®å¤‰æ•°ã®å€¤ãŒ 0 ã«ãªã£ã¦ã„ã‚‹å ´åˆã¯ã€ãƒ—ロンプトを出ã™ç›´å‰ã«æ¯Žå›žãƒã‚§ãƒƒã‚¯ã‚’行ã„ã¾ã™ã€‚ã¾ãŸå¤‰æ•°ã®å€¤ãŒ 0 ä»¥ä¸Šã®æ•´æ•°ã§ãªã„å ´åˆã¯ã€ãƒã‚§ãƒƒã‚¯ã¯ä¸€åˆ‡è¡Œã„ã¾ã›ã‚“。 更新日時をãƒã‚§ãƒƒã‚¯ã™ã‚‹å¯¾è±¡ã®ãƒ•ァイル㯠link:params.html#sv-mail[+MAIL+ 変数]ã§æŒ‡å®šã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã«ãƒã‚§ãƒƒã‚¯ã—ãŸã„ファイルã®ãƒ‘スåを指定ã—ã¦ãŠãã¨ã€ã‚·ã‚§ãƒ«ã¯ãã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚ã‚’ãƒã‚§ãƒƒã‚¯ã—ã¾ã™ã€‚ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚ãŒå‰å›žãƒã‚§ãƒƒã‚¯ã—ãŸã¨ãã¨å¤‰ã‚ã£ã¦ã„ãŸã‚‰ã€æ–°ç€ãƒ¡ãƒ¼ãƒ«ã‚’知らã›ã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’標準エラーã«å‡ºåŠ›ã—ã¾ã™ã€‚(ãŸã ã—ファイルãŒç©ºã®ã¨ãã¯ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¯å‡ºã¾ã›ã‚“ (link:posix.html[POSIX 準拠モード]ã®ã¨ãを除ã)) 複数ã®ãƒ•ァイルをãƒã‚§ãƒƒã‚¯ã®å¯¾è±¡ã«ã—ãŸã„å ´åˆã‚„ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’è‡ªåˆ†ã§æŒ‡å®šã—ãŸã„å ´åˆã¯ã€+MAIL+ 変数ã®ä»£ã‚り㫠link:params.html#sv-mailpath[+MAILPATH+ 変数]を使ã†ã“ã¨ãŒã§ãã¾ã™ã€‚+MAILPATH+ 変数ãŒè¨­å®šã•れã¦ã„ã‚‹å ´åˆã¯ã€+MAIL+ 変数ã®è¨­å®šã¯ç„¡è¦–ã•れã¾ã™ã€‚+MAILPATH+ 変数ã®å€¤ã«ã¯ã€ä¸€ã¤ä»¥ä¸Šã®ãƒ•ァイルã®ãƒ‘スåをコロン (+:+) ã§åŒºåˆ‡ã£ã¦æŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚·ã‚§ãƒ«ã¯æ¯Žå›žã®ãƒã‚§ãƒƒã‚¯ã§ãれãžã‚Œã®ãƒ•ã‚¡ã‚¤ãƒ«ã®æ›´æ–°æ—¥æ™‚を調ã¹ã€ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ›´æ–°ã•れã¦ã„ãŸã‚‰ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’表示ã—ã¾ã™ã€‚ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’è‡ªåˆ†ã§æŒ‡å®šã™ã‚‹ã«ã¯ã€ãƒ‘スåã®ç›´å¾Œã«ãƒ‘ーセント (+%+) ã‚’ç½®ãã€ç¶šã‘ã¦è¡¨ç¤ºã•ã›ãŸã„メッセージを置ãã¾ã™ã€‚ãれãžã‚Œã®ãƒ•ァイルã”ã¨ã«ç•°ãªã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚(パーセントをパスåã¨ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¨ã®åŒºåˆ‡ã‚Šã§ã¯ãªãパスåã®ä¸€éƒ¨ã¨ã—ãŸã„å ´åˆã¯ãƒ‘ーセントをãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§link:syntax.html#quotes[クォート]ã—ã¦ãã ã•ã„) パーセントã®å¾Œã«æŒ‡å®šã•れãŸãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¯ã€è¡¨ç¤ºã®å‰ã«link:expand.html#params[パラメータ展開]ã•れã¾ã™ã€‚ 例ãˆã° +MAILPATH+ 変数ã®å€¤ãŒ `/foo/mail%New mail!:/bar/mailbox%You've got mail:/baz/mail\%data` ã ã¨ã™ã‚‹ã¨ã€ãƒ•ァイル /foo/mail ãŒæ›´æ–°ã•れãŸã¨ã㯠`New mail!` ãŒã€/bar/mailbox ãŒæ›´æ–°ã•れãŸã¨ã㯠`You've got mail` ãŒã€/baz/mail%data ãŒæ›´æ–°ã•れãŸã¨ãã¯ãƒ‡ãƒ•ォルトã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒè¡¨ç¤ºã•れã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_unset.txt0000644000175000017500000000317612154557026015752 0ustar magicantmagicant= Unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Unset 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’削除ã—ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +unset [-fv] [{{åå‰}}...]+ [[description]] == 説明 Unset コマンドã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸåå‰ã®link:params.html#variables[変数]ã¾ãŸã¯link:exec.html#function[関数]を削除ã—ã¾ã™ã€‚ 元々存在ã—ãªã„変数・関数を削除ã—よã†ã¨ã—ã¦ã‚‚ã€ä½•ã‚‚èµ·ã“りã¾ã›ã‚“ (エラーã«ã¯ãªã‚Šã¾ã›ã‚“)。 [[options]] == オプション +-f+:: +--functions+:: 関数を削除ã—ã¾ã™ã€‚ +-v+:: +--variables+:: 変数を削除ã—ã¾ã™ã€‚ +-f+ (+--functions+) オプション㨠+-v+ (+--variables+) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€+-v+ を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ [[operands]] == オペランド {{åå‰}}:: 削除ã™ã‚‹å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã®åå‰ã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š unset コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 Unset コマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ POSIX ã§ã¯ã€+-f+ 㨠+-v+ ã®ã©ã¡ã‚‰ã®ã‚ªãƒ—ションも指定ã•れã¦ã„ãªã„å ´åˆã€æŒ‡å®šã—ãŸåå‰ã®å¤‰æ•°ãŒãªã„å ´åˆã¯ã‹ã‚りã«ãã®åå‰ã®é–¢æ•°ã‚’削除ã—ã¦ã‚ˆã„ã¨è¦å®šã—ã¦ã„ã¾ã™ã€‚ link:posix.html[POSIX 準拠モード]ã§ã¯å°‘ãªãã¨ã‚‚一ã¤{{åå‰}}を指定ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/redir.html0000644000175000017500000004040112154557026015677 0ustar magicantmagicant リダイレクト

リダイレクトã¯ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ•ァイル記述å­ã‚’変更ã™ã‚‹æ©Ÿèƒ½ã§ã™ã€‚リダイレクトを使用ã™ã‚‹ã¨ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–入力や標準出力を通常ã¨ã¯ç•°ãªã‚‹ãƒ•ァイルã«ç¹‹ãŽæ›ãˆãŸçŠ¶æ…‹ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

リダイレクトã¯ã‚³ãƒžãƒ³ãƒ‰ (å˜ç´”コマンドã¾ãŸã¯è¤‡åˆã‚³ãƒžãƒ³ãƒ‰) ã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’付ã™ã‚‹ã“ã¨ã§è¡Œã„ã¾ã™ã€‚å˜ç´”コマンドã§ã¯ (ä»–ã®ãƒˆãƒ¼ã‚¯ãƒ³ã¨ãã£ã¤ã‹ãªã„é™ã‚Š) ã©ã“ã§ã‚‚リダイレクト演算å­ã‚’ç½®ãã“ã¨ãŒã§ãã¾ã™ã€‚複åˆã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã‚³ãƒžãƒ³ãƒ‰ã®æœ€å¾Œã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’付ã‘ã¾ã™ã€‚

リダイレクトã¯ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒå§‹ã¾ã‚‹å‰ã«å‡¦ç†ã•れã¾ã™ã€‚一ã¤ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆãŒã‚ã‚‹å ´åˆã¯ã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ãŒæ›¸ã„ã¦ã‚ã‚‹é †åºã§å‡¦ç†ã•れã¾ã™ã€‚オペランドãªã—ã® exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹å ´åˆã‚’除ãã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯å¯¾è±¡ã¨ãªã£ã¦ã„るコマンドã«å¯¾ã—ã¦ã®ã¿åƒãã¾ã™ã€‚ã™ãªã‚ã¡ã€å¯¾è±¡ã®ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒãŒçµ‚ã‚ã‚‹ã¨ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã«ã‚ˆã£ã¦å¤‰æ›´ã•れãŸãƒ•ァイル記述å­ã¯å…ƒã®çŠ¶æ…‹ã«æˆ»ã‚Šã¾ã™ã€‚

リダイレクト演算å­ã¯ã€< ã¾ãŸã¯ > ã§å§‹ã¾ã‚Šã¾ã™ã€‚< ã§å§‹ã¾ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã¯ãƒ‡ãƒ•ォルトã§ã¯æ¨™æº–入力 (ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ 0) ã«ä½œç”¨ã—ã¾ã™ã€‚> ã§å§‹ã¾ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã¯ãƒ‡ãƒ•ォルトã§ã¯æ¨™æº–出力 (ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ 1) ã«ä½œç”¨ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã®ç¨®é¡žã®æ¼”ç®—å­ã§ã‚‚ã€æ¼”ç®—å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ãƒ‡ãƒ•ォルト以外ã®ãƒ•ァイル記述å­ã«ä½œç”¨ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ (ã“ã®ã¨ãæ•´æ•°ã¨æ¼”ç®—å­ã¨ã®é–“ã«ä¸€åˆ‡ç©ºç™½ãªã©ã‚’入れã¦ã¯ã„ã‘ã¾ã›ã‚“。ã¾ãŸæ•´æ•°ã‚’クォートã—ã¦ã‚‚ã„ã‘ã¾ã›ã‚“)。

ファイルã¸ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ

最もよã使ã‚れるリダイレクトã¯ã€ãƒ•ァイルã¸ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã™ã€‚

入力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ

< トークン

出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ

> トークン

>| トークン

>> トークン

入出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ

<> トークン

リダイレクトã«å«ã¾ã‚Œã‚‹ãƒˆãƒ¼ã‚¯ãƒ³ã¯å››ç¨®å±•é–‹ã•れã¾ã™ã€‚対話シェルã§ã¯ã•らã«ãƒ‘スå展開も行ã‚れã¾ã™ (パスå展開ã®çµæžœãŒä¸€ã¤ã®ãƒ•ァイルã§ãªã‘れã°ã‚¨ãƒ©ãƒ¼ã§ã™)。トークンã®å±•é–‹çµæžœãŒãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆå¯¾è±¡ã®ãƒ•ァイルåã¨ã—ã¦ä½¿ã‚れã¾ã™ã€‚

入力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–入力ãŒå¯¾è±¡ãƒ•ァイルã‹ã‚‰ã®èª­ã¿è¾¼ã¿å°‚用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルを開ãã“ã¨ãŒã§ããªã‘れã°ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚

出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–出力ãŒå¯¾è±¡ãƒ•ァイルã¸ã®æ›¸ãè¾¼ã¿å°‚用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルãŒå­˜åœ¨ã—ãªã‘れã°ç©ºã®é€šå¸¸ãƒ•ァイルãŒä½œæˆã•れã¾ã™ã€‚å¯¾è±¡ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ—¢ã«ã‚ã‚‹å ´åˆã¯ãã®ãƒ•ァイルãŒé–‹ã‹ã‚Œã¾ã™ã€‚ãŸã ã—演算å­ã®ç¨®é¡žã«ã‚ˆã£ã¦ä»¥ä¸‹ã®ã‚ˆã†ã«æŒ™å‹•ãŒç•°ãªã‚Šã¾ã™ã€‚

  • æ¼”ç®—å­ >| ã§ã¯ã€å¯¾è±¡ãƒ•ァイルãŒå­˜åœ¨ã—ãれãŒé€šå¸¸ã®ãƒ•ァイルã®å ´åˆã€ãƒ•ァイルを開ãéš›ã«ãƒ•ァイルã®å†…容を空ã«ã—ã¾ã™ã€‚

  • æ¼”ç®—å­ > ã¯ã€clobber ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åйãªã‚‰ã°æ¼”ç®—å­ >| ã¨åŒã˜ã§ã™ã€‚ã—ã‹ã— clobber オプションãŒç„¡åйãªã‚‰ã°ã€å¯¾è±¡ãƒ•ァイルãŒå­˜åœ¨ã—ãれãŒé€šå¸¸ã®ãƒ•ァイルã®å ´åˆã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã€‚

  • æ¼”ç®—å­ >> ã§ã¯ã€ãƒ•ァイルを追記モードã§é–‹ãã¾ã™ã€‚ファイルã¸ã®æ›¸ãè¾¼ã¿ã¯å¸¸ã«ãƒ•ã‚¡ã‚¤ãƒ«ã®æœ«å°¾ã¸è¿½è¨˜ã™ã‚‹å½¢ã§è¡Œã‚れã¾ã™ã€‚

入出力ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯æ¨™æº–入力ãŒå¯¾è±¡ãƒ•ァイルã¸ã®èª­ã¿æ›¸ã両用ファイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚対象ファイルãŒå­˜åœ¨ã—ãªã‘れã°ç©ºã®é€šå¸¸ãƒ•ァイルãŒä½œæˆã•れã¾ã™ã€‚

ソケットリダイレクト

ファイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã«ãŠã„ã¦ã€å¯¾è±¡ãƒ•ァイルå㌠/dev/tcp/ホストå/ãƒãƒ¼ãƒˆ ã¾ãŸã¯ /dev/udp/ホストå/ãƒãƒ¼ãƒˆ ã®å½¢å¼ã‚’ã—ã¦ã„ã¦ã€ãã®ãƒ•ァイルを開ãã“ã¨ãŒã§ããªã„å ´åˆã€ãƒ•ァイルåã«å«ã¾ã‚Œã‚‹ãƒ›ã‚¹ãƒˆåã¨ãƒãƒ¼ãƒˆã«å¯¾ã—ã¦é€šä¿¡ã‚’行ã†ãŸã‚ã®ã‚½ã‚±ãƒƒãƒˆãŒé–‹ã‹ã‚Œã¾ã™ã€‚

/dev/tcp/ホストå/ãƒãƒ¼ãƒˆ ãŒå¯¾è±¡ã®å ´åˆã¯ã‚¹ãƒˆãƒªãƒ¼ãƒ é€šä¿¡ã‚½ã‚±ãƒƒãƒˆã‚’ã€/dev/udp/ホストå/ãƒãƒ¼ãƒˆ ãŒå¯¾è±¡ã®å ´åˆã¯ãƒ‡ãƒ¼ã‚¿ã‚°ãƒ©ãƒ é€šä¿¡ã‚½ã‚±ãƒƒãƒˆã‚’é–‹ãã¾ã™ã€‚典型的ã«ã¯ã€å‰è€…㯠TCP ã‚’ã€å¾Œè€…㯠UDP をプロトコルã¨ã—ã¦ä½¿ç”¨ã—ã¾ã™ã€‚

ソケットリダイレクトã¯ã©ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ã‚’使ã£ã¦ã„ã‚‹ã‹ã«ã‹ã‹ã‚らãšå¸¸ã«èª­ã¿æ›¸ã両用ã®ãƒ•ァイル記述å­ã‚’é–‹ãã¾ã™ã€‚

ソケットリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚ãŸã ã—ã€bash ã«ã‚‚åŒæ§˜ã®æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚

ファイル記述å­ã®è¤‡è£½

ファイル記述å­ã®è¤‡è£½ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã§ã¯ã€æ—¢å­˜ã®ãƒ•ァイル記述å­ã‚’コピーã—ãŸã‚Šé–‰ã˜ãŸã‚Šã§ãã¾ã™ã€‚

ファイル記述å­ã®è¤‡è£½

<& トークン

>& トークン

トークンã¯ãƒ•ァイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ãŒã€ã“れã¯ãƒ•ァイルåã§ã¯ãªãファイル記述å­ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹çµæžœã¯ãƒ•ァイル記述å­ã‚’表ã™éžè² æ•´æ•°ã¨ãªã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚

æ¼”ç®—å­ <& ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ã‚’標準入力ã«è¤‡è£½ã—ã¾ã™ã€‚æ¼”ç®—å­ >& ã¯ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ã‚’標準出力ã«è¤‡è£½ã—ã¾ã™ã€‚演算å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ã€è¤‡è£½å…ˆã®ãƒ•ァイル記述å­ã‚’変更ã§ãã¾ã™ã€‚

トークンã®å±•é–‹çµæžœãŒéžè² æ•´æ•°ã§ã¯ãªããƒã‚¤ãƒ•ン (-) ã¨ãªã£ãŸå ´åˆã¯ã€ãƒ•ァイル記述å­ã‚’複製ã™ã‚‹ä»£ã‚りã«é–‰ã˜ã¾ã™ã€‚æ¼”ç®—å­ <& ã§ã¯æ¨™æº–入力ãŒã€æ¼”ç®—å­ >& ã§ã¯æ¨™æº–出力ãŒãƒ‡ãƒ•ォルトã§é–‰ã˜ã‚‰ã‚Œã¾ã™ãŒã€æ¼”ç®—å­ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã™ã‚‹ã“ã¨ã§ã€é–‰ã˜ã‚‹ãƒ•ァイル記述å­ã‚’変更ã§ãã¾ã™ã€‚

POSIX 準拠モードã§ã¯ã€<& ã§è¤‡è£½ã™ã‚‹ãƒ•ァイル記述å­ã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ãªã‘れã°ãªã‚‰ãšã€>& ã§è¤‡è£½ã™ã‚‹ãƒ•ァイル記述å­ã¯æ›¸ãè¾¼ã¿å¯èƒ½ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。

ヒアドキュメントã¨ãƒ’アストリング

ヒアドキュメント・ヒアストリングを使ã†ã¨ã‚³ãƒžãƒ³ãƒ‰ã«ç›´æŽ¥ãƒ†ã‚­ã‚¹ãƒˆã‚’渡ã™ã“ã¨ãŒã§ãã¾ã™ã€‚

ヒアドキュメント

<< トークン

<<- トークン

ヒアストリング

<<< トークン

ヒアドキュメント・ヒアストリングã§ã¯ã€æ¨™æº–入力ãŒãƒ’アドキュメント・ヒアストリングã®å†…容を読ã¿è¾¼ã¿å¯èƒ½ãªãƒ•ァイル記述å­ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ã€‚

ãƒ’ã‚¢ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆæ¼”ç®—å­ (<< ã¾ãŸã¯ <<-) ãŒã‚³ãƒžãƒ³ãƒ‰ä¸­ã«ç¾ã‚Œã‚‹ã¨ã€ãã®æ¼”ç®—å­ã®ã‚ã‚‹è¡Œã®æ¬¡ã®è¡Œã‹ã‚‰ã¯ãƒ’アドキュメントã®å†…容ã¨ã¿ãªã•れã¾ã™ã€‚ヒアドキュメントã®å†…容ã®éƒ¨åˆ†ã¯ã€ã‚·ã‚§ãƒ«ã®ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦ã¯è§£é‡ˆã•れã¾ã›ã‚“。演算å­ã®å¾Œã«ã‚るトークンã¯ãƒ’アドキュメントã®å†…容ã®çµ‚ã‚りを表ã—ã¾ã™ã€‚(トークンã§ã¯å±•é–‹ã¯è¡Œã‚れã¾ã›ã‚“ãŒã€ã‚¯ã‚©ãƒ¼ãƒˆã¯èªè­˜ã•れã¾ã™ã€‚) 演算å­ã®ã‚る行より後ã®è¡Œã§ãƒˆãƒ¼ã‚¯ãƒ³ã ã‘ã‹ã‚‰ãªã‚‹è¡ŒãŒç¾ã‚ŒãŸæ™‚点ã§ãƒ’アドキュメントã®å†…容ã¯çµ‚ã‚りã ã¨åˆ¤æ–­ã•れã¾ã™ã€‚終ã‚りを表ã™è¡Œã¯ãƒ’アドキュメントã®å†…容ã«ã¯å«ã¾ã‚Œã¾ã›ã‚“ã€‚æ¼”ç®—å­ <<- を使ã£ã¦ã„ã‚‹å ´åˆã¯ã€ãƒ’アドキュメントã®å†…容ã®å„行頭ã«ã‚るタブã¯ã™ã¹ã¦å‰Šé™¤ã•れã¾ã™ã€‚ã“ã®ã¨ãトークンã®å‰ã«ã‚¿ãƒ–ãŒã‚ã£ã¦ã‚‚ (ãã®è¡Œã«ä»–ã®ä½™è¨ˆãªæ–‡å­—ãŒãªã‘れã°) ヒアドキュメントã®å†…容ã®çµ‚ã‚りã¨ã—ã¦èªè­˜ã—ã¾ã™ã€‚

一行ã®ã‚³ãƒžãƒ³ãƒ‰ã«è¤‡æ•°ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ãŒã‚ã‚‹å ´åˆã¯ã€ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¯é †ç•ªã«å‡¦ç†ã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãã®è¡Œã®æ¬¡ã®è¡Œã‹ã‚‰ã¯æœ€åˆã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¨ã—ã¦æ‰±ã‚れã€ãã®å†…容ãŒçµ‚ã‚ã£ãŸã‚‰ã€ãã®æ¬¡ã®è¡Œã‹ã‚‰ã¯æ¬¡ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚最後ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å†…容ãŒçµ‚ã‚ã£ãŸã‚‰ã€ãã®æ¬¡ã®è¡Œã‹ã‚‰ã¯å†ã³ã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚

リダイレクトã®å†…容ã¯åŸºæœ¬çš„ã«å˜ãªã‚‹æ–‡å­—列ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚内容ã«å«ã¾ã‚Œã‚‹ç©ºç™½ã‚„タブã€ãã®ä»–ã®è¨˜å·ã¯ãã®ã¾ã¾ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã•れã¾ã™ã€‚ãŸã ã—ã€ãƒˆãƒ¼ã‚¯ãƒ³ãŒå…¨ãクォートã•れã¦ã„ãªã„å ´åˆã¯ã€ãƒ’アドキュメントã®å†…容ã¯ãƒ‘ラメータ展開・コマンド置æ›ãƒ»æ•°å¼å±•é–‹ã•れã€$, `, ", \ ã®ç›´å‰ã«ã‚ã‚‹å ´åˆãŠã‚ˆã³è¡Œã®é€£çµã‚’行ã†å ´åˆã«ã®ã¿ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã‚’引用符ã¨ã—ã¦æ‰±ãˆã¾ã™ã€‚

ヒアストリングã§ã¯ã€æ¼”ç®—å­ã®å¾Œã«ã‚るトークンã¯ãƒ•ァイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ã€‚ã“ã®å±•é–‹çµæžœãŒãƒ’アストリングã®å†…容ã¨ãªã‚Šã¾ã™ã€‚ãŸã ã—ヒアストリングã®å†…å®¹ã®æœ«å°¾ã«ã¯è‡ªå‹•çš„ã«æ”¹è¡ŒãŒä»˜ãã¾ã™ã€‚

ヒアストリング㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ãŒã€bash, ksh, zsh ã«ã‚‚åŒæ§˜ã®æ©Ÿèƒ½ãŒã‚りã¾ã™ã€‚

パイプリダイレクト

パイプリダイレクトを用ã„ã‚‹ã¨ãƒ—ロセス間通信ã«åˆ©ç”¨å¯èƒ½ãªãƒ‘イプを開ãã“ã¨ãŒã§ãã¾ã™ã€‚

パイプリダイレクト

>>| トークン

トークンã¯ãƒ•ァイルã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å ´åˆã¨åŒæ§˜ã«å±•é–‹ã•れã¾ã™ãŒã€ã“れã¯ãƒ•ァイルåã§ã¯ãªãファイル記述å­ã¨ã—ã¦è§£é‡ˆã•れã¾ã™ã€‚ã™ãªã‚ã¡ã€ãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹çµæžœã¯ãƒ•ァイル記述å­ã‚’表ã™éžè² æ•´æ•°ã¨ãªã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚

パイプリダイレクトã¯ãƒ‘イプを開ãã¾ã™ã€‚標準出力 (æ¼”ç®—å­ >>| ã®ç›´å‰ã«éžè² æ•´æ•°ã‚’指定ã—ã¦ã„ã‚‹å ´åˆã¯ãã®å€¤ã®ãƒ•ァイル記述å­) ãŒãƒ‘ã‚¤ãƒ—ã«æ›¸ãã“ã‚€ãŸã‚ã®ãƒ•ァイル記述å­ã«ãªã‚Šã¾ã™ã€‚ã¾ãŸãƒˆãƒ¼ã‚¯ãƒ³ã®å±•é–‹çµæžœã§ç¤ºã•れãŸãƒ•ァイル記述å­ãŒãƒ‘イプã‹ã‚‰èª­ã¿è¾¼ã‚€ãŸã‚ã®ãƒ•ァイル記述å­ã«ãªã‚Šã¾ã™ã€‚

パイプリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚

プロセスリダイレクト

プロセスリダイレクトを用ã„ã‚‹ã¨åˆ¥ã®ã‚³ãƒžãƒ³ãƒ‰ã®å…¥åŠ›ã¾ãŸã¯å‡ºåŠ›ã‚’å—ã‘æ¸¡ã›ã‚‹ãƒ‘イプを開ãã“ã¨ãŒã§ãã¾ã™ã€‚

プロセスリダイレクト

<(サブコマンド…)

>(サブコマンド…)

プロセスリダイレクトã§ã¯ã€ã‚µãƒ–コマンドãŒã‚µãƒ–シェルã§å®Ÿè¡Œã•れã¾ã™ã€‚ã“ã®ã¨ãã€<(サブコマンド…) ã®å½¢å¼ã®ãƒ—ロセスリダイレクトã§ã¯ã€ã‚µãƒ–ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ãŒã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å…¥åŠ›ã«æ¸¡ã‚‹ã‚ˆã†ãƒ‘イプãŒé–‹ã‹ã‚Œã¾ã™ã€‚>(サブコマンド…) ã®å½¢å¼ã®ãƒ—ロセスリダイレクトã§ã¯ã€ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–出力ãŒã‚µãƒ–ã‚³ãƒžãƒ³ãƒ‰ã®æ¨™æº–å…¥åŠ›ã«æ¸¡ã‚‹ã‚ˆã†ãƒ‘イプãŒé–‹ã‹ã‚Œã¾ã™ã€‚

プロセスリダイレクト㯠POSIX è¦æ ¼ã«ã¯ãªã„ yash ã®ç‹¬è‡ªæ‹¡å¼µã§ã™ã€‚Bash 㨠zsh ã«ã¯ãƒ—ロセスリダイレクトã¨åŒæ§˜ã®æ§‹æ–‡ã‚’用ã„るプロセス置æ›ã¨ã„ã†æ©Ÿèƒ½ãŒã‚りã¾ã™ãŒã€ãƒ—ロセスリダイレクトã¨ãƒ—ロセス置æ›ã®æŒ™å‹•ã¯ç•°ãªã£ã¦ãŠã‚Šã€äº’æ›æ€§ã¯ã‚りã¾ã›ã‚“。

yash-2.35/doc/ja/_break.html0000644000175000017500000000714112154557026016021 0ustar magicantmagicant Break 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Break 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯å®Ÿè¡Œä¸­ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚

æ§‹æ–‡

  • break [æ·±ã•]

  • break -i

説明

-i (--iteration) オプションを付ã‘ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€break コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã® for ループã¾ãŸã¯ while ループã¾ãŸã¯ until ループを中断ã—ã¾ã™ã€‚多é‡ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§å®Ÿè¡Œã—ãŸå ´åˆã€å†…å´ã‹ã‚‰æ•°ãˆã¦æ·±ã•番目ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚æ·±ã•ãŒæŒ‡å®šã•れã¦ã„ãªã„ã¨ãã¯ã€æœ€ã‚‚内å´ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ (深㕠= 1)。指定ã•ã‚ŒãŸæ·±ã•ãŒå®Ÿéš›ã«å®Ÿè¡Œã—ã¦ã„る多é‡ãƒ«ãƒ¼ãƒ—ã®æ·±ã•より大ãã„å ´åˆã¯æœ€ã‚‚外å´ã®ãƒ«ãƒ¼ãƒ—を中断ã—ã¾ã™ã€‚

-i (--iteration) オプションを付ã‘ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€break コマンドã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®å復実行を中断ã—ã¾ã™ã€‚

オプション

-i
--iteration

ループã§ã¯ãªãå復実行を中断ã—ã¾ã™ã€‚

オペランド

nest

内å´ã‹ã‚‰ä½•番目ã®ãƒ«ãƒ¼ãƒ—を中断ã™ã‚‹ã®ã‹ã‚’指定ã™ã‚‹ 1 以上ã®è‡ªç„¶æ•°ã§ã™ã€‚

終了ステータス

ループã®ä¸­æ–­ã«æˆåŠŸã™ã‚‹ã¨çµ‚了ステータス㯠0 ã§ã™ã€‚å復実行ã®ä¸­æ–­ã«æˆåŠŸã™ã‚‹ã¨ break コマンドã®ç›´å‰ã«å®Ÿè¡Œã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®çµ‚了ステータス㌠break コマンドã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚

補足

Break コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ -i (--interact) オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã“ã®ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/_cd.html0000644000175000017500000001444112154557026015324 0ustar magicantmagicant Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Cd 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã—ã¾ã™ã€‚

æ§‹æ–‡

  • cd [-L|-P] [ディレクトリ]

説明

Cd コマンドã¯ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«å¤‰æ›´ã—ã¾ã™ã€‚æ–°ã—ã„作業ディレクトリã«å¿œã˜ã¦ PWD 変数ã®å€¤ãŒå†è¨­å®šã•れるã¨ã¨ã‚‚ã«ã€å‰ã® PWD 変数ã®å€¤ãŒ OLDPWD 変数ã«è¨­å®šã•れã¾ã™ã€‚

指定ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒç›¸å¯¾ãƒ‘スã®å ´åˆ (最åˆãŒ . ã¾ãŸã¯ .. ã§å§‹ã¾ã‚‹ã‚‚ã®ã‚’除ã)ã€ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ã«ãŠã‘ã‚‹ PATH å¤‰æ•°ã®æ¤œç´¢ã¨åŒæ§˜ã«ã—ã¦ã€CDPATH 変数ã®å€¤ã«ã‚るコロンã§åŒºåˆ‡ã£ãŸå„ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªå†…ã«æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒã‚ã‚‹ã‹ã©ã†ã‹èª¿ã¹ã¾ã™ã€‚ディレクトリãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¯ã€ãã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒæ–°ã—ã„作業ディレクトリã«ãªã‚Šã¾ã™ã€‚見ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã¯ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘スã¨ãªã‚Šã¾ã™ã€‚

CDPATH å¤‰æ•°ã®æ¤œç´¢ã§æ–°ã—ã„作業ディレクトリãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¾ãŸã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¨ã—㦠- ãŒæŒ‡å®šã•れãŸå ´åˆã¯æ–°ã—ã„作業ディレクトリã®ãƒ‘スを標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚

作業ディレクトリã®å¤‰æ›´ã«æˆåŠŸã—ãŸå ´åˆã€YASH_AFTER_CD 変数ãŒè¨­å®šã•れã¦ã„れã°ãã®å€¤ãŒã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦è§£é‡ˆãƒ»å®Ÿè¡Œã•れã¾ã™ (éž POSIX 準拠モード時)。

オプション

-L
--logical

ディレクトリパスã«å«ã¾ã‚Œã‚‹ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’解決ã›ãšã«æ–°ã—ã„作業ディレクトリを決定ã—ã¾ã™ã€‚æ–°ã—ã„ PWD 変数ã®å€¤ã«ã¯ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã«ãªã£ã¦ã„るパスåコンãƒãƒ¼ãƒãƒ³ãƒˆãŒãã®ã¾ã¾æ®‹ã‚Šã¾ã™ã€‚

-P
--physical

ディレクトリパスã«å«ã¾ã‚Œã‚‹ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’解決ã—ã¾ã™ã€‚æ–°ã—ã„ PWD 変数ã®å€¤ã¯ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’å«ã¿ã¾ã›ã‚“。

--default-directory=ディレクトリ

ディレクトリオペランドãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã¯ã€ä»£ã‚りã«ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’æ–°ã—ã„作業ディレクトリã¨ã—ã¾ã™ã€‚

-L (--logical) オプション㨠-P (--physical) オプションã®ä¸¡æ–¹ã‚’指定ã—ãŸå ´åˆã€å¾Œã«æŒ‡å®šã—ãŸã»ã†ã‚’優先ã—ã¾ã™ã€‚ã©ã¡ã‚‰ã‚‚指定ã—ã¦ã„ãªã„å ´åˆã¯ã€-L を指定ã—ãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚

オペランド

ディレクトリ

æ–°ã—ã„作業ディレクトリã®ãƒ‘スåã§ã™ã€‚絶対パスã¾ãŸã¯å…ƒã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‹ã‚‰ã®ç›¸å¯¾ãƒ‘ã‚¹ã§æŒ‡å®šã—ã¾ã™ã€‚

ã“ã®å€¤ãŒãƒã‚¤ãƒ•ン一㤠(「-ã€) ã®å ´åˆã€OLDPWD 変数ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ã€‚ã“ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ãªã„å ´åˆã€HOME 変数ã®å€¤ãŒæŒ‡å®šã•れãŸã‚‚ã®ã¨ã¿ãªã—ã¾ã™ (--default-directory オプションを指定ã—ãŸå ´åˆã‚’除ã)。

終了ステータス

作業ディレクトリを正ã—ã変更ã§ããŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚エラーãŒã‚ã‚‹ã¨çµ‚了ステータスã¯éž 0 ã§ã™ã€‚

補足

Cd ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ YASH_AFTER_CD 変数ãŠã‚ˆã³ --default-directory=… オプションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。POSIX ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¨ã—ã¦ãƒã‚¤ãƒ•ン一ã¤ã‚’指定ã—ãŸã¨ãã« -L ã¾ãŸã¯ -P オプションを併用ã™ã‚‹ã“ã¨ã‚’èªã‚ã¦ã„ã¾ã›ã‚“。

YASH_AFTER_CD 変数ã®å®Ÿè¡Œçµæžœã¯ cd コマンドã®çµ‚了ステータスã«ã¯å½±éŸ¿ã—ã¾ã›ã‚“。

yash-2.35/doc/ja/_times.html0000644000175000017500000000414712154557026016061 0ustar magicantmagicant Times 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Times 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã¨ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒæ¶ˆè²»ã—㟠CPU 時間を表示ã—ã¾ã™ã€‚

æ§‹æ–‡

  • times

説明

Times コマンドã¯ã‚·ã‚§ãƒ«ãƒ—ロセスã¨ãã®å­ãƒ—ãƒ­ã‚»ã‚¹ãŒæ¶ˆè²»ã—㟠CPU 時間を標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚一行目ã«ã‚·ã‚§ãƒ«ãƒ—ロセス自身ãŒãƒ¦ãƒ¼ã‚¶ãƒ¢ãƒ¼ãƒ‰ãŠã‚ˆã³ã‚·ã‚¹ãƒ†ãƒ ãƒ¢ãƒ¼ãƒ‰ã§æ¶ˆè²»ã—㟠CPU 時間をãれãžã‚Œè¡¨ç¤ºã—ã¾ã™ã€‚二行目ã«ã‚·ã‚§ãƒ«ã®å…¨ã¦ã®å­å­«ãƒ—ロセス (親プロセス㌠wait ã—ã¦ã„ãªã„ã‚‚ã®ã‚’除ã) ãŒãƒ¦ãƒ¼ã‚¶ãƒ¢ãƒ¼ãƒ‰ãŠã‚ˆã³ã‚·ã‚¹ãƒ†ãƒ ãƒ¢ãƒ¼ãƒ‰ã§æ¶ˆè²»ã—㟠CPU 時間をãれãžã‚Œè¡¨ç¤ºã—ã¾ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š times コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Times コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

yash-2.35/doc/ja/_colon.txt0000644000175000017500000000174212154557026015723 0ustar magicantmagicant= コロン組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - コロン組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[コロン組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯ä½•も行ã‚ãªã„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +: [{{引数}}...]+ [[description]] == 説明 コロンコマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚ [[exitstatus]] == 終了ステータス コロンコマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 コロンコマンドã¯link:builtin.html#types[特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã§ã™ã€‚ 引数ã®link:expand.html[展開]ã¨link:redir.html[リダイレクト]ã¯ä»–ã®ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«è¡Œã„ã¾ã™ã€‚ link:_true.html[True コマンド]ã¯ã‚³ãƒ­ãƒ³ã‚³ãƒžãƒ³ãƒ‰ã¨åŒæ§˜ã«ä½•も行ã„ã¾ã›ã‚“ãŒã€ã‚³ãƒ­ãƒ³ã‚³ãƒžãƒ³ãƒ‰ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ã‚‹ã®ã«å¯¾ã— true ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_complete.txt0000644000175000017500000001462412154557026016424 0ustar magicantmagicant= Complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:lineedit.html#completion[コマンドライン補完]ã«ãŠã„ã¦è£œå®Œå€™è£œã‚’生æˆã—ã¾ã™ã€‚ã“ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯è£œå®Œé–¢æ•°ã®å®Ÿè¡Œä¸­ã«ã ã‘使ãˆã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +complete [-A {{パターン}}] [-R {{パターン}}] [-T] [-P {{接頭辞}}] [-S {{接尾辞}}] [-abcdfghjkuv] [[-O] [-D {{説明}}] {{å˜èªž}}...]+ [[description]] == 説明 補完関数ã®ä¸­ã§ã“ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã¨ã€complete ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸå¼•æ•°ã«å¾“ã£ã¦è£œå®Œå€™è£œã‚’生æˆã—ã¾ã™ã€‚ã©ã®ã‚ªãƒ—ション・オペランドã§å€™è£œã‚’生æˆã™ã‚‹ã«ã›ã‚ˆã€å®Ÿéš›ã«ç”Ÿæˆã•れる候補ã¯ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹ (コマンドライン上ã«é€”中ã¾ã§å…¥åŠ›ã•れãŸ) å˜èªžã«ä¸€è‡´ã™ã‚‹ã‚‚ã®ã«é™ã‚‰ã‚Œã¾ã™ã€‚ [[options]] == オプション +-A {{パターン}}+:: +--accept={{パターン}}+:: ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ{{link:pattern.html[パターン]}}ã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã ã‘を生æˆã—ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯è¤‡æ•°å›žæŒ‡å®šã§ãã¾ã™ (指定ã—ãŸå…¨ã¦ã®{{パターン}}ã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã ã‘を生æˆã—ã¾ã™)。 +-D {{説明}}+:: +--description={{説明}}+:: ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸ{{説明}}ãŒè£œå®Œã®éš›ã«å€™è£œã®èª¬æ˜Žã¨ã—ã¦è¡¨ç¤ºã•れã¾ã™ã€‚ +-O+:: +--option+:: 生æˆã™ã‚‹å€™è£œã‚’コマンドã®ã‚ªãƒ—ションã¨ã¿ãªã™ã‚ˆã†ã«ã—ã¾ã™ã€‚候補を画é¢ä¸Šã«ä¸€è¦§è¡¨ç¤ºã™ã‚‹éš›ã«è‡ªå‹•çš„ã«å…ˆé ­ã«ãƒã‚¤ãƒ•ンを付加ã—ã¾ã™ã€‚ +-P {{接頭辞}}+:: +--prefix={{接頭辞}}+:: ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã™ã‚‹{{接頭辞}}ã¯ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžã®æŽ¥é ­è¾žã«ãªã£ã¦ã„ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€å€™è£œç”Ÿæˆã®éš›ã«ã“ã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã—ãŸ{{接頭辞}}を無視ã—ã¦ãƒžãƒƒãƒãƒ³ã‚°ã‚’行ã„ã¾ã™ã€‚例ãˆã°è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžãŒ +file:///home/user/docume+ ã§ã‚りã€ã“ã® URL をファイルåã¨ã—ã¦è£œå®Œã—ãŸã„ã¨ã—ã¾ã—ょã†ã€‚ã“ã®å ´åˆã¯ã€+complete -P file:// -f+ ã¨ã™ã‚‹ã¨ URL ã‹ã‚‰ +file://+ を除ã„ãŸæ®‹ã‚Šã® +/home/user/docume+ ã®éƒ¨åˆ†ã«å¯¾ã—ã¦ãƒ•ァイルåã¨ã—ã¦ã®è£œå®Œå€™è£œãŒç”Ÿæˆã•れã¾ã™ã€‚ +-R {{パターン}}+:: +--reject={{パターン}}+:: ã“ã®ã‚ªãƒ—ションを指定ã™ã‚‹ã¨ã€æŒ‡å®šã—ãŸ{{link:pattern.html[パターン]}}ã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã‚’生æˆã—ã¾ã›ã‚“。ã“ã®ã‚ªãƒ—ションã¯è¤‡æ•°å›žæŒ‡å®šã§ãã¾ã™ (指定ã—ãŸ{{パターン}}ã®å°‘ãªãã¨ã‚‚一ã¤ã«ãƒžãƒƒãƒã™ã‚‹å€™è£œã‚’å…¨ã¦é™¤å¤–ã—ã¾ã™)。 +-S {{接尾辞}}+:: +--suffix={{接尾辞}}+:: 生æˆã—ãŸå„å€™è£œã®æœ«å°¾ã«{{接尾辞}}を付加ã—ã¾ã™ã€‚ +-T+:: +--no-termination+:: 通常ã¯ã€è£œå®ŒãŒçµ‚ã‚ã£ãŸå¾Œã«æ¬¡ã®å˜èªžã‚’ã™ã入力ã§ãるよã†ã«ã€è£œå®Œã—ãŸå˜èªžã®ç›´å¾Œã«ç©ºç™½ã‚’è‡ªå‹•çš„ã«æŒ¿å…¥ã—ã¾ã™ãŒã€ã“ã®ã‚ªãƒ—ションを指定ã—ãŸã¨ãã¯ç©ºç™½ã‚’挿入ã—ã¾ã›ã‚“。 === 補完方å¼è¨­å®šã®ãŸã‚ã®ã‚ªãƒ—ション +-a+:: +--alias+:: link:syntax.html#aliases[エイリアス] (+--normal-alias --global-alias+ ã«åŒã˜) +--array-variable+:: link:params.html#arrays[é…列] +--bindkey+:: link:_bindkey.html[Bindkey コマンド]ã§åˆ©ç”¨å¯èƒ½ãª{zwsp}link:lineedit.html#commands[行編集コマンド] +-b+:: +--builtin-command+:: link:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰] (+--special-builtin --semi-special-builtin --regular-builtin+ ã«åŒã˜) +-c+:: +--command+:: コマンド (+--builtin-command --external-command --function+ ã«åŒã˜) +-d+:: +--directory+:: ディレクトリ +--dirstack-index+:: ディレクトリスタックã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ +--executable-file+:: 実行å¯èƒ½ãƒ•ァイル +--external-command+:: 外部コマンド +-f+:: +--file+:: ファイル (ディレクトリå«ã‚€) +--finished-job+:: 終了ã—ãŸã‚¸ãƒ§ãƒ–ã®link:job.html#jobid[ジョブ ID] +--function+:: link:exec.html#function[関数] +--global-alias+:: グローãƒãƒ«link:syntax.html#aliases[エイリアス] +-g+:: +--group+:: (ファイルã®ãƒ‘ーミッションãªã©ã«ãŠã‘ã‚‹) グループ +-h+:: +--hostname+:: ホストå +-j+:: +--job+:: link:job.html#jobid[ジョブ ID] +-k+:: +--keyword+:: シェルã®link:syntax.html#tokens[予約語] +--normal-alias+:: 通常㮠(グローãƒãƒ«ã§ãªã„) link:syntax.html#aliases[エイリアス] +--regular-builtin+:: 通常ã®link:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰] +--running-job+:: 実行中ã®ã‚¸ãƒ§ãƒ–ã®link:job.html#jobid[ジョブ ID] +--scalar-variable+:: (é…列を除ã„ãŸé€šå¸¸ã®) link:params.html#variables[変数] +--semi-special-builtin+:: 準特殊link:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰] +--signal+:: シグナル +--special-builtin+:: 特殊link:builtin.html[組込ã¿ã‚³ãƒžãƒ³ãƒ‰] +--stopped-job+:: åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ã®link:job.html#jobid[ジョブ ID] +-u+:: +--username+:: ユーザã®ãƒ­ã‚°ã‚¤ãƒ³å +-v+:: +--variable+:: link:params.html#variables[変数] +-d+ (+--directory+) オプションを指定ã›ãšã« +-f+ (+--file+) オプションを指定ã—ãŸå ´åˆã€+-S …+ (+--suffix=…+) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã®æŒ‡å®šã®æœ‰ç„¡ã«ã‹ã‹ã‚らãšã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを表ã™è£œå®Œå€™è£œã«ã¯æŽ¥å°¾è¾žã¨ã—ã¦ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ãŒä»˜ãã€å€™è£œã®ç›´å¾Œã«ã¯ç©ºç™½ãŒå…¥ã‚Šã¾ã›ã‚“ (+-S / -T+ を指定ã—ãŸã¨ãã¨åŒã˜å‹•作)。 link:job.html#jobid[ジョブ ID] ã®è£œå®Œã¯å…ˆé ­ã® +%+ を除ã„ãŸéƒ¨åˆ†ã«å¯¾ã—ã¦è¡Œã‚れるã®ã§ã€è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžãŒæ—¢ã« +%+ ã‚’å«ã‚“ã§ã„ã‚‹å ´åˆã¯ +%+ を接頭辞ã¨ã—ã¦æŒ‡å®šã—ã¦ãã ã•ã„。 [[operands]] == オペランド Complete コマンドã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¯ã€å„オペランドãŒãれãžã‚Œè£œå®Œå€™è£œã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚指定ã—ãŸã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®ã†ã¡ã€ç¾åœ¨è£œå®Œã—よã†ã¨ã—ã¦ã„ã‚‹å˜èªžã«åˆã†ã‚‚ã®ãŒè£œå®Œå€™è£œã¨ãªã‚Šã¾ã™ã€‚ [[exitstatus]] == 終了ステータス 候補ãŒå°‘ãªãã¨ã‚‚一ã¤ç”Ÿæˆã§ããŸå ´åˆã¯ã€çµ‚了ステータス㯠0 ã§ã™ã€‚æ–°ãŸãªå€™è£œãŒä¸€ã¤ã‚‚生æˆã§ããªã‹ã£ãŸã¨ãã¯ã€çµ‚了ステータス㯠1 ã§ã™ã€‚ãã®ä»–ã®ã‚¨ãƒ©ãƒ¼ã®å ´åˆã¯ 2 以上ã®çµ‚了ステータスã«ãªã‚Šã¾ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ complete コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_true.html0000644000175000017500000000366412154557026015722 0ustar magicantmagicant True 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

True 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ä½•も行ã‚ãšã« 0 ã®çµ‚了ステータスã§çµ‚了ã—ã¾ã™ã€‚

æ§‹æ–‡

  • true

説明

True コマンドã¯ä½•も行ã„ã¾ã›ã‚“。コマンドライン引数ã¯ä¸€åˆ‡ç„¡è¦–ã—ã¾ã™ã€‚

終了ステータス

True コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

True ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

コロンコマンド㯠true コマンドã¨åŒæ§˜ã«ä½•も行ã„ã¾ã›ã‚“ãŒã€true ã‚³ãƒžãƒ³ãƒ‰ã¯æº–特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã‚ã‚‹ã®ã«å¯¾ã—コロンコマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

yash-2.35/doc/ja/Makefile.in0000644000175000017500000001331712154557026015757 0ustar magicantmagicant# Makefile.in for the documentation of yash # (C) 2007-2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # NOTE: In this Makefile it is assumed that the make implementation allows the # use of hyphens in target names. This means that there may be a strictly # POSIX-conforming implementation of make that rejects this Makefile. I have # never seen such an implementation but if you know of one please let me know. .POSIX: .SUFFIXES: .txt .1 .xml .html @MAKE_SHELL@ topdir = ../.. subdir = doc/$(LOCALE) recdirs = ASCIIDOC = @ASCIIDOC@ ASCIIDOCFLAGS = @ASCIIDOCFLAGS@ ASCIIDOCATTRS = @ASCIIDOCATTRS@ A2X = @A2X@ A2XFLAGS = @A2XFLAGS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_DIR = @INSTALL_DIR@ VERSION = @VERSION@ LOCALE = ja MANTXT = yash.txt INDEXTXT = index.txt # MAINTXTS must be in the contents order MAINTXTS = intro.txt invoke.txt syntax.txt params.txt expand.txt pattern.txt redir.txt exec.txt interact.txt job.txt builtin.txt lineedit.txt posix.txt fgrammar.txt # BUILTINTXTS must be in the alphabetic order BUILTINTXTS = _alias.txt _array.txt _bg.txt _bindkey.txt _break.txt _cd.txt _colon.txt _command.txt _complete.txt _continue.txt _dirs.txt _disown.txt _dot.txt _echo.txt _eval.txt _exec.txt _exit.txt _export.txt _false.txt _fc.txt _fg.txt _getopts.txt _hash.txt _help.txt _history.txt _jobs.txt _kill.txt _popd.txt _printf.txt _pushd.txt _pwd.txt _read.txt _readonly.txt _return.txt _set.txt _shift.txt _suspend.txt _test.txt _times.txt _trap.txt _true.txt _type.txt _typeset.txt _ulimit.txt _umask.txt _unalias.txt _unset.txt _wait.txt # CONTENTSTXTS must be in the contents order CONTENTSTXTS = $(MAINTXTS) $(BUILTINTXTS) TXTS = $(MANTXT) $(INDEXTXT) $(CONTENTSTXTS) MANFILE = $(MANTXT:.txt=.1) INDEXHTML = $(INDEXTXT:.txt=.html) HTMLFILES = $(INDEXHTML) $(CONTENTSTXTS:.txt=.html) HTMLAUXFILES = asciidoc.css TARGETS = $(MANFILE) $(HTMLFILES) CONFFILE = asciidoc.conf DESTDIR = prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ datarootdir = @datarootdir@ datadir = @datadir@ yashdatadir = $(datadir)/$(TARGET) localedir = @localedir@ mandir = @mandir@ man1dir = $(mandir)/man1 docdir = @docdir@ htmldir = @htmldir@ localemandir = $(mandir)/$(LOCALE) localeman1dir = $(localemandir)/man1 localedocdir = $(docdir)/$(LOCALE) localehtmldir = $(htmldir)/$(LOCALE) default-rec: default all-rec: all man-rec: man html-rec: html default: man html all: $(TARGETS) man: $(MANFILE) html: $(HTMLFILES) .txt.1: $(A2X) -d manpage -f manpage -L $(A2XFLAGS) $(ASCIIDOCATTRS) $< .txt.html: $(ASCIIDOC) -b html -d article $(ASCIIDOCFLAGS) $(ASCIIDOCATTRS) $< $(MANTXT): ../makeyash.sh $(MANTXT).in $(SHELL) ../makeyash.sh $(CONTENTSTXTS) <$@.in >$@ $(INDEXTXT): ../makeindex.sh $(INDEXTXT).in $(MAINTXTS) $(SHELL) ../makeindex.sh $(MAINTXTS) <$@.in >$@ $(MANFILE): $(MANTXT) $(CONTENTSTXTS) $(CONFFILE) $(HTMLFILES): $(CONFFILE) # update date in index.html when any contents file has been modified $(INDEXHTML): $(CONTENTSTXTS) install-rec: install install-data-rec: install-data install-html-rec: install-html installdirs-rec: installdirs installdirs-data-rec: installdirs-data installdirs-html-rec: installdirs-html uninstall-rec: uninstall uninstall-data-rec: uninstall-data INSTALLDIRS = $(DESTDIR)$(localeman1dir) $(DESTDIR)$(localehtmldir) install: install-data install-data: man installdirs-data $(INSTALL_DATA) $(MANFILE) $(DESTDIR)$(localeman1dir) install-html: html installdirs-html $(INSTALL_DATA) $(HTMLFILES) $(HTMLAUXFILES) $(DESTDIR)$(localehtmldir) installdirs: installdirs-data installdirs-data: $(DESTDIR)$(localeman1dir) installdirs-html: $(DESTDIR)$(localehtmldir) $(INSTALLDIRS): $(INSTALL_DIR) $@ uninstall: uninstall-data uninstall-data: rm -f $(DESTDIR)$(localeman1dir)/$(MANFILE) (if cd $(DESTDIR)$(localehtmldir); then rm -f $(HTMLFILES) $(HTMLAUXFILES); fi) -rmdir $(DESTDIR)$(localehtmldir) DISTFILES = $(TARGETS) $(HTMLAUXFILES) $(TXTS) $(MANTXT).in $(INDEXTXT).in Makefile.in $(CONFFILE) distfiles: $(DISTFILES) copy-distfiles: distfiles mkdir -p $(topdir)/$(DISTTARGETDIR) cp $(DISTFILES) $(topdir)/$(DISTTARGETDIR) mostlyclean: _mostlyclean _mostlyclean: clean: _clean _clean: _mostlyclean distclean: _distclean _distclean: _clean rm -fr Makefile maintainer-clean: _maintainer-clean _maintainer-clean: _distclean rm -fr $(TARGETS) $(MANTXT) $(INDEXTXT) Makefile: Makefile.in $(topdir)/config.status @+(cd $(topdir) && $(MAKE) config.status) @(cd $(topdir) && $(SHELL) config.status $(subdir)/$@) default-rec all-rec man-rec html-rec install-rec install-data-rec install-html-rec installdirs-rec installdirs-data-rec installdirs-html-rec uninstall-rec uninstall-data-rec mostlyclean clean distclean maintainer-clean: @+for dir in $(recdirs); do (cd $$dir && $(MAKE) $@) done .PHONY: default-rec all-rec man-rec html-rec default all man html install-rec install-data-rec install-html-rec installdirs-rec installdirs-data-rec installdirs-html-rec uninstall-rec uninstall-data-rec install install-data install-html installdirs installdirs-data installdirs-html uninstall uninstall-data distfiles copy-distfiles mostlyclean _mostlyclean clean _clean distclean _distclean maintainer-clean _maintainer-clean yash-2.35/doc/ja/_array.txt0000644000175000017500000000544612154557026015734 0ustar magicantmagicant= Array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ :encoding: UTF-8 :lang: ja //:title: Yash マニュアル - Array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ dfn:[Array 組込ã¿ã‚³ãƒžãƒ³ãƒ‰]ã¯link:params.html#arrays[é…列]ã®è¡¨ç¤ºã‚„æ“作を行ã„ã¾ã™ã€‚ [[syntax]] == æ§‹æ–‡ - +array+ - +array {{é…列å}} [{{値}}...]+ - +array -d {{é…列å}} [{{インデックス}}...]+ - +array -i {{é…列å}} {{インデックス}} [{{値}}...]+ - +array -s {{é…列å}} {{インデックス}} {{値}}+ [[description]] == 説明 オプションもオペランドも指定ã›ãšã«å®Ÿè¡Œã™ã‚‹ã¨ã€array コマンドã¯å…¨ã¦ã®é…列ã®å®šç¾©ã‚’ (コマンドã¨ã—ã¦è§£é‡ˆå¯èƒ½ãªå½¢å¼ã§) 標準出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚ オプションを指定ã›ãšã«{{é…列å}}ã¨{{値}}を与ãˆã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array コマンドã¯ãã®é…列ã®å†…容を指定ã•れãŸå€¤ã«è¨­å®šã—ã¾ã™ã€‚ +-d+ (+--delete+) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã‚’削除ã—ã¾ã™ã€‚é…列ã®è¦ç´ æ•°ã¯å‰Šé™¤ã—ãŸè¦ç´ ã®åˆ†ã ã‘å°‘ãªããªã‚Šã¾ã™ã€‚存在ã—ãªã„è¦ç´ ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’指定ã—ãŸã¨ãã¯ç„¡è¦–ã—ã¾ã™ã€‚ +-i+ (+--insert+) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã®ç›´å¾Œã«æŒ‡å®šã—ãŸå€¤ã‚’è¦ç´ ã¨ã—ã¦è¿½åŠ ã—ã¾ã™ã€‚é…列ã®è¦ç´ æ•°ã¯è¿½åŠ ã—ãŸè¦ç´ ã®åˆ†ã ã‘増ãˆã¾ã™ã€‚{{インデックス}} ã¨ã—㦠0 を指定ã™ã‚‹ã¨é…列ã®å…ˆé ­ã«è¦ç´ ã‚’追加ã—ã¾ã™ã€‚{{インデックス}}ã¨ã—ã¦é…列ã®è¦ç´ æ•°ã‚ˆã‚Šå¤§ããªæ•°ã‚’指定ã™ã‚‹ã¨é…åˆ—ã®æœ«å°¾ã«è¦ç´ ã‚’追加ã—ã¾ã™ã€‚ +-s+ (+--set+) オプションを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€array ã‚³ãƒžãƒ³ãƒ‰ã¯æŒ‡å®šã—ãŸé…åˆ—ã®æŒ‡å®šã—ãŸã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«ã‚ã‚‹è¦ç´ ã®å€¤ã‚’指定ã—ãŸå€¤ã«å¤‰æ›´ã—ã¾ã™ã€‚ [[options]] == オプション +-d+:: +--delete+:: é…列ã®è¦ç´ ã‚’削除ã—ã¾ã™ã€‚ +-i+:: +--insert+:: é…列ã«è¦ç´ ã‚’挿入ã—ã¾ã™ã€‚ +-s+:: +--set+:: é…列ã®è¦ç´ ã‚’変更ã—ã¾ã™ã€‚ [[operands]] == オペランド {{é…列å}}:: 表示ã¾ãŸã¯æ“作ã™ã‚‹é…列ã®åå‰ã§ã™ã€‚ {{インデックス}}:: é…列ã®è¦ç´ ã‚’指定ã™ã‚‹è‡ªç„¶æ•°ã§ã™ã€‚ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã¯æœ€åˆã®è¦ç´ ã‹ã‚‰é †ã« 1, 2, 3, … ã¨å‰²ã‚ŠæŒ¯ã‚‰ã‚Œã¾ã™ã€‚ {{値}}:: é…列ã®è¦ç´ ã¨ãªã‚‹æ–‡å­—列ã§ã™ã€‚ [[exitstatus]] == 終了ステータス エラーãŒãªã„é™ã‚Š array コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ [[notes]] == 補足 POSIX ã«ã¯ array コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。 +array {{é…列å}} [{{値}}...]+ ã®å½¢å¼ã® array コマンドã¯å¤‰æ•°ä»£å…¥ã‚’用ã„㦠+{{é…列å}}=({{値}}...)+ ã¨æ›¸ãã“ã¨ã‚‚ã§ãã¾ã™ã€‚ // vim: set filetype=asciidoc expandtab: yash-2.35/doc/ja/_exec.html0000644000175000017500000001402112154557026015654 0ustar magicantmagicant Exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Exec 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚·ã‚§ãƒ«ã®ãƒ—ロセスを別ã®å¤–部コマンドã«ç½®ãæ›ãˆã¾ã™ã€‚ã¾ãŸã‚·ã‚§ãƒ«ã®ãƒ—ロセスã«å¯¾ã—ã¦ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã‚’実行ã—ã¾ã™ã€‚

æ§‹æ–‡

  • exec [-cf] [-a コマンドå] [コマンド [引数…]]

Exec コマンドã§ã¯ã€POSIX 準拠モードã§ã‚ã‚‹ã‹ã©ã†ã‹ã«ã‹ã‹ã‚らãšã‚ªãƒ—ションã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚ˆã‚Šå…ˆã«å…¨ã¦æŒ‡å®šã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“れ㯠exec コマンドã«å¯¾ã™ã‚‹ã‚ªãƒ—ションã¨ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾ã™ã‚‹ã‚ªãƒ—ションを区別ã™ã‚‹ãŸã‚ã«é‡è¦ã§ã™ã€‚コマンドより後ã«ã‚る引数ã¯ã™ã¹ã¦å¼•æ•°ã¨ã¿ãªã•れã¾ã™ã€‚

説明

Exec コマンドをコマンドを指定ã—ã¦å®Ÿè¡Œã™ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯å˜ç´”コマンドã®å®Ÿè¡Œã®æœ€å¾Œã®ã‚¹ãƒ†ãƒƒãƒ—ã¨åŒæ§˜ã«ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ãŸã ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã¯å¿…ãšå¤–部コマンドã¨ã—ã¦ã¿ãªã•れã€é–¢æ•°ã‚„組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ç„¡è¦–ã—ã¾ã™ã€‚ãã—ã¦ãã®å¤–部コマンドã¯ã‚µãƒ–シェルã§ã¯ãªãç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã§ exec システムコールを呼ã³å‡ºã™ã“ã¨ã§å®Ÿè¡Œã—ã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ã‚·ã‚§ãƒ«ã®ãƒ—ãƒ­ã‚»ã‚¹ã¯æ–°ã—ãèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«ç½®ãæ›ã‚りã¾ã™ã€‚

シェル㌠POSIX 準拠モードã®ã¨ãã¾ãŸã¯å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã§ãªã„ã¨ãã€ã‚³ãƒžãƒ³ãƒ‰ã®èµ·å‹•ã«å¤±æ•—ã™ã‚‹ã¨ã‚·ã‚§ãƒ«ã¯ç›´ã¡ã«çµ‚了ã—ã¾ã™ã€‚

シェル㌠POSIX 準拠モードã§ã¯ãªãã‹ã¤å¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã¨ãã€åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚ã‚‹ã¨ã€ã‚·ã‚§ãƒ«ã¯è­¦å‘Šã‚’表示ã—ã€ã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã—ã¾ã›ã‚“。一度 exec ãŒå®Ÿè¡Œã•れるã¨ã€ã‚·ã‚§ãƒ«ãŒæŒã£ã¦ã„ã‚‹ã‚¸ãƒ§ãƒ–ã®æƒ…å ±ã¯å¤±ã‚れるãŸã‚ã€æ‰‹å‹•ã§ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã£ã¦ã‚¸ãƒ§ãƒ–ã‚’å†é–‹ã¾ãŸã¯çµ‚了ã•ã›ãªã‘れã°ãªã‚‰ãªããªã‚Šã¾ã™ã€‚警告を無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’èµ·å‹•ã™ã‚‹ã«ã¯ -f (--force) オプションを付ã‘ã¦ãã ã•ã„。

コマンドãªã—ã§å®Ÿè¡Œã—ãŸå ´åˆ exec コマンドã¯ä½•も行ã„ã¾ã›ã‚“ãŒã€ã“ã® exec コマンドを実行ã™ã‚‹éš›ã«è¡Œã£ãŸãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®åŠ¹æžœã¯ç¾åœ¨ã®ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œç’°å¢ƒã«æ®‹ã‚Šã¾ã™ã€‚

オプション

-a コマンドå
--as=コマンドå

コマンドã®ä»£ã‚りã«ã‚³ãƒžãƒ³ãƒ‰åをコマンドåã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã—ã¾ã™ã€‚

-c
--clear

既存ã®ç’°å¢ƒå¤‰æ•°ã‚’ã™ã¹ã¦å‰Šé™¤ã—ãŸçŠ¶æ…‹ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚ãŸã ã—ã“ã® exec コマンドを実行ã™ã‚‹éš›ã«è¡Œã£ãŸå¤‰æ•°ä»£å…¥ã®çµæžœã¯ç’°å¢ƒå¤‰æ•°ã¨ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã—ã¾ã™ã€‚

-f
--force

警告を無視ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¾ã™ã€‚

オペランド

コマンド

実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

引数

実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«æ¸¡ã™ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•æ•°ã§ã™ã€‚

終了ステータス

指定ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã®èµ·å‹•ã«æˆåŠŸã—ãŸå ´åˆã€ã‚·ã‚§ãƒ«ã®ãƒ—ロセスã¯ãã®ã‚³ãƒžãƒ³ãƒ‰ã®ãƒ—ロセスã«ç½®ãæ›ã‚ã£ã¦ã—ã¾ã†ã®ã§ã€çµ‚了ステータスã¯ã‚りã¾ã›ã‚“。

実行ã—よã†ã¨ã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠127 ã§ã™ã€‚コマンドãŒè¦‹ã¤ã‹ã£ãŸãŒå®Ÿè¡Œã§ããªã‹ã£ãŸå ´åˆã€çµ‚了ステータス㯠126 ã§ã™ã€‚コマンドを指定ã›ãšã« exec コマンドを実行ã—ãŸå ´åˆã€çµ‚了ステータス㯠0 ã§ã™ã€‚

補足

Exec コマンドã¯ç‰¹æ®Šçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã™ã€‚

POSIX ã«ã¯ã‚ªãƒ—ションã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。よã£ã¦ã‚ªãƒ—ション㯠POSIX 準拠モードã§ã¯ä½¿ãˆã¾ã›ã‚“。

yash-2.35/doc/ja/_help.html0000644000175000017500000000523212154557026015664 0ustar magicantmagicant Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰

Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«é–¢ã™ã‚‹èª¬æ˜Žã‚’表示ã—ã¾ã™ã€‚

æ§‹æ–‡

  • help [コマンド…]

説明

Help 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã§æŒ‡å®šã—ãŸçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã«é–¢ã™ã‚‹èª¬æ˜Žã‚’出力ã—ã¾ã™ã€‚

ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã€man yash ã®å‡ºåŠ›ã®ä¸€éƒ¨ã‚’抜ã出ã—ã¦æ¨™æº–出力ã«å‡ºåŠ›ã—ã¾ã™ã€‚従ã£ã¦ã€ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ãƒšãƒ¼ã‚¸ãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•れã¦ã„ãªã‘ã‚Œã°æ­£ã—ã動作ã—ã¾ã›ã‚“。ã¾ãŸã€man コマンドã®å‡ºåŠ›ã®å½¢å¼ã«ã‚ˆã£ã¦ã¯æ­£ã—ã説明を抜ã出ã›ãªã„ã“ã¨ãŒã‚りã¾ã™ã€‚

オペランド

コマンド

説明を表示ã™ã‚‹çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã§ã™ã€‚

終了ステータス

エラーãŒãªã„é™ã‚Š help コマンドã®çµ‚了ステータス㯠0 ã§ã™ã€‚ The exit status of the help built-in is zero unless there is any error.

補足

POSIX ã«ã¯ help コマンドã«é–¢ã™ã‚‹è¦å®šã¯ã‚りã¾ã›ã‚“。

Yash ã®å¤šãã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§ã¯ã€--help オプションを与ãˆã‚‹ã“ã¨ã§ help コマンドã®å‡ºåŠ›ã¨åŒæ§˜ã®èª¬æ˜Žã‚’表示ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚

yash-2.35/doc/_type.txt0000644000175000017500000000120012154557026015165 0ustar magicantmagicant= Type built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Type built-in The dfn:[type built-in] identifies a command. [[syntax]] == Syntax - +type [-abefkp] [{{command}}...]+ [[description]] == Description The type built-in is equivalent to the link:_command.html[command built-in] with the +-V+ option. [[notes]] == Notes The POSIX standard does not define the relation between the type and command built-ins. The standard does not define options for the type built-in. At least one {{command}} operand must be specified in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/index.html0000644000175000017500000004443612154557026015323 0ustar magicantmagicant Yet another shell (yash) manual

Contents

  1. Introduction

  2. Invocation

  3. Syntax

  4. Parameters and variables

  5. Word expansions

  6. Pattern matching notation

  7. Redirection

  8. Command execution

  9. Interactive mode

  10. Job control

  11. Built-in commands

  12. Line-editing

  13. POSIXly-correct mode

  14. Formal definition of command syntax

Built-ins

The ‘*’ mark indicates a special built-in and the ‘+’ mark a semi-special built-in. (See Types of built-in commands)

Categorized list of built-ins

Execution control commands

Command execution environment

Job control and signalling

Parameters and variables

Working directory

Aliases

Command history

Printing strings

Line-editing

yash-2.35/doc/index.txt.in0000644000175000017500000001042312154557026015570 0ustar magicantmagicant= Yet another shell (yash) manual Yuki Watanabe v{yashversion}, :encoding: UTF-8 :lang: en //:title: Yet another shell (yash) manual :description: The table of contents for the yash manual. [[contents-list]] == Contents [role="list-group"] -- // (Replaced with generated contents list) // -- [[builtins]] == Built-ins The `*' mark indicates a special built-in and the `+' mark a semi-special built-in. (See link:builtin.html#types[Types of built-in commands]) [[alpha-order]] === All built-ins in alphabetic order [role="list-group"] - link:_dot.html[+.+ (dot)] * - link:_colon.html[+:+ (colon)] * - link:_test.html[+[+ (bracket)] - link:_alias.html[+alias+] + - link:_array.html[+array+] - link:_bg.html[+bg+] + - link:_bindkey.html[+bindkey+] - link:_break.html[+break+] * - link:_cd.html[+cd+] + - link:_command.html[+command+] + - link:_complete.html[+complete+] - link:_continue.html[+continue+] * - link:_dirs.html[+dirs+] - link:_disown.html[+disown+] - link:_echo.html[+echo+] - link:_eval.html[+eval+] * - link:_exec.html[+exec+] * - link:_exit.html[+exit+] * - link:_export.html[+export+] * - link:_false.html[+false+] + - link:_fc.html[+fc+] + - link:_fg.html[+fg+] + - link:_getopts.html[+getopts+] + - link:_hash.html[+hash+] - link:_help.html[+help+] - link:_history.html[+history+] - link:_jobs.html[+jobs+] + - link:_kill.html[+kill+] + - link:_popd.html[+popd+] - link:_printf.html[+printf+] - link:_pushd.html[+pushd+] - link:_pwd.html[+pwd+] + - link:_read.html[+read+] + - link:_readonly.html[+readonly+] * - link:_return.html[+return+] * - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_suspend.html[+suspend+] * - link:_test.html[+test+] - link:_times.html[+times+] * - link:_trap.html[+trap+] * - link:_true.html[+true+] + - link:_type.html[+type+] - link:_typeset.html[+typeset+] - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_unalias.html[+unalias+] + - link:_unset.html[+unset+] * - link:_wait.html[+wait+] + [[groups]] === Categorized list of built-ins [[g-control]] ==== Execution control commands [role="list-group"] - link:_eval.html[+eval+] * - link:_dot.html[+.+ (dot)] * - link:_exec.html[+exec+] * - link:_command.html[+command+] + - link:_hash.html[+hash+] - link:_break.html[+break+] * - link:_continue.html[+continue+] * - link:_return.html[+return+] * - link:_suspend.html[+suspend+] * - link:_exit.html[+exit+] * [[g-environ]] ==== Command execution environment [role="list-group"] - link:_set.html[+set+] * - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_trap.html[+trap+] * - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_times.html[+times+] * [[g-job]] ==== Job control and signalling [role="list-group"] - link:_jobs.html[+jobs+] + - link:_fg.html[+fg+] + - link:_bg.html[+bg+] + - link:_wait.html[+wait+] + - link:_disown.html[+disown+] - link:_kill.html[+kill+] + - link:_trap.html[+trap+] * [[g-variable]] ==== Parameters and variables [role="list-group"] - link:_typeset.html[+typeset+] - link:_export.html[+export+] * - link:_readonly.html[+readonly+] * - link:_array.html[+array+] - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_read.html[+read+] + - link:_getopts.html[+getopts+] + - link:_unset.html[+unset+] * [[g-directory]] ==== Working directory [role="list-group"] - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_pushd.html[+pushd+] - link:_popd.html[+popd+] - link:_dirs.html[+dirs+] [[g-alias]] ==== Aliases [role="list-group"] - link:_alias.html[+alias+] + - link:_unalias.html[+unalias+] + [[g-history]] ==== Command history [role="list-group"] - link:_fc.html[+fc+] + - link:_history.html[+history+] [[g-print]] ==== Printing strings [role="list-group"] - link:_echo.html[+echo+] - link:_printf.html[+printf+] [[g-lineedit]] ==== Line-editing [role="list-group"] - link:_bindkey.html[+bindkey+] - link:_complete.html[+complete+] [[g-misc]] ==== Miscellaneous [role="list-group"] - link:_help.html[+help+] - link:_colon.html[+:+ (colon)] * - link:_true.html[+true+] + - link:_false.html[+false+] + - link:_test.html[+[+ (bracket), +test+] - link:_type.html[+type+] // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_disown.html0000644000175000017500000000475712154557026015660 0ustar magicantmagicant Disown built-in

The disown built-in removes jobs.

Syntax

  • disown [-a] [job…}

Description

The disown built-in removes the specified jobs from the job list. The removed jobs will no longer be job-controlled, but the job processes continue execution (unless they have been suspended).

Options

-a
--all

Removes all jobs.

Operands

job

The job ID of the job to be removed.

You can specify more than one job ID. If you do not specify any job ID, the current job is removed. If the shell is not in the POSIXly-correct mode, the %-prefix of the job ID can be omitted.

Exit status

The exit status of the disown built-in is zero unless there is any error.

Notes

The disown built-in is not defined in the POSIX standard.

yash-2.35/doc/invoke.txt0000644000175000017500000001212712154557026015352 0ustar magicantmagicant= Invocation :encoding: UTF-8 :lang: en //:title: Yash manual - Invocation :description: This page describes how yash is initialized when invoked. When invoked as a program, yash performs the predefined initialization steps and repeatedly reads and executed commands. Command line arguments given in the invocation determines how the shell initializes itself and executes commands. [[arguments]] == Command line arguments The syntax of command line arguments for yash conforms to POSIX. As defined in POSIX, arguments are separated into dfn:[options] and dfn:[operands]. For more detailed explanation about options and operands, see link:builtin.html#argsyntax[Command argument syntax]. All options must come before operands. The interpretation of operands depends on options specified. When you specify the +-c+ (+--cmdline+) option, you must give at least one operand. The shell interprets and executes the first operand as a command string. The second operand, if any, is used to initialize the link:params.html#sp-zero[+0+ special parameter]. The other operands, if any, are used to initialize the link:params.html#positional[positional parameters]. When the +-c+ (+--cmdline+) option is specified, the shell does not read any file or the standard input (unless the link:_dot.html[dot built-in] is used). If you specify the +-s+ (+--stdin+) option, the shell reads the standard input, interprets the input as commands, and executes them. All the operands given are used to initialize the link:params.html#positional[positional parameters]. The link:params.html#sp-zero[+0+ special parameter] is initialized to the name the shell is invoked as. If you specify neither the +-c+ (+--cmdline+) nor +-s+ (+--stdin+) option, the shell reads a file, interprets the file contents as commands, and executes them. The first operand specifies the pathname of the file. The remaining operands are used to initialize the link:params.html#positional[positional parameters]. If you do not give any operands, the shell reads the standard input as if the +-s+ (+--stdin+) option is specified. You cannot use both the +-c+ (+--cmdline+) and +-s+ (+--stdin+) options at a time. If you specify either the +--help+ or +--version+ option, the shell never performs the usual initialization or command execution. Instead, it just prints brief usage (for +--help+) or version information (for +--version+). If the +--version+ option is accompanied by the +-v+ (+--verbose+) option, the shell prints a list of the available optional features as well. If you specify the +-i+ (+--interactive+) option, the shell goes into the link:interact.html[interactive mode]. If you specify the `+i` (`++interactive`) option, conversely, the shell never goes into the interactive mode. If you specify the +-l+ (+--login+) option, the shell behaves as a login shell. The +--noprofile+, +--norcfile+, +--profile+, and +--rcfile+ options determine how the shell is initialized (see below for details). In addition to the options described above, you can specify options that can be specified to the link:_set.html[set built-in]. If the first operand is +-+ and the options and the operands are not separated by +--+, the first operand is ignored. [[init]] == Initialization of yash Yash initializes itself as follows: . Yash first parses the name it was invoked as. If the name starts with +-+, the shell behaves as a login shell. If the name is +sh+ (including names such as +/bin/sh+), the shell goes into the link:posix.html[POSIXly-correct mode]. . If no operands are given and the standard input and standard error are both connected to a terminal, the shell goes into the link:interact.html[interactive mode] unless the `+i` (`++interactive`) option is specified. . link:job.html[Job control] is automatically enabled in an interactive shell unless the `+m` (`++monitor`) option is specified. . Yash reads and executes commands from the following files (unless the real and effective user IDs of the shell process are different or the real and effective group IDs of the shell process are different): .. If it is behaving as a login shell, the shell reads the file specified by the +--profile={{filename}}+ option unless the +--noprofile+ option is specified or the shell is in the link:posix.html[POSIXly-correct mode]. + If the +--profile={{filename}}+ option is not specified, the shell reads link:expand.html#tilde[~]/.yash_profile as a default. .. If in the interactive mode, the shell reads the file specified by the +--rcfile={{filename}}+ option unless the +--norcfile+ option is specified. + If the +--rcfile={{filename}}+ option is not specified, the shell - reads link:expand.html#tilde[~]/.yashrc as a default if not in the POSIXly-correct mode; or - performs link:expand.html[parameter expansion] on the value of the link:params.html#sv-env[+ENV+ environment variable] and treats the expansion result as the name of the file to read if in the POSIXly-correct mode. [NOTE] Yash never automatically reads /etc/profile, /etc/yashrc, nor link:expand.html#tilde[~]/.profile. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_popd.html0000644000175000017500000000432112154557026015302 0ustar magicantmagicant Popd built-in

The popd built-in pops a directory from the directory stack.

Syntax

  • popd [index]

Description

The popd built-in removes the last entry from the directory stack, returning to the previous working directory. If index is given, the entry specified by index is removed instead of the last one.

Operands

index

The index of a directory stack entry you want to remove.

If omitted, +0 (the last entry) is assumed.

Exit status

The exit status of the popd built-in is zero unless there is any error.

Notes

It is an error to use this built-in when there is only one directory stack entry.

The popd built-in is not defined in the POSIX standard.

yash-2.35/doc/_hash.html0000644000175000017500000001030312154557026015260 0ustar magicantmagicant Hash built-in

The hash built-in remembers, forgets, or reports command locations.

Syntax

  • hash command

  • hash -r [command…]

  • hash [-a]

  • hash -d user

  • hash -dr [user…]

  • hash -d

Description

When executed with commands but without options, the built-in immediately performs command path search and caches commands' full paths.

When executed with the -r (--remove) option, it removes the paths of commands (or all cached paths if none specified) from the cache.

When executed without options or commands, it prints the currently cached paths to the standard output.

With the -d (--directory) option, the built-in does the same things to the home directory cache, rather than the command path cache. Cached home directory paths are used in tilde expansion.

Options

-a
--all

Print all cached paths.

Without this option, paths for built-ins are not printed.

-d
--directory

Affect the home directory cache instead of the command path cache.

-r
--remove

Remove cached paths.

Operands

command

The name of an external command (that does not contain any slash).

user

A user name.

Exit status

The exit status of the hash built-in is zero unless there is any error.

Notes

The shell automatically caches command and directory paths when executing a command or performing tilde expansion, so normally there is no need to use this built-in explicitly to cache paths.

Assigning a value to the PATH variable removes all command paths from the cache as if hash -r was executed.

The POSIX standard defines the -r option only: other options cannot be used in the POSIXly-correct mode.

yash-2.35/doc/_export.txt0000644000175000017500000000126712154557026015542 0ustar magicantmagicant= Export built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Export built-in The dfn:[export built-in] marks variables for export to child processes. [[syntax]] == Syntax - +export [-prX] [{{name}}[={{value}}]...]+ [[description]] == Description The export built-in is equivalent to the link:_typeset.html[typeset built-in] with the +-gx+ option. [[notes]] == Notes The export built-in is a link:builtin.html#types[special built-in]. The POSIX standard defines the +-p+ option only; other options cannot be used in the link:posix.html[POSIXly-correct mode]. The POSIX does not allow using the option together with operands. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_complete.html0000644000175000017500000002247312154557026016160 0ustar magicantmagicant Complete built-in

The complete built-in generates completion candidates. This built-in can only be executed from completion functions during command line completion.

Syntax

  • complete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] [-abcdfghjkuv] [[-O] [-D description] word…]

Description

The built-in generates completion candidates according to the specified arguments. No matter how candidates are generated, only candidates that match the word being completed are generated.

Options

-A pattern
--accept=pattern

Only accept candidates that match the pattern specified by this option. When more than one of this option is specified, only candidates that match all of the patterns are generated.

-D description
--description=description

Give a description of the word candidates. The description is shown beside the candidates in the candidate list.

-O
--option

The candidates are treated as command line options. A hyphen is prepended to each candidate that is treated as an option.

-P prefix
--prefix=prefix

Ignore prefix of the word being completed when generating candidates. The specified prefix must be initial part of the word.

If the word being completed is file:///home/user/docume for example, the command line complete -P file:// -f will generate pathname candidates that complete /home/user/docume.

-R pattern
--reject=pattern

Reject candidates that match the pattern specified by this option. When more than one of this option is specified, only candidates that match none of the patterns are generated.

-S suffix
--suffix=suffix

Append suffix to each generated candidate.

-T
--no-termination

Do not append a space after the word is completed. Without this option, a space is appended to the completed word so that you do not have to enter a space before the next word.

Options that select candidate types

-a
--alias

Aliases. (same as --normal-alias --global-alias)

--array-variable

Arrays.

--bindkey

Line-editing commands the bindkey built-in accepts.

-b
--builtin-command

Built-in commands. (same as --special-builtin --semi-special-builtin --regular-builtin)

-c
--command

Commands. (same as --builtin-command --external-command --function)

-d
--directory

Directories.

--dirstack-index

Valid indices of the directory stack.

--executable-file

Executable regular files.

--external-command

External commands.

-f
--file

Files (including directories).

--finished-job

Job IDs of finished jobs.

--function

Functions.

--global-alias

Global aliases.

-g
--group

User groups.

-h
--hostname

Host names.

-j
--job

Job IDs.

-k
--keyword

Keywords.

--normal-alias

Normal aliases.

--regular-builtin

Regular built-in commands.

--running-job

Job IDs of jobs that are being executed.

--scalar-variable

Variables that are not arrays.

--semi-special-builtin

Semi-special built-in commands.

--signal

Signals.

--special-builtin

Special built-in commands.

--stopped-job

Job IDs of jobs that are suspended.

-u
--username

Users' log-in names.

-v
--variable

Variables.

If the -d (--directory) option is specified without the -f (--file) option, the -S / -T options are assumed.

Generated candidates for job IDs do not have leading percent signs (%). If the word being completed starts with a percent sign, the -P % option should be specified.

Operands

Operands are treated as completion candidates.

Exit status

The exit status of the built-in is zero if one or more candidates were generated, one if no candidates were generated, or larger than one if an error occurred.

Notes

The complete built-in is not defined in the POSIX standard.

yash-2.35/doc/_unalias.html0000644000175000017500000000446112154557026016001 0ustar magicantmagicant Unalias built-in

The unalias built-in undefines aliases.

Syntax

  • unalias name

  • unalias -a

Description

The unalias built-in removes the definition of the aliases specified by operands.

Options

-a
--all

Undefine all aliases.

Operands

name

The name of an alias to be undefined.

Exit status

The exit status of the unalias built-in is zero unless there is any error. It is an error to specify the name of a non-existing alias as name.

Notes

The unalias built-in is a semi-special built-in.

yash-2.35/doc/asciidoc.conf0000644000175000017500000000160612154557026015743 0ustar magicantmagicant[macros] (?su)dfn:\[(?P.*?)\]=dfn (?su)dfn:(?P\w+)\[(?P.*?)\]=dfnid (?su)lang:(?P\w+)\[(?P.*?)\]=lang [quotes] ~= ((|))= (((|)))= +=code ++=#code `=#code {{|}}=#var ifdef::basebackend-html[] [tags] code=| var=| [dfn-inlinemacro] {value} [dfnid-inlinemacro] {value} ifdef::backend-xhtml11[] [lang-inlinemacro] {value} endif::backend-xhtml11[] ifndef::backend-xhtml11[] [lang-inlinemacro] {value} endif::backend-xhtml11[] endif::basebackend-html[] ifdef::basebackend-docbook[] [tags] code=| var=| [dfn-inlinemacro] {value} [dfnid-inlinemacro] {value} [lang-inlinemacro] {value} endif::basebackend-docbook[] # vim: set filetype=cfg: yash-2.35/doc/_command.html0000644000175000017500000001562512154557026015767 0ustar magicantmagicant Command built-in

The command built-in executes or identifies a command.

Syntax

  • command [-befp] command [argument…]

  • command -v|-V [-abefkp] command

Description

Without the -v (--identify) or -V (--verbose-identify) option, the built-in executes command with arguments in the same manner as the last step of execution of simple commands. The command is treated as a built-in or external command or a function according to the options specified to the command built-in. The shell does not exit on argument syntax error etc. even if the command is a special built-in

With the -v (--identify) option, command is identified. If the command is found in $PATH, its full pathname is printed. If it is a keyword, function, or built-in that is not found in $PATH, the command name is simply printed. If it is an alias, it is printed in the form like alias ll='ls -l'. If the command is not found, nothing is printed and the exit status is non-zero.

The -V (--verbose-identify) option is similar to the -v (--identify) option, but the output format is more human-friendly.

Options

-a
--alias

Search for the command as an alias. Must be used with the -v (--identify) or -V (--verbose-identify) option.

-b
--builtin-command

Search for the command as a built-in.

-e
--external-command

Search for the command as an external command.

-f
--function

Search for the command as a function.

-k
--keyword

Search for the command as a keyword. Must be used with the -v (--identify) or -V (--verbose-identify) option.

-p
--standard-path

Search the system’s default PATH instead of the current $PATH.

-v
--identify

Identify commands and print in the format defined in the POSIX standard.

-V
--verbose-identify

Identify commands and print in a human-friendly format.

If none of the -a (--alias), -b (--builtin-command), -e (--external-command), -f (--function), and -k (--keyword) options is specified, the following defaults are assumed:

Without the -v (--identify) or -V (--verbose-identify) option

-b -e

With the -v (--identify) or -V (--verbose-identify) option

-a -b -e -f -k

Operands

command

A command to be executed or identified.

argument

Arguments passed to the executed command.

Exit status

The exit status of the command built-in is:

Without the -v (--identify) or -V (--verbose-identify) option

the exit status of the executed command.

With the -v (--identify) or -V (--verbose-identify) option

zero unless there is any error.

Notes

The command built-in is a semi-special built-in.

In the POSIXly-correct mode, options other than -p, -v, and -V cannot be used and at most one command can be specified. The POSIX standard does not allow specifying both -v and -V together, but yash does (only the last specified one is effective).

yash-2.35/doc/_shift.txt0000644000175000017500000000160012154557026015325 0ustar magicantmagicant= Shift built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Shift built-in The dfn:[shift built-in] removes some positional parameters. [[syntax]] == Syntax - +shift [{{count}}]+ [[description]] == Description The shift built-in removes the first {{count}} link:params.html#positional[positional parameters]. [[operands]] == Operands {{count}}:: The number of positional parameters to be removed. + It is an error if the actual number of positional parameters is less than {{count}}. If omitted, the default value is one. [[exitstatus]] == Exit status The exit status of the shift built-in is zero unless there is any error. [[notes]] == Notes The shift built-in is a link:builtin.html#types[special built-in]. The number of positional parameters can be obtained with the link:params.html#sp-hash[+#+ special parameter]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_jobs.html0000644000175000017500000000765112154557026015306 0ustar magicantmagicant Jobs built-in

The jobs built-in reports job status.

Syntax

  • jobs [-lnprs] [job…]

Description

The jobs built-in prints information of jobs the shell is currently controlling.

By default, the following information is printed for each job, line by line:

  • the job number,

  • the + or - symbol if the job is the current or previous job, respectively,

  • the status, and

  • the command string.

Options

-l
--verbose

Print the process ID, status, and command string for each process in the jobs.

-n
--new

Print new jobs only: jobs whose status has never been reported since the status changed.

-p
--pgid-only

Print process group IDs of jobs only.

-r
--running-only

Print running jobs only.

-s
--stopped-only

Print stopped jobs only.

Operands

jobs

The job IDs of jobs to be reported. When no job is specified, all jobs under the shell’s control are reported.

Exit status

The exit status of the jobs built-in is zero unless there is any error.

Notes

The jobs built-in is a semi-special built-in.

The POSIX standard defines the -l and -p options only: other options cannot be used in the POSIXly-correct mode. In the POSIXly-correct mode, the effect of the -l option is different in that status is reported for each job rather than for each process.

The process group ID of a job executed by yash is equal to the process ID of the first command of the pipeline that forms the job.

yash-2.35/doc/index.txt0000644000175000017500000002061612154557026015170 0ustar magicantmagicant= Yet another shell (yash) manual Yuki Watanabe v{yashversion}, :encoding: UTF-8 :lang: en //:title: Yet another shell (yash) manual :description: The table of contents for the yash manual. [[contents-list]] == Contents [role="list-group"] -- . link:intro.html[Introduction] . link:invoke.html[Invocation] .. link:invoke.html#arguments[Command line arguments] .. link:invoke.html#init[Initialization of yash] . link:syntax.html[Syntax] .. link:syntax.html#tokens[Tokens and keywords] .. link:syntax.html#quotes[Quotations] .. link:syntax.html#aliases[Aliases] .. link:syntax.html#simple[Simple commands] .. link:syntax.html#pipelines[Pipelines] .. link:syntax.html#and-or[And/or lists] .. link:syntax.html#async[Command separators and asynchronous commands] .. link:syntax.html#compound[Compound commands] ... link:syntax.html#grouping[Grouping] ... link:syntax.html#if[If command] ... link:syntax.html#while-until[While and until loops] ... link:syntax.html#for[For loop] ... link:syntax.html#case[Case command] .. link:syntax.html#funcdef[Function definition] . link:params.html[Parameters and variables] .. link:params.html#positional[Positional parameters] .. link:params.html#special[Special parameters] .. link:params.html#variables[Variables] ... link:params.html#shellvars[Variables used by the shell] ... link:params.html#arrays[Arrays] . link:expand.html[Word expansions] .. link:expand.html#tilde[Tilde expansion] .. link:expand.html#params[Parameter expansion] ... link:expand.html#param-prefix[Prefix] ... link:expand.html#param-name[Parameter name] ... link:expand.html#param-index[Index] ... link:expand.html#param-mod[Modifier] .. link:expand.html#cmdsub[Command substitution] .. link:expand.html#arith[Arithmetic expansion] .. link:expand.html#brace[Brace expansion] .. link:expand.html#split[Field splitting] .. link:expand.html#glob[Pathname expansion] ... link:expand.html#extendedglob[Extension in pathname expansion] . link:pattern.html[Pattern matching notation] .. link:pattern.html#normal[Normal characters] .. link:pattern.html#single[Single-character wildcard] .. link:pattern.html#multiple[Multi-character wildcard] .. link:pattern.html#bracket[Bracket expression] .. link:pattern.html#bra-normal[Normal characters (in bracket expression pattern)] .. link:pattern.html#bra-range[Range expressions] .. link:pattern.html#bra-colsym[Collating symbols] .. link:pattern.html#bra-eqclass[Equivalence classes] .. link:pattern.html#bra-chclass[Character classes] . link:redir.html[Redirection] .. link:redir.html#file[Redirection to files] ... link:redir.html#socket[Socket redirection] .. link:redir.html#dup[Duplication of file descriptors] .. link:redir.html#here[Here documents and here strings] .. link:redir.html#pipe[Pipeline redirection] .. link:redir.html#process[Process redirection] . link:exec.html[Command execution] .. link:exec.html#simple[Execution of simple commands] ... link:exec.html#search[Command search] .. link:exec.html#exit[Termination of the shell] .. link:exec.html#function[Functions] ... link:exec.html#localvar[Local variables] .. link:exec.html#environment[Command execution environment] ... link:exec.html#subshell[Subshells] . link:interact.html[Interactive mode] .. link:interact.html#prompt[Prompts] .. link:interact.html#history[Command history] .. link:interact.html#mailcheck[Mail checking] . link:job.html[Job control] .. link:job.html#jobid[Job ID] . link:builtin.html[Built-in commands] .. link:builtin.html#types[Types of built-in commands] .. link:builtin.html#argsyntax[Syntax of command arguments] . link:lineedit.html[Line-editing] .. link:lineedit.html#options[Shell options on line-editing] .. link:lineedit.html#modes[Editing modes] .. link:lineedit.html#commands[Line-editing commands] ... link:lineedit.html#basic-commands[Basic editing commands] ... link:lineedit.html#motion-commands[Motion commands] ... link:lineedit.html#editing-commands[Editing commands] ... link:lineedit.html#completion-commands[Completion commands] ... link:lineedit.html#vi-commands[Vi-specific commands] ... link:lineedit.html#emacs-commands[Emacs-specific commands] ... link:lineedit.html#history-commands[History-related commands] ... link:lineedit.html#search-commands[Search mode commands] .. link:lineedit.html#escape[Escape sequences] .. link:lineedit.html#completion[Command line completion] ... link:lineedit.html#completion-detail[Completion details] . link:posix.html[POSIXly-correct mode] . link:fgrammar.html[Formal definition of command syntax] -- [[builtins]] == Built-ins The `*' mark indicates a special built-in and the `+' mark a semi-special built-in. (See link:builtin.html#types[Types of built-in commands]) [[alpha-order]] === All built-ins in alphabetic order [role="list-group"] - link:_dot.html[+.+ (dot)] * - link:_colon.html[+:+ (colon)] * - link:_test.html[+[+ (bracket)] - link:_alias.html[+alias+] + - link:_array.html[+array+] - link:_bg.html[+bg+] + - link:_bindkey.html[+bindkey+] - link:_break.html[+break+] * - link:_cd.html[+cd+] + - link:_command.html[+command+] + - link:_complete.html[+complete+] - link:_continue.html[+continue+] * - link:_dirs.html[+dirs+] - link:_disown.html[+disown+] - link:_echo.html[+echo+] - link:_eval.html[+eval+] * - link:_exec.html[+exec+] * - link:_exit.html[+exit+] * - link:_export.html[+export+] * - link:_false.html[+false+] + - link:_fc.html[+fc+] + - link:_fg.html[+fg+] + - link:_getopts.html[+getopts+] + - link:_hash.html[+hash+] - link:_help.html[+help+] - link:_history.html[+history+] - link:_jobs.html[+jobs+] + - link:_kill.html[+kill+] + - link:_popd.html[+popd+] - link:_printf.html[+printf+] - link:_pushd.html[+pushd+] - link:_pwd.html[+pwd+] + - link:_read.html[+read+] + - link:_readonly.html[+readonly+] * - link:_return.html[+return+] * - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_suspend.html[+suspend+] * - link:_test.html[+test+] - link:_times.html[+times+] * - link:_trap.html[+trap+] * - link:_true.html[+true+] + - link:_type.html[+type+] - link:_typeset.html[+typeset+] - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_unalias.html[+unalias+] + - link:_unset.html[+unset+] * - link:_wait.html[+wait+] + [[groups]] === Categorized list of built-ins [[g-control]] ==== Execution control commands [role="list-group"] - link:_eval.html[+eval+] * - link:_dot.html[+.+ (dot)] * - link:_exec.html[+exec+] * - link:_command.html[+command+] + - link:_hash.html[+hash+] - link:_break.html[+break+] * - link:_continue.html[+continue+] * - link:_return.html[+return+] * - link:_suspend.html[+suspend+] * - link:_exit.html[+exit+] * [[g-environ]] ==== Command execution environment [role="list-group"] - link:_set.html[+set+] * - link:_ulimit.html[+ulimit+] - link:_umask.html[+umask+] + - link:_trap.html[+trap+] * - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_times.html[+times+] * [[g-job]] ==== Job control and signalling [role="list-group"] - link:_jobs.html[+jobs+] + - link:_fg.html[+fg+] + - link:_bg.html[+bg+] + - link:_wait.html[+wait+] + - link:_disown.html[+disown+] - link:_kill.html[+kill+] + - link:_trap.html[+trap+] * [[g-variable]] ==== Parameters and variables [role="list-group"] - link:_typeset.html[+typeset+] - link:_export.html[+export+] * - link:_readonly.html[+readonly+] * - link:_array.html[+array+] - link:_set.html[+set+] * - link:_shift.html[+shift+] * - link:_read.html[+read+] + - link:_getopts.html[+getopts+] + - link:_unset.html[+unset+] * [[g-directory]] ==== Working directory [role="list-group"] - link:_cd.html[+cd+] + - link:_pwd.html[+pwd+] + - link:_pushd.html[+pushd+] - link:_popd.html[+popd+] - link:_dirs.html[+dirs+] [[g-alias]] ==== Aliases [role="list-group"] - link:_alias.html[+alias+] + - link:_unalias.html[+unalias+] + [[g-history]] ==== Command history [role="list-group"] - link:_fc.html[+fc+] + - link:_history.html[+history+] [[g-print]] ==== Printing strings [role="list-group"] - link:_echo.html[+echo+] - link:_printf.html[+printf+] [[g-lineedit]] ==== Line-editing [role="list-group"] - link:_bindkey.html[+bindkey+] - link:_complete.html[+complete+] [[g-misc]] ==== Miscellaneous [role="list-group"] - link:_help.html[+help+] - link:_colon.html[+:+ (colon)] * - link:_true.html[+true+] + - link:_false.html[+false+] + - link:_test.html[+[+ (bracket), +test+] - link:_type.html[+type+] // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/asciidoc.css0000644000175000017500000000334512154557026015610 0ustar magicantmagicanthtml, body { color: black; background: white; } body { margin: 1em 5%; text-align: justify; } h1, h2, h3, h4, h5, h6 { padding: 0; padding-left: 0.5em; border-style: none none solid solid; border-bottom-width: 1px; } h1, h2, h3 { margin: 1em -3.5% 0.5em; } h4, h5, h6 { margin: 1em -2.5% 0.5em; } h1 { border-color: orange; border-left-width: 1em; } h2 { border-color: navy; border-left-width: 0.7em; } h3 { border-color: green; border-left-width: 0.5em; } .sectionbody { /*margin: 0 3%;*/ } #footer { margin: 1em -3% 0; font-size: small; border: none; border-top: 2px solid silver; } .title { border-bottom: 1px solid maroon; font-weight: bold; } .list-group p { margin-top: 0.2em; margin-bottom: 0.2em; } .admonitionblock td.icon { vertical-align: top; padding-right: 0.5em; } .exampleblock { margin: 0.8em auto; border: 0.15em dotted maroon; padding: 0 0.5em; } .exampleblock > .title { margin-top: 0.5em; } ul, ol { list-style-position: outside; } ol.arabic { list-style-type: decimal; } ol.loweralpha { list-style-type: lower-alpha; } ol.upperalpha { list-style-type: upper-alpha; } ol.lowerroman { list-style-type: lower-roman; } ol.upperroman { list-style-type: upper-roman; } li p { margin-top: 0.65em; margin-bottom: 0.65em; } dd p { margin-top: 0.1em; margin-bottom: 0.65em; } pre { border: dashed 1px gray; padding: 0.3em; } code, kbd, samp { border: dotted 1px gray; padding: 1px; text-decoration: none; white-space: pre-wrap; } pre > code:only-child, pre > kbd:only-child, pre > samp:only-child { display: block; } pre code, pre kbd, pre samp { white-space: inherit; } code { background: #efe; } kbd { background: #ffd; } samp { background: #eef; } var { color: maroon; background: inherit; } yash-2.35/doc/expand.txt0000644000175000017500000005362412154557026015345 0ustar magicantmagicant= Word expansions :encoding: UTF-8 :lang: en //:title: Yash manual - Word expansions :description: This page describes word expansions supported by yash. dfn:[Word expansion] is substitution of part of a word with another particular string. There are seven types of word expansions: . <> . <> . <> . <> . <> . <> . <> (globbing) These types of expansions are performed in the order specified above. Tilde expansion, parameter expansion, command substitution, and arithmetic expansion are called the dfn:[four expansions]. [[tilde]] == Tilde expansion In dfn:[tilde expansion], parts of words that start with a tilde (+~+) are substituted with particular pathnames. The part of each word that gets substituted is from the beginning of the word, which is a tilde, up to (but not including) the first slash (+/+) in the word. If the word does not contain a slash, the whole word is substituted. If any character in the substituted part is link:syntax.html#quotes[quoted], tilde expansion is not performed on the word. The results of expansion are determined by the format of the substituted part: +~+:: A single tilde is substituted with the value of the link:params.html#sv-home[+HOME+ variable]. +~{{username}}+:: A tilde followed by a user name is substituted with the pathname of the user's home directory. +~++:: +~++ is substituted with the value of the link:params.html#sv-pwd[+PWD+ variable]. +~-+:: +~-+ is substituted with the value of the link:params.html#sv-oldpwd[+OLDPWD+ variable]. +~+{{n}}+:: +~-{{n}}+:: where {{n}} is a non-negative integer. This type of tilde expansion yields the pathname of a directory of which +~+{{n}}+ or +~-{{n}}+ is the index in the directory stack. When tilde expansion is performed on the value of a variable assignment that occurs during execution of a link:syntax.html#simple[simple command], the value is considered as a colon-separated list of words and those words are each subject to tilde expansion. For example, the variable assignment ---- VAR=~/a:~/b:~/c ---- is equivalent to ---- VAR=/home/foo/a:/home/foo/b:/home/foo/c ---- if the value of +HOME+ variable is +/home/foo+. The POSIX standard does not prescribe how the shell should behave when it encounters an error during tilde expansion (e.g., when the +HOME+ variable is not defined). Yash silently ignores any errors during tilde expansion; the part of the word that would be substituted is left intact. In the link:posix.html[POSIXly-correct mode], tilde expansion supports the formats of +~+ and +~{{username}}+ only. [[params]] == Parameter expansion dfn:[Parameter expansion] expands to the value of a parameter. The syntax of typical, simple parameter expansion is +${{{parameter}}}+, which expands to the value of the parameter whose name is {{parameter}}. You can omit the braces (e.g., +${{parameter}}+) if - {{parameter}} is a link:params.html#special[special parameter], - {{parameter}} is a link:params.html#positional[positional parameter] whose index is a one-digit integer, or - {{parameter}} is a variable and the parameter expansion is not followed by a character that can be used as part of a variable name. + ==== For example, +${path}-name+ is equivalent to +$path-name+, but +${path}name+ and +$pathname+ are different. ==== If {{parameter}} is none of a special parameter, positional parameter, and variable, it is a syntax error. (Some shells other than yash may treat such a case as an expansion error.) If the link:_set.html#so-unset[unset option] is disabled and the {{parameter}} is an undefined variable, it is an expansion error. If the unset option is enabled, an undefined variable expands to the empty string. More complex syntax of parameter expansion allows modifying the value of a parameter. Parameter expansion:: +${ {{prefix}} {{parameter}} {{index}} {{modifier}} }+ The spaces in the syntax definition above are for readability only and must be omitted. You can omit {{prefix}}, {{index}}, and/or {{modifier}}. [[param-prefix]] === Prefix The {{prefix}}, if any, must be a hash sign (+#+). If a parameter expansion has the prefix, the result of expansion is the number of characters in the value this expansion would be expanded to without the prefix. [[param-name]] === Parameter name The parameter name ({{parameter}}) must be either - a name of a special parameter, positional parameter, or variable; or - another parameter expansion, <>, or <>. The parameter expansion is expanded to the value of the {{parameter}}. If {{parameter}} is an link:params.html#arrays[array] variable, the values of the array are <> like the link:params.html#sp-at[+@+ special parameter] unless the index +[*]+ is specified. If {{parameter}} is another expansion, it is called a dfn:[nested expansion]. Nested expansion cannot be used in the link:posix.html[POSIXly-correct mode]. The braces (+{ }+) of a nested parameter expansion cannot be omitted. [[param-index]] === Index An {{index}} allows extracting part of the parameter value (or some of array values). Index:: +[{{word1}}]+ + +[{{word1}},{{word2}}]+ where {{word1}} and {{word2}} are parsed in the same manner as normal tokens except that they are always delimited by +,+ or +]+ and can contain whitespace characters. If there is an {{index}} in a parameter expansion, it is interpreted as follows: . Words {{word1}} and {{word2}} are subjected to parameter expansion, <>, and <>. . If there is no {{word2}} and if {{word1}} expands to one of +*+, +@+, and +#+, then that is the interpretation of {{index}} and the next step is not taken. . The results of the previous steps (the expanded {{word1}} and {{word2}}) are interpreted and evaluated as an arithmetic expression in the same manner as in arithmetic expansion. The resulting integers are the interpretation of {{index}}. If the results are not integers, it is an expansion error. If there is no {{word2}}, it is assumed that {{word2}} is equal to {{word1}}. If {{parameter}} is an link:params.html#arrays[array] variable, the {{index}} specifies the part of the array. If {{parameter}} is either the link:params.html#sp-asterisk[+*+] or link:params.html#sp-at[+@+] special parameter, the {{index}} specifies the index range of positional parameters. In other cases, the {{index}} specifies the index range of a substring of the parameter value that is being expanded. In all cases, the specified range of the array values, positional parameters, or parameter value remains in the results of the expansion and other values are dropped. If the interpretation of {{index}} is one or two integers, the following rules apply: - If the interpreted index value is negative, it _wraps around_. For example, the index value of -1 corresponds to the last value/character. - It is not an error when the index value is out of range. Existing values/characters within the range are just selected. - If the interpretation of either {{word1}} or {{word2}} is 0, the range is assumed empty and the expansion results in nothing. If the interpretation of {{index}} is one of +*+, +@+, and +#+, it is treated as follows: +*+:: If {{parameter}} is an array, all values of the array are concatenated into a single string. If {{parameter}} is the +*+ or +@+ special parameter, all positional parameters are concatenated into a string. See the description of the link:params.html#sp-asterisk[+*+ special parameter] for how the values/positional parameters are separated in the result string. In other cases, the interpretation of {{index}} is treated as if the interpretation is the two integers 1 and -1. +@+:: The interpretation of {{index}} is treated as if the interpretation is the two integers 1 and -1. +#+:: The interpretation of the +#+ {{index}} is special in that it does not simply specify a range. Instead, the expanded values are substituted with the count. + If {{parameter}} is an array, the result of this parameter expansion will be the number of values in the array being expanded. If {{parameter}} is the +*+ or +@+ special parameter, the result will be the number of current positional parameters. Otherwise, the result will be the number of characters in the value that is being expanded. If a parameter expansion does not contain an {{index}}, it is assumed to be +[@]+. In the link:posix.html[POSIXly-correct mode], {{index}} cannot be specified. .Expansion of a normal variable ==== The following commands will print the string +ABC+: ---- var='123ABC789' echo "${var[4,6]}" ---- ==== .Expansion of positional parameters ==== The following commands will print the string +2 3 4+: ---- set 1 2 3 4 5 echo "${*[2,-2]}" ---- ==== .Expansion of an array ==== The following commands will print the string +2 3 4+: ---- array=(1 2 3 4 5) echo "${array[2,-2]}" ---- ==== [[param-mod]] === Modifier You can modify the value to be expanded by using dfn:[modifiers]: +-{{word}}+:: If the parameter name ({{parameter}}) is an undefined variable, the parameter expansion is expanded to {{word}}. It is not treated as an error if the link:_set.html#so-unset[unset option] is disabled. ++{{word}}+:: If the parameter name ({{parameter}}) is an existing variable, the parameter expansion is expanded to {{word}}. It is not treated as an error if the link:_set.html#so-unset[unset option] is disabled. +={{word}}+:: If the parameter name ({{parameter}}) is an undefined variable, {{word}} is assigned to the variable and the parameter expansion is expanded to {{word}}. It is not treated as an error if the link:_set.html#so-unset[unset option] is disabled. +?{{word}}+:: If the parameter name ({{parameter}}) is an undefined variable, {{word}} is printed as an error message to the standard error. If {{word}} is empty, the default error message is printed instead. +:-{{word}}+:: +:+{{word}}+:: +:={{word}}+:: +:?{{word}}+:: These are similar to the four types of modifiers above. The only difference is that, if {{parameter}} exists and has an empty value, it is also treated as an undefined variable. +#{{word}}+:: The shell performs link:pattern.html[pattern matching] against the value that is being expanded, using {{word}} as a pattern. If {{word}} matches the beginning of the value, the matching part is removed from the value and the other part remains as expansion results. The shortest matching is used if more than one matching is possible. +##{{word}}+:: This is similar to +#{{word}}+ above. The only difference is that the longest matching is used if more than one matching is possible. +%{{word}}+:: This is similar to +#{{word}}+ above. The only difference is that matching is tried at the end of the value rather than at the beginning: if {{word}} matches the end of the value, the matching part is removed from the value and the other part remains as expansion results. +%%{{word}}+:: This is similar to +%{{word}}+ above. The only difference is that the longest matching is used if more than one matching is possible. +/{{word1}}/{{word2}}+:: The shell performs link:pattern.html[pattern matching] against the value that is being expanded, using {{word1}} as a pattern. If {{word1}} matches any part of the value, the matching part is replaced with {{word2}} and the whole value after the replacement remains as expansion results. If {{word1}} matches more than one part of the value, only the first part is replaced. The shortest matching is replaced if more than one matching is possible for the same starting point in the value. + This modifier cannot be used in the link:posix.html[POSIXly-correct mode]. +/#{{word1}}/{{word2}}+:: This is similar to +/{{word1}}/{{word2}}+ above. The only difference is that {{word1}} matches only at the beginning of the value being expanded. +/%{{word1}}/{{word2}}+:: This is similar to +/{{word1}}/{{word2}}+ above. The only difference is that {{word1}} matches only at the end of the value being expanded. +//{{word1}}/{{word2}}+:: This is similar to +/{{word1}}/{{word2}}+ above. The only difference is that all matched parts are replaced if {{word1}} matches more than one part of the value. +:/{{word1}}/{{word2}}+:: This is similar to +/{{word1}}/{{word2}}+ above. The only difference is that the value is replaced only when {{word1}} matches the whole value. In all types of modifiers above, words are subjected to the four expansions when (and only when) they are used. If {{parameter}} is an array variable or the link:params.html#sp-at[+@+] or link:params.html#sp-asterisk[+*+] special parameter, modifiers affect each value of the array or all positional parameters. [[cmdsub]] == Command substitution dfn:[Command substitution] expands to output of commands specified. Command substitution:: +$({{commands}})+ + +`{{commands}}`+ When command substitution is evaluated, {{commands}} are executed by a link:exec.html#subshell[subshell] with output pipelined to the shell. When the {{commands}} finished, command substitution is substituted with the output of the {{commands}}. Any trailing newline characters in the output are ignored. When command substitution of the form +$({{commands}})+ is parsed, the {{commands}} are parsed carefully so that complex commands such as nested command substitution are parsed correctly. If {{commands}} start with +(+, you should put a space before {{commands}} so that the whole command substitution is not confused with <>. If the shell is in the link:posix.html[POSIXly-correctly mode], the {{commands}} are parsed each time the command substitution is expanded; otherwise, {{commands}} are parsed only when the command substitution is parsed. If command substitution is of the form +`{{commands}}`+, the {{commands}} are not parsed when the command substitution is parsed. The end of {{commands}} is detected by the first backquote character (+`+) after the beginning of {{commands}} that is not link:syntax.html#quotes[quoted] by a backslash. Backquotes that are part of {{commands}} (typically used for nested command substitution) must be quoted by backslashes. The {{commands}} are parsed each time the command substitution is expanded. [[arith]] == Arithmetic expansion dfn:[Arithmetic expansion] evaluates an arithmetic expression and expands to the value of the expression. Arithmetic expansion:: +$(({{expression}}))+ When arithmetic expansion is expanded, the {{expression}} is subject to <>, <>, and (nested) arithmetic expansion. The {{expression}} is parsed in (almost) same manner as an expression of the C programming language. Yash allows an expression to be either an integer (of the long type in C) or a floating-point number (of the double type in C). An operation on integers yields an integer and an operation involving a floating-point number yields a floating-point number. In the link:posix.html[POSIXly-correct mode], you can use integers only. The following operators are available (in the order of precedence): . +( )+ . `++` +--+ (postfix operators) . `++` +--+ `+` +-+ +~+ +!+ (prefix operators) . +*+ +/+ +%+ . `+` +-+ (binary operators) . +<<+ +>>+ . +<+ +<=+ +>+ +>=+ . +==+ +!=+ . +&+ . +^+ . +|+ . +&&+ . +||+ . +? :+ . +=+ +*=+ +/=+ +%=+ `+=` +-=+ +<<=+ +>>=+ +&=+ +^=+ +|=+ The `++` and `--` operators cannot be used in the POSIXly-correct mode. An atomic expression can be one of an integer literal, a floating-point number literal, and a variable. Literals are parsed in the same manner as in C. An octal integer literal starts with +0+, and hexadecimal with +0x+. A floating-point number literal may have an exponent (i.e. `1.23e+6`). A variable with a non-numeric value will result in an error. [[brace]] == Brace expansion dfn:[Brace expansion] expands to several split words with preceding and succeeding portions duplicated to each split words. Brace expansion is expanded only when the link:_set.html#so-braceexpand[brace-expand option] is enabled. Comma-separated brace expansion:: +{{{word1}},{{word2}},...,{{wordn}}}+ Range brace expansion:: +{{{start}}..{{end}}}+ + +{{{start}}..{{end}}..{{delta}}}+ Comma-separated brace expansion is expanded to each comma-separated word. For example, +a{1,2,3}b+ is expanded to the three words +a1b+, +a2b+, and +a3b+. Range brace expansion is expanded to integers in the range defined by {{start}} and {{end}}. The difference between each integer can be defined by {{delta}}. If {{start}} is larger than {{end}}, the results will be in descending order. When +..{{delta}}+ is omitted, it defaults to 1 or -1. For example, +a{1..3}b+ is expanded to the three words +a1b+, +a2b+, and +a3b+; and +a{1..7..2}b+ to the four words +a1b+, +a3b+, +a5b+, and +a7b+. Multiple brace expansions can be used in one word. Brace expansions can also be nested. You can link:syntax.html#quotes[quote] braces and/or commas to prevent them from being treated as brace expansion. Any errors in brace expansion are silently ignored. [[split]] == Field splitting In dfn:[field splitting], words are split at predefined separators. Field splitting can occur only within parts of words that resulted from <>, <>, and <> that are not between link:syntax.html#quotes[double-quotation marks]. Expansion results of the link:params.html#sp-at[+@+ special parameter] are exceptionally split even between double-quotation marks. Separators used in field splitting are defined by the value of the link:params.html#sv-ifs[+IFS+ variable]. If the variable does not exist, the value is assumed to be the three characters of space, tab, and newline. Characters included in the value of the +IFS+ variable are called dfn:[IFS characters]. IFS characters that are any of space, tab, and newline are called dfn:[IFS whitespace] and other IFS characters are called dfn:[IFS non-whitespace]. Field splitting is performed as follows: . The shell searches words for split points. A split point is one or more adjacent IFS characters within the word portions that are subject to field splitting. The following steps are taken for each split point found. . If the split point includes one or more IFS non-whitespaces, any IFS whitespaces in the split point are ignored and the word is split at each IFS non-whitespace in the split point. . If the split point includes no IFS non-whitespaces, the word is split at the split point unless it is at the beginning or end of the word. . The split points are removed from the results. [NOTE] Words are not split at all when the value of the +IFS+ variable is empty. [[glob]] == Pathname expansion dfn:[Pathname expansion] performs pattern matching and expands to pathnames matched by the pattern. A word subjected to pathname expansion is treated as a link:pattern.html[pattern]. If one or more pathnames are found that are matched by the pattern, the pathnames become the results of the pathname expansion. Pathname expansion is not performed when the link:_set.html#so-glob[glob option] is disabled. The shell searches readable directories for matching pathnames. Unreadable directories are silently ignored. The following options affect the behavior of pathname expansion: [[opt-nullglob]]null-glob:: This option affects the result of pathname expansion when no matching pathnames are found. If enabled, the result is no word. If disabled, the result is the original pattern word. [[opt-caseglob]]case-glob:: This option specifies case-sensitivity in matching. If enabled, pattern matching is done case-sensitively. [[opt-dotglob]]dot-glob:: This option affects matching of filenames that start with a period (+.+). If disabled, a period at the beginning of a filename does not match wildcard patterns (+?+ and +*+) or bracket expressions. If enabled, there is no such special treatment of periods. [[opt-markdirs]]mark-dirs:: If enabled, each resulting pathname that is a directory name is suffixed by a slash (+/+). [[opt-extendedglob]]extended-glob:: ifdef::basebackend-html[] This option enables the <>. endif::basebackend-html[] ifdef::basebackend-docbook[] This option enables the extension. (See below) endif::basebackend-docbook[] Any errors in pathname expansion are silently ignored. If the word is an invalid pattern, it just becomes the result. The results depend on the null-glob option when no matching pathnames are found. Pattern matching is done for each filename (or pathname component) of pathnames. The shell skips matching for literal patterns that contain no wildcards or bracket expressions. As a result, the patterns +/*/foo+ and +/*/fo[o]+ may yield different expansion results when the <> option is disabled; for example, the pattern +/*/fo[o]+ matches the pathname +/bar/FOO+ but the pattern +/*/foo+ does not because matching is skipped for +foo+. [[extendedglob]] === Extension in pathname expansion The following patterns can be used when the <> option is enabled. +**+:: The directory is searched recursively and the pattern matches any number of directory filenames (each separated by a slash). Any directory whose name begins with a period is excluded from search. For example, the pattern +dir/**/file+ can match the pathnames +dir/file+, +dir/foo/file+, +dir/a/b/c/file+, etc. + This pattern is not effective when appearing at the end of the whole pattern (i.e. +foo/bar/**+). +.**+:: This pattern is like +**+, but all directories are searched including ones with a name starting with a period. +***+:: This pattern is like +**+, but if a symbolic link to a directory is found during recursive search, the directory is searched recursively as well. +.***+:: This pattern is like +***+, but all directories are searched including ones with a name starting with a period. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_dot.html0000644000175000017500000001111012154557026015120 0ustar magicantmagicant Dot built-in

The dot built-in reads a file and executes commands in it.

Syntax

  • . [-AL] file [argument…]

Description

The dot built-in reads the specified file, parses its contents as commands, and executes them in the current command execution environment.

If arguments are specified, positional parameters are temporarily set to them. The positional parameters will be restored when the dot built-in finishes. If no arguments are specified, the positional parameters are not changed.

If file does not contain any slashes, the shell searches $PATH for a readable (but not necessarily executable) shell script file whose name is file in the same manner as command search. If no such file was found, the shell searches the current working directory for a file unless in the POSIXly-correct mode. To ensure that the file in the current working directory is used, start file with ‘./’.

Options

-A
--no-alias

Disable alias substitution while parsing.

-L
--autoload

Search $YASH_LOADPATH instead of $PATH, regardless of whether file contains slashes. The file value is not considered relative to the current working directory.

The dot built-in treats as operands any command line arguments after the first operand.

Operands

file

The pathname of a file to be read.

arguments

Strings to which positional parameters are set while execution.

Exit status

The exit status of the dot built-in is that of the last command executed. The exit status is zero if the file contains no commands to execute and non-zero if a file was not found or could not be opened.

Notes

The dot built-in is a special built-in.

A non-interactive shell that is not in the POSIXly-correct mode will immediately exit with a non-zero exit status if the dot built-in fails to find or open a file to execute.

The POSIX standard defines no options for the dot built-in; the built-in accepts no options in the POSIXly-correct mode.

The POSIX standard does not define the arguments… operands. It is an error to specify the arguments… operands in the POSIXly-correct mode.

yash-2.35/doc/_typeset.html0000644000175000017500000001312212154557026016034 0ustar magicantmagicant Typeset built-in

The typeset built-in prints or sets variables or functions.

Syntax

  • typeset [-gprxX] [variable[=value]…]

  • typeset -f[pr] [function…]

Description

If executed without the -f (--functions) option, the typeset built-in prints or sets variables to the standard output. Otherwise, it prints or sets functions.

If executed with the -p (--print) option, the built-in prints the variables or functions specified by operands. Without the option, it sets variables or functions. If no operands are specified, it prints all existing variables or functions, regardless of whether the -p (--print) option is specified.

Options

-f
--functions

Print or set functions rather than variables.

-g
--global

When setting a new variable, the variable will be a global variable if this option is specified. Without this option, the variable would be a local variable.

When printing variables, all existing variables including global variables are printed if this option is specified. Without this option, only local variables are printed.

-p
--print

Print variables or functions in a form that can be parsed and executed as commands that will restore the currently set variables or functions.

-r
--readonly

When setting variables or functions, make them read-only.

When printing variables or functions, print read-only variables or functions only.

-x
--export

When setting variables, mark them for export, so that they will be exported to external commands.

When printing variables, print exported variables only.

-X
--unexport

When setting variables, cancel exportation of the variables.

Operands

variable (without value)

The name of a variable that is to be set or printed.

Without the -p (--print) option, the variable is defined (if not yet defined) but its value is not set nor changed. Variables that are defined without values are treated as unset in parameter expansion.

variable=value

The name of a variable and its new value.

The value is assigned to the variable (regardless of the -p (--print) option).

function

The name of an existing function that is to be set or printed.

Exit status

The exit status of the typeset built-in is zero unless there is any error.

Notes

A global variable cannot be newly defined if a local variable has already been defined with the same name. The local variable will be set regardless of the -g (--global) option.

The POSIX standard does not define the typeset built-in.

The export and readonly built-ins are equivalent to the typeset built-in with the -gx and -gr options, respectively.

yash-2.35/doc/_fc.txt0000644000175000017500000000715012154557026014606 0ustar magicantmagicant= Fc built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Fc built-in The dfn:[fc built-in] re-executes or prints commands from link:interact.html#history[command history]. [[syntax]] == Syntax - +fc [-qr] [-e {{editor}}] [{{start}} [{{end}}]]+ - +fc -s[q] [{{old}}={{new}}] [{{start}}]+ - +fc -l[nrv] [{{start}} [{{end}}]]+ [[description]] == Description When executed without the +-l+ (+--list+) option, the built-in executes the commands in the link:interact.html#history[command history] range specified by the operands. If the +-s+ (+--silent+) option is not specified, the shell invokes an editor which allows you to edit the commands before they are executed. The commands are executed when you quit the editor. If the +-s+ (+--silent+) option is specified, the commands are immediately executed. In either case, the executed commands are printed to the standard output and added to the history. When executed with the +-l+ (+--list+) option, the built-in prints the commands in the command history range specified by the operands. By default, commands are printed with their history entry numbers, but output format can be changed using the +-n+ (+--no-numbers)+) and +-v+ (+--verbose+) options. [[options]] == Options +-e {{editor}}+:: +--editor={{editor}}+:: Specify an editor that is used to edit commands. + If this option is not specified, the value of the link:params.html#sv-fcedit[+FCEDIT+ variable] is used. If the variable is not set either, +vi+ is used. +-l+:: +--list+:: Print command history entries. +-n+:: +--no-numbers+:: Don't print entry numbers when printing history entries. +-q+:: +--quiet+:: Don't print commands before executing. +-r+:: +--reverse+:: Reverse the order of command entries in the range. +-s+:: +--silent+:: Execute commands without editing them. +-v+:: +--verbose+:: Print execution time before each history entry when printing. [[operands]] == Operands {{start}} and {{end}}:: The {{start}} and {{end}} operands specify a range of command history entries that are executed or printed. If one of the operands is an integer, it is treated as a history entry number. A negative integer means the {{n}}th most recent entry where {{n}} is the absolute value of the integer. If one of the operands is not an integer, it is treated as part of a command string: the most recent entry that starts with the string is selected as the start or end of the range. + If the first entry of the range that is specified by {{start}} is newer than the last entry of the range that is specified by {{end}}, the range is reversed as if the +-r+ (+--reverse+) option was specified. (If the option is already specified, it is cancelled.) + The default values for {{start}} and {{end}} are: + [width="50%",options="header"] |=== | |with +-l+ |without +-l+ |{{start}} |-16 |-1 |{{end}} |-16 |same as {{start}} |=== {{old}}={{new}}:: An operand of this format replaces part of the command string. If the command string contains {{old}}, it is replaced with {{new}} and the new string is executed. Only the first occurrence of {{old}} is replaced. [[exitstatus]] == Exit status If commands was executed, the exit status of the fc built-in is that of the last executed command. Otherwise, the exit status is zero unless there is any error. [[notes]] == Notes The fc built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard does not define the +-q+ (+--quiet+) or +-v+ (+--verbose+) options, so they cannot be used in the link:posix.html[POSIXly-correct mode]. Command history cannot be modified during link:lineedit.html[line-editing]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/lineedit.html0000644000175000017500000022173212154557026016005 0ustar magicantmagicant Line-editing

With the line-editing feature, you can edit the command text when you input a command to an interactive shell. It not only works as a simple visual-interface editor, but also is integrated with the command history. You can recall, edit, and execute commands in the history with line-editing instead of using the fc built-in.

Line-editing has two editing modes, the vi and emacs modes, which each have their own key binding settings. By switching editing modes, you can change key bindings used in line-editing. Each mode has a corresponding shell option, which determines whether the mode is currently active or not. No more than one mode can be active at a time, so the options for the other modes are automatically turned off when you turn on the option for one mode. The whole line-editing feature is deactivated when those options are off.

When an interactive shell is started, the vi mode is automatically activated if the standard input and error are both connected to a terminal.

Line-editing can be used only when the standard input and error are both connected to a terminal. If not, the shell silently falls back to the normal input mechanism. While line-editing is being used, the shell uses the termios interface to change I/O settings of the terminal and the terminfo interface to parse input key sequences.

Shell options on line-editing

The following options can be set by the set built-in to enable line-editing and choose an editing mode to activate:

vi

activates the vi mode.

emacs

activates the emacs mode.

The other line-editing-related options are:

le-always-rp

When this options is enabled, the right prompt is always visible: when the cursor reaches the right prompt, it moves to the next line from the original position, which would otherwise be overwritten by input text.

le-comp-debug

When enabled, internal information is printed during completion, which will help debugging completion scripts.

le-conv-meta

When enabled, the 8th bit of each input byte is always treated as a meta-key flag, regardless of terminfo data.

le-no-conv-meta

When enabled, the 8th bit of each input byte is never treated as a meta-key flag, regardless of terminfo data.

The le-conv-meta and le-no-conv-meta options cannot be both enabled at a time. When either is enabled, the other is automatically disabled. When neither is enabled, the 8th bit may be treated as a meta-key flag depending on terminfo data.

le-prompt-sp

When enabled, the shell prints a special character sequence before printing each prompt so that every prompt is printed at the beginning of a line.

This option is enabled by default.

le-visible-bell

When enabled, the shell flashes the terminal instead of sounding an alarm when an alert is required.

Editing modes

The vi mode is an editing mode that offers key bindings similar to that of the vi editor. The vi mode has two sub-modes that are switched during editing: the insert and command modes. The sub-mode is always reset to the insert mode when line-editing is started for a new command line. In the insert mode, most characters are inserted to the buffer as typed. In the command mode, input characters are treated as commands that move the cursor, insert/delete text, etc.

The emacs mode offers key bindings similar to the emacs editor. Most characters are inserted to the buffer as typed, but more characters are treated as commands than the vi insert mode.

Another sub-mode is used while you enter search keywords. The sub-mode is called the search mode, which offers slightly different key bindings depending on the active editing mode.

Line-editing commands

All characters the user enters while line-editing is active are treated as line-editing commands listed below. The bindkey built-in allows customizing the key bindings of each mode (except for the search mode).

The list below shows not only the functions of commands but also the default key bindings. The keywords “vi-insert”, “vi-command”, “vi-search”, “emacs”, “emacs-search” means the vi insert mode, the vi command mode, the search mode for the vi mode (the vi search mode), the emacs mode, and the search mode for the emacs mode (the emacs search mode), respectively.

Some commands take an argument that affects the function of the commands. For example, the forward-char command moves the cursor by as many characters as specified by the argument. To specify an argument, use the digit-argument command just before another command that takes an argument.

Basic editing commands

noop

Do nothing.

vi-command

\^[

alert

Alert.

self-insert

Insert the input character at the current cursor position. Characters escaped by escape sequences cannot be inserted.

vi-insert
emacs

\\

insert-tab

Insert a tab character at the current cursor position.

emacs

\^[\^I

expect-verbatim

Insert a character that is entered just after this command at the current cursor position. This command can input a character that cannot be input by the self-insert command, except a null character ('\0').

vi-insert
vi-search
emacs-search

\^V

emacs

\^Q, \^V

digit-argument

Pass the input digit to the next command as an argument.

This command can be bound to a digit or hyphen. To pass “12” as an argument to the forward-char command in the vi mode, for example, enter 12l.

vi-command

1, 2, 3, 4, 5, 6, 7, 8, 9

emacs

\^[0, \^[1, \^[2, \^[3, \^[4, \^[5, \^[6, \^[7, \^[8, \^[9, \^[-

bol-or-digit

Like the beginning-of-line command if there is no argument; like the digit-argument command otherwise.

vi-command

0

accept-line

Finish editing the current line. A newline is automatically appended to the line. The line will be executed by the shell.

vi-insert
vi-command
emacs
emacs-search

\^J, \^M

abort-line

Abandon the current buffer and finish editing as if an empty line was input.

vi-insert
vi-command
vi-search
emacs
emacs-search

\!, \^C

eof

Abandon the current buffer and finish editing as if the shell reached the end of input. This normally makes the shell exit.

eof-if-empty

Like the eof command if the buffer is empty; like the alert command otherwise.

vi-insert
vi-command

\#, \^D

eof-or-delete

Like the eof command if the buffer is empty; like the delete-char command otherwise.

emacs

\#, \^D

accept-with-hash

Like the accept-line command, but:

  • A hash sign (#) is inserted at the beginning of the line if there is none.

  • Otherwise, the hash sign is removed from the beginning of the line.

vi-command

#

emacs

\^[#

setmode-viinsert

Switch to the vi insert mode.

vi-command

i, \I

setmode-vicommand

Switch to the vi command mode.

vi-insert

\^[

setmode-emacs

Switch to the emacs mode.

expect-char
abort-expect-char

These commands are not meant for use by the user. They are used by the shell to implement some other commands.

redraw-all

Reprint the prompt and the current line to the terminal.

vi-insert
vi-command
vi-search
emacs
emacs-search

\^L

clear-and-redraw-all

Clear the terminal and reprint the prompt and the current line.

Motion commands

Motion commands move the cursor on the line. Most motion commands accept an argument. When passed an argument, they repeat the cursor motion as many times as specified by the argument. Passing “4” as an argument to the forward-char command, for example, advances the cursor by four characters.

The shell has several definitions of words as units of distance: A bigword is one or more adjacent non-whitespace characters. A semiword is one or more adjacent characters that contain no whitespaces or punctuations. An emacsword is one or more adjacent alphanumeric characters. A viword is either:

  • one or more adjacent alphanumeric characters and/or underscores (_), or

  • one or more adjacent characters that contain none of alphanumeric characters, underscores, and whitespaces.

forward-char

Move the cursor to the next character.

vi-insert

\R

vi-command

l, (a space), \R

emacs

\R, \^F

backward-char

Move the cursor to the previous character.

vi-insert

\L

vi-command

h, \B, \L, \?, \^H,

emacs

\L, \^B

forward-bigword

Move the cursor to the next bigword.

vi-command

W

end-of-bigword

Move the cursor to the next end of a bigword.

vi-command

E

backward-bigword

Move the cursor to the previous bigword.

vi-command

B

forward-semiword

Move the cursor to the next semiword.

end-of-semiword

Move the cursor to the next end of a semiword.

backward-semiword

Move the cursor to the previous semiword.

forward-viword

Move the cursor to the next viword.

vi-command

w

end-of-viword

Move the cursor to the next end of a viword.

vi-command

e

backward-viword

Move the cursor to the previous viword.

vi-command

b

forward-emacsword

Move the cursor to the next emacsword.

emacs

\^[f, \^[F

backward-emacsword

Move the cursor to the previous emacsword.

emacs

\^[b, \^[B

beginning-of-line

Move the cursor to the beginning of the line.

vi-insert
vi-command

\H

emacs

\H, \^A

end-of-line

Move the cursor to the end of the line.

vi-insert

\E

vi-command

$, \E

emacs

\E, \^E

go-to-column

Move the cursor to the nth character on the line, where n is the argument. Assume n = 1 when no argument.

vi-command

|

first-nonblank

Move the cursor to the first non-blank character on the line.

vi-command

^

find-char

Move the cursor to the first position where a character that is entered just after this command appears after the current cursor position.

vi-command

f

emacs

\^]

find-char-rev

Move the cursor to the last position where a character that is entered just after this command appears before the current cursor position.

vi-command

F

emacs

\^[\^]

till-char

Move the cursor to the first position just before a character that is entered just after this command appears after the current cursor position.

vi-command

t

till-char-rev

Move the cursor to the last position just after a character that is entered just after this command appears before the current cursor position.

vi-command

T

refind-char

Redo the last find-char, find-char-rev, till-char, till-char-rev command.

vi-command

;

refind-char-rev

Redo the last find-char, find-char-rev, till-char, till-char-rev command in the reverse direction.

vi-command

,

Editing commands

Editing commands modify contents of the buffer. Most editing commands accept an argument. When passed an argument, they repeat the modification as many times as specified by the argument.

Texts deleted by commands whose name starts with “kill” are saved in kill ring, from which deleted contents can be restored to the buffer. The most recent 32 texts are kept in the kill ring.

delete-char

Delete a character at the current cursor position if no argument is passed; like the kill-char command otherwise.

vi-insert
emacs

\X

delete-bigword

Delete a bigword at the current cursor position if no argument is passed; like the kill-bigword command otherwise.

delete-semiword

Delete a semiword at the current cursor position if no argument is passed; like the kill-semiword command otherwise.

delete-viword

Delete a viword at the current cursor position if no argument is passed; like the kill-viword command otherwise.

delete-emacsword

Delete a emacsword at the current cursor position if no argument is passed; like the kill-emacsword command otherwise.

backward-delete-char

Delete a character just before the current cursor position if no argument is passed; like the backward-kill-char command otherwise.

vi-insert
emacs

\B, \?, \^H

backward-delete-bigword

Delete a bigword just before the current cursor position if no argument is passed; like the backward-kill-bigword command otherwise.

backward-delete-semiword

Delete a semiword just before the current cursor position if no argument is passed; like the backward-kill-semiword command otherwise.

vi-insert

\^W

backward-delete-viword

Delete a viword just before the current cursor position if no argument is passed; like the backward-kill-viword command otherwise.

backward-delete-emacsword

Delete a emacsword just before the current cursor position if no argument is passed; like the backward-kill-emacsword command otherwise.

delete-line

Delete the whole buffer contents.

forward-delete-line

Delete all characters from the current cursor position to the end of the buffer.

backward-delete-line

Delete all characters before the current cursor position.

vi-insert

\$, \^U

kill-char

Delete a character at the current cursor position and add it to the kill ring.

vi-command

x, \X

kill-bigword

Delete a bigword at the current cursor position and add it to the kill ring.

kill-semiword

Delete a semiword at the current cursor position and add it to the kill ring.

kill-viword

Delete a viword at the current cursor position and add it to the kill ring.

kill-emacsword

Delete a emacsword at the current cursor position and add it to the kill ring.

emacs

\^[d, \^[D

backward-kill-char

Delete a character just before the current cursor position and add it to the kill ring.

vi-command

X

backward-kill-bigword

Delete a bigword just before the current cursor position and add it to the kill ring.

emacs

\^W

backward-kill-semiword

Delete a semiword just before the current cursor position and add it to the kill ring.

backward-kill-viword

Delete a viword just before the current cursor position and add it to the kill ring.

backward-kill-emacsword

Delete a emacsword just before the current cursor position and add it to the kill ring.

emacs

\^[\B, \^[\?, \^[\^H

kill-line

Delete the whole buffer contents and add it to the kill ring.

forward-kill-line

Delete all characters from the current cursor position to the end of the buffer and add it to the kill ring.

emacs

\^K

backward-kill-line

Delete all characters before the current cursor position and add it to the kill ring.

emacs

\$, \^U, \^X\B, \^X\?

put-before

Insert the last-killed text before the current cursor position and move the cursor to the last character that was inserted.

vi-command

P

put

Insert the last-killed text after the current cursor position and move the cursor to the last character that was inserted.

vi-command

p

put-left

Insert the last-killed text before the current cursor position and move the cursor to the last character that was inserted.

emacs

\^Y

put-pop

Replace the just put text with the next older killed text.

This command can be used only just after the put-before, put, put-left, or put-pop command.

emacs

\^[y, \^[Y

undo

Cancel modification by the last editing command.

vi

u

emacs

\^_, \^X\$, \^X\^U

undo-all

Cancel all modification in the current buffer, restoring the initial contents.

vi

U

emacs

\^[\^R, \^[r, \^[R

cancel-undo

Cancel cancellation by the last undo or undo-all command.

vi

\^R

cancel-undo-all

Cancel all cancellation by all most recent undo and undo-all commands.

redo

Repeat modification by the last editing command.

vi-command

.

Completion commands

complete

Complete a word just before the cursor position and, if there is more than one candidate, show a list of the candidates.

complete-next-candidate

Like the complete command when candidates are not being listed; otherwise, select the next candidate in the list.

vi-insert
emacs

\^I

complete-prev-candidate

Like the complete command when candidates are not being listed; otherwise, select the previous candidate in the list.

vi-insert
emacs

\bt

complete-next-column

Like the complete command when candidates are not being listed; otherwise, select the first candidate in the next column in the list.

complete-prev-column

Like the complete command when candidates are not being listed; otherwise, select the first candidate in the previous column in the list.

complete-next-page

Like the complete command when candidates are not being listed; otherwise, select the first candidate in the next page in the list.

complete-prev-page

Like the complete command when candidates are not being listed; otherwise, select the first candidate in the previous page in the list.

complete-list

Complete a word just before the cursor position.

If you pass no argument, a list of completion candidates is shown. Otherwise, the word is completed with the nth candidate where n is the argument.

emacs

\^[?, \^[=

complete-all

Replace a word just before the cursor position with all possible completion candidates, each separated by a space.

emacs

\^[*

complete-max

Complete a word just before the cursor position with the longest prefix of all possible completion candidates.

clear-candidates

Clear the list of completion candidates.

Vi-specific commands

vi-replace-char

Replace the character at the cursor position with a character that is entered just after this command.

vi-command

r

vi-insert-beginning

Move the cursor to the beginning of the line and switch to the vi insert mode.

vi-command

I

vi-append

Move the cursor to the next character and switch to the vi insert mode.

vi-command

I

vi-append-to-eol

Move the cursor to the end of the line and switch to the vi insert mode.

vi-command

A

vi-replace

Switch to the vi insert mode and start overwriting. While overwriting, the self-insert command replaces the character at cursor position rather than inserting a character. Overwriting ends when the editing mode is changed.

vi-command

R

vi-switch-case

Switch case of characters between the current and next cursor positions. This command must be followed by a motion command, which determines the next cursor position.

vi-switch-case-char

Switch case of the character at the current cursor position and move the cursor to the next character.

vi-command

~

vi-yank

Add to the kill ring the characters between the current and next cursor positions. This command must be followed by a motion command, which determines the next cursor position.

vi-command

y

vi-yank-to-eol

Add to the kill ring the characters from the current cursor position to the end of the line.

vi-command

Y

vi-delete

Delete characters between the current and next cursor positions and add it to the kill ring. This command must be followed by a motion command, which determines the next cursor position.

vi-command

d

vi-delete-to-eol

Delete the characters from the current cursor position to the end of the line and add it to the kill ring.

vi-command

D

vi-change

Delete characters between the current and next cursor positions and switch to the vi insert mode. This command must be followed by a motion command, which determines the next cursor position.

vi-command

c

vi-change-to-eol

Delete the characters from the current cursor position to the end of the line and switch to the vi insert mode.

vi-command

C

vi-change-line

Delete the whole buffer contents and switch to the vi insert mode.

vi-command

S

vi-yank-and-change

Like the vi-change command, but the deleted text is added to the kill ring.

vi-yank-and-change-to-eol

Like the vi-change-to-eol command, but the deleted text is added to the kill ring.

vi-yank-and-change-line

Like the vi-change-line command, but the deleted text is added to the kill ring.

vi-substitute

Delete a character at the current cursor position, add it to the kill ring, and switch to the vi insert mode.

vi-command

s

vi-append-last-bigword

Insert a space and the last bigword in the most recent command history entry just after the current cursor position and switch to the vi insert mode. If argument n is passed, the nth bigword in the entry is inserted instead of the last.

vi-command

_

vi-exec-alias

Execute the value of an alias named _c as editing commands where c is a character input just after this command.

vi-command

@

vi-edit-and-accept

Start the vi editor to edit the current buffer contents. When the editor finished, the edited buffer contents is accepted like the accept-line command unless the exit status of the editor is non-zero.

vi-command

v

vi-complete-list

Like the complete-list command, but also switch to the vi insert mode.

vi-command

=

vi-complete-all

Like the complete-all command, but also switch to the vi insert mode.

vi-command

*

vi-complete-max

Like the complete-max command, but also switch to the vi insert mode.

vi-command

\\

vi-search-forward

Switch to the vi search mode and start forward history search.

vi-command

?

vi-search-backward

Switch to the vi search mode and start backward history search.

vi-command

/

Emacs-specific commands

emacs-transpose-chars

Move a character just before the cursor to the right.

emacs

\^T

emacs-transpose-words

Move an emacsword just before the cursor to the right.

emacs

\^[t, \^[T

emacs-downcase-word

Make an emacsword just after the cursor lowercase.

emacs

\^[l, \^[L

emacs-upcase-word

Make an emacsword just after the cursor uppercase.

emacs

\^[u, \^[U

emacs-capitalize-word

Capitalize the first letter of an emacsword just after the cursor.

emacs

\^[c, \^[C

emacs-delete-horizontal-space

Delete spaces around the cursor. If any argument was passed, delete spaces just before the cursor only.

emacs

\^[\\

emacs-just-one-space

Delete spaces around the cursor and leave one space. If an argument is specified, leave as many spaces as the argument.

emacs

\^[ (Escape followed by a space)

emacs-search-forward

Switch to the emacs search mode and start forward history search.

emacs

\^S

emacs-search-backward

Switch to the emacs search mode and start backward history search.

emacs

\^R

History-related commands

oldest-history

Recall the oldest entry in the history. If argument n is passed, the entry whose number is n is recalled instead. The cursor position remains unchanged.

newest-history

Recall the newest entry in the history. If argument n is passed, the entry whose number is n is recalled instead. The cursor position remains unchanged.

return-history

Return to the initial buffer corresponding to none of existing history entries. If argument n is passed, the entry whose number is n is recalled instead. The cursor position remains unchanged.

oldest-history-bol

Recall the oldest entry in the history and move the cursor to the beginning of the line. If argument n is passed, the entry whose number is n is recalled instead.

vi-command

G

newest-history-bol

Recall the newest entry in the history and move the cursor to the beginning of the line. If argument n is passed, the entry whose number is n is recalled instead.

return-history-bol

Return to the initial buffer corresponding to none of existing history entries and move the cursor to the beginning of the line. If argument n is passed, the entry whose number is n is recalled instead.

vi-command

g

oldest-history-eol

Recall the oldest entry in the history and move the cursor to the end of the line. If argument n is passed, the entry whose number is n is recalled instead.

emacs

\^[<

newest-history-eol

Recall the newest entry in the history and move the cursor to the end of the line. If argument n is passed, the entry whose number is n is recalled instead.

return-history-eol

Return to the initial buffer corresponding to none of existing history entries and move the cursor to the end of the line. If argument n is passed, the entry whose number is n is recalled instead.

emacs

\^[>

next-history

Recall the next history entry. The cursor position remains unchanged.

prev-history

Recall the previous history entry. The cursor position remains unchanged.

next-history-bol

Recall the next history entry and move the cursor to the beginning of the line.

vi-command

j, +, \D, \^N

prev-history-bol

Recall the previous history entry and move the cursor to the beginning of the line.

vi-command

k, -, \U, \^P

next-history-eol

Recall the next history entry and move the cursor to the end of the line.

vi-insert
emacs

\D, \^N

prev-history-eol

Recall the previous history entry and move the cursor to the end of the line.

vi-insert
emacs

\U, \^P

search-again

Repeat the last command history search.

vi-command

n

search-again-rev

Repeat the last command history search in the reverse direction.

vi-command

N

search-again-forward

Repeat the last command history search in the forward direction.

search-again-backward

Repeat the last command history search in the backward direction.

beginning-search-forward

Recall the next history entry that starts with the same text as the text from the beginning of the line up to the current cursor position. The cursor position remains unchanged.

beginning-search-backward

Recall the previous history entry that starts with the same text as the text from the beginning of the line up to the current cursor position. The cursor position remains unchanged.

Search mode commands

srch-self-insert

Insert the input character at the current cursor position. Characters escaped by escape sequences cannot be inserted.

vi-search
emacs-search

\\

srch-backward-delete-char

Delete the last character in the search text. If the text is empty:

  • like the srch-abort-search command when in the vi search mode, or

  • like the alert command when in the emacs search mode.

vi-search
emacs-search

\B, \?, \^H

srch-backward-delete-line

Delete the whole search text.

vi-search
emacs-search

\$, \^U

srch-continue-forward

Find the next matching history entry.

emacs-search

\^S

srch-continue-backward

Find the previous matching history entry.

emacs-search

\^R

srch-accept-search

Finish the search mode, accepting the result being shown.

vi-search

\^J, \^M

emacs-search

\^J, \^[

srch-abort-search

Abort search and restore the previous buffer contents.

vi-search

\^[

emacs-search

\^G

Escape sequences

In the bindkey built-in, escape sequences are used to represent special keys such as function keys and arrow keys. Every escape sequence starts with a backslash (\) and thus there is also an escape sequence for a backslash itself.

Below are available escape sequences:

\\

Backslash (\)

\B

Backspace

\D

Down arrow

\E

End

\H

Home

\I

Insert (Insert-char, Enter-insert-mode)

\L

Left arrow

\N

Page-down (Next-page)

\P

Page-up (Previous-page)

\R

Right arrow

\U

Up arrow

\X

Delete

\!

INTR

\#

EOF

\$

KILL

\?

ERASE

\^@

Ctrl + @

\^A, \^B, …, \^Z

Ctrl + A, Ctrl + B, …, Ctrl + Z

Note that Ctrl + I, Ctrl + J, and Ctrl + M are tab, newline, and carriage return, respectively.

\^[

Ctrl + [ (Escape)

\^\

Ctrl + \

\^]

Ctrl + ]

\^^

Ctrl + ^

\^_

Ctrl + _

\^?

Ctrl + ? (Delete)

\F00, \F01, …, \F63

F0, F1, …, F63

\a1

Top-left on keypad

\a3

Top-right on keypad

\b2

Center on keypad

\bg

Beginning

\bt

Back-tab

\c1

Bottom-left on keypad

\c3

Bottom-right on keypad

\ca

Clear-all-tabs

\cl

Close

\cn

Cancel

\co

Command

\cp

Copy

\cr

Create

\cs

Clear-screen or erase

\ct

Clear-tab

\dl

Delete-line

\ei

Exit-insert-mode

\el

Clear-to-end-of-line

\es

Clear-to-end-of-screen

\et

Enter (Send)

\ex

Exit

\fd

Find

\hp

Help

\il

Insert-line

\ll

Home-down

\me

Message

\mk

Mark

\ms

Mouse event

\mv

Move

\nx

Next-object

\on

Open

\op

Options

\pr

Print (Copy)

\pv

Previous-object

\rd

Redo

\re

Resume

\rf

Ref (Reference)

\rh

Refresh

\rp

Replace

\rs

Restart

\sf

Scroll-forward (Scroll-down)

\sl

Select

\sr

Scroll-backward (Scroll-up)

\st

Set-tab

\su

Suspend

\sv

Save

\ud

Undo

\SE

Shift + End

\SH

Shift + Home

\SI

Shift + Insert

\SL

Shift + Left arrow

\SR

Shift + Right arrow

\SX

Shift + Delete

\Sbg

Shift + Beginning

\Scn

Shift + Cancel

\Sco

Shift + Command

\Scp

Shift + Copy

\Scr

Shift + Create

\Sdl

Shift + Delete-line

\Sel

Shift + End-of-line

\Sex

Shift + Exit

\Sfd

Shift + Find

\Shp

Shift + Help

\Smg

Shift + Message

\Smv

Shift + Move

\Snx

Shift + Next

\Sop

Shift + Options

\Spr

Shift + Print

\Spv

Shift + Previous

\Srd

Shift + Redo

\Sre

Shift + Resume

\Srp

Shift + Replace

\Ssu

Shift + Suspend

\Ssv

Shift + Save

\Sud

Shift + Undo

INTR, EOF, KILL, and ERASE are special characters configured by the stty command. In a typical configuration, they are sent by typing Ctrl+C, Ctrl+D, Ctrl+U, and Ctrl+H, respectively, but some configuration uses Ctrl+? instead of Ctrl+H for ERASE.

Command line completion

By using the complete and complete-next-candidate commands, etc., you can complete command names, options, and operands. By default, the complete-next-candidate command is bound with the Tab key in the vi insert and emacs modes.

Type a few first letters of a command name or pathname and hit the Tab key, and a list of matching names will be shown. You can choose a candidate from the list to complete the name by hitting the Tab key again. If there is only one matching name, no list will be shown and the name will directly be completed.

If the name to be completed contains characters like * and ?, it is treated as a pattern. The name on the command line will be directly substituted with all possible names matching the pattern (you cannot choose from a list).

Normally, command names are completed with command names and command arguments with pathnames. However, completion functions can be defined to refine completion results.

Completion details

When doing completion for the first time after the shell has been started, the INIT file is loaded as if the command string . -AL completion/INIT is executed. If the file is not found, it is silently ignored. This automatic loading is mainly intended for loading completion functions bundled with the shell, but you can let the shell load your own functions by putting a file in the load path.

When completing a command name, the shell executes the completion//command function and when completing a command argument, the completion//argument function. If those completion functions are not defined, the shell just completes with command names or pathnames. When completing other names, such as the user name in tilde expansion and the parameter name in parameter expansion, completion functions are never used: the shell just completes with user names, parameter names, or whatever applicable.

Completion functions are executed without any arguments. The following local variables are automatically defined while executing completion functions:

IFS

The value is the three characters of a space, a tab, and a newline, which are the default value of the variable.

WORDS

This variable is an array whose elements are a command name and arguments that have already been entered before the argument being completed. When completing a command name, the array has no elements.

TARGETWORD

The value is the partially entered command name or argument that is being completed.

Completion candidates are generated by executing the complete built-in during a completion function.

Completion functions must not perform I/O to the terminal, or displayed text will be corrupted. Completion functions should run as quickly as possible for better user experience.

While a completion function is being executed:

yash-2.35/doc/_bindkey.html0000644000175000017500000000741612154557026015775 0ustar magicantmagicant Bindkey built-in

The bindkey built-in prints or modifies key bindings used in line-editing.

Syntax

  • bindkey -aev [key [command]]

  • bindkey -l

Description

When executed with the -l (--list) option, the built-in lists all available line-editing commands to the standard output.

When executed with one of the other options, the built-in prints or modifies key bindings for the editing mode specified by the option:

  • Without key or command, all currently defined bindings are printed to the standard output in a form that can be parsed as commands that restore the current bindings when executed.

  • With key but without command, only the binding for the given key is printed.

  • With key and command, key is bound to command.

Options

-a
--vi-command

Print or modify bindings for the vi command mode.

-e
--emacs

Print or modify bindings for the emacs mode.

-v
--vi-insert

Print or modify bindings for the vi insert mode.

Operands

key

A character sequence of one or more keys that is bound to an editing command. The sequence may include escape sequences.

command

A line-editing command to which key is bound. If command is a single hyphen (-), key is unbound.

Exit status

The exit status of the bindkey built-in is zero unless there is any error.

Notes

The bindkey built-in is not defined in the POSIX standard.

yash-2.35/doc/_ulimit.html0000644000175000017500000001516012154557026015646 0ustar magicantmagicant Ulimit built-in

The ulimit built-in sets or prints a resource limit.

Syntax

  • ulimit -a [-H|-S]

  • ulimit [-H|-S] [-efilnqrstuvx] [limit]

Description

The ulimit built-in sets or prints a resource limit.

If executed with the -a (--all) option, the built-in prints the current limits for all resource types. Otherwise, it sets or prints the limit of a single resource type. The resource type can be specified by the options listed below. The resource limits will affect the current shell process and all commands invoked from the shell.

Each resource type has two limit values: the hard and soft limit. You can change a soft limit freely as long as it does not exceed the hard limit. You can decrease a hard limit but cannot increase it without a proper permission.

When the -H (--hard) or -S (--soft) option is specified, the built-in sets or prints the hard or soft limit, respectively. If neither of the options is specified, the built-in sets both the hard and soft limit or prints the soft limit.

Options

-H
--hard

Set or print a hard limit.

-S
--soft

Set or print a soft limit.

-a
--all

Print all current limit settings.

The following options specify the type of resources. If none of them is specified, -f is the default. The types of resources that can be set depend on the operating system.

-c
--core

Maximum size of core files created (in 512-byte blocks)

-d
--data

Maximum size of a process’s data segment (in kilobytes)

-e
--nice

Maximum scheduling priority (‘nice’)

-f
--fsize

Maximum size of files created by a process (in 512-byte blocks)

-i
--sigpending

Maximum number of pending signals

-l
--memlock

Maximum memory size that can be locked into RAM (in kilobytes)

-m
--rss

Maximum size of a process’s resident set (in kilobytes)

-n
--nofile

Maximum file descriptor + 1

-q
--msgqueue

Maximum size of POSIX message queues

-r
--rtprio

Maximum real-time scheduling priority

-s
--stack

Maximum size of a process’s stack (in kilobytes)

-t
--cpu

Maximum CPU time that can be used by a process (in seconds)

-u
--nproc

Maximum number of processes for a user

-v
--as

Maximum size of memory used by a process (in kilobytes)

-x
--locks

Maximum number of file locks

Operands

limit

A limit to be set.

The value must be a non-negative integer or one of hard, soft, and unlimited. If value is hard or soft, the new limit is set to the current hard or soft limit. If limit is not specified, the current limit is printed.

Exit status

The exit status of the ulimit built-in is zero unless there is any error.

Notes

The POSIX standard defines no options other than -f. It neither defines hard, soft, or unlimited for limit values.

yash-2.35/doc/_getopts.txt0000644000175000017500000000703112154557026015701 0ustar magicantmagicant= Getopts built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Getopts built-in The dfn:[getopts built-in] parses command options. [[syntax]] == Syntax - +getopts {{optionlist}} {{variable}} [{{argument}}...]+ [[description]] == Description The getopts built-in parses link:builtin.html#argsyntax[single-character options] that appear in {{argument}}s. Each time the built-in is invoked, it parses one option and assigns the option character to {{variable}}. The {{optionlist}} operand is a list of option characters that should be accepted by the parser. In {{optionlist}}, an option that takes an argument should be specified as the option character followed by a colon. For example, if you want the +-a+, +-b+ and +-c+ options to be parsed and the +-b+ option to take an argument, then {{optionlist}} should be +ab:c+. When an option that takes an argument is parsed, the argument is assigned to the link:params.html#sv-optarg[+OPTARG+ variable]. When an option that is not specified in {{optionlist}} is found or when an option argument is missing, the result depends on the first character of {{optionlist}}: - If {{optionlist}} starts with a colon, the option character is assigned to the +OPTARG+ variable and {{variable}} is set to either +?+ (when the option is not in {{optionlist}}) or +:+ (when the option argument is missing). - Otherwise, {{variable}} is set to +?+, the +OPTARG+ variable is unset, and an error message is printed. The built-in parses one option for each execution. For all options in a set of command line arguments to be parsed, the built-in has to be executed repeatedly with the same arguments. The built-in uses the link:params.html#sv-optind[+OPTIND+ variable] to remember which {{argument}} should be parsed next. When the built-in is invoked for the first time, the variable value must be +1+, which is the default value. You must not modify the variable until all the options have been parsed, when the built-in sets the variable to the index of the first operand in {{argument}}s. (If there are no operands, it will be set to the number of {{argument}}s plus one.) When you want to start parsing a new set of {{argument}}s, you have to reset the +OPTIND+ variable to +1+ beforehand. [[operands]] == Operands {{optionlist}}:: A list of options that should be accepted as valid options in parsing. {{variable}}:: The name of a variable the result is to be assigned to. {{argument}}s:: Command line arguments that are to be parsed. + When no {{argument}}s are given, the link:params.html#positional[positional parameters] are parsed. [[exitstatus]] == Exit status If an option is found, whether or not it is specified in {{optionlist}}, the exit status is zero. If there is no more option to be parsed, the exit status is non-zero. [[example]] == Example ---- aopt=false bopt= copt=false while getopts ab:c opt do case $opt in a) aopt=true ;; b) bopt=$OPTARG ;; c) copt=true ;; \?) return 2 ;; esac done if $aopt; then echo Option -a specified; fi if [ -n "$bopt" ]; then echo Option -b $bopt specified; fi if $copt; then echo Option -c specified; fi shift $((OPTIND - 1)) echo Operands are: $* ---- [[notes]] == Notes In {{argument}}s that are parsed, options must precede operands. The built-in ends parsing when it encounters the first operand. The getopts built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard does not specify what will happen when the +OPTIND+ variable is assigned a value other than +1+. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/job.txt0000644000175000017500000001205112154557026014625 0ustar magicantmagicant= Job control :encoding: UTF-8 :lang: en //:title: Yash manual - Job control :description: This page describes yash's job control feature. dfn:[Job control] is a function of the shell that executes multiple commands simultaneously and suspends/resumes the commands. When control is active: - Every link:syntax.html#pipelines[pipeline] executed by the shell becomes a dfn:[job]. A job has its unique process group ID that is shared among all processes in the job. - If the processes of a job are suspended while the shell is waiting for the processes to finish, the shell continues to the next command as if the process have finished. The shell remembers the job as suspended so that it can be resumed later. - If a job is executed link:syntax.html#async[synchronously], the shell sets the foreground process group of the terminal to the process group of the job. When the job is finished (or suspended), the shell gets back to the foreground. - The link:exec.html#subshell[subshell] executing a link:expand.html#cmdsub[command substitution] has its own unique process group ID like a job. However, the shell does not remember the subshell as a job, so it cannot be suspended or resumed. - If the shell is link:interact.html[interactive], job status is reported before every command line prompt as if the command +link:_jobs.html[jobs] -n+ is executed. - The standard input of an link:syntax.html#async[asynchronous command] is not automatically redirected to /dev/null (unless in the link:posix.html[POSIXly-correct mode]). - The shell does not exit when it receives the SIGTSTP signal. - The value of the link:params.html#sp-hyphen[+-+ special parameter] contains +m+. - When a job finished for which the link:_wait.html[wait built-in] has been waiting, the fact is reported (only if the shell is link:interact.html[interactive] and not in the link:posix.html[POSIXly-correct mode]). When job control is inactive, processes executed by the shell have the same process group ID as the shell. The shell treats link:syntax.html#async[asynchronous commands] as an uncontrolled job. You can use the following built-ins to manipulate jobs: link:_jobs.html[jobs]:: prints existing jobs link:_fg.html[fg] and link:_bg.html[bg]:: run jobs in the foreground or background link:_wait.html[wait]:: waits for jobs to be finished (or suspended) link:_disown.html[disown]:: forgets jobs link:_kill.html[kill]:: sends a signal to jobs An interactive job-controlling shell reports jobs status before every prompt by default. You can set the following options to make the shell report status at other timings: link:_set.html#so-notify[notify]:: the shell reports immediately whenever job status changes. link:_set.html#so-notifyle[notify-le]:: the shell reports immediately when job status changes while link:lineedit.html[line-editing]. A job is removed from the shell's job list when: - it has finished and the ``finished'' status is reported, - the link:_wait.html[wait built-in] successfully waited for the job to finish, or - the link:_disown.html[disown built-in] removed the job. [NOTE] The word ``stop'' is synonymous to ``suspend'' in the context of job control. [[jobid]] == Job ID Some link:builtin.html[built-in]s use the following notation, which is called dfn:[job ID], to specify a job to operate on: +%+:: +%%+:: +%++:: the current job +%-+:: the previous job +%{{n}}+:: the job that has job number {{n}}, where {{n}} is a positive integer +%{{string}}+:: the job whose name begins with {{string}} +%?{{string}}+:: the job whose name contains {{string}} The dfn:[current job] and dfn:[previous job] are jobs selected by the shell according to the following rules: - When there is one or more suspended jobs, the current job is selected from them. - When there is one or more suspended jobs other than the current job, the previous job is selected from them. - The current and previous jobs are always different. When the shell has only one job, it is the current job and there is no previous job. - When the current job finished, the previous job becomes the current job. - When the current job is changed, the old current job becomes the previous job except when the old job finished. - When the foreground job is suspended, the job becomes the current job. Yash has some options to modify the rules of the current/previous job selection. (The rules above have priority over the options below.) link:_set.html#so-curasync[cur-async]:: When a new link:syntax.html#async[asynchronous command] is started, it becomes the current job. link:_set.html#so-curbg[cur-bg]:: When a job is resumed by the link:_bg.html[bg built-in], the job becomes the current job. link:_set.html#so-curstop[cur-stop]:: When a job is suspended, it becomes the current job. The current and previous jobs are not changed as long as the rules above are met. The rules of the current/previous job selection defined in the POSIX standard are looser than yash's rules above. Other POSIX-compliant shells may select the current and previous jobs differently. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_read.html0000644000175000017500000000760012154557026015256 0ustar magicantmagicant Read built-in

The read built-in reads a line from the standard input.

Syntax

  • read [-Ar] variable

Description

The read built-in reads a line of string from the standard input and assigns it to the specified variables. If the shell is interactive and line-editing is enabled, you can use line-editing when inputting a line.

If the -r (--raw-mode) option is specified, all characters in the line are treated literally.

If the -r (--raw-mode) option is not specified, backslashes in the line are treated as quotations. If a backslash is at the end of the line, it is treated as a line continuation. When the built-in reads the next line, the PS2 variable is used as a prompt if the standard input is a terminal.

The input line is subject to field splitting. The resulting words are assigned to variables in order. If there are more words than variables, the last variable is assigned all the remaining words (as if the words were not split). If the words are fewer than variables, the remaining variables are assigned empty strings.

Options

-A
--array

Make the last variable an array. Instead of assigning a concatenation of the remaining words to a normal variable, the words are assigned to an array.

-r
--raw-mode

Don’t treat backslashes as quotations.

Operands

variables

Names of variables to which input words are assigned.

Exit status

The exit status of the read built-in is zero unless there is any error.

Notes

The read built-in is a semi-special built-in.

The POSIX standard defines the -r option only: other options cannot be used in the POSIXly-correct mode.

yash-2.35/doc/_bindkey.txt0000644000175000017500000000337712154557026015652 0ustar magicantmagicant= Bindkey built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Bindkey built-in The dfn:[bindkey built-in] prints or modifies key bindings used in link:lineedit.html[line-editing]. [[syntax]] == Syntax - +bindkey -aev [{{key}} [{{command}}]]+ - +bindkey -l+ [[description]] == Description When executed with the +-l+ (+--list+) option, the built-in lists all available link:lineedit.html#commands[line-editing commands] to the standard output. When executed with one of the other options, the built-in prints or modifies key bindings for the link:lineedit.html#modes[editing mode] specified by the option: - Without {{key}} or {{command}}, all currently defined bindings are printed to the standard output in a form that can be parsed as commands that restore the current bindings when executed. - With {{key}} but without {{command}}, only the binding for the given {{key}} is printed. - With {{key}} and {{command}}, {{key}} is bound to {{command}}. [[options]] == Options +-a+:: +--vi-command+:: Print or modify bindings for the vi command mode. +-e+:: +--emacs+:: Print or modify bindings for the emacs mode. +-v+:: +--vi-insert+:: Print or modify bindings for the vi insert mode. [[operands]] == Operands {{key}}:: A character sequence of one or more keys that is bound to an editing command. The sequence may include link:lineedit.html#escape[escape sequences]. {{command}}:: A link:lineedit.html#commands[line-editing command] to which {{key}} is bound. If {{command}} is a single hyphen (+-+), {{key}} is unbound. [[exitstatus]] == Exit status The exit status of the bindkey built-in is zero unless there is any error. [[notes]] == Notes The bindkey built-in is not defined in the POSIX standard. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_trap.txt0000644000175000017500000000475312154557026015172 0ustar magicantmagicant= Trap built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Trap built-in The dfn:[trap built-in] sets or prints signal handlers. [[syntax]] == Syntax - +trap+ - +trap {{action}} {{signal}}...+ - +trap {{signal_number}} [{{signal}}...]+ - +trap -p [{{signal}}...]+ [[description]] == Description The trap built-in sets or prints actions that are taken when the shell receives signals. (Those actions are called dfn:[traps].) When executed with {{action}} and one or more {{signal}}s, the built-in sets the traps for {{signal}}s to {{action}}. If the shell receives one of the signals, the action will be taken. If the first operand is {{signal_number}} instead of {{action}}, the built-in resets the traps for {{signal_number}} and {{signal}}s as if {{action}} was +-+. When executed with the +-p+ (+--print+) option or with no operands, the built-in prints currently set traps to the standard output in a format that can be executed as commands that restore the current traps. If one or more {{signal}}s are specified, only those signals are printed. Otherwise, all signals with non-default actions are printed. [[options]] == Options +-p+:: +--print+:: Print current trap settings. [[operands]] == Operands {{action}}:: An action that will be taken when {{signal}} is received. + If {{action}} is a single hyphen (+-+), the action is reset to the default action that is defined by the operating system. If {{action}} is an empty string, the signal is ignored on receipt. Otherwise, {{action}} is treated as a command string: the string is parsed and executed as commands when the signal is received. (If a signal is received while a command is being executed, the action is taken just after the command finishes.) {{signal}}:: The number or name of a signal. + If {{signal}} is number +0+ or name +EXIT+, it is treated as a special imaginary signal that is always received when the shell exits. The action set for this signal is taken when the shell exits normally. {{signal_number}}:: This is like {{signal}}, but must be a number. [[exitstatus]] == Exit status The exit status of the trap built-in is zero unless there is any error. [[notes]] == Notes The trap built-in is a link:builtin.html#types[special built-in]. The POSIX standard requires that signal names must be specified without the +SIG+-prefix, like +INT+ and +QUIT+. As an extension, yash accepts +SIG+-prefixed names like +SIGINT+ and +SIGQUIT+ and treats signal names case-insensitively. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_read.txt0000644000175000017500000000403612154557026015131 0ustar magicantmagicant= Read built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Read built-in The dfn:[read built-in] reads a line from the standard input. [[syntax]] == Syntax - +read [-Ar] {{variable}}...+ [[description]] == Description The read built-in reads a line of string from the standard input and assigns it to the specified link:params.html#variables[variables]. If the shell is link:interact.html[interactive] and link:lineedit.html[line-editing] is enabled, you can use line-editing when inputting a line. If the +-r+ (+--raw-mode+) option is specified, all characters in the line are treated literally. If the +-r+ (+--raw-mode+) option is not specified, backslashes in the line are treated as link:syntax.html#quotes[quotations]. If a backslash is at the end of the line, it is treated as a line continuation. When the built-in reads the next line, the link:params.html#sv-ps2[+PS2+ variable] is used as a prompt if the standard input is a terminal. The input line is subject to link:expand.html#split[field splitting]. The resulting words are assigned to {{variable}}s in order. If there are more words than {{variable}}s, the last variable is assigned all the remaining words (as if the words were not split). If the words are fewer than {{variable}}s, the remaining variables are assigned empty strings. [[options]] == Options +-A+:: +--array+:: Make the last {{variable}} an link:params.html#arrays[array]. Instead of assigning a concatenation of the remaining words to a normal variable, the words are assigned to an array. +-r+:: +--raw-mode+:: Don't treat backslashes as quotations. [[operands]] == Operands {{variable}}s:: Names of variables to which input words are assigned. [[exitstatus]] == Exit status The exit status of the read built-in is zero unless there is any error. [[notes]] == Notes The read built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard defines the +-r+ option only: other options cannot be used in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/yash.txt.in0000644000175000017500000000052612154557026015430 0ustar magicantmagicant= YASH(1) Yuki Watanabe v{yashversion}, :encoding: UTF-8 :lang: en == Name yash - a POSIX-compliant command line shell == Synopsis +yash [options...] [--] [operands...]+ :leveloffset: 1 // (Replaced with generated contents list) // :leveloffset: 0 // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_kill.html0000644000175000017500000001371312154557026015300 0ustar magicantmagicant Kill built-in

The kill built-in sends a signal to processes.

Syntax

  • kill [-signal|-s signal|-n signal] process

  • kill -l [-v] [signal…]

The kill built-in requires that all options precede operands. Any command line arguments after the first operand are all treated as operands.

Description

When executed without the -l option, the built-in sends a signal to processes. The signal sent can be specified by option. The SIGTERM signal is sent if no signal is specified.

When executed with the -l option, the built-in prints information of signals to the standard output. If no signal is specified, information of all signals is printed.

Options

Signal-specifying options

-signal
-s signal
-n signal

A signal-specifying option specifies a signal to be sent to processes. signal can be specified by name or number. If number 0 is specified, the built-in checks if a signal could be sent to the processes but no signal is actually sent. Signal names are case-insensitive.

You can specify at most one signal-specifying option at a time.

Other options

-l

Print signal information instead of sending a signal.

-v

Print more signal information.

Without this option, the built-in prints the signal name only. This option adds the signal number and a short description.

When the -v option is specified, the -l option can be omitted.

Operands

processes

Specify processes to which a signal is sent.

Processes can be specified by the process ID, the process group ID, or the job ID. The process group ID must be prefixed with a hyphen (-) so that it is not treated as a process ID.

When 0 is specified as process, the signal is sent to the process group to which the shell process belongs. When -1 is specified, the signal is sent to all processes on the system.

signal

Specify a signal of which information is printed.

The signal can be specified by the name, the number, or the exit status of a command that was killed by the signal.

Exit status

The exit status of the kill built-in is zero unless there is any error. If the signal was sent to at least one process, the exit status is zero even if the signal was not sent to all of the specified processes.

Notes

The kill built-in is a semi-special built-in.

Command arguments that start with a hyphen should be used with care. The command kill -1 -2, for example, sends signal 1 to process group 2 since -1 is treated as a signal-specifying option and -2 as an operand that specifies a process group. The commands kill -- -1 -2 and kill -TERM -1 -2, on the other hand, treats both -1 and -2 as operands.

The POSIX standard does not define the -n or -v options, so they cannot be used in the POSIXly-correct mode. The standard does not allow specifying a signal number as the argument of the -s option or a signal name as the signal operand.

The standard requires signal names to be specified without the SIG prefix, like INT and QUIT. If the shell is not in the POSIXly-correct mode, the built-in accepts SIG-prefixed signal names as well.

yash-2.35/doc/_ulimit.txt0000644000175000017500000000600112154557026015513 0ustar magicantmagicant= Ulimit built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Ulimit built-in The dfn:[ulimit built-in] sets or prints a resource limit. [[syntax]] == Syntax - +ulimit -a [-H|-S]+ - +ulimit [-H|-S] [-efilnqrstuvx] [{{limit}}]+ [[description]] == Description The ulimit built-in sets or prints a resource limit. If executed with the +-a+ (+--all+) option, the built-in prints the current limits for all resource types. Otherwise, it sets or prints the limit of a single resource type. The resource type can be specified by the options listed below. The resource limits will affect the current shell process and all commands invoked from the shell. Each resource type has two limit values: the hard and soft limit. You can change a soft limit freely as long as it does not exceed the hard limit. You can decrease a hard limit but cannot increase it without a proper permission. When the +-H+ (+--hard+) or +-S+ (+--soft+) option is specified, the built-in sets or prints the hard or soft limit, respectively. If neither of the options is specified, the built-in sets both the hard and soft limit or prints the soft limit. [[options]] == Options +-H+:: +--hard+:: Set or print a hard limit. +-S+:: +--soft+:: Set or print a soft limit. +-a+:: +--all+:: Print all current limit settings. The following options specify the type of resources. If none of them is specified, +-f+ is the default. The types of resources that can be set depend on the operating system. +-c+:: +--core+:: Maximum size of core files created (in 512-byte blocks) +-d+:: +--data+:: Maximum size of a process's data segment (in kilobytes) +-e+:: +--nice+:: Maximum scheduling priority (`nice') +-f+:: +--fsize+:: Maximum size of files created by a process (in 512-byte blocks) +-i+:: +--sigpending+:: Maximum number of pending signals +-l+:: +--memlock+:: Maximum memory size that can be locked into RAM (in kilobytes) +-m+:: +--rss+:: Maximum size of a process's resident set (in kilobytes) +-n+:: +--nofile+:: Maximum file descriptor + 1 +-q+:: +--msgqueue+:: Maximum size of POSIX message queues +-r+:: +--rtprio+:: Maximum real-time scheduling priority +-s+:: +--stack+:: Maximum size of a process's stack (in kilobytes) +-t+:: +--cpu+:: Maximum CPU time that can be used by a process (in seconds) +-u+:: +--nproc+:: Maximum number of processes for a user +-v+:: +--as+:: Maximum size of memory used by a process (in kilobytes) +-x+:: +--locks+:: Maximum number of file locks [[operands]] == Operands {{limit}}:: A limit to be set. + The value must be a non-negative integer or one of `hard`, `soft`, and `unlimited`. If {{value}} is `hard` or `soft`, the new limit is set to the current hard or soft limit. If {{limit}} is not specified, the current limit is printed. [[exitstatus]] == Exit status The exit status of the ulimit built-in is zero unless there is any error. [[notes]] == Notes The POSIX standard defines no options other than +-f+. It neither defines `hard`, `soft`, or `unlimited` for {{limit}} values. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_popd.txt0000644000175000017500000000161712154557026015162 0ustar magicantmagicant= Popd built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Popd built-in The dfn:[popd built-in] pops a directory from the directory stack. [[syntax]] == Syntax - +popd [{{index}}]+ [[description]] == Description The popd built-in removes the last entry from the link:_dirs.html[directory stack], returning to the previous working directory. If {{index}} is given, the entry specified by {{index}} is removed instead of the last one. [[operands]] == Operands {{index}}:: The index of a directory stack entry you want to remove. + If omitted, `+0` (the last entry) is assumed. [[exitstatus]] == Exit status The exit status of the popd built-in is zero unless there is any error. [[notes]] == Notes It is an error to use this built-in when there is only one directory stack entry. The popd built-in is not defined in the POSIX standard. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_alias.txt0000644000175000017500000000277412154557026015316 0ustar magicantmagicant= Alias built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Alias built-in The dfn:[alias built-in] defines and/or prints link:syntax.html#aliases[aliases]. [[syntax]] == Syntax - +alias [-gp] [{{name}}[={{value}}]...]+ [[description]] == Description The alias built-in defines and/or prints link:syntax.html#aliases[aliases] as specified by operands. The printed aliases can be used as (part of) shell commands. The built-in prints all currently defined aliases when given no operands. [[options]] == Options +-g+:: +--global+:: With this option, aliases are defined as global aliases; without this option, as normal aliases. +-p+:: +--prefix+:: With this option, aliases are printed in a full command form like `alias -g foo='bar'`. Without this option, only command operands are printed like `foo='bar'`. [[operands]] == Operands {{name}}:: The name of an alias that should be printed. {{name}}={{value}}:: The name and value of an alias that is being defined. [[exitstatus]] == Exit status The exit status of the alias built-in is zero unless there is any error. [[notes]] == Notes The characters that cannot be used in an alias name are the space, tab, newline, and any of +=$<>\'"`;&|()#+. You can use any characters in an alias value. The alias built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard defines no options for the alias built-in, thus no options are available in the link:posix.html[POSIXly correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_umask.html0000644000175000017500000001521712154557026015466 0ustar magicantmagicant Umask built-in

The umask built-in sets or prints the file mode creation mask.

Syntax

  • umask mask

  • umask [-S]

Description

If executed without the mask operand, the built-in prints the current file mode creation mask of the shell to the standard output in a form that can later be used as mask to restore the current mask.

Otherwise, the built-in sets the file mode creation mask to mask.

Options

-S
--symbolic

Print in the symbolic form instead of the octal integer form.

Operands

mask

The new file mode creation mask either in the symbolic or octal integer form.

Octal integer form

In the octal integer form, the mask is specified as a non-negative octal integer that is the sum of the following permissions:

0400

read by owner

0200

write by owner

0100

execute/search by owner

0040

read by group

0020

write by group

0010

execute/search by group

0004

read by others

0002

write by others

0001

execute/search by others

Symbolic form

In the symbolic form, the mask is specified as a symbolic expression that denotes permissions that are not included in the mask.

The entire expression is one or more clauses separated by comma. A clause is a sequence of whos followed by one or more actions.

A who is one of:

u

owner

g

group

o

others

a

all of owner, group, and others

An empty sequence of whos is equivalent to who a.

An action is an operator followed by permission. An operator is one of:

=

set who's permission to permission

+

add permission to who's permission

-

remove permission from who's permission

and permission is one of:

r

read

w

write

x

execute/search

X

execute/search (only if some user already has execute/search permission)

s

set-user-ID and set-group-ID

u

user’s current permissions

g

group’s current permissions

o

others' current permissions

but more than one of r, w, x, X, and s can be specified after a single operand.

For example, the command umask u=rwx,go+r-w

  • unmasks the user’s read, write, and execute/search permissions;

  • unmasks the group’s and others' read permission; and

  • masks the group’s and others' write permission.

Exit status

The exit status of the umask built-in is zero unless there is any error.

Notes

The umask built-in is a semi-special built-in.

The POSIX standard does not require the default output format (used when the -S option is not specified) to be the octal integer form.

yash-2.35/doc/fgrammar.html0000644000175000017500000003615712154557026016011 0ustar magicantmagicant Formal definition of command syntax

This chapter defines the syntax of shell commands as a parsing expression grammar.

The set of terminals of the grammar is the set of characters that can be handled on the environment in which the shell is run (a.k.a. execution character set), with the exception that the set does not contain the null character ('\0').

Below is a list of nonterminals of the grammar with corresponding parsing expressions. The list does not include rules for parsing contents and ends of here documents. In the POSIXly-correct mode, the grammar varies from the list below to disable non-POSIX functionalities.

CompleteCommand

Sequence EOF

Sequence

N* List*

List

Pipeline ((&& / ||) N* Pipeline)* ListSeparator

Pipeline

Bang? Command (| N* Command)*

Command

CompoundCommand Redirection* /
!R FunctionDefinition /
!R SimpleCommand

CompoundCommand

Subshell /
Grouping /
IfCommand /
ForCommand /
WhileCommand /
CaseCommand /
FunctionCommand

Subshell

( Sequence ) S*

Grouping

LeftBrace Sequence RightBrace

IfCommand

If Sequence Then Sequence (Elif Sequence Then Sequence)* (Else Sequence)? Fi

ForCommand

For Name S* Separator? (In Word* Separator)? Do Sequence Done

WhileCommand

(While / Until) Sequence Do Sequence Done

CaseCommand

Case Word N* In N* CaseItem* Esac

CaseItem

!Esac (( S*)? Word (| S* Word)* ) Sequence (;; / &Esac)

FunctionCommand

Function Word (( S* ))? N* CompoundCommand Redirection*

FunctionDefinition

Name S* ( S* ) N* CompoundCommand Redirection*

SimpleCommand

&(Word / Redirection) (Assignment / Redirection)* (Word / Redirection)*

Assignment

Name = Word /
Name =( N* (Word N*)* )

Name

![[:digit:]] [[:alnum:] _]+

PortableName

![0-9] [0-9 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+

Word

(WordElement / !SpecialChar .)+ S*

WordElement

\ . /
' (!' .)* ' /
" QuoteElement* " /
Parameter /
Arithmetic /
CommandSubstitution

QuoteElement

\ ([$`"\] / NL) /
Parameter /
Arithmetic /
CommandSubstitution /
![`"\] .

Parameter

$ [@*#?-$! [:digit:]] /
$ PortableName /
$ ParameterBody

ParameterBody

{ ParameterNumber? (ParameterName / ParameterBody / Parameter) ParameterIndex? ParameterMatch? }

ParameterNumber

# ![+=:/%] !([-?#] })

ParameterName

[@*#?-$!] /
[[:alnum:] _]+

ParameterIndex

[ ParameterIndexWord (, ParameterIndexWord)? ]

ParameterIndexWord

(WordElement / !["'],] .)+

ParameterMatch

:? [-+=?] ParameterMatchWord /
(# / ## / % / %%) ParameterMatchWord /
(:/ / / [#%/]?) ParameterMatchWordNoSlash (/ ParameterMatchWord)?

ParameterMatchWord

(WordElement / !["'}] .)*

ParameterMatchWordNoSlash

(WordElement / !["'/}] .)*

Arithmetic

$(( ArithmeticBody* ))

ArithmeticBody

\ . /
Parameter /
Arithmetic /
CommandSubstitution /
( ArithmeticBody ) /
![`()] .

CommandSubstitution

$( Sequence ) /
` CommandSubstitutionBody* `

CommandSubstitutionBody

\ [$`\] /
!` .

Redirection

RedirectionFD RedirectionOperator S* Word /
RedirectionFD <( Sequence ) /
RedirectionFD >( Sequence )

RedirectionFD

[[:digit:]]*

RedirectionOperator

< / <> / > / >| / >> / >>| / <& / >& / << / <<- / <<<

ListSeparator

Separator /
& N* /
&) /
&;;

Separator

; N* /
N+ /
EOF

N

S* NL

S

[[:blank:]] /
Comment

Comment

# (!NL .)*

R

Bang / LeftBrace / RightBrace / Case / Do / Done / Elif / Else / Esac / Fi / For / If / In / Then / Until / While

Bang

! D

LeftBrace

{ D

RightBrace

} D

Case

case D

Do

do D

Done

done D

Elif

elif D

Else

else D

Esac

esac D

Fi

fi D

For

for D

Function

function D

If

if D

In

in D

Then

then D

Until

until D

While

while D

D

!Word S*

SpecialChar

[|&;<>()`\"' [:blank:]] / NL

NL

<newline>

EOF

!.

yash-2.35/doc/_type.html0000644000175000017500000000322212154557026015320 0ustar magicantmagicant Type built-in

The type built-in identifies a command.

Syntax

  • type [-abefkp] [command…]

Description

The type built-in is equivalent to the command built-in with the -V option.

Notes

The POSIX standard does not define the relation between the type and command built-ins. The standard does not define options for the type built-in.

At least one command operand must be specified in the POSIXly-correct mode.

yash-2.35/doc/_set.html0000644000175000017500000003350012154557026015134 0ustar magicantmagicant Set built-in

The set built-in sets shell options and positional parameters.

Syntax

  • set [options] [operands]

  • set -o

  • set +o

The set built-in requires that all options precede operands. Any command line arguments after the first operand are all treated as operands.

Description

When executed without any command arguments, the built-in prints a list of all existing variables to the standard input in a form that can be reused as commands that will restore the variable definitions.

When -o is the only command argument, the built-in prints a list of shell options with their current settings. When +o is the only command argument, the built-in prints commands that can be reused to restore the current shell option settings.

In other cases, the built-in changes shell option settings and/or positional parameters.

Options

When one or more options are specified, the built-in enables or disables the shell options. A normal hyphen-prefixed option enables a shell option. An option that is prefixed with a plus (+) instead of a hyphen disables a shell option. For example, options -m, -o monitor, and --monitor enable the monitor option and options +m, +o monitor, ++monitor disable it.

The name of a long option is case-insensitive and may include irrelevant non-alphanumeric characters, which are ignored. For example, options --le-comp-debug and --LeCompDebug are equivalent. If no is prepended to the name of a long option, the meaning is reversed. For example, --noallexport is equivalent to ++allexport and ++nonotify to --notify.

An option can be specified in one of the following forms:

  • a long option e.g. --allexport

  • an -o option with a option name specified as the argument e.g. -o allexport

  • a single-character option e.g. -a

Not all options can be specified as single-character options.

The available options are:

all-export (-a)

When enabled, all variables are automatically exported when assigned.

brace-expand

This option enables brace expansion.

case-glob

(Enabled by default) When enabled, pattern matching is case-sensitive in pathname expansion.

clobber (+C)

(Enabled by default) When enabled, the > redirection behaves the same as the >| redirection.

cur-async
cur-bg
cur-stop

(Enabled by default) These options affect choice of the current job (cf. job ID).

dot-glob

When enabled, periods at the beginning of filenames are not treated specially in pathname expansion.

emacs

This option enables line-editing in the emacs mode.

err-exit (-e)

When enabled, if a pipeline ends with a non-zero exit status, the shell immediately exits unless:

exec (+n)

(Enabled by default) Commands are actually executed only when this option is enabled. Otherwise, commands are just parsed and not executed. Disabling this option may be useful for syntax checking. In an interactive shell, this option is always assumed enabled.

extended-glob

This option enables extension in pathname expansion.

glob (+f)

(Enabled by default) This option enables pathname expansion.

hash-on-def (-h)

When a function is defined when this option is enabled, the shell immediately performs command path search for each command that appears in the function and caches the command’s full path.

hist-space

When enabled, command lines that start with a whitespace are not saved in command history.

ignore-eof

When enabled, an interactive shell does not exit when EOF (end of file) is input. This prevents the shell from exiting when you accidentally hit Ctrl-D.

le-always-rp
le-comp-debug
le-conv-meta
le-no-conv-meta
le-prompt-sp
le-visible-bell

See shell options on line-editing.

mark-dirs

When enabled, resulting directory names are suffixed by a slash in pathname expansion.

monitor (-m)

This option enables job control. This option is enabled by default for an interactive shell.

notify (-b)

When the status of a job changes when this option is enabled, the shell immediately notifies at any time. This option overrides the notify-le option.

notify-le

This option is similar to the notify option, but the status change is notified only while the shell is waiting for input with line-editing.

null-glob

When enabled, in pathname expansion, patterns that do not match any pathname are removed from the command line rather than left as is.

posixly-correct

This option enables the POSIXly-correct mode.

trace-all

(Enabled by default) When this option is disabled, the x-trace option is temporarily disabled while the shell is executing commands defined in the COMMAND_NOT_FOUND_HANDLER, PROMPT_COMMAND, or YASH_AFTER_CD variable.

unset (+u)

(Enabled by default) When enabled, undefined parameters are expanded to empty strings in parameter expansion. When disabled, expansion of undefined parameter results in an error.

verbose (-v)

When enabled, the shell prints each command line to the standard error before parsing and executing it.

vi

This option enables line-editing in the vi mode. This option is enabled by default in an interactive shell if the standard input and error are both terminals.

x-trace (-x)

When enabled, the results of expansion are printed to the standard error for each simple command being executed. When printed, each line is prepended with an expansion result of the PS4 variable. See also the trace-all option.

Operands

If one or more operands are passed to the set built-in, current positional parameters are all removed and the operands are set as new positional parameters. If the -- separator (cf. syntax of command arguments) is passed, the positional parameters are set even when there are no operands, in which case new positional parameters will be nothing.

Exit status

The exit status of the set built-in is zero unless there is any error.

Notes

The set built-in is a special built-in.

In the POSIX standard, available shell options are much limited. The standard does not define:

  • long options such as --allexport,

  • prepending no to negate an option,

  • using uppercase letters and/or non-alphanumeric characters in option names

The options defined in the standard are:

  • -a, -o allexport

  • -e, -o errexit

  • -m, -o monitor

  • -C, -o noclobber

  • -n, -o noexec

  • -f, -o noglob

  • -b, -o notify

  • -u, -o nounset

  • -v, -o verbose

  • -x, -o xtrace

  • -h

  • -o ignoreeof

  • -o nolog

  • -o vi

Yash does not support the nolog option, which prevents function definitions from being added to command history.

yash-2.35/doc/_exec.txt0000644000175000017500000000607512154557026015147 0ustar magicantmagicant= Exec built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Exec built-in The dfn:[exec built-in] replaces the shell process with another external command. [[syntax]] == Syntax - +exec [-cf] [-a {{name}}] [{{command}} [{{argument}}...]]+ The exec built-in requires that all options precede operands. It is important so that options to the exec built-in are not confused with options to {{command}}. Any command line arguments after {{command}} are treated as {{argument}}s. [[description]] == Description When the exec built-in is executed with {{command}}, the shell executes {{command}} with {{argument}}s in a manner similar to the last step of link:exec.html#simple[execution of a simple command]. The differences are that {{command}} is always treated as an external command ignoring any existing functions and built-ins and that the exec system call that starts the external command is called in the current link:exec.html#environment[command execution environment] instead of a subshell, replacing the shell process with the new command process. If the shell is in the link:posix.html[POSIXly-correct mode] or not link:interact.html[interactive], failure in execution of {{command}} causes the shell to exit immediately. If an interactive shell that is not in the POSIXly-correct mode has a stopped link:job.html[job], the shell prints a warning message and refuses to execute {{command}}. Once the shell process is replaced with an external command, information about the shell's jobs is lost, so you will have to resume or kill the stopped jobs by sending signals by hand. To force the shell to execute {{command}} regardless, specify the +-f+ (+--force+) option. When executed without {{command}}, the built-in does nothing. As a side effect, however, link:redir.html[redirection] applied to the built-in remains in the current link:exec.html#environment[command execution environment] even after the built-in finished. [[options]] == Options +-a {{name}}+:: +--as={{name}}+:: Pass {{name}}, instead of {{command}}, to the external command as its name. +-c+:: +--clear+:: Pass to the external command only variables that are assigned in the link:exec.html#simple[simple command] in which the built-in is being executed. Other environment variables are not passed to the command. +-f+:: +--force+:: Suppress warnings that would prevent command execution. [[operands]] == Operands {{command}}:: An external command to be executed. {{argument}}...:: Arguments to be passed to the command. [[exitstatus]] == Exit status If the shell process was successfully replaced with the external command, there is no exit status since the shell process no longer exists. The exit status is: - 127 if the command was not found, - 126 if the command was found but could not be executed, and - zero if no {{command}} was specified. [[notes]] == Notes The exec built-in is a link:builtin.html#types[special built-in]. The POSIX standard defines no options for the exec built-in; the built-in accepts no options in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/interact.html0000644000175000017500000004400112154557026016011 0ustar magicantmagicant Interactive mode

The interactive mode is a mode of the shell intended for direct interaction with a user. If yash is in the interactive mode, it is called an interactive shell.

Whether a shell runs in the interactive mode or not is determined in the invocation of the shell. After the shell has started up, the interactive mode cannot be switched on or off.

When the shell is interactive:

  • Initialization scripts are executed during invocation.

  • The shell checks for mail and prints a command prompt when it reads a command. Job status changes are also reported if job control is active. Line-editing may be used depending on the capability of the terminal.

  • Commands executed are automatically registered in command history.

  • If a command executed by the shell is killed by a signal other than SIGINT and SIGPIPE, the shell reports the fact to the standard error.

  • The filename token is subject to pathname expansion in file redirection.

  • The standard input of an asynchronous command is not automatically redirected to /dev/null (in the POSIXly-correct mode only).

  • The shell does not exit when it encounters a syntax or expansion error during command execution. (cf. Termination of the shell)

  • The shell does not exit when it receives the SIGINT, SIGTERM, or SIGQUIT signal.

  • A signal handler can be changed by the trap built-in even if the handler had been set to “ignore” when the shell was invoked.

  • The value of the - special parameter contains i.

  • The shell’s locale reflects the value of the LC_CTYPE variable whenever the value is changed (if the shell is not in the POSIXly-correct mode).

  • Commands are executed even when the exec option is off.

  • The ignore-eof option takes effect when enabled.

  • When the shell reaches the end of input or the exit built-in is executed, the shell checks if there is any stopped job. If so, the shell prints a warning and does not actually exit.

  • The suspend built-in by default cannot stop the shell if it is a session leader.

  • The shell does not exit when the dot built-in fails to find a script file to read.

  • The shell does not exit when the exec built-in fails to execute a command (if not in the POSIXly-correct mode).

  • When a job finished for which the wait built-in has been waiting, the fact is reported (only if job control is active and not in the POSIXly-correct mode).

  • A prompt is printed when the read built-in reads a second or following line.

Prompts

The interactive shell prints a prompt just before it reads a command. The contents of the prompt is specified by the value of the PS1 and PS2 variables. The former is used for reading the first line of the command and the latter for other lines.

When the prompt is printed, the variable value is subjected to parameter expansion, command substitution, and arithmetic expansion (but note that the POSIX standard requires parameter expansion only). The result of the expansion is parsed by the rules below to make the actual prompt string, which is printed to the standard error.

In the POSIXly-correct mode, each exclamation mark (!) in the string is substituted with the command history number of the command that is being input. Two adjacent exclamation marks (!!) are printed as a single exclamation. Other characters are printed intact.

If the shell is not in the POSIXly-command mode, the following notations can be used to format the prompt string. Notations are replaced with the strings designated in the list below. Characters that are not interpreted as notations are printed intact.

\a

Bell character (ASCII code: 7)

\e

Escape character (ASCII code: 27)

\j

The number of jobs in the shell.

\n

Newline character (ASCII code: 10)

\r

Carriage return character (ASCII code: 13)

\!

The command history number of the command that is being input

\$

# if the shell’s effective user ID is 0; $ otherwise.

\\

Backslash

\[
\]

These two notations can surround part of the prompt string that is not visible on the terminal. The surrounded part is ignored when the shell counts the number of characters that is displayed on the terminal, thus making characters correctly aligned on the terminal when the prompt string contains special invisible characters.

\ffontspecs.

When line-editing is active, this notation is replaced with special characters to change font styles on the terminal if the terminal is capable of it. If line-editing is inactive or the terminal is incapable of changing font styles, this notation is silently ignored. One or more of the following can be used for fontspecs:

k

Change font color to black

r

Change font color to red

g

Change font color to green

y

Change font color to yellow

b

Change font color to blue

m

Change font color to magenta

c

Change font color to cyan

w

Change font color to white

K

Change background color to black

R

Change background color to red

G

Change background color to green

Y

Change background color to yellow

B

Change background color to blue

M

Change background color to magenta

C

Change background color to cyan

W

Change background color to white

t

Make font color or background brighter (can only be used just after one of the characters above)

d

Change font and background colors to normal

s

Make font standout

u

Make font underlined

v

Make font and background colors reversed

b

Make font blink

i

Make font dim

o

Make font bold

x

Make font invisible

D

Make color and style normal

The actual colors of font and background are defined by the terminal. Different terminals may use different colors.

In addition to the normal prompt, a prompt string can be displayed to the right of the cursor if line-editing is active. Those prompts are called right prompts. The contents of right prompts are defined by the value of the PS1R and PS2R variables, each corresponding to the PS1 and PS2 variables.

Using the above-said notations, the font style of command strings the user inputs can be changed as well as that of prompts. The font style of command strings is defined by the value of the PS1S and PS2S variables, each corresponding to the PS1 and PS2 variables. The value can contain the \ffontspecs. notation only.

When the shell is not in the POSIXly-correct mode, the value of the PROMPT_COMMAND variable is executed before each prompt.

Command history

Command history is a feature of the shell that remembers executed commands to allow re-executing them later. Commands executed in the interactive mode are automatically saved in the command history. Saved commands can be edited and re-executed using line-editing and the fc and history built-ins.

Commands are saved line by line. Lines that do not contain any non-whitespace characters are not saved in the history. Lines that start with whitespaces are not saved when the hist-space option is on.

Command history is saved in a file. When history is first used after an interactive shell was started, the shell opens a file to save history in. The filename is specified by the value of the HISTFILE variable. If the file contains history data when opened, the data is restored to the shell’s history. The file contents are updated in real time as the user inputs commands into the shell. If the HISTFILE variable is not set or the file cannot be opened successfully, history is not saved in the file, but the history feature will be functional in all other respects.

The number of commands saved in history is specified by the value of the HISTSIZE variable. The shell automatically removes old history data so that the number of saved commands does not exceed the value. If the HISTSIZE variable is not set or its value is not a natural number, 500 items will be saved in history.

The shell looks at the value of the HISTFILE and HISTSIZE variables only when the history feature is first used after the shell was started. “The history feature is used” when:

  • the fc or history built-in is executed,

  • line-editing is used (regardless of whether or not history data is recalled in line-editing), or

  • a command is input to the shell

Therefore, the variables should be set in initialization scripts.

When more than one instance of yash shares a single history file, all the shells use the same history data. As a result, commands that have been executed by a shell instance can be recalled on another shell instance. Shells sharing the same history should have the same HISTSIZE value so that they manipulate history data properly.

Yash’s history data file has its own format that is incompatible with other kinds of shells.

The HISTRMDUP variable can be set to remove duplicate history items.

Mail checking

An interactive shell can notify receipt of email. The shell periodically checks the modification date/time of a file specified by the user. If the file has been modified since the previous check, the shell prints a notification message (except when the shell is not in the POSIXly-correct mode and the file is empty). By specifying a mailbox file to be checked, the shell will print a message when the file has been modified, that is, some mail has been received.

Check is done just before the shell prints a command line prompt. The interval of checks can be specified by the MAILCHECK variable in seconds. If the variable value is 0, check is done before every prompt. If the variable value is not a non-negative integer, no checks are done.

The file whose modification time is checked is specified by the MAIL variable. The variable value should be set to the pathname of the file.

If you want to check more than one file or customize the notification message, you can set the MAILPATH variable instead of the MAIL variable. When the MAILPATH variable is set, the MAIL variable is ignored. The value of the MAILPATH variable should be set to one or more colon-separated pathnames of files to be checked. Each pathname can be followed by a percent sign (%) and a custom notification message, which is printed when the corresponding file has been modified. If the pathname contains a percent sign, it should be quoted by a backslash. The specified message is subject to parameter expansion. For example, if the value of the MAILPATH variable is /foo/mail%New mail!:/bar/mailbox%You've got mail:/baz/mail\%data, the shell will print

  • New mail! when the file /foo/mail has been modified

  • You've got mail when the file /bar/mailbox has been modified

  • the default message when the file /baz/mail%data has been modified.

yash-2.35/doc/_fg.html0000644000175000017500000000541012154557026014734 0ustar magicantmagicant Fg built-in

The fg built-in resumes a job in the foreground.

Syntax

  • fg [job…]

Description

The fg built-in brings the specified job to the foreground and sends the SIGCONT signal to the job. As a result, the job is resumed in the foreground (if it has been suspended). The built-in then waits for the job to finish and returns the exit status of it.

The name of the job is printed when the job is resumed.

The built-in can be used only when job control is enabled.

Operands

job

The job ID of the job to be resumed.

If more than one job is specified, they are resumed in order, one at a time. The current job is resumed if none is specified.

The percent sign (%) at the beginning of a job ID can be omitted if the shell is not in the POSIXly-correct mode.

Exit status

The exit status of the fg built-in is that of the (last) job resumed. The exit status is non-zero when there was some error.

Notes

The fg built-in is a semi-special built-in.

You cannot specify more than one job in the POSIXly-correct mode.

yash-2.35/doc/_set.txt0000644000175000017500000002073412154557026015014 0ustar magicantmagicant= Set built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Set built-in The dfn:[set built-in] sets shell options and positional parameters. [[syntax]] == Syntax - +set [{{option}}s] [{{operand}}s]+ - +set -o+ - +set +o+ The set built-in requires that all options precede operands. Any command line arguments after the first operand are all treated as operands. [[description]] == Description When executed without any command arguments, the built-in prints a list of all existing link:params.html#variables[variables] to the standard input in a form that can be reused as commands that will restore the variable definitions. When +-o+ is the only command argument, the built-in prints a list of shell options with their current settings. When `+o` is the only command argument, the built-in prints commands that can be reused to restore the current shell option settings. In other cases, the built-in changes shell option settings and/or link:params.html#positional[positional parameters]. [[options]] == Options When one or more options are specified, the built-in enables or disables the shell options. A normal hyphen-prefixed option enables a shell option. An option that is prefixed with a plus (`+`) instead of a hyphen disables a shell option. For example, options +-m+, +-o monitor+, and +--monitor+ enable the monitor option and options `+m`, `+o monitor`, `++monitor` disable it. The name of a long option is case-insensitive and may include irrelevant non-alphanumeric characters, which are ignored. For example, options +--le-comp-debug+ and +--LeCompDebug+ are equivalent. If +no+ is prepended to the name of a long option, the meaning is reversed. For example, +--noallexport+ is equivalent to `++allexport` and `++nonotify` to +--notify+. An option can be specified in one of the following forms: - a long option e.g. +--allexport+ - an +-o+ option with a option name specified as the argument e.g. +-o allexport+ - a single-character option e.g. +-a+ Not all options can be specified as single-character options. The available options are: [[so-allexport]]all-export (+-a+):: When enabled, all link:params.html#variables[variables] are automatically link:params.html#variables[exported] when assigned. [[so-braceexpand]]brace-expand:: This option enables link:expand.html#brace[brace expansion]. [[so-caseglob]]case-glob:: (Enabled by default) When enabled, pattern matching is case-sensitive in link:expand.html#glob[pathname expansion]. [[so-clobber]]clobber (`+C`):: (Enabled by default) When enabled, the +>+ link:redir.html#file[redirection] behaves the same as the +>|+ redirection. [[so-curasync]]cur-async:: [[so-curbg]]cur-bg:: [[so-curstop]]cur-stop:: (Enabled by default) These options affect choice of the current job (cf. link:job.html#jobid[job ID]). [[so-dotglob]]dot-glob:: When enabled, periods at the beginning of filenames are not treated specially in link:expand.html#glob[pathname expansion]. [[so-emacs]]emacs:: This option enables link:lineedit.html[line-editing] in the link:lineedit.html#modes[emacs mode]. [[so-errexit]]err-exit (+-e+):: When enabled, if a link:syntax.html#pipelines[pipeline] ends with a non-zero exit status, the shell immediately exits unless: - the pipeline is a condition of an link:syntax.html#if[if command] or link:syntax.html#while-until[while or until loop]; - the pipeline is prefixed by +!+; or - the pipeline is a single link:syntax.html#compound[compound command] other than a subshell link:syntax.html#grouping[grouping]. [[so-exec]]exec (`+n`):: (Enabled by default) Commands are actually executed only when this option is enabled. Otherwise, commands are just parsed and not executed. Disabling this option may be useful for syntax checking. In an link:interact.html[interactive shell], this option is always assumed enabled. [[so-extendedglob]]extended-glob:: This option enables link:expand.html#extendedglob[extension in pathname expansion]. [[so-glob]]glob (`+f`):: (Enabled by default) This option enables link:expand.html#glob[pathname expansion]. [[so-hashondef]]hash-on-def (+-h+):: When a link:exec.html#function[function] is defined when this option is enabled, the shell immediately performs link:exec.html#search[command path search] for each command that appears in the function and caches the command's full path. [[so-histspace]]hist-space:: When enabled, command lines that start with a whitespace are not saved in link:interact.html#history[command history]. [[so-ignoreeof]]ignore-eof:: When enabled, an link:interact.html[interactive shell] does not exit when EOF (end of file) is input. This prevents the shell from exiting when you accidentally hit Ctrl-D. [[so-lealwaysrp]]le-always-rp:: [[so-lecompdebug]]le-comp-debug:: [[so-leconvmeta]]le-conv-meta:: [[so-lenoconvmeta]]le-no-conv-meta:: [[so-lepromptsp]]le-prompt-sp:: [[so-levisiblebell]]le-visible-bell:: See link:lineedit.html#options[shell options on line-editing]. [[so-markdirs]]mark-dirs:: When enabled, resulting directory names are suffixed by a slash in link:expand.html#glob[pathname expansion]. [[so-monitor]]monitor (+-m+):: This option enables link:job.html[job control]. This option is enabled by default for an link:interact.html[interactive shell]. [[so-notify]]notify (+-b+):: When the status of a link:job.html[job] changes when this option is enabled, the shell immediately notifies at any time. This option overrides the notify-le option. [[so-notifyle]]notify-le:: This option is similar to the notify option, but the status change is notified only while the shell is waiting for input with link:lineedit.html[line-editing]. [[so-nullglob]]null-glob:: When enabled, in link:expand.html#glob[pathname expansion], patterns that do not match any pathname are removed from the command line rather than left as is. [[so-posixlycorrect]]posixly-correct:: This option enables the link:posix.html[POSIXly-correct mode]. [[so-traceall]]trace-all:: (Enabled by default) When this option is disabled, the <> is temporarily disabled while the shell is executing commands defined in the link:params.html#sv-command_not_found_handler[+COMMAND_NOT_FOUND_HANDLER+], link:params.html#sv-prompt_command[+PROMPT_COMMAND+], or link:params.html#sv-yash_after_cd[+YASH_AFTER_CD+] variable. [[so-unset]]unset (`+u`):: (Enabled by default) When enabled, undefined parameters are expanded to empty strings in link:expand.html#params[parameter expansion]. When disabled, expansion of undefined parameter results in an error. [[so-verbose]]verbose (+-v+):: When enabled, the shell prints each command line to the standard error before parsing and executing it. [[so-vi]]vi:: This option enables link:lineedit.html[line-editing] in the link:lineedit.html#modes[vi mode]. This option is enabled by default in an link:interact.html[interactive shell] if the standard input and error are both terminals. [[so-xtrace]]x-trace (+-x+):: When enabled, the results of link:expand.html[expansion] are printed to the standard error for each link:syntax.html#simple[simple command] being executed. When printed, each line is prepended with an expansion result of the link:params.html#sv-ps4[+PS4+ variable]. See also the <>. [[operands]] == Operands If one or more operands are passed to the set built-in, current link:params.html#positional[positional parameters] are all removed and the operands are set as new positional parameters. If the +--+ separator (cf. link:builtin.html#argsyntax[syntax of command arguments]) is passed, the positional parameters are set even when there are no operands, in which case new positional parameters will be nothing. [[exitstatus]] == Exit status The exit status of the set built-in is zero unless there is any error. [[notes]] == Notes The set built-in is a link:builtin.html#types[special built-in]. In the POSIX standard, available shell options are much limited. The standard does not define: - long options such as +--allexport+, - prepending +no+ to negate an option, - using uppercase letters and/or non-alphanumeric characters in option names The options defined in the standard are: - +-a+, +-o allexport+ - +-e+, +-o errexit+ - +-m+, +-o monitor+ - +-C+, +-o noclobber+ - +-n+, +-o noexec+ - +-f+, +-o noglob+ - +-b+, +-o notify+ - +-u+, +-o nounset+ - +-v+, +-o verbose+ - +-x+, +-o xtrace+ - +-h+ - +-o ignoreeof+ - +-o nolog+ - +-o vi+ Yash does not support the nolog option, which prevents link:syntax.html#funcdef[function definitions] from being added to link:interact.html#history[command history]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_trap.html0000644000175000017500000001120512154557026015305 0ustar magicantmagicant Trap built-in

The trap built-in sets or prints signal handlers.

Syntax

  • trap

  • trap action signal

  • trap signal_number [signal…]

  • trap -p [signal…]

Description

The trap built-in sets or prints actions that are taken when the shell receives signals. (Those actions are called traps.)

When executed with action and one or more signals, the built-in sets the traps for signals to action. If the shell receives one of the signals, the action will be taken.

If the first operand is signal_number instead of action, the built-in resets the traps for signal_number and signals as if action was -.

When executed with the -p (--print) option or with no operands, the built-in prints currently set traps to the standard output in a format that can be executed as commands that restore the current traps. If one or more signals are specified, only those signals are printed. Otherwise, all signals with non-default actions are printed.

Options

-p
--print

Print current trap settings.

Operands

action

An action that will be taken when signal is received.

If action is a single hyphen (-), the action is reset to the default action that is defined by the operating system. If action is an empty string, the signal is ignored on receipt. Otherwise, action is treated as a command string: the string is parsed and executed as commands when the signal is received. (If a signal is received while a command is being executed, the action is taken just after the command finishes.)

signal

The number or name of a signal.

If signal is number 0 or name EXIT, it is treated as a special imaginary signal that is always received when the shell exits. The action set for this signal is taken when the shell exits normally.

signal_number

This is like signal, but must be a number.

Exit status

The exit status of the trap built-in is zero unless there is any error.

Notes

The trap built-in is a special built-in.

The POSIX standard requires that signal names must be specified without the SIG-prefix, like INT and QUIT. As an extension, yash accepts SIG-prefixed names like SIGINT and SIGQUIT and treats signal names case-insensitively.

yash-2.35/doc/_alias.html0000644000175000017500000000636612154557026015444 0ustar magicantmagicant Alias built-in

The alias built-in defines and/or prints aliases.

Syntax

  • alias [-gp] [name[=value]…]

Description

The alias built-in defines and/or prints aliases as specified by operands. The printed aliases can be used as (part of) shell commands. The built-in prints all currently defined aliases when given no operands.

Options

-g
--global

With this option, aliases are defined as global aliases; without this option, as normal aliases.

-p
--prefix

With this option, aliases are printed in a full command form like alias -g foo='bar'. Without this option, only command operands are printed like foo='bar'.

Operands

name

The name of an alias that should be printed.

name=value

The name and value of an alias that is being defined.

Exit status

The exit status of the alias built-in is zero unless there is any error.

Notes

The characters that cannot be used in an alias name are the space, tab, newline, and any of =$<>\'"`;&|()#. You can use any characters in an alias value.

The alias built-in is a semi-special built-in.

The POSIX standard defines no options for the alias built-in, thus no options are available in the POSIXly correct mode.

yash-2.35/doc/expand.html0000644000175000017500000010311012154557026015454 0ustar magicantmagicant Word expansions

Word expansion is substitution of part of a word with another particular string. There are seven types of word expansions:

These types of expansions are performed in the order specified above.

Tilde expansion, parameter expansion, command substitution, and arithmetic expansion are called the four expansions.

Tilde expansion

In tilde expansion, parts of words that start with a tilde (~) are substituted with particular pathnames. The part of each word that gets substituted is from the beginning of the word, which is a tilde, up to (but not including) the first slash (/) in the word. If the word does not contain a slash, the whole word is substituted. If any character in the substituted part is quoted, tilde expansion is not performed on the word.

The results of expansion are determined by the format of the substituted part:

~

A single tilde is substituted with the value of the HOME variable.

~username

A tilde followed by a user name is substituted with the pathname of the user’s home directory.

~+

~+ is substituted with the value of the PWD variable.

~-

~- is substituted with the value of the OLDPWD variable.

~+n
~-n

where n is a non-negative integer. This type of tilde expansion yields the pathname of a directory of which ~+n or ~-n is the index in the directory stack.

When tilde expansion is performed on the value of a variable assignment that occurs during execution of a simple command, the value is considered as a colon-separated list of words and those words are each subject to tilde expansion. For example, the variable assignment

VAR=~/a:~/b:~/c

is equivalent to

VAR=/home/foo/a:/home/foo/b:/home/foo/c

if the value of HOME variable is /home/foo.

The POSIX standard does not prescribe how the shell should behave when it encounters an error during tilde expansion (e.g., when the HOME variable is not defined). Yash silently ignores any errors during tilde expansion; the part of the word that would be substituted is left intact.

In the POSIXly-correct mode, tilde expansion supports the formats of ~ and ~username only.

Parameter expansion

Parameter expansion expands to the value of a parameter.

The syntax of typical, simple parameter expansion is ${parameter}, which expands to the value of the parameter whose name is parameter. You can omit the braces (e.g., $parameter) if

  • parameter is a special parameter,

  • parameter is a positional parameter whose index is a one-digit integer, or

  • parameter is a variable and the parameter expansion is not followed by a character that can be used as part of a variable name.

    For example, ${path}-name is equivalent to $path-name, but ${path}name and $pathname are different.

If parameter is none of a special parameter, positional parameter, and variable, it is a syntax error. (Some shells other than yash may treat such a case as an expansion error.)

If the unset option is disabled and the parameter is an undefined variable, it is an expansion error. If the unset option is enabled, an undefined variable expands to the empty string.

More complex syntax of parameter expansion allows modifying the value of a parameter.

Parameter expansion

${ prefix parameter index modifier }

The spaces in the syntax definition above are for readability only and must be omitted. You can omit prefix, index, and/or modifier.

Prefix

The prefix, if any, must be a hash sign (#). If a parameter expansion has the prefix, the result of expansion is the number of characters in the value this expansion would be expanded to without the prefix.

Parameter name

The parameter name (parameter) must be either

The parameter expansion is expanded to the value of the parameter. If parameter is an array variable, the values of the array are field-split like the @ special parameter unless the index [*] is specified.

If parameter is another expansion, it is called a nested expansion. Nested expansion cannot be used in the POSIXly-correct mode. The braces ({ }) of a nested parameter expansion cannot be omitted.

Index

An index allows extracting part of the parameter value (or some of array values).

Index

[word1]

[word1,word2]

where word1 and word2 are parsed in the same manner as normal tokens except that they are always delimited by , or ] and can contain whitespace characters.

If there is an index in a parameter expansion, it is interpreted as follows:

  1. Words word1 and word2 are subjected to parameter expansion, command substitution, and arithmetic expansion.

  2. If there is no word2 and if word1 expands to one of *, @, and #, then that is the interpretation of index and the next step is not taken.

  3. The results of the previous steps (the expanded word1 and word2) are interpreted and evaluated as an arithmetic expression in the same manner as in arithmetic expansion. The resulting integers are the interpretation of index. If the results are not integers, it is an expansion error. If there is no word2, it is assumed that word2 is equal to word1.

If parameter is an array variable, the index specifies the part of the array. If parameter is either the * or @ special parameter, the index specifies the index range of positional parameters. In other cases, the index specifies the index range of a substring of the parameter value that is being expanded. In all cases, the specified range of the array values, positional parameters, or parameter value remains in the results of the expansion and other values are dropped.

If the interpretation of index is one or two integers, the following rules apply:

  • If the interpreted index value is negative, it wraps around. For example, the index value of -1 corresponds to the last value/character.

  • It is not an error when the index value is out of range. Existing values/characters within the range are just selected.

  • If the interpretation of either word1 or word2 is 0, the range is assumed empty and the expansion results in nothing.

If the interpretation of index is one of *, @, and #, it is treated as follows:

*

If parameter is an array, all values of the array are concatenated into a single string. If parameter is the * or @ special parameter, all positional parameters are concatenated into a string. See the description of the * special parameter for how the values/positional parameters are separated in the result string. In other cases, the interpretation of index is treated as if the interpretation is the two integers 1 and -1.

@

The interpretation of index is treated as if the interpretation is the two integers 1 and -1.

#

The interpretation of the # index is special in that it does not simply specify a range. Instead, the expanded values are substituted with the count.

If parameter is an array, the result of this parameter expansion will be the number of values in the array being expanded. If parameter is the * or @ special parameter, the result will be the number of current positional parameters. Otherwise, the result will be the number of characters in the value that is being expanded.

If a parameter expansion does not contain an index, it is assumed to be [@]. In the POSIXly-correct mode, index cannot be specified.

Example 1. Expansion of a normal variable

The following commands will print the string ABC:

var='123ABC789'
echo "${var[4,6]}"
Example 2. Expansion of positional parameters

The following commands will print the string 2 3 4:

set 1 2 3 4 5
echo "${*[2,-2]}"
Example 3. Expansion of an array

The following commands will print the string 2 3 4:

array=(1 2 3 4 5)
echo "${array[2,-2]}"

Modifier

You can modify the value to be expanded by using modifiers:

-word

If the parameter name (parameter) is an undefined variable, the parameter expansion is expanded to word. It is not treated as an error if the unset option is disabled.

+word

If the parameter name (parameter) is an existing variable, the parameter expansion is expanded to word. It is not treated as an error if the unset option is disabled.

=word

If the parameter name (parameter) is an undefined variable, word is assigned to the variable and the parameter expansion is expanded to word. It is not treated as an error if the unset option is disabled.

?word

If the parameter name (parameter) is an undefined variable, word is printed as an error message to the standard error. If word is empty, the default error message is printed instead.

:-word
:+word
:=word
:?word

These are similar to the four types of modifiers above. The only difference is that, if parameter exists and has an empty value, it is also treated as an undefined variable.

#word

The shell performs pattern matching against the value that is being expanded, using word as a pattern. If word matches the beginning of the value, the matching part is removed from the value and the other part remains as expansion results. The shortest matching is used if more than one matching is possible.

##word

This is similar to #word above. The only difference is that the longest matching is used if more than one matching is possible.

%word

This is similar to #word above. The only difference is that matching is tried at the end of the value rather than at the beginning: if word matches the end of the value, the matching part is removed from the value and the other part remains as expansion results.

%%word

This is similar to %word above. The only difference is that the longest matching is used if more than one matching is possible.

/word1/word2

The shell performs pattern matching against the value that is being expanded, using word1 as a pattern. If word1 matches any part of the value, the matching part is replaced with word2 and the whole value after the replacement remains as expansion results. If word1 matches more than one part of the value, only the first part is replaced. The shortest matching is replaced if more than one matching is possible for the same starting point in the value.

This modifier cannot be used in the POSIXly-correct mode.

/#word1/word2

This is similar to /word1/word2 above. The only difference is that word1 matches only at the beginning of the value being expanded.

/%word1/word2

This is similar to /word1/word2 above. The only difference is that word1 matches only at the end of the value being expanded.

//word1/word2

This is similar to /word1/word2 above. The only difference is that all matched parts are replaced if word1 matches more than one part of the value.

:/word1/word2

This is similar to /word1/word2 above. The only difference is that the value is replaced only when word1 matches the whole value.

In all types of modifiers above, words are subjected to the four expansions when (and only when) they are used.

If parameter is an array variable or the @ or * special parameter, modifiers affect each value of the array or all positional parameters.

Command substitution

Command substitution expands to output of commands specified.

Command substitution

$(commands)

`commands`

When command substitution is evaluated, commands are executed by a subshell with output pipelined to the shell. When the commands finished, command substitution is substituted with the output of the commands. Any trailing newline characters in the output are ignored.

When command substitution of the form $(commands) is parsed, the commands are parsed carefully so that complex commands such as nested command substitution are parsed correctly. If commands start with (, you should put a space before commands so that the whole command substitution is not confused with arithmetic expansion. If the shell is in the POSIXly-correctly mode, the commands are parsed each time the command substitution is expanded; otherwise, commands are parsed only when the command substitution is parsed.

If command substitution is of the form `commands`, the commands are not parsed when the command substitution is parsed. The end of commands is detected by the first backquote character (`) after the beginning of commands that is not quoted by a backslash. Backquotes that are part of commands (typically used for nested command substitution) must be quoted by backslashes. The commands are parsed each time the command substitution is expanded.

Arithmetic expansion

Arithmetic expansion evaluates an arithmetic expression and expands to the value of the expression.

Arithmetic expansion

$((expression))

When arithmetic expansion is expanded, the expression is subject to parameter expansion, command substitution, and (nested) arithmetic expansion. The expression is parsed in (almost) same manner as an expression of the C programming language.

Yash allows an expression to be either an integer (of the long type in C) or a floating-point number (of the double type in C). An operation on integers yields an integer and an operation involving a floating-point number yields a floating-point number. In the POSIXly-correct mode, you can use integers only.

The following operators are available (in the order of precedence):

  1. ( )

  2. ++ -- (postfix operators)

  3. ++ -- + - ~ ! (prefix operators)

  4. * / %

  5. + - (binary operators)

  6. << >>

  7. < <= > >=

  8. == !=

  9. &

  10. ^

  11. |

  12. &&

  13. ||

  14. ? :

  15. = *= /= %= += -= <<= >>= &= ^= |=

The ++ and -- operators cannot be used in the POSIXly-correct mode.

An atomic expression can be one of an integer literal, a floating-point number literal, and a variable. Literals are parsed in the same manner as in C. An octal integer literal starts with 0, and hexadecimal with 0x. A floating-point number literal may have an exponent (i.e. 1.23e+6). A variable with a non-numeric value will result in an error.

Brace expansion

Brace expansion expands to several split words with preceding and succeeding portions duplicated to each split words. Brace expansion is expanded only when the brace-expand option is enabled.

Comma-separated brace expansion

{word1,word2,…,wordn}

Range brace expansion

{start..end}

{start..end..delta}

Comma-separated brace expansion is expanded to each comma-separated word. For example, a{1,2,3}b is expanded to the three words a1b, a2b, and a3b.

Range brace expansion is expanded to integers in the range defined by start and end. The difference between each integer can be defined by delta. If start is larger than end, the results will be in descending order. When ..delta is omitted, it defaults to 1 or -1. For example, a{1..3}b is expanded to the three words a1b, a2b, and a3b; and a{1..7..2}b to the four words a1b, a3b, a5b, and a7b.

Multiple brace expansions can be used in one word. Brace expansions can also be nested. You can quote braces and/or commas to prevent them from being treated as brace expansion.

Any errors in brace expansion are silently ignored.

Field splitting

In field splitting, words are split at predefined separators.

Field splitting can occur only within parts of words that resulted from parameter expansion, command substitution, and arithmetic expansion that are not between double-quotation marks. Expansion results of the @ special parameter are exceptionally split even between double-quotation marks.

Separators used in field splitting are defined by the value of the IFS variable. If the variable does not exist, the value is assumed to be the three characters of space, tab, and newline.

Characters included in the value of the IFS variable are called IFS characters. IFS characters that are any of space, tab, and newline are called IFS whitespace and other IFS characters are called IFS non-whitespace.

Field splitting is performed as follows:

  1. The shell searches words for split points. A split point is one or more adjacent IFS characters within the word portions that are subject to field splitting. The following steps are taken for each split point found.

  2. If the split point includes one or more IFS non-whitespaces, any IFS whitespaces in the split point are ignored and the word is split at each IFS non-whitespace in the split point.

  3. If the split point includes no IFS non-whitespaces, the word is split at the split point unless it is at the beginning or end of the word.

  4. The split points are removed from the results.

Note
Words are not split at all when the value of the IFS variable is empty.

Pathname expansion

Pathname expansion performs pattern matching and expands to pathnames matched by the pattern.

A word subjected to pathname expansion is treated as a pattern. If one or more pathnames are found that are matched by the pattern, the pathnames become the results of the pathname expansion.

Pathname expansion is not performed when the glob option is disabled.

The shell searches readable directories for matching pathnames. Unreadable directories are silently ignored.

The following options affect the behavior of pathname expansion:

null-glob

This option affects the result of pathname expansion when no matching pathnames are found. If enabled, the result is no word. If disabled, the result is the original pattern word.

case-glob

This option specifies case-sensitivity in matching. If enabled, pattern matching is done case-sensitively.

dot-glob

This option affects matching of filenames that start with a period (.). If disabled, a period at the beginning of a filename does not match wildcard patterns (? and *) or bracket expressions. If enabled, there is no such special treatment of periods.

mark-dirs

If enabled, each resulting pathname that is a directory name is suffixed by a slash (/).

extended-glob

This option enables the extension.

Any errors in pathname expansion are silently ignored. If the word is an invalid pattern, it just becomes the result. The results depend on the null-glob option when no matching pathnames are found.

Pattern matching is done for each filename (or pathname component) of pathnames. The shell skips matching for literal patterns that contain no wildcards or bracket expressions. As a result, the patterns /*/foo and /*/fo[o] may yield different expansion results when the case-glob option is disabled; for example, the pattern /*/fo[o] matches the pathname /bar/FOO but the pattern /*/foo does not because matching is skipped for foo.

Extension in pathname expansion

The following patterns can be used when the extended-glob option is enabled.

**

The directory is searched recursively and the pattern matches any number of directory filenames (each separated by a slash). Any directory whose name begins with a period is excluded from search. For example, the pattern dir/**/file can match the pathnames dir/file, dir/foo/file, dir/a/b/c/file, etc.

This pattern is not effective when appearing at the end of the whole pattern (i.e. foo/bar/**).

.**

This pattern is like **, but all directories are searched including ones with a name starting with a period.

***

This pattern is like **, but if a symbolic link to a directory is found during recursive search, the directory is searched recursively as well.

.***

This pattern is like ***, but all directories are searched including ones with a name starting with a period.

yash-2.35/doc/_exit.txt0000644000175000017500000000425712154557026015174 0ustar magicantmagicant= Exit built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Exit built-in The dfn:[exit built-in] causes the shell process to exit. [[syntax]] == Syntax - +exit [-f] [{{exit_status}}]+ [[description]] == Description The exit built-in causes the current shell (or link:exec.html#subshell[subshell]) process to exit. If an interactive shell has a stopped link:job.html[job], the shell prints a warning message and refuses to exit. To force the shell to exit regardless, specify the +-f+ (+--force+) option or execute the built-in twice in a row. If an EXIT link:_trap.html[trap] has been set, the shell executes the trap before exiting. [[options]] == Options +-f+:: +--force+:: Suppress warnings that would prevent the shell from exiting. [[operands]] == Operands {{exit_status}}:: A non-negative integer that will be the exit status of the exiting shell. + If this operand is omitted, the exit status of the shell will be that of the last command executed before the exit built-in (but, if the built-in is executed during a link:_trap.html[trap], the exit status will be that of the last command before the trap is entered). + If {{exit_status}} is 256 or larger, the actual exit status will be the remainder of {{exit_status}} divided by 256. [[exitstatus]] == Exit status Because the built-in causes the shell to exit, there is no exit status of the built-in. As an exception, if the shell refused to exit, the exit status of the built-in is non-zero. [[notes]] == Notes The exit built-in is a link:builtin.html#types[special built-in]. The POSIX standard defines no options for the exit built-in; the built-in accepts no options in the link:posix.html[POSIXly-correct mode]. The POSIX standard provides that the {{exit_status}} operand should be between 0 and 255 (inclusive). Yash accepts integers larger than 255 as an extension. If the built-in is executed during an EXIT link:_trap.html[trap], the shell just exits without executing the trap again. If {{exit_status}} was not specified, the exit status of the shell is what the exit status would be if the trap had not been set. See also link:exec.html#exit[Termination of the shell]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_true.txt0000644000175000017500000000116312154557026015173 0ustar magicantmagicant= True built-in :encoding: UTF-8 :lang: en //:title: Yash manual - True built-in The dfn:[true built-in] does nothing successfully. [[syntax]] == Syntax - +true+ [[description]] == Description The true built-in does nothing. Any command line arguments are ignored. [[exitstatus]] == Exit status The exit status of the true built-in is zero. [[notes]] == Notes The true built-in is a link:builtin.html#types[semi-special built-in]. The true and link:_colon.html[colon] built-ins have the same effect, but true is a semi-special built-in while colon is a special. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_pwd.html0000644000175000017500000000530312154557026015133 0ustar magicantmagicant Pwd built-in

The pwd built-in prints the current working directory.

Syntax

  • pwd [-L|-P]

Description

The pwd built-in prints an absolute path to the shell’s current working directory to the standard output.

Options

-L
--logical

If the value of the PWD variable is an absolute path to the shell’s working directory and the path does not contain any . or .. components, then the path is printed. Otherwise, the printed path is the same as when the -P option is specified.

-P
--physical

The printed path does not contain any . or .. components, symbolic link components, or redundant slashes.

The -L (--logical) and -P (--physical) options are mutually exclusive: only the last specified one is effective. If neither is specified, -L is assumed.

Exit status

The exit status of the pwd built-in is zero unless there is any error.

Notes

The pwd built-in is a semi-special built-in.

yash-2.35/doc/_unset.html0000644000175000017500000000604212154557026015500 0ustar magicantmagicant Unset built-in

The unset built-in undefines variables or functions.

Syntax

  • unset [-fv] [name…]

Description

The unset built-in removes the definition of the variables or functions specified by operands.

It is not an error if any of the specified variables or functions do not exist; they are silently ignored.

Options

-f
--functions

Undefine functions.

-v
--variables

Undefine variables.

These options are mutually exclusive: only the last specified one is effective. If neither is specified, -v is assumed.

Operands

name

The name of a variable or function to be undefined.

Exit status

The exit status of the unset built-in is zero unless there is any error.

Notes

The unset built-in is a special built-in.

Although yash does not do so, the POSIX standard allows removing a function if neither of the -f and -v options is specified and the specified variable does not exist.

At least one name operand must be specified in the POSIXly-correct mode.

yash-2.35/doc/_colon.html0000644000175000017500000000352312154557026015455 0ustar magicantmagicant Colon built-in

The colon built-in does nothing.

Syntax

  • : [argument…]

Description

The colon built-in does nothing. Any command line arguments are ignored.

Exit status

The exit status of the colon built-in is zero.

Notes

The colon built-in is a special built-in.

Arguments are expanded and redirections are performed as usual. The colon and true built-ins have the same effect, but colon is a special built-in while true is a semi-special.

yash-2.35/doc/intro.html0000644000175000017500000000406312154557026015337 0ustar magicantmagicant Introduction

Yet anther shell (yash) is a command line shell for UNIX-like operating systems. The shell conforms to the POSIX.1-2008 standard (for the most parts), and actually is more conforming than other POSIX-conforming shells. Moreover, it has many features that are used for interactive use, such as command history and command line editing.

This program can be freely modified and redistributed under the terms of GNU General Public License (Version 2). Use of this program is all at your own risk. There is no warranty and the author is not responsible for any consequences caused by use of this program.

This manual can be freely modified and redistributed under the terms of Creative Commons Attribution-ShareAlike 2.1 Japan.

Yash is developed and maintained by 渡邊裕貴 (WATANABE Yuki) aka Magicant. Yash development project and Yash’s homepage are hosted by SourceForge.jp.

yash-2.35/doc/builtin.txt0000644000175000017500000001305412154557026015525 0ustar magicantmagicant= Built-in commands :encoding: UTF-8 :lang: en //:title: Yash manual - Built-in commands :description: This page describes common properties of built-ins of yash. dfn:[Built-in commands] are commands that are implemented in the shell and are executed by the shell without external programs. [[types]] == Types of built-in commands There are three types of built-in commands in yash: special built-in commands, semi-special built-in commands and regular built-in commands. dfn:[Special built-in commands] are much more important commands than others. They are executed regardless of whether the corresponding external commands exist or not. Results of variable assignments that occur in a link:syntax.html#simple[simple command] that invokes a special built-in last after the command has finished. Moreover, in the link:posix.html[POSIXly-correct mode], a link:interact.html[non-interactive] shell immediately exits with a non-zero exit status when a redirect error, assignment error, or misuse of option or operand occurs in a special built-in command. dfn:[Semi special built-in commands] are the second important built-in commands. They are executed regardless of whether the corresponding external commands exist or not. In other parts they are the same as regular built-in commands. dfn:[Regular built-in commands] are less important built-in commands including commands that can be implemented as external commands or are not listed in POSIX. In the POSIXly-correct mode, a regular built-in is executed only when a corresponding external command is link:exec.html#search[found in PATH]. [[argsyntax]] == Syntax of command arguments In this section we explain common rules about command arguments. The built-in commands of yash follow the rules unless otherwise stated. There are two types of command arguments. One is options and the other is operands. An option is an argument that starts with a hyphen (+-+) and changes the way the command behaves. Some options take arguments. An operand is an argument that is not an option and specifies objects the command operates on. If you specify more than one option to a command, the order of the options are normally not significant. The order of operands, however, affects the command behavior. An option is either a single-character option or a long option. A single-character option is identified by one alphabetic character. A long option is identified by multiple alphabetic characters. The POSIX standard only prescribes single-character options, so in the link:posix.html[POSIXly-correct mode] you cannot use long options. A single-character option is composed of a hyphen followed by a letter. For example, +-a+ is a single-character option. A single-character option that takes an argument requires the argument to be just after the option name. .The set built-in and single-character options ==== For the set built-in, +-m+ is a single-character option that does not take an argument and +-o+ is one that takes an argument. - +set -o errexit -m+ - +set -oerrexit -m+ In these two command lines, +errexit+ is the argument to the +-o+ option. ==== In the second example above, the +-o+ option and its argument are combined into a single command line argument. The POSIX standard deprecates that style and any POSIX-conforming applications must specify options and their arguments as separate command line arguments, although yash accepts both styles. You can combine single-character options that do not take arguments into a single command line argument. For example, the three options +-a+, +-b+ and +-c+ can be combined into +-abc+. A long option is composed of two hyphens followed by an option name. For example, +--long-option+ is a long option. You can omit some last characters of a long option name as long as it is not ambiguous. For example, you can use +--long+ instead of +--long-option+ if there is no other options beginning with +--long+. Like a single-character option, a long option that takes an argument requires the argument to be a command line argument just after the option name or to be specified in the same command line argument as the option name, separated by an equal sign (+=+). .The fc built-in and long options ==== For the fc built-in, +--quiet+ is a long option that does not take an argument and +--editor+ is one that takes an argument. - +fc --editor vi --quiet+ - +fc --editor=vi --quiet+ In these command lines, +vi+ is the argument to the +--editor+ option. ==== Arguments that are not options (nor arguments to them) are interpreted as operands. The POSIX standard requires all options should be specified before any operands. Therefore, in the link:posix.html[POSIXly-correct mode], any arguments that come after the first operand are interpreted as operands (even if they look like options). If not in the POSIXly-correct mode, you can specify options after operand. Regardless of whether the shell is in the POSIXly-correct mode or not, an argument that is just composed of two hyphens (+--+) can be used as a separator between options and operands. All command line arguments after the +--+ separator are interpreted as operands, so you can specify operands that start with a hyphen correctly using the separator. .Options and operands to the set built-in ==== - `set -a -b -- -c -d` In this example, +-a+ and +-b+ are options and +-c+ and +-d+ are operands. The +--+ separator itself is neither an option nor an operand. ==== Regardless of whether the shell is in the POSIXly-correct mode or not, an argument that is just composed of a single hyphen (+-+) is interpreted as an operand. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_umask.txt0000644000175000017500000000540312154557026015335 0ustar magicantmagicant= Umask built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Umask built-in The dfn:[umask built-in] sets or prints the file mode creation mask. [[syntax]] == Syntax - +umask {{mask}}+ - +umask [-S]+ [[description]] == Description If executed without the {{mask}} operand, the built-in prints the current file mode creation mask of the shell to the standard output in a form that can later be used as {{mask}} to restore the current mask. Otherwise, the built-in sets the file mode creation mask to {{mask}}. [[options]] == Options +-S+:: +--symbolic+:: Print in the symbolic form instead of the octal integer form. [[operands]] == Operands {{mask}}:: The new file mode creation mask either in the symbolic or octal integer form. === Octal integer form In the octal integer form, the mask is specified as a non-negative octal integer that is the sum of the following permissions: 0400:: read by owner 0200:: write by owner 0100:: execute/search by owner 0040:: read by group 0020:: write by group 0010:: execute/search by group 0004:: read by others 0002:: write by others 0001:: execute/search by others === Symbolic form In the symbolic form, the mask is specified as a symbolic expression that denotes permissions that are *not* included in the mask. The entire expression is one or more {{clause}}s separated by comma. A {{clause}} is a sequence of {{who}}s followed by one or more {{action}}s. A {{who}} is one of: +u+:: owner +g+:: group +o+:: others +a+:: all of owner, group, and others An empty sequence of {{who}}s is equivalent to who +a+. An {{action}} is an {{operator}} followed by {{permission}}. An {{operator}} is one of: +=+:: set {{who}}'s permission to {{permission}} +++:: add {{permission}} to {{who}}'s permission +-+:: remove {{permission}} from {{who}}'s permission and {{permission}} is one of: +r+:: read +w+:: write +x+:: execute/search +X+:: execute/search (only if some user already has execute/search permission) +s+:: set-user-ID and set-group-ID +u+:: user's current permissions +g+:: group's current permissions +o+:: others' current permissions but more than one of +r+, +w+, +x+, +X+, and +s+ can be specified after a single {{operand}}. For example, the command +umask u=rwx,go+r-w+ - unmasks the user's read, write, and execute/search permissions; - unmasks the group's and others' read permission; and - masks the group's and others' write permission. [[exitstatus]] == Exit status The exit status of the umask built-in is zero unless there is any error. [[notes]] == Notes The umask built-in is a link:builtin.html#types[semi-special built-in]. The POSIX standard does not require the default output format (used when the +-S+ option is not specified) to be the octal integer form. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/invoke.html0000644000175000017500000001701312154557026015476 0ustar magicantmagicant Invocation

When invoked as a program, yash performs the predefined initialization steps and repeatedly reads and executed commands. Command line arguments given in the invocation determines how the shell initializes itself and executes commands.

Command line arguments

The syntax of command line arguments for yash conforms to POSIX. As defined in POSIX, arguments are separated into options and operands. For more detailed explanation about options and operands, see Command argument syntax. All options must come before operands. The interpretation of operands depends on options specified.

When you specify the -c (--cmdline) option, you must give at least one operand. The shell interprets and executes the first operand as a command string. The second operand, if any, is used to initialize the 0 special parameter. The other operands, if any, are used to initialize the positional parameters. When the -c (--cmdline) option is specified, the shell does not read any file or the standard input (unless the dot built-in is used).

If you specify the -s (--stdin) option, the shell reads the standard input, interprets the input as commands, and executes them. All the operands given are used to initialize the positional parameters. The 0 special parameter is initialized to the name the shell is invoked as.

If you specify neither the -c (--cmdline) nor -s (--stdin) option, the shell reads a file, interprets the file contents as commands, and executes them. The first operand specifies the pathname of the file. The remaining operands are used to initialize the positional parameters. If you do not give any operands, the shell reads the standard input as if the -s (--stdin) option is specified.

You cannot use both the -c (--cmdline) and -s (--stdin) options at a time.

If you specify either the --help or --version option, the shell never performs the usual initialization or command execution. Instead, it just prints brief usage (for --help) or version information (for --version). If the --version option is accompanied by the -v (--verbose) option, the shell prints a list of the available optional features as well.

If you specify the -i (--interactive) option, the shell goes into the interactive mode. If you specify the +i (++interactive) option, conversely, the shell never goes into the interactive mode.

If you specify the -l (--login) option, the shell behaves as a login shell.

The --noprofile, --norcfile, --profile, and --rcfile options determine how the shell is initialized (see below for details).

In addition to the options described above, you can specify options that can be specified to the set built-in.

If the first operand is - and the options and the operands are not separated by --, the first operand is ignored.

Initialization of yash

Yash initializes itself as follows:

  1. Yash first parses the name it was invoked as. If the name starts with -, the shell behaves as a login shell. If the name is sh (including names such as /bin/sh), the shell goes into the POSIXly-correct mode.

  2. If no operands are given and the standard input and standard error are both connected to a terminal, the shell goes into the interactive mode unless the +i (++interactive) option is specified.

  3. Job control is automatically enabled in an interactive shell unless the +m (++monitor) option is specified.

  4. Yash reads and executes commands from the following files (unless the real and effective user IDs of the shell process are different or the real and effective group IDs of the shell process are different):

    1. If it is behaving as a login shell, the shell reads the file specified by the --profile=filename option unless the --noprofile option is specified or the shell is in the POSIXly-correct mode.
      If the --profile=filename option is not specified, the shell reads ~/.yash_profile as a default.

    2. If in the interactive mode, the shell reads the file specified by the --rcfile=filename option unless the --norcfile option is specified.
      If the --rcfile=filename option is not specified, the shell

      • reads ~/.yashrc as a default if not in the POSIXly-correct mode; or

      • performs parameter expansion on the value of the ENV environment variable and treats the expansion result as the name of the file to read if in the POSIXly-correct mode.

Note
Yash never automatically reads /etc/profile, /etc/yashrc, nor ~/.profile.
yash-2.35/doc/_help.txt0000644000175000017500000000166512154557026015153 0ustar magicantmagicant= Help built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Help built-in The dfn:[help built-in] prints usage of built-ins. [[syntax]] == Syntax - +help [{{built-in}}...]+ [[description]] == Description The help built-in prints a description of {{built-in}}s. The built-in extracts part of the output of +man yash+ and prints it to the standard output. Therefore, the manual page of yash must have been installed for the built-in to work. Depending on the formatting style of the man command, the built-in may not work as expected. [[operands]] == Operands {{built-in}}s:: Names of link:builtin.html[built-ins]. [[exitstatus]] == Exit status The exit status of the help built-in is zero unless there is any error. [[notes]] == Notes The help built-in is not defined in the POSIX standard. Many built-ins of yash accept the +--help+ option that prints the same description. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_eval.html0000644000175000017500000000715412154557026015276 0ustar magicantmagicant Eval built-in

The eval built-in evaluates operands as commands.

Syntax

  • eval [-i] [command…]

The eval built-in requires that all options precede operands. Any command line arguments after the first operand are all treated as operands.

Description

The eval parses operands as commands and executes them in the current command execution environment.

When executed without the -i (--iteration) option, all the operands are concatenated into one string (with a space inserted between each operand) and parsed/executed at once.

With the -i (--iteration) option, the built-in performs iterative execution: operands are parsed/executed one by one. If the continue built-in is executed with the -i (--iteration) option during the iterative execution, the execution of the current operand is aborted and the next operand is parsed/executed immediately. The break built-in with the -i (--iteration) option is similar but the remaining operands are not parsed/executed.

Options

-i
--iteration

Perform iterative execution.

Operands

command

A string that is parsed and executed as commands.

Exit status

The exit status is zero if no command was specified or command contained no actual command that can be executed. Otherwise, that is, if the eval built-in executed one or more commands, the exit status of the eval built-in is that of the last executed command.

Notes

The eval built-in is a special built-in.

The POSIX standard defines no options for the eval built-in; the built-in accepts no options in the POSIXly-correct mode.

yash-2.35/doc/params.html0000644000175000017500000006015412154557026015472 0ustar magicantmagicant Parameters and variables

Parameters are string values that are expanded in parameter expansion. There are three types of parameters: positional parameters, special parameters and variables.

Positional parameters

Positional parameters are parameters that are identified by natural numbers. If there are three positional parameters, for example, they are identified as 1, 2, and 3. You can obtain the number of positional parameters by the # special parameter. The * and @ special parameters are expanded to all positional parameters.

Positional parameters are initialized from the shell’s command line arguments when the shell is started (see Command line arguments). In the initialization, the order of the operands are preserved as the order of the positional parameters.

When the shell executes a function call, positional parameters are changed to the arguments to the function call so that you can access the arguments while the function is being executed. Positional parameters are restored to the original values when the execution of the function is finished.

Positional parameters can be manipulated by built-in commands like set and shift.

Note that 0 is not a positional parameter but a special parameter.

Special parameters

Special parameters are parameters each identified by a single symbol. They cannot be directly assigned to by the user.

Yash provides the following special parameters:

0

The name of the shell executable file or the script file that was specified in the invocation of the shell.

#

The number of current positional parameters. The value is a non-negative integer.

$

The process ID of the shell. The value is a positive integer and is never changed even in subshells.

-

Currently enabled shell options. The value is a concatenation of alphabet characters that are the names of currently enabled single-character options that can be specified in shell invocation. The value reflects changes of enabled options when you enable or disable options using the set built-in.

?

The exit status of the last executed pipeline. The value is a non-negative integer.

!

The process ID of the last executed asynchronous list.

*

This special parameter represents the whole positional parameters. When there is no positional parameters, the value of this special parameter is the empty string. When there is more than one positional parameter, the value is a concatenation of all the positional parameters, each of which is separated as follows:

  • If the IFS variable exists and its value is not empty, positional parameters are each separated by the first character of the value of the IFS variable.

  • If the IFS variable exists and has an empty value, positional parameters are just concatenated without any separator.

  • If the IFS variable does not exist, positional parameters are each separated by a space character.

@

This special parameter represents the whole positional parameters like the * special parameter above. The difference between the two is the results of expansion that occurs between a pair of double-quotation marks. If the @ special parameter is expanded inside double-quotations, positional parameters are field-split rather than concatenated (in spite of the quotation). If there are no positional parameters, the expansion yields no word rather than an empty word.

  • When there are no positional parameters, the command words echo 1 "$@" 2 is expanded to the three words echo, 1, and 2.

  • When positional parameters are the three words 1, 2 2, and 3, the command words echo "$@" is expanded to the four words echo, 1, 2 2, and 3, and the words echo "a$@b" to the four words echo, a1, 2 2, and 3b.

Variables

Variables are parameters the user can assign values to. Each variable has a name that identifies it and a value that defines the results of expansion.

A variable name is composed of one or more alphanumeric characters and underscores (_). A name cannot start with a digit. Other characters may be used in a name depending on internationalization support of your environment.

Variables that are exported to external commands are called environment variables. They are passed to all external commands the shell invokes. Variables passed to the shell in invocation will be automatically exported.

You can assign to variables by a simple command as well as the typeset built-in. You can remove variables by using the unset built-in.

Variables used by the shell

The following variables are used by the shell for special purposes.

CDPATH

This variable is used by the cd built-in to find a destination directory.

COLUMNS

This variable specifies the width (the number of character columns) of the terminal screen. The value affects the display of line-editing.

COMMAND_NOT_FOUND_HANDLER

When the shell cannot find a command to be executed, the value of this variable is interpreted and executed instead. You can override the shell’s error handling behavior with this variable. See Execution of simple commands for detail.

This feature is disabled in the POSIXly-correct mode.

DIRSTACK

This array variable is used by the shell to store the directory stack contents. If you modify the value of this variable, the directory stack may be corrupted.

ECHO_STYLE

This variable specifies the behavior of the echo built-in.

ENV

When an interactive shell is started in the POSIXly-correct mode, the value of this variable is used to find the initialization file. See Initialization of yash.

FCEDIT

This variable specifies an editor program used to edit command lines during execution of the fc built-in.

HANDLED

This variable can be set in the command-not-found handler to tell the shell not to produce a further error message. See Execution of simple commands for detail.

HISTFILE

This variable specifies the pathname of the file to save the command history in.

HISTRMDUP

This variable specifies the number of command history items to be checked for duplication. When the shell is adding a new history item to the command history, if some of the most recent n items have the same contents as the new one, then the duplicate existing items are removed from the history before the new one is added, where n is the value of this variable.

If the value of this variable is 1, for example, the most recent item is removed when a new item that have the same contents is added.

Items older than the nth recent item are not removed. No items are removed if the value of this variable is 0. All items are subject to removal if the variable value is greater than or equal to the value of the HISTSIZE variable.

HISTSIZE

This variable specifies the maximum number of items in the command history.

HOME

This variable specifies the pathname of the user’s home directory and affects results of tilde expansion and cd built-in.

IFS

This variable specifies separators used in field splitting. The variable value is initialized to the three characters of a space, a tab, and a newline when the shell is started.

LANG
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MESSAGES
LC_MONETARY
LC_NUMERIC
LC_TIME

These variables specify a locale in which the shell runs. The shell chooses the file input/output encoding, the error message language, etc. according to the locale specified.

Unless the shell is interactive and not in the POSIXly-correct mode, the value of the LC_CTYPE variable is considered only when the shell is started. Once the shell has been initialized, changing the value of LC_CTYPE will have no effect on the shell’s behavior.

LINENO

The value of this variable is automatically set to the line number in which the currently executed command appears in the file.

In the interactive shell, the line number is reset to 1 each time the shell reads and executes a command.

If you assign to or remove this variable, it will no longer provide line numbers.

LINES

This variable specifies the height (the number of character lines) of the terminal screen. The value affects the display of line-editing.

MAIL

This variable specifies the pathname of a file that is checked in mail checking.

MAILCHECK

This variable specifies how often the shell should do mail checking. The value has to be specified as a positive integer in seconds. The value is initialized to the default value of 600 when the shell is started.

MAILPATH

This variable specifies the pathnames of files that are checked in mail checking.

NLSPATH

The POSIX standard prescribes that the value of this variable specifies pathname templates of locale-dependent message data files, but yash does not use it.

OLDPWD

This variable is set to the previous working directory path when you change the working directory by using the cd or other built-ins. This variable is exported by default.

OPTARG

When the getopts built-in parses an option that takes an argument, the argument value is assigned to this variable.

OPTIND

The value of this variable specifies the index of an option that is to be parsed by the next getopts built-in execution. This variable is initialized to 1 when the shell is started.

PATH

This variable specifies paths that are searched for a command in command search.

PPID

The value of this variable is the process ID of the shell’s parent process, which is a positive integer. This variable is initialized when the shell is started. The value is not changed when the shell makes a new subshell.

PROMPT_COMMAND

The shell interprets and executes the value of this variable before printing each command prompt if the shell is interactive and not in the POSIXly-correct mode. This behavior is equivalent to executing the command eval -i -- "${PROMPT_COMMAND-}" before each command prompt, but its exit status does not affect the expansion of the ? special parameter in the next command.

PS1

This variable specifies the main command prompt string printed by an interactive shell. See Prompts for the format of the variable value. The value is initialized to \$ when the shell is started. (In the POSIXly-correct mode, the initial value is either $ or # depending on whether the effective user ID of the shell process is zero or not.)

PS1R

This variable specifies the auxiliary prompt string printed to the right of the cursor when you input a command line to an interactive shell. See Prompts for the format of the variable value.

PS1S

This variable specifies the font style of command strings you enter to an interactive shell. See Prompts for the format of the variable value.

PS2

This variable is like the PS1 variable, but it is used for the second and following lines of a command that is longer than one line. See Prompts for the format of the variable value. The value is initialized to > when the shell is started.

PS2R

This variable is like the PS1R variable, but it is used when PS2 is used. See Prompts for the format of the variable value.

PS2S

This variable is like the PS1S variable, but it is used when PS2 is used. See Prompts for the format of the variable value.

PS4

The value of this variable is printed before each command trace output when the xtrace option is enabled. The value is subject to parameter expansion, command substitution, arithmetic expansion. You can also use backslash notations if the shell is not in the POSIXly-correct mode. The value is initialized to + when the shell is started.

PS4S

This variable is like the PS1S variable, but it is used when PS4 is used. You can use this variable to modify font style of command trace output.

PWD

The value of this variable is the pathname of the current working directory. The value is set when the shell is started and reset each time the working directory is changed by the cd or other built-ins. This variable is exported by default.

RANDOM

You can use this variable to get random numbers. The value of this variable is a uniformly distributed random integer between 0 and 32767 (inclusive). You will get a different number each time the variable is expanded.

You can set the “seed” of random numbers by assigning a non-negative integer to the variable.

If you remove this variable, it will no longer work as a random number generator. If the shell was invoked in the POSIXly-correct mode, this variable does not work as a random number generator.

TERM

This variable specifies the type of the terminal in which the shell is running. The value affects the behavior of line-editing.

YASH_AFTER_CD

The shell interprets and executes the value of this variable after each time the shell’s working directory is changed by the cd or other built-ins. This behavior is equivalent to executing the command eval -i -- "${YASH_AFTER_CD-}" after the directory was changed.

YASH_LOADPATH

This variable specifies directories the dot built-in searches for a script file. More than one directory can be specified by separating them by colons like the PATH variable. When the shell is started, this variable is initialized to the pathname of the directory where common script files are installed.

YASH_LE_TIMEOUT

This variable specifies how long the shell should wait for a next possible input from the terminal when it encountered an ambiguous control sequence while line-editing. The value must be specified in milliseconds. If you do not define this variable, the default value of 100 milliseconds is assumed.

YASH_VERSION

The value is initialized to the version number of the shell when the shell is started.

Arrays

An array is a variable that contains zero or more strings. The string values of an array are identified by natural numbers (like positional parameters).

You can assign values to an array by using a simple command as well as the array built-in. You can use the unset built-in to remove arrays.

Arrays cannot be exported as arrays. When an array is exported, it is treated as a normal variable whose value is a concatenation of all the array values, each separated by a colon.

Arrays are not supported in the POSIXly-correct mode.

yash-2.35/doc/syntax.txt0000644000175000017500000004350512154557026015411 0ustar magicantmagicant= Syntax :encoding: UTF-8 :lang: en //:title: Yash manual - Syntax :description: This page defines yash's command syntax and semantics. The shell reads, parses, and executes command line by line. If there is more than one command on a line, all the commands are parsed before executed. If a command is continued to next lines, the shell reads more enough lines to complete the command. On a syntax error, the shell neither reads nor executes any more commands. [[tokens]] == Tokens and keywords A command is composed of one or more tokens. In the shell syntax, a dfn:[token] is a word that is part of a command. Normally, tokens are separated by whitespaces, that is, the space or tab character. Whitespaces inside a command substitution or a parameter expansion, however, do not separate tokens. The following symbols have special meanings in the shell syntax and in most cases separate tokens: ; & | < > ( ) [newline] The following symbols do not separate tokens, but have syntactic meanings: $ ` \ " ' * ? [ # ~ = % The following tokens are treated as dfn:[keywords] depending on the context in which they appear: ! { } case do done elif else esac fi for function if in then until while A token is treated as a keyword when: * it is the first token of a command, * it follows another keyword (except +case+, +for+, and +in+), or * it is a non-first token of a command and is supposed to be a keyword to compose a composite command. If a token begins with `#`, then the `#` and any following characters up to the end of the line are treated as a dfn:[comment], which is completely ignored in syntax parsing. [[quotes]] == Quotations If you want whitespaces, separator characters, or keywords described above to be treated as a normal characters, you must quote the characters using appropriate quotation marks. Quotation marks are not treated as normal characters unless they are themselves quoted. You can use the following three quotation marks: * A backslash (+\+) quotes a character that immediately follows. + The only exception about a backslash is the case where a backslash is followed by a newline. In this case, the two characters are treated as a dfn:[line continuation] rather than a newline being quoted. The two characters are removed from the input and the two lines surrounding the line continuation are concatenated into a single line. * A pair of single-quotation marks (+'+) quote any characters between them except another single-quotation. Note that newlines can be quoted using single-quotations. * Double-quotation marks (+"+) are like single-quotations, but they have a few exceptions: Parameter expansion, command substitution, and arithmetic expansion are interpreted as usual even between double-quotations. A backslash between double-quotations is treated as a quotation mark only when it is followed by +$+, +`+, +"+, +\+, or a newline; other backslashes are treated as normal characters. [[aliases]] == Aliases Tokens that compose a command are subject to dfn:[alias substitution]. A token that matches the name of an alias that has already been defined is substituted with the value of the alias before the command is parsed. Tokens that contain quotations are not alias-substituted since an alias name cannot contain quotation marks. Keywords and command separator characters are not alias-substituted either. There are two kinds of aliases: normal aliases and global aliases. A dfn:[normal alias] can only substitute the first token of a command while a dfn:[global alias] can substitute any part of a command. Global aliases are yash extension that is not defined in POSIX. If a token is alias-substituted with the value of a normal alias that ends with a whitespace, the next token is exceptionally subject to alias substitution for normal aliases. The results of alias substitution are again subject to alias substitution for other aliases (but not for the aliases that have been already applied). You can define aliases using the link:_alias.html[alias built-in] and remove using the link:_unalias.html[unalias built-in]. [[simple]] == Simple commands A command that does not start with a keyword token is a dfn:[simple command]. Simple commands are executed as defined in link:exec.html#simple[Execution of simple commands]. If the first and any number of following tokens of a simple command have the form +{{name}}={{value}}+, they are interpreted as link:params.html#variables[variable] assignments. A variable name must consist of one or more alphabets, digits and/or underlines (+_+) and must not start with a digit. The first token that is not a variable assignment is considered as a command name and all the following tokens (whether or not they have the form +{{name}}={{value}}+) as command arguments. A variable assignment of the form +{{var}}=({{tokens}})+ is interpreted as assignment to an link:params.html#arrays[array]. You can write any number of tokens between a pair of parentheses. Tokens can be separated by not only spaces and tabs but also newlines. [[pipelines]] == Pipelines A dfn:[pipeline] is a sequence of one or more <>, <>, and/or <> that are separated by +|+. A pipeline that has more than one subcommand is executed by executing each subcommand of the pipeline in a subshell simultaneously. The standard output of each subcommand except the last one is redirected to the standard input of the next subcommand. The standard input of the first subcommand and the standard output of the last subcommand are not redirected. The exit status of the pipeline is that of the last subcommand. A pipeline can be prefixed by +!+, in which case the exit status of the pipeline is _reversed_: the exit status of the pipeline is 1 if that of the last subcommand is 0, and 0 otherwise. [NOTE] When the execution of a pipeline finishes, at least the execution of the last subcommand has finished since the exit status of the last subcommand defines that of the whole pipeline. The execution of other subcommands, however, may not have finished then. On the other hand, the execution of the pipeline may not finish soon after that of the last subcommand finished because the shell may choose to wait for the execution of other subcommands to finish. [NOTE] The POSIX standard allows executing any of subcommands in the current shell rather than subshells, though yash does not do so. [[and-or]] == And/or lists An dfn:[and/or list] is a sequence of one or more <> separated by +&&+ or +||+. An and/or list is executed by executing some of the pipelines conditionally. The first pipeline is always executed. The other pipelines are either executed or not executed according to the exit status of the previous pipelines. - If two pipelines are separated by +&&+ and the exit status of the first pipeline is zero, the second pipeline is executed. - If two pipelines are separated by +||+ and the exit status of the first pipeline is not zero, the second pipeline is executed. - In other cases, the execution of the and/or list ends: the second and any remaining pipelines are not executed. The exit status of an and/or list is that of the last pipeline that was executed. Normally, an and/or list must be terminated by a semicolon, ampersand, or newline. See <>. [[async]] == Command separators and asynchronous commands The whole input to the shell must be composed of any number of <> separated by a semicolon or ampersand. A terminating semicolon can be omitted if it is followed by +;;+, +)+, or a newline. Otherwise, an and/or list must be terminated by a semicolon or ampersand. If an and/or list is terminated by a semicolon, it is executed synchronously: the shell waits for the and/or list to finish before executing the next and/or list. If an and/or list is terminated by an ampersand, it is executed asynchronously: after the execution of the and/or list is started, the next and/or list is executed immediately. An asynchronous and/or list is always executed in a link:exec.html#subshell[subshell] and its exit status is zero. If the shell is not doing link:job.html[job control], the standard input of an asynchronous and/or list is automatically redirected to /dev/null. Signal handlers of the and/or list for the SIGINT and SIGQUIT signals are set to ``ignore'' the signal so that the execution of the and/or list cannot be stopped by those signals. (In the link:posix.html[POSIXly-correct mode], the standard input is redirected if and only if the shell is link:interact.html[interactive], regardless of whether job control is on. Moreover, the SIGINT and SIGQUIT signals are ignored even if job control is on.) When the execution of an asynchronous and/or list is started, the shell remembers its process ID. You can obtain the ID by referencing the link:params.html#sp-exclamation[+!+ special parameter]. You can obtain the current and exit status of the asynchronous list as well by using the link:_jobs.html[jobs] and link:_wait.html[wait] built-ins. [[compound]] == Compound commands Compound commands provide you with programmatic control of shell command execution. [[grouping]] === Grouping A grouping is a list of commands that is treated as a <>. Normal grouping syntax:: +{ {{command}}...; }+ Subshell grouping syntax:: +({{command}}...)+ The +{+ and +}+ tokens are keywords, which must be separated from other tokens. The +(+ and +)+ tokens, however, are special separators that need not to be separated. In the normal grouping syntax, the commands in a grouping are executed in the current shell. In the subshell grouping syntax, the commands are executed in a new link:exec.html#subshell[subshell]. In the link:posix.html[POSIXly-correct mode], a grouping must contain at least one command. If the shell is not in the POSIXly-correct mode, a grouping may contain no commands. The exit status of a grouping is that of the last command in the grouping. If the grouping contains no commands, its exit status is that of the last executed command before the grouping. [[if]] === If command The if command performs a conditional branch. Basic if command syntax:: +if {{condition}}...; then {{body}}...; fi+ Syntax with the else clause:: +if {{condition}}...; then {{body}}...; else {{body}}...; fi+ Syntax with the elif clause:: +if {{condition}}...; then {{body}}...; elif {{condition}}...; then {{body}}...; fi+ Syntax with the elif clause:: +if {{condition}}...; then {{body}}...; elif {{condition}}...; then {{body}}...; else {{body}}...; fi+ For all the syntaxes, the execution of an if command starts with the execution of the {{condition}} commands that follows the +if+ token. If the exit status of the condition commands is zero, the condition is considered as ``true''. In this case, the {{body}} commands that follows the +then+ token are executed and the execution of the if command finishes. If the exit status of the condition commands is non-zero, the condition is considered as ``false''. In this case, the {{condition}} commands for the next elif clause are executed and the exit status is tested in the same manner as above. If there is no elif clause, the {{body}} commands that follow the +else+ token are executed and the execution of the if command finishes. If there is no else clause either, the execution of the if command just ends. An if command may have more than one elif-then clause. The exit status of an if command is that of the {{body}} commands that were executed. The exit status is zero if no {{body}} commands were executed, that is, all the conditions were false and there was no else clause. [[while-until]] === While and until loops The while loop and until loop are simple loops with condition. While loop syntax:: +while {{condition}}...; do {{body}}...; done+ Until loop syntax:: +until {{condition}}...; do {{body}}...; done+ If the shell is not in the link:posix.html[POSIXly-correct mode], you can omit the {{condition}} and/or {{body}} commands of a while/until loop. The execution of a while loop is started by executing the {{condition}} commands. If the exit status of the {{condition}} commands is zero, the shell executes the {{body}} commands and returns to the execution of the {{condition}} commands. The {{condition}} and {{body}} commands are repeatedly executed until the exit status of the {{condition}} commands is non-zero. [NOTE] The {{body}} commands are not executed at all if the first execution of the {{condition}} commands yields a non-zero exit status. An until loop is executed in the same manner as a while loop except that the condition to repeat the loop is reversed: the {{body}} commands are executed when the exit status of the {{condition}} commands is non-zero. The exit status of a while/until loop is that of the last executed {{body}} command. The exit status is zero if the {{body}} commands are empty or were not executed at all. [[for]] === For loop The for loop repeats commands with a variable assigned one of given values in each round. For loop syntax:: +for {{varname}} in {{word}}...; do {{command}}...; done+ + +for {{varname}} do {{command}}...; done+ The {{word}} list after the +in+ token may be empty, but the semicolon (or newline) before the +do+ token is required even in that case. The {{word}}s are not treated as keywords, but you need to <> separator characters (such as +&+ and +|+) to include them as part of a {{word}}. If you omit the +in+ token and the following {{word}}s, you must also omit the semicolon before the +do+ token. However, the shell does not complain about the existence of the semicolon if not in the link:posix.html[POSIXly-correct mode]. The {{command}} list may be empty if not in the POSIXly-correct mode. The execution of a for loop is started by expanding the {{word}}s in the same manner as in the execution of a <>. If the +in+ and {{word}} tokens are omitted, the shell assumes the {{word}} tokens to be +"$@"+. Next, the following steps are taken for each word expanded (in the order the words were expanded): . Assign the word to the variable whose name is {{varname}}. . Execute the {{command}}s. Each word is assigned as a link:exec.html#localvar[local variable] except in the POSIXly-correct mode. If the expansion of the {{word}}s yielded no words as a result, the {{command}}s are not executed at all. The exit status of a for loop is that of the last executed {{command}}. The exit status is zero if the {{command}}s are not empty and not executed at all. If the {{command}}s are empty, the exit status is that of the last executed command before the for loop. [[case]] === Case command The case command performs a pattern matching to select commands to execute. Case command syntax:: +case {{word}} in {{caseitem}}... esac+ Case item syntax:: +({{patterns}}) {{command}}...;;+ The {{word}} between the +case+ and +in+ tokens must be exactly one word. The {{word}} is not treated as a keyword, but you need to <> separator characters (such as +&+ and +|+) to include them as part of the {{word}}. Between the +in+ and +esac+ tokens you can put any number of case items (may be none). You can omit the first +(+ token of a case item and the last +;;+ token before the +esac+ token. If the last {{command}} of a case item is terminated by a semicolon, you can omit the semicolon as well. The {{command}}s in a case item may be empty. The {{patterns}} in a case item are one or more tokens each separated by a +|+ token. The execution of a case command starts with subjecting the {{word}} to link:expand.html[the four expansions]. Next, the following steps are taken for each case item (in the order of appearance): . For each word in the {{patterns}}, expand the word in the same manner as the {{word}} and test if the expanded pattern link:pattern.html[matches] the expanded word. (If a pattern is found that matches the word, the remaining patterns are not expanded nor tested, so some of the {{patterns}} may not be expanded. Yash expands and tests the patterns in the order of appearance, but it may not be the case for other shells.) . If one of the {{patterns}} was found to match the {{word}} in the previous step, the {{command}}s in this case item are executed and the execution of the whole case item ends. Otherwise, proceed to the next case item. The exit status of a case command is that of the {{command}}s executed. The exit status is zero if no {{command}}s were executed, that is, there were no case items, no matching pattern was found, or no commands were associated with the matching pattern. In the link:posix.html[POSIXly-correct mode], the first pattern in a case item cannot be +esac+ (even if you do not omit the +(+ token). [[funcdef]] == Function definition The function definition command defines a link:exec.html#function[function]. Function definition syntax:: +{{funcname}} ( ) {{compound_command}}+ + +function {{funcname}} {{compound_command}}+ + +function {{funcname}} ( ) {{compound_command}}+ In the first syntax without the +function+ keyword, {{funcname}} cannot contain any special characters such as semicolons and quotation marks. In the second and third syntax, which cannot be used in the link:posix.html[POSIXly-correct mode], {{funcname}} is subjected to link:expand.html[the four expansions] when executed. When a function definition command is executed, a function whose name is {{funcname}} is defined with its body being {{compound_command}}. A function definition command cannot be directly link:redir.html[redirected]. Any redirections that follow a function definition are associated with {{compound_command}} rather than the whole function definition command. In +func() { cat; } >/dev/null+, for example, it is not +func() { cat; }+ but +{ cat; }+ that is redirected. The exit status of a function definition is zero if the function was defined without errors, and non-zero otherwise. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_readonly.txt0000644000175000017500000000133612154557026016033 0ustar magicantmagicant= Readonly built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Readonly built-in The dfn:[readonly built-in] makes variables and functions read-only. [[syntax]] == Syntax - +readonly [-pxX] [{{name}}[={{value}}]...]+ - +readonly -f[p] [{{name}}...]+ [[description]] == Description The readonly built-in is equivalent to the link:_typeset.html[typeset built-in] with the +-gr+ option. [[notes]] == Notes The readonly built-in is a link:builtin.html#types[special built-in]. The POSIX standard defines the +-p+ option only; other options cannot be used in the link:posix.html[POSIXly-correct mode]. The POSIX does not allow using the option together with operands. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/posix.html0000644000175000017500000001450112154557026015344 0ustar magicantmagicant POSIXly-correct mode

Yash behaves as defined in POSIX.1-2008, Shell & Utilities for the most part, but some functionalities disobey POSIX for usability. When full POSIX-conformance is needed, you can enable the POSIXly-correct mode to make yash obey POSIX as mush as possible.

If yash is started with the name “sh”, the POSIXly-correct mode is automatically enabled. The -o posixly-correct command-line option also enables the POSIXly-correct mode. After yash has been started, the POSIXly-correct mode can be enabled by executing the command string set -o posixly-correct.

When the POSIXly-correct mode is on, yash not only tries to obey the requirements by POSIX, but also treats as errors most conditions where the behavior is undefined or unspecified by POSIX. As a result, most yash-specific functionalities are disabled in the POSIXly-correct mode.

Below is the complete list of the behavioral differences between when yash is in the POSIXly-correct mode and when not. When the POSIXly-correct mode is enabled:

yash-2.35/doc/interact.txt0000644000175000017500000003020012154557026015660 0ustar magicantmagicant= Interactive mode :encoding: UTF-8 :lang: en //:title: Yash manual - Interactive mode :description: This page describes the interactive mode of the yash shell. The dfn:[interactive mode] is a mode of the shell intended for direct interaction with a user. If yash is in the interactive mode, it is called an dfn:[interactive shell]. Whether a shell runs in the interactive mode or not is determined in the link:invoke.html[invocation of the shell]. After the shell has started up, the interactive mode cannot be switched on or off. When the shell is interactive: - link:invoke.html#init[Initialization] scripts are executed during invocation. - The shell link:interact.html#mailcheck[checks for mail] and prints a command <> when it reads a command. Job status changes are also reported if link:job.html[job control] is active. link:lineedit.html[Line-editing] may be used depending on the capability of the terminal. - Commands executed are automatically registered in command <>. - If a command executed by the shell is killed by a signal other than SIGINT and SIGPIPE, the shell reports the fact to the standard error. - The filename token is subject to link:expand.html#glob[pathname expansion] in link:redir.html#file[file redirection]. - The standard input of an link:syntax.html#async[asynchronous command] is not automatically redirected to /dev/null (in the link:posix.html[POSIXly-correct mode] only). - The shell does not exit when it encounters a syntax or expansion error during command execution. (cf. link:exec.html#exit[Termination of the shell]) - The shell does not exit when it receives the SIGINT, SIGTERM, or SIGQUIT signal. - A signal handler can be changed by the link:_trap.html[trap built-in] even if the handler had been set to ``ignore'' when the shell was invoked. - The value of the link:params.html#sp-hyphen[+-+ special parameter] contains +i+. - The shell's locale reflects the value of the link:params.html#sv-lc_ctype[+LC_CTYPE+ variable] whenever the value is changed (if the shell is not in the link:posix.html[POSIXly-correct mode]). - Commands are executed even when the link:_set.html#so-exec[exec option] is off. - The link:_set.html#so-ignoreeof[ignore-eof option] takes effect when enabled. - When the shell reaches the end of input or the link:_exit.html[exit built-in] is executed, the shell checks if there is any stopped link:job.html[job]. If so, the shell prints a warning and does not actually exit. - The link:_suspend.html[suspend built-in] by default cannot stop the shell if it is a session leader. - The shell does not exit when the link:_dot.html[dot built-in] fails to find a script file to read. - The shell does not exit when the link:_exec.html[exec built-in] fails to execute a command (if not in the link:posix.html[POSIXly-correct mode]). - When a job finished for which the link:_wait.html[wait built-in] has been waiting, the fact is reported (only if link:job.html[job control] is active and not in the link:posix.html[POSIXly-correct mode]). - A prompt is printed when the link:_read.html[read built-in] reads a second or following line. [[prompt]] == Prompts The interactive shell prints a dfn:[prompt] just before it reads a command. The contents of the prompt is specified by the value of the link:params.html#sv-ps1[+PS1+] and link:params.html#sv-ps2[+PS2+] variables. The former is used for reading the first line of the command and the latter for other lines. When the prompt is printed, the variable value is subjected to link:expand.html#params[parameter expansion], link:expand.html#cmdsub[command substitution], and link:expand.html#arith[arithmetic expansion] (but note that the POSIX standard requires parameter expansion only). The result of the expansion is parsed by the rules below to make the actual prompt string, which is printed to the standard error. In the link:posix.html[POSIXly-correct mode], each exclamation mark (+!+) in the string is substituted with the command <> number of the command that is being input. Two adjacent exclamation marks (+!!+) are printed as a single exclamation. Other characters are printed intact. If the shell is not in the POSIXly-command mode, the following notations can be used to format the prompt string. Notations are replaced with the strings designated in the list below. Characters that are not interpreted as notations are printed intact. +\a+:: Bell character (ASCII code: 7) +\e+:: Escape character (ASCII code: 27) +\j+:: The number of link:job.html[jobs] in the shell. +\n+:: Newline character (ASCII code: 10) +\r+:: Carriage return character (ASCII code: 13) +\!+:: The command <> number of the command that is being input +\$+:: +#+ if the shell's effective user ID is 0; +$+ otherwise. +\\+:: Backslash +\[+:: +\]+:: These two notations can surround part of the prompt string that is not visible on the terminal. The surrounded part is ignored when the shell counts the number of characters that is displayed on the terminal, thus making characters correctly aligned on the terminal when the prompt string contains special invisible characters. +\f{{fontspecs}}.+:: When link:lineedit.html[line-editing] is active, this notation is replaced with special characters to change font styles on the terminal if the terminal is capable of it. If line-editing is inactive or the terminal is incapable of changing font styles, this notation is silently ignored. One or more of the following can be used for {{fontspecs}}: + -- +k+:: Change font color to black +r+:: Change font color to red +g+:: Change font color to green +y+:: Change font color to yellow +b+:: Change font color to blue +m+:: Change font color to magenta +c+:: Change font color to cyan +w+:: Change font color to white +K+:: Change background color to black +R+:: Change background color to red +G+:: Change background color to green +Y+:: Change background color to yellow +B+:: Change background color to blue +M+:: Change background color to magenta +C+:: Change background color to cyan +W+:: Change background color to white +t+:: Make font color or background brighter (can only be used just after one of the characters above) +d+:: Change font and background colors to normal +s+:: Make font standout +u+:: Make font underlined +v+:: Make font and background colors reversed +b+:: Make font blink +i+:: Make font dim +o+:: Make font bold +x+:: Make font invisible +D+:: Make color and style normal -- + The actual colors of font and background are defined by the terminal. Different terminals may use different colors. In addition to the normal prompt, a prompt string can be displayed to the right of the cursor if link:lineedit.html[line-editing] is active. Those prompts are called dfn:[right prompts]. The contents of right prompts are defined by the value of the link:params.html#sv-ps1r[+PS1R+] and link:params.html#sv-ps2r[+PS2R+] variables, each corresponding to the link:params.html#sv-ps1[+PS1+] and link:params.html#sv-ps2[+PS2+] variables. Using the above-said notations, the font style of command strings the user inputs can be changed as well as that of prompts. The font style of command strings is defined by the value of the link:params.html#sv-ps1s[+PS1S+] and link:params.html#sv-ps2s[+PS2S+] variables, each corresponding to the link:params.html#sv-ps1[+PS1+] and link:params.html#sv-ps2[+PS2+] variables. The value can contain the +\f{{fontspecs}}.+ notation only. When the shell is not in the link:posix.html[POSIXly-correct mode], the value of the link:params.html#sv-prompt_command[+PROMPT_COMMAND+ variable] is executed before each prompt. [[history]] == Command history dfn:[Command history] is a feature of the shell that remembers executed commands to allow re-executing them later. Commands executed in the interactive mode are automatically saved in the command history. Saved commands can be edited and re-executed using link:lineedit.html[line-editing] and the link:_fc.html[fc] and link:_history.html[history] built-ins. Commands are saved line by line. Lines that do not contain any non-whitespace characters are not saved in the history. Lines that start with whitespaces are not saved when the link:_set.html#so-histspace[hist-space option] is on. Command history is saved in a file. When history is first used after an interactive shell was started, the shell opens a file to save history in. The filename is specified by the value of the link:params.html#sv-histfile[+HISTFILE+ variable]. If the file contains history data when opened, the data is restored to the shell's history. The file contents are updated in real time as the user inputs commands into the shell. If the +HISTFILE+ variable is not set or the file cannot be opened successfully, history is not saved in the file, but the history feature will be functional in all other respects. The number of commands saved in history is specified by the value of the link:params.html#sv-histsize[+HISTSIZE+ variable]. The shell automatically removes old history data so that the number of saved commands does not exceed the value. If the +HISTSIZE+ variable is not set or its value is not a natural number, 500 items will be saved in history. The shell looks at the value of the +HISTFILE+ and +HISTSIZE+ variables only when the history feature is first used after the shell was started. ``The history feature is used'' when: - the link:_fc.html[fc] or link:_history.html[history] built-in is executed, - link:lineedit.html[line-editing] is used (regardless of whether or not history data is recalled in line-editing), or - a command is input to the shell Therefore, the variables should be set in link:invoke.html#init[initialization] scripts. When more than one instance of yash shares a single history file, all the shells use the same history data. As a result, commands that have been executed by a shell instance can be recalled on another shell instance. Shells sharing the same history should have the same +HISTSIZE+ value so that they manipulate history data properly. Yash's history data file has its own format that is incompatible with other kinds of shells. The link:params.html#sv-histrmdup[+HISTRMDUP+ variable] can be set to remove duplicate history items. [[mailcheck]] == Mail checking An interactive shell can notify receipt of email. The shell periodically checks the modification date/time of a file specified by the user. If the file has been modified since the previous check, the shell prints a notification message (except when the shell is not in the link:posix.html[POSIXly-correct mode] and the file is empty). By specifying a mailbox file to be checked, the shell will print a message when the file has been modified, that is, some mail has been received. Check is done just before the shell prints a command line prompt. The interval of checks can be specified by the link:params.html#sv-mailcheck[+MAILCHECK+ variable] in seconds. If the variable value is 0, check is done before every prompt. If the variable value is not a non-negative integer, no checks are done. The file whose modification time is checked is specified by the link:params.html#sv-mail[+MAIL+ variable]. The variable value should be set to the pathname of the file. If you want to check more than one file or customize the notification message, you can set the link:params.html#sv-mailpath[+MAILPATH+ variable] instead of the +MAIL+ variable. When the +MAILPATH+ variable is set, the +MAIL+ variable is ignored. The value of the +MAILPATH+ variable should be set to one or more colon-separated pathnames of files to be checked. Each pathname can be followed by a percent sign (+%+) and a custom notification message, which is printed when the corresponding file has been modified. If the pathname contains a percent sign, it should be link:syntax.html#quotes[quoted] by a backslash. The specified message is subject to link:expand.html#params[parameter expansion]. For example, if the value of the +MAILPATH+ variable is `/foo/mail%New mail!:/bar/mailbox%You've got mail:/baz/mail\%data`, the shell will print - `New mail!` when the file /foo/mail has been modified - `You've got mail` when the file /bar/mailbox has been modified - the default message when the file /baz/mail%data has been modified. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_unset.txt0000644000175000017500000000245612154557026015360 0ustar magicantmagicant= Unset built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Unset built-in The dfn:[unset built-in] undefines variables or functions. [[syntax]] == Syntax - +unset [-fv] [{{name}}...]+ [[description]] == Description The unset built-in removes the definition of the link:params.html#variables[variables] or link:exec.html#function[functions] specified by operands. It is not an error if any of the specified variables or functions do not exist; they are silently ignored. [[options]] == Options +-f+:: +--functions+:: Undefine functions. +-v+:: +--variables+:: Undefine variables. These options are mutually exclusive: only the last specified one is effective. If neither is specified, +-v+ is assumed. [[operands]] == Operands {{name}}:: The name of a variable or function to be undefined. [[exitstatus]] == Exit status The exit status of the unset built-in is zero unless there is any error. [[notes]] == Notes The unset built-in is a link:builtin.html#types[special built-in]. Although yash does not do so, the POSIX standard allows removing a function if neither of the +-f+ and +-v+ options is specified and the specified variable does not exist. At least one {{name}} operand must be specified in the link:posix.html[POSIXly-correct mode]. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/redir.html0000644000175000017500000003375612154557026015324 0ustar magicantmagicant Redirection

Redirection is a feature you can use to modify file descriptors of commands. By using redirection, you can execute commands with their standard input/output connected with files or devices other than the terminal.

You can do redirection by adding redirection operators to a command (simple command or compound command) In a simple command, redirection operators may appear anywhere in the command as long as operator tokens are separated from other tokens. In a compound command, redirection operators must appear at the end of the command.

Redirection operators are processed before the command body is executed. More than one redirection operator in a command are processed in the order of appearance. Redirection operators affect only the command in which they appear, except when they appear in an exec built-in without command operands. That is, file descriptors modified by redirection are restored after the command has finished.

A redirection operator starts with < or >. Redirection operators starting with < affects the standard input (file descriptor 0) by default. Redirection operators starting with > affects the standard output (file descriptor 1) by default. To affect another file descriptor, you can prefix a redirection operator with a non-negative integer; the operator will affect the file descriptor specified by the integer. The integer must immediately precede the < or > without any whitespaces in between. The integer must not be quoted, either.

Redirection to files

The most common type of redirection is redirection to files.

Redirection of input

< token

Redirection of output

> token

>| token

>> token

Redirection of input and output

<> token

The token is subject to the four expansions. It is also subject to pathname expansion if the shell is interactive. The expansion result is treated as the pathname of the file to which redirection is performed. If the pathname expansion does not result in a single pathname, it is an error.

In redirection of input, the standard input is replaced with a file descriptor which is open for read-only access to the target file. If the target file cannot be opened for read-only access, it is an error.

In redirection of output, the standard output is replaced with a file descriptor which is open for write-only access to the target file. If the target file cannot be opened for write-only access, it is an error. If the target file does not exist, a new empty file is created and opened. If the target file already exists, the file is opened as follows:

  • For the >| operator, the file is emptied when opened if it is a regular file.

  • For the > operator, the behavior is the same as the >| operator if the clobber option is enabled. If the option is disabled and the file is a regular file, it is treated as an error.

  • For the >> operator, the file is opened for appending; any output to the file descriptor is appended to the end of the file.

In redirection of input and output, the standard input is replaced with a file descriptor which is open for read-and-write access to the target file. If the file does not exist, a new empty file is created and opened.

Socket redirection

If the pathname of the target file is of the form /dev/tcp/host/port or /dev/udp/host/port and the file cannot be opened in the usual manner, a new socket is opened for communication with the port of the host. The redirection replaces the standard input or output with the file descriptor to the socket.

A stream socket is opened for the form /dev/tcp/host/port and a datagram socket for the form /dev/udp/host/port. The protocol actually used for communication is determined by the socket library the shell uses. Typically, stream sockets use TCP and datagram sockets UDP.

In socket redirection, the file descriptor is both readable and writable regardless of the type of the redirection operator used.

Socket redirection is yash’s extension that is not defined in POSIX. Bash as well has socket redirection as extension.

Duplication of file descriptors

Redirection allows duplicating or closing existing file descriptors.

Duplication of file descriptor

<& token

>& token

The token is subject to expansion as in redirection to files, but it is treated as a file descriptor rather than a pathname. Thus the expanded token must be a non-negative integer.

The <& and >& operators duplicate the file descriptor specified by token to the standard input and output, respectively. (The operators can be prefixed with a non-negative integer so that the file descriptor is duplicated to a file descriptor other than the standard input or output.)

If the expanded token is a single hyphen rather than a non-negative integer, the file descriptor is closed rather than duplicated. By default, the <& and >& operators close the standard input and output, respectively, but the operators can be prefixed with a non-negative integer so that another file descriptor is closed.

In the POSIXly-correct mode, a file descriptor must be readable when duplicated by the <& operator and writable when duplicated by the >& operator.

Here documents and here strings

Here document and here string allow redirection to file descriptors that reads strings directly specified in shell commands.

Here document

<< token

<<- token

Here string

<<< token

In a here document or here string, the standard input is replaced with a readable file descriptor. When the command reads from the file descriptor, it will read the contents of the here document/string, which is defined below.

When a here document operator (<< or <<-) appears in a command, the shell reads the contents of the here document starting from the next line. The contents of here documents are not parsed nor executed as commands. The token after the operand specifies a delimiter that indicates the end of the contents. (The token is not subject to any expansion, but quotation is processed.) The contents of the here document is terminated just before the first line containing the token only. When using the <<- operator, all tab characters at the beginning of each line in the here document contents are removed and the delimiter token may be preceded by tab characters.

If there are more than one here document operator on one line, the contents of the here documents are parsed in order: The contents of the first here document starts from the next line and ends before the first line containing the token that followed the first operator. Just after that line, the contents of the second here document starts, and so on.

The contents of here documents are treated literally: whitespaces, tabs, etc. remain as is. The exception is that, when the token is not quoted at all:

In here string, the token after the operator is subject to expansion as in redirection to files. The expansion result becomes the contents of the here string. A newline character is automatically appended to the end of here string contents.

Here string is yash’s extension that is not defined in POSIX. Other shells like bash, ksh, and zsh have the same feature.

Pipeline redirection

Pipeline redirection allows opening pipelines that can be used for arbitrary purposes.

Pipeline redirection

>>| token

The token is subject to expansion as in redirection to files, but it is treated as a file descriptor rather than a pathname. Thus the expanded token must be a non-negative integer.

Pipeline redirection opens a new pipeline. The standard output (or the file descriptor specified before the operator, if any) is replaced with the file descriptor open for writing to the pipeline. The file descriptor specified by token is replaced with the file descriptor open for reading from the pipeline.

Pipeline redirection is yash’s extension that is not defined in POSIX.

Process redirection

Process redirection creates a pipeline connected to another command.

Process redirection

<(command…)

>(command…)

In process redirection, the command specified is executed in a subshell. If the process redirection is of the form <(command…), the standard output of command is connected with a pipeline to the standard input of the command the redirection is associated with. If the process redirection is of the form >(command…), the standard input of command is connected with a pipeline to the standard output of the command the redirection is associated with.

Process redirection is yash’s extension that is not defined in POSIX. Bash and zsh have a feature called process substitution, which uses the same syntax as yash’s process redirection, but incompatibly differs in behavior.

yash-2.35/doc/_break.html0000644000175000017500000000632512154557026015432 0ustar magicantmagicant Break built-in

The break built-in aborts a loop being executed.

Syntax

  • break [nest]

  • break -i

Description

When executed without the -i (--iteration) option, the built-in aborts a currently executed for, while, or until loop. When executed in nested loops, it aborts the nestth innermost loop. The default nest is one. If the number of currently executed nested loops is less than nest, the built-in aborts the outermost loop.

When executed with the -i (--iteration) option, the built-in aborts the currently executed (innermost) iterative execution.

Options

-i
--iteration

Abort an iterative execution instead of a loop.

Operands

nest

The number of loops to abort, which must be a positive integer.

Exit status

The exit status of the break built-in is:

  • zero if a loop was successfully aborted.

  • that of the command that was executed just before the break built-in if an iterative execution was successfully aborted.

Notes

The break built-in is a special built-in.

The POSIX standard defines no options for the break built-in; the built-in accepts no options in the POSIXly-correct mode.

yash-2.35/doc/_cd.html0000644000175000017500000001300212154557026014722 0ustar magicantmagicant Cd built-in

The cd built-in changes the working directory.

Syntax

  • cd [-L|-P] [directory]

Description

The cd built-in changes the working directory to the directory specified by the operand. The pathname of the new working directory is assigned to the PWD variable, whose previous value is again assigned to the OLDPWD variable.

If directory is a relative path that does not start with ‘.’ or ‘..’, paths in the CDPATH variable are searched to find a new working directory. The search is done in a manner similar to the last step of command search, but a directory is sought instead of an executable regular file. If a new working directory was found from CDPATH, its pathname is printed to the standard output. If no applicable directory was found in the search, directory is simply treated as a pathname relative to the current working directory.

If the working directory was successfully changed, the value of the YASH_AFTER_CD variable is executed as a command unless the shell is in the POSIXly-correct mode. If the variable is an array, its values are executed iteratively (cf. eval built-in).

Options

-L
--logical

Symbolic links in the pathname of the new working directory are not resolved. The new value of the PWD may include pathname components that are symbolic links.

-P
--physical

Symbolic links in the pathname of the new working directory are resolved. The new value of the PWD variable never includes pathname components that are symbolic links.

--default-directory=directory

If this option is specified and the directory operand is omitted, the argument to this option is used for the directory operand. If the directory operand is specified, this option is ignored.

The -L (--logical) and -P (--physical) options are mutually exclusive: only the last specified one is effective. If neither is specified, -L is assumed.

Operands

directory

The pathname of the new working directory.

If directory is a single hyphen (‘-’), the value of the OLDPWD variable is assumed for the new directory pathname, which is printed to the standard output.

If directory is omitted, the working directory is changed to the directory specified by the --default-directory=… option. If that option is not specified either, the default is the home directory.

Exit status

The exit status of the cd built-in is zero if the working directory was successfully changed and non-zero if there was an error.

Notes

The cd built-in is a semi-special built-in.

The POSIX standard does not define the use of the YASH_AFTER_CD variable or the --default-directory=… option. The standard does not allow using an option with a single hyphen operand.

The exit status of the commands in the YASH_AFTER_CD variable does not affect that of the cd built-in.

yash-2.35/doc/_times.html0000644000175000017500000000360712154557026015467 0ustar magicantmagicant Times built-in

The times built-in prints CPU time usage.

Syntax

  • times

Description

The times built-in prints the CPU times consumed by the shell process and its child processes to the standard output.

The built-in prints two lines: the first line shows the CPU time of the shell process and the second one that of its child processes (not including those which have not terminated). Each line shows the CPU times consumed in the user and system mode.

Exit status

The exit status of the times built-in is zero unless there is any error.

Notes

The times built-in is a special built-in.

yash-2.35/doc/_colon.txt0000644000175000017500000000133012154557026015322 0ustar magicantmagicant= Colon built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Colon built-in The dfn:[colon built-in] does nothing. [[syntax]] == Syntax - +: [{{argument}}...]+ [[description]] == Description The colon built-in does nothing. Any command line arguments are ignored. [[exitstatus]] == Exit status The exit status of the colon built-in is zero. [[notes]] == Notes The colon built-in is a link:builtin.html#types[special built-in]. Arguments are link:expand.html[expanded] and link:redir.html[redirections] are performed as usual. The colon and link:_true.html[true] built-ins have the same effect, but colon is a special built-in while true is a semi-special. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_complete.txt0000644000175000017500000001110412154557026016020 0ustar magicantmagicant= Complete built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Complete built-in The dfn:[complete built-in] generates completion candidates. This built-in can only be executed from completion functions during link:lineedit.html#completion[command line completion]. [[syntax]] == Syntax - +complete [-A {{pattern}}] [-R {{pattern}}] [-T] [-P {{prefix}}] [-S {{suffix}}] [-abcdfghjkuv] [[-O] [-D {{description}}] {{word}}...]+ [[description]] == Description The built-in generates completion candidates according to the specified arguments. No matter how candidates are generated, only candidates that match the word being completed are generated. [[options]] == Options +-A {{pattern}}+:: +--accept={{pattern}}+:: Only accept candidates that match the link:pattern.html[pattern] specified by this option. When more than one of this option is specified, only candidates that match all of the patterns are generated. +-D {{description}}+:: +--description={{description}}+:: Give a description of the {{word}} candidates. The description is shown beside the candidates in the candidate list. +-O+:: +--option+:: The candidates are treated as command line options. A hyphen is prepended to each candidate that is treated as an option. +-P {{prefix}}+:: +--prefix={{prefix}}+:: Ignore {{prefix}} of the word being completed when generating candidates. The specified {{prefix}} must be initial part of the word. + If the word being completed is `file:///home/user/docume` for example, the command line `complete -P file:// -f` will generate pathname candidates that complete `/home/user/docume`. +-R {{pattern}}+:: +--reject={{pattern}}+:: Reject candidates that match the link:pattern.html[pattern] specified by this option. When more than one of this option is specified, only candidates that match none of the patterns are generated. +-S {{suffix}}+:: +--suffix={{suffix}}+:: Append {{suffix}} to each generated candidate. +-T+:: +--no-termination+:: Do not append a space after the word is completed. Without this option, a space is appended to the completed word so that you do not have to enter a space before the next word. === Options that select candidate types +-a+:: +--alias+:: link:syntax.html#aliases[Aliases]. (same as +--normal-alias --global-alias+) +--array-variable+:: link:params.html#arrays[Arrays]. +--bindkey+:: link:lineedit.html#commands[Line-editing commands] the link:_bindkey.html[+bindkey+ built-in] accepts. +-b+:: +--builtin-command+:: link:builtin.html[Built-in commands]. (same as +--special-builtin --semi-special-builtin --regular-builtin+) +-c+:: +--command+:: Commands. (same as +--builtin-command --external-command --function+) +-d+:: +--directory+:: Directories. +--dirstack-index+:: Valid indices of the link:_dirs.html[directory stack]. +--executable-file+:: Executable regular files. +--external-command+:: External commands. +-f+:: +--file+:: Files (including directories). +--finished-job+:: link:job.html#jobid[Job IDs] of finished jobs. +--function+:: link:exec.html#function[Functions]. +--global-alias+:: Global link:syntax.html#aliases[aliases]. +-g+:: +--group+:: User groups. +-h+:: +--hostname+:: Host names. +-j+:: +--job+:: link:job.html#jobid[Job IDs]. +-k+:: +--keyword+:: link:syntax.html#tokens[Keywords]. +--normal-alias+:: Normal link:syntax.html#aliases[aliases]. +--regular-builtin+:: link:builtin.html#types[Regular built-in commands]. +--running-job+:: link:job.html#jobid[Job IDs] of jobs that are being executed. +--scalar-variable+:: link:params.html#variables[Variables] that are not arrays. +--semi-special-builtin+:: link:builtin.html#types[Semi-special built-in commands]. +--signal+:: Signals. +--special-builtin+:: link:builtin.html#types[Special built-in commands]. +--stopped-job+:: link:job.html#jobid[Job IDs] of jobs that are suspended. +-u+:: +--username+:: Users' log-in names. +-v+:: +--variable+:: link:params.html#variables[Variables]. If the +-d+ (+--directory+) option is specified without the +-f+ (+--file+) option, the +-S / -T+ options are assumed. Generated candidates for link:job.html#jobid[job IDs] do not have leading percent signs (+%+). If the word being completed starts with a percent sign, the +-P %+ option should be specified. [[operands]] == Operands Operands are treated as completion candidates. [[exitstatus]] == Exit status The exit status of the built-in is zero if one or more candidates were generated, one if no candidates were generated, or larger than one if an error occurred. [[notes]] == Notes The complete built-in is not defined in the POSIX standard. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_true.html0000644000175000017500000000332112154557026015316 0ustar magicantmagicant True built-in

The true built-in does nothing successfully.

Syntax

  • true

Description

The true built-in does nothing. Any command line arguments are ignored.

Exit status

The exit status of the true built-in is zero.

Notes

The true built-in is a semi-special built-in.

The true and colon built-ins have the same effect, but true is a semi-special built-in while colon is a special.

yash-2.35/doc/Makefile.in0000644000175000017500000001277712154557026015376 0ustar magicantmagicant# Makefile.in for the documentation of yash # (C) 2007-2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # NOTE: In this Makefile it is assumed that the make implementation allows the # use of hyphens in target names. This means that there may be a strictly # POSIX-conforming implementation of make that rejects this Makefile. I have # never seen such an implementation but if you know of one please let me know. .POSIX: .SUFFIXES: .txt .1 .xml .html @MAKE_SHELL@ topdir = .. subdir = doc recdirs = ja ASCIIDOC = @ASCIIDOC@ ASCIIDOCFLAGS = @ASCIIDOCFLAGS@ ASCIIDOCATTRS = @ASCIIDOCATTRS@ A2X = @A2X@ A2XFLAGS = @A2XFLAGS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_DIR = @INSTALL_DIR@ VERSION = @VERSION@ MANTXT = yash.txt INDEXTXT = index.txt # MAINTXTS must be in the contents order MAINTXTS = intro.txt invoke.txt syntax.txt params.txt expand.txt pattern.txt redir.txt exec.txt interact.txt job.txt builtin.txt lineedit.txt posix.txt fgrammar.txt # BUILTINTXTS must be in the alphabetic order BUILTINTXTS = _alias.txt _array.txt _bg.txt _bindkey.txt _break.txt _cd.txt _colon.txt _command.txt _complete.txt _continue.txt _dirs.txt _disown.txt _dot.txt _echo.txt _eval.txt _exec.txt _exit.txt _export.txt _false.txt _fc.txt _fg.txt _getopts.txt _hash.txt _help.txt _history.txt _jobs.txt _kill.txt _popd.txt _printf.txt _pushd.txt _pwd.txt _read.txt _readonly.txt _return.txt _set.txt _shift.txt _suspend.txt _test.txt _times.txt _trap.txt _true.txt _type.txt _typeset.txt _ulimit.txt _umask.txt _unalias.txt _unset.txt _wait.txt # CONTENTSTXTS must be in the contents order CONTENTSTXTS = $(MAINTXTS) $(BUILTINTXTS) TXTS = $(MANTXT) $(INDEXTXT) $(CONTENTSTXTS) MANFILE = $(MANTXT:.txt=.1) INDEXHTML = $(INDEXTXT:.txt=.html) HTMLFILES = $(INDEXHTML) $(CONTENTSTXTS:.txt=.html) HTMLAUXFILES = asciidoc.css TARGETS = $(MANFILE) $(HTMLFILES) CONFFILE = asciidoc.conf DESTDIR = prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ datarootdir = @datarootdir@ datadir = @datadir@ yashdatadir = $(datadir)/$(TARGET) localedir = @localedir@ mandir = @mandir@ man1dir = $(mandir)/man1 docdir = @docdir@ htmldir = @htmldir@ default-rec: default all-rec: all man-rec: man html-rec: html default: man html all: $(TARGETS) man: $(MANFILE) html: $(HTMLFILES) .txt.1: $(A2X) -d manpage -f manpage -L $(A2XFLAGS) $(ASCIIDOCATTRS) $< .txt.html: $(ASCIIDOC) -b html -d article $(ASCIIDOCFLAGS) $(ASCIIDOCATTRS) $< $(MANTXT): makeyash.sh $(MANTXT).in $(SHELL) makeyash.sh $(CONTENTSTXTS) <$@.in >$@ $(INDEXTXT): makeindex.sh $(INDEXTXT).in $(MAINTXTS) $(SHELL) makeindex.sh $(MAINTXTS) <$@.in >$@ $(MANFILE): $(MANTXT) $(CONTENTSTXTS) $(CONFFILE) $(HTMLFILES): $(CONFFILE) # update date in index.html when any contents file has been modified $(INDEXHTML): $(CONTENTSTXTS) install-rec: install install-data-rec: install-data install-html-rec: install-html installdirs-rec: installdirs installdirs-data-rec: installdirs-data installdirs-html-rec: installdirs-html uninstall-rec: uninstall uninstall-data-rec: uninstall-data INSTALLDIRS = $(DESTDIR)$(man1dir) $(DESTDIR)$(htmldir) install: install-data install-data: man installdirs-data $(INSTALL_DATA) $(MANFILE) $(DESTDIR)$(man1dir) install-html: html installdirs-html $(INSTALL_DATA) $(HTMLFILES) $(HTMLAUXFILES) $(DESTDIR)$(htmldir) installdirs: installdirs-data installdirs-data: $(DESTDIR)$(man1dir) installdirs-html: $(DESTDIR)$(htmldir) $(INSTALLDIRS): $(INSTALL_DIR) $@ uninstall: uninstall-data uninstall-data: rm -f $(DESTDIR)$(man1dir)/$(MANFILE) (if cd $(DESTDIR)$(htmldir); then rm -f $(HTMLFILES) $(HTMLAUXFILES); fi) -rmdir $(DESTDIR)$(htmldir) DISTFILES = $(TARGETS) $(HTMLAUXFILES) $(TXTS) $(MANTXT).in $(INDEXTXT).in makeyash.sh makeindex.sh Makefile.in $(CONFFILE) distfiles: $(DISTFILES) copy-distfiles: distfiles mkdir -p $(topdir)/$(DISTTARGETDIR) cp $(DISTFILES) $(topdir)/$(DISTTARGETDIR) mostlyclean: _mostlyclean _mostlyclean: clean: _clean _clean: _mostlyclean distclean: _distclean _distclean: _clean rm -fr Makefile maintainer-clean: _maintainer-clean _maintainer-clean: _distclean rm -fr $(TARGETS) $(MANTXT) $(INDEXTXT) Makefile: Makefile.in $(topdir)/config.status @+(cd $(topdir) && $(MAKE) config.status) @(cd $(topdir) && $(SHELL) config.status $(subdir)/$@) default-rec all-rec man-rec html-rec install-rec install-data-rec install-html-rec installdirs-rec installdirs-data-rec installdirs-html-rec uninstall-rec uninstall-data-rec mostlyclean clean distclean maintainer-clean: @+for dir in $(recdirs); do (cd $$dir && $(MAKE) $@) done .PHONY: default-rec all-rec man-rec html-rec default all man html install-rec install-data-rec install-html-rec installdirs-rec installdirs-data-rec installdirs-html-rec uninstall-rec uninstall-data-rec install install-data install-html installdirs installdirs-data installdirs-html uninstall uninstall-data distfiles copy-distfiles mostlyclean _mostlyclean clean _clean distclean _distclean maintainer-clean _maintainer-clean yash-2.35/doc/_array.txt0000644000175000017500000000432012154557026015330 0ustar magicantmagicant= Array built-in :encoding: UTF-8 :lang: en //:title: Yash manual - Array built-in The dfn:[array built-in] prints or modifies link:params.html#arrays[arrays]. [[syntax]] == Syntax - +array+ - +array {{name}} [{{value}}...]+ - +array -d {{name}} [{{index}}...]+ - +array -i {{name}} {{index}} [{{value}}...]+ - +array -s {{name}} {{index}} {{value}}+ [[description]] == Description When executed without any option or operands, the built-in prints all array definitions to the standard output in a form that can be parsed as commands. When executed with {{name}} and {{value}}s (but without an option), the built-in sets the {{value}}s as the values of the array named {{name}}. With the +-d+ (+--delete+) option, the built-in removes the {{index}}th values of the array named {{name}}. The number of values in the array will be decreased by the number of the {{index}}es specified. If the {{index}}th value does not exist, it is silently ignored. With the +-i+ (+--insert+) option, the built-in inserts {{value}}s into the array named {{name}}. The number of values in the array will be increased by the number of the {{value}}s specified. The values are inserted between the {{index}}th and next values. If {{index}} is zero, the values are inserted before the first value. If {{index}} is larger than the number of values in the array, the values are appended after the last element. With the +-s+ (+--set+) option, the built-in sets {{value}} as the {{index}}th value of the array named {{name}}. The array must have at least {{index}} values. [[options]] == Options +-d+:: +--delete+:: Delete array values. +-i+:: +--insert+:: Insert array values. +-s+:: +--set+:: Set an array value. [[operands]] == Operands {{name}}:: The name of an array to operate on. {{index}}:: The index to an array element. The first element has the index of 1. {{value}}:: A string to which the array element is set. [[exitstatus]] == Exit status The exit status of the array built-in is zero unless there is any error. [[notes]] == Notes The array built-in is not defined in the POSIX standard. The command +array {{name}} {{value}}...+ is equivalent to the assignment +{{name}}=({{value}}...)+. // vim: set filetype=asciidoc textwidth=78 expandtab: yash-2.35/doc/_exec.html0000644000175000017500000001247512154557026015275 0ustar magicantmagicant Exec built-in

The exec built-in replaces the shell process with another external command.

Syntax

  • exec [-cf] [-a name] [command [argument…]]

The exec built-in requires that all options precede operands. It is important so that options to the exec built-in are not confused with options to command. Any command line arguments after command are treated as arguments.

Description

When the exec built-in is executed with command, the shell executes command with arguments in a manner similar to the last step of execution of a simple command. The differences are that command is always treated as an external command ignoring any existing functions and built-ins and that the exec system call that starts the external command is called in the current command execution environment instead of a subshell, replacing the shell process with the new command process.

If the shell is in the POSIXly-correct mode or not interactive, failure in execution of command causes the shell to exit immediately.

If an interactive shell that is not in the POSIXly-correct mode has a stopped job, the shell prints a warning message and refuses to execute command. Once the shell process is replaced with an external command, information about the shell’s jobs is lost, so you will have to resume or kill the stopped jobs by sending signals by hand. To force the shell to execute command regardless, specify the -f (--force) option.

When executed without command, the built-in does nothing. As a side effect, however, redirection applied to the built-in remains in the current command execution environment even after the built-in finished.

Options

-a name
--as=name

Pass name, instead of command, to the external command as its name.

-c
--clear

Pass to the external command only variables that are assigned in the simple command in which the built-in is being executed. Other environment variables are not passed to the command.

-f
--force

Suppress warnings that would prevent command execution.

Operands

command

An external command to be executed.

argument

Arguments to be passed to the command.

Exit status

If the shell process was successfully replaced with the external command, there is no exit status since the shell process no longer exists.

The exit status is:

  • 127 if the command was not found,

  • 126 if the command was found but could not be executed, and

  • zero if no command was specified.

Notes

The exec built-in is a special built-in.

The POSIX standard defines no options for the exec built-in; the built-in accepts no options in the POSIXly-correct mode.

yash-2.35/doc/_help.html0000644000175000017500000000440312154557026015271 0ustar magicantmagicant Help built-in

The help built-in prints usage of built-ins.

Syntax

  • help [built-in…]

Description

The help built-in prints a description of built-ins.

The built-in extracts part of the output of man yash and prints it to the standard output. Therefore, the manual page of yash must have been installed for the built-in to work. Depending on the formatting style of the man command, the built-in may not work as expected.

Operands

built-ins

Names of built-ins.

Exit status

The exit status of the help built-in is zero unless there is any error.

Notes

The help built-in is not defined in the POSIX standard.

Many built-ins of yash accept the --help option that prints the same description.

yash-2.35/parser.c0000644000175000017500000027150712154557026014222 0ustar magicantmagicant/* Yash: yet another shell */ /* parser.c: syntax parser */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "parser.h" #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include #include #if YASH_ENABLE_ALIAS # include "alias.h" #endif #include "expand.h" #include "input.h" #include "option.h" #include "plist.h" #include "strbuf.h" #include "util.h" #if YASH_ENABLE_LINEEDIT # include "lineedit/lineedit.h" #endif /********** Functions That Free Parse Trees **********/ static void pipesfree(pipeline_T *p); static void ifcmdsfree(ifcommand_T *i); static void caseitemsfree(caseitem_T *i); static void wordfree_vp(void *w); static void assignsfree(assign_T *a); static void redirsfree(redir_T *r); static void embedcmdfree(embedcmd_T c); void andorsfree(and_or_T *a) { while (a != NULL) { pipesfree(a->ao_pipelines); and_or_T *next = a->next; free(a); a = next; } } void pipesfree(pipeline_T *p) { while (p != NULL) { comsfree(p->pl_commands); pipeline_T *next = p->next; free(p); p = next; } } void comsfree(command_T *c) { while (c != NULL) { c->refcount--; if (c->refcount > 0) break; redirsfree(c->c_redirs); switch (c->c_type) { case CT_SIMPLE: assignsfree(c->c_assigns); plfree(c->c_words, wordfree_vp); break; case CT_GROUP: case CT_SUBSHELL: andorsfree(c->c_subcmds); break; case CT_IF: ifcmdsfree(c->c_ifcmds); break; case CT_FOR: free(c->c_forname); plfree(c->c_forwords, wordfree_vp); andorsfree(c->c_forcmds); break; case CT_WHILE: andorsfree(c->c_whlcond); andorsfree(c->c_whlcmds); break; case CT_CASE: wordfree(c->c_casword); caseitemsfree(c->c_casitems); break; case CT_FUNCDEF: wordfree(c->c_funcname); comsfree(c->c_funcbody); break; } command_T *next = c->next; free(c); c = next; } } void ifcmdsfree(ifcommand_T *i) { while (i != NULL) { andorsfree(i->ic_condition); andorsfree(i->ic_commands); ifcommand_T *next = i->next; free(i); i = next; } } void caseitemsfree(caseitem_T *i) { while (i != NULL) { plfree(i->ci_patterns, wordfree_vp); andorsfree(i->ci_commands); caseitem_T *next = i->next; free(i); i = next; } } void wordfree(wordunit_T *w) { while (w != NULL) { switch (w->wu_type) { case WT_STRING: free(w->wu_string); break; case WT_PARAM: paramfree(w->wu_param); break; case WT_CMDSUB: embedcmdfree(w->wu_cmdsub); break; case WT_ARITH: wordfree(w->wu_arith); break; } wordunit_T *next = w->next; free(w); w = next; } } void wordfree_vp(void *w) { wordfree((wordunit_T *) w); } void paramfree(paramexp_T *p) { if (p != NULL) { if (p->pe_type & PT_NEST) wordfree(p->pe_nest); else free(p->pe_name); wordfree(p->pe_start); wordfree(p->pe_end); wordfree(p->pe_match); wordfree(p->pe_subst); free(p); } } void assignsfree(assign_T *a) { while (a != NULL) { free(a->a_name); switch (a->a_type) { case A_SCALAR: wordfree(a->a_scalar); break; case A_ARRAY: plfree(a->a_array, wordfree_vp); break; } assign_T *next = a->next; free(a); a = next; } } void redirsfree(redir_T *r) { while (r != NULL) { switch (r->rd_type) { case RT_INPUT: case RT_OUTPUT: case RT_CLOBBER: case RT_APPEND: case RT_INOUT: case RT_DUPIN: case RT_DUPOUT: case RT_PIPE: case RT_HERESTR: wordfree(r->rd_filename); break; case RT_HERE: case RT_HERERT: free(r->rd_hereend); wordfree(r->rd_herecontent); break; case RT_PROCIN: case RT_PROCOUT: embedcmdfree(r->rd_command); break; } redir_T *next = r->next; free(r); r = next; } } void embedcmdfree(embedcmd_T c) { if (c.is_preparsed) andorsfree(c.value.preparsed); else free(c.value.unparsed); } /********** Auxiliary Functions for Parser **********/ static wchar_t *skip_name(const wchar_t *s) __attribute__((pure,nonnull)); /* Checks if the specified character can be used in a portable variable name. * Returns true for a digit. */ bool is_portable_name_char(wchar_t c) { switch (c) { case L'0': case L'1': case L'2': case L'3': case L'4': case L'5': case L'6': case L'7': case L'8': case L'9': case L'a': case L'b': case L'c': case L'd': case L'e': case L'f': case L'g': case L'h': case L'i': case L'j': case L'k': case L'l': case L'm': case L'n': case L'o': case L'p': case L'q': case L'r': case L's': case L't': case L'u': case L'v': case L'w': case L'x': case L'y': case L'z': case L'A': case L'B': case L'C': case L'D': case L'E': case L'F': case L'G': case L'H': case L'I': case L'J': case L'K': case L'L': case L'M': case L'N': case L'O': case L'P': case L'Q': case L'R': case L'S': case L'T': case L'U': case L'V': case L'W': case L'X': case L'Y': case L'Z': case L'_': return true; default: return false; } } /* Checks if the specified character can be used in a variable name. * Returns true for a digit. */ bool is_name_char(wchar_t c) { return c == L'_' || iswalnum(c); } /* Skips an identifier at the head of the specified string and returns a * pointer to the character right after the identifier in the string. * If there is no identifier, the argument `s' is simply returned. */ wchar_t *skip_name(const wchar_t *s) { if (!iswdigit(*s)) while (is_name_char(*s)) s++; return (wchar_t *) s; } /* Returns true iff the specified string constitutes a valid identifier. */ bool is_name(const wchar_t *s) { return s[0] != L'\0' && skip_name(s)[0] == L'\0'; } /* Returns true iff the string is a reserved word. */ bool is_keyword(const wchar_t *s) { /* List of keywords: * case do done elif else esac fi for function if in then until while * { } ! * The following words are currently not keywords: * select [[ ]] */ switch (s[0]) { case L'c': return s[1] == L'a' && s[2] == L's' && s[3] == L'e' && s[4]== L'\0'; case L'd': return s[1] == L'o' && (s[2] == L'\0' || (s[2] == L'n' && s[3] == L'e' && s[4] == L'\0')); case L'e': return ((s[1] == L'l' && ((s[2] == L's' && s[3] == L'e') || (s[2] == L'i' && s[3] == L'f'))) || (s[1] == L's' && s[2] == L'a' && s[3] == L'c')) && s[4] == L'\0'; case L'f': return (s[1] == L'i' && s[2] == L'\0') || (s[1] == L'o' && s[2] == L'r' && s[3] == L'\0') || (s[1] == L'u' && s[2] == L'n' && s[3] == L'c' && s[4] == L't' && s[5] == L'i' && s[6] == L'o' && s[7] == L'n' && s[8] == L'\0'); case L'i': return (s[1] == L'f' || s[1] == L'n') && s[2] == L'\0'; case L't': return s[1] == L'h' && s[2] == L'e' && s[3] == L'n' && s[4]== L'\0'; case L'u': return s[1] == L'n' && s[2] == L't' && s[3] == L'i' && s[4] == L'l' && s[5] == L'\0'; case L'w': return s[1] == L'h' && s[2] == L'i' && s[3] == L'l' && s[4] == L'e' && s[5] == L'\0'; case L'{': case L'}': case L'!': return s[1] == L'\0'; default: return false; } } /********** Parser **********/ /* Holds data that are used in parsing. */ typedef struct parsestate_T { parseparam_T *info; bool error; struct xwcsbuf_T src; size_t index; struct plist_T pending_heredocs; #if YASH_ENABLE_ALIAS bool enable_alias, reparse; struct aliaslist_T *aliases; #endif } parsestate_T; /* info: contains parameter that affect the behavior of parsing. * error: set to true when an parsing error occurs. * src: a buffer that contains the source code to parse. * index: the index to the string in `src'. * indicates the character position that is being parsed. * pending_heredocs: a list of here-documents whose contents have not been read. * enable_alias: indicates if alias substitution should be performed. * reparse: indicates that the current word must be re-parsed because * alias substitution has been performed at the current position. * aliases: a list of alias substitutions that were performed at the current * position. */ typedef enum { AT_NONE, AT_GLOBAL, AT_ALL, } aliastype_T; static void serror(parsestate_T *restrict ps, const char *restrict format, ...) __attribute__((nonnull(1,2),format(printf,2,3))); static inputresult_T read_more_input(parsestate_T *ps) __attribute__((nonnull)); static void line_continuation(parsestate_T *ps, size_t index) __attribute__((nonnull)); static void ensure_buffer(parsestate_T *ps, size_t n) __attribute__((nonnull)); static size_t count_name_length(parsestate_T *ps, bool isnamechar(wchar_t c)) __attribute__((nonnull)); static void skip_blanks_and_comment(parsestate_T *ps) __attribute__((nonnull)); static bool skip_to_next_token(parsestate_T *ps) __attribute__((nonnull)); static void next_line(parsestate_T *ps) __attribute__((nonnull)); static bool is_command_delimiter_char(wchar_t c) __attribute__((const)); static bool is_comma_or_closing_bracket(wchar_t c) __attribute__((const)); static bool is_slash_or_closing_brace(wchar_t c) __attribute__((const)); static bool is_closing_brace(wchar_t c) __attribute__((const)); static bool has_token(const parsestate_T *ps, const wchar_t *t) __attribute__((pure,nonnull)); static const wchar_t *check_opening_token(parsestate_T *ps) __attribute__((nonnull)); static const wchar_t *check_closing_token(parsestate_T *ps) __attribute__((nonnull)); static and_or_T *parse_command_list(parsestate_T *ps, bool toeol) __attribute__((nonnull,malloc,warn_unused_result)); static and_or_T *parse_compound_list(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static and_or_T *parse_and_or_list(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static pipeline_T *parse_pipelines_in_and_or(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static pipeline_T *parse_pipeline(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_commands_in_pipeline(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_command(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static redir_T **parse_assignments_and_redirects(parsestate_T *ps, command_T *c) __attribute__((nonnull,malloc,warn_unused_result)); static void **parse_words_and_redirects( parsestate_T *ps, redir_T **redirlastp, bool first) __attribute__((nonnull,malloc,warn_unused_result)); static void parse_redirect_list(parsestate_T *ps, redir_T **lastp) __attribute__((nonnull)); static assign_T *tryparse_assignment(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static void **parse_words_to_paren(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static redir_T *tryparse_redirect(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static wordunit_T *parse_word(parsestate_T *ps, aliastype_T type) __attribute__((nonnull,malloc,warn_unused_result)); static wordunit_T *parse_word_to(parsestate_T *ps, bool testfunc(wchar_t c)) __attribute__((nonnull,malloc,warn_unused_result)); static void skip_to_next_single_quote(parsestate_T *ps) __attribute__((nonnull)); static wordunit_T *parse_special_word_unit(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static wordunit_T *tryparse_paramexp_raw(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static wordunit_T *parse_paramexp_in_brace(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static wordunit_T *parse_cmdsubst_in_paren(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static embedcmd_T extract_command_in_paren(parsestate_T *ps) __attribute__((nonnull,warn_unused_result)); #if YASH_ENABLE_ALIAS static wchar_t *extract_command_in_paren_unparsed(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); #endif static wordunit_T *parse_cmdsubst_in_backquote(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static wordunit_T *tryparse_arith(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static wchar_t *parse_word_as_wcs(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_compound_command( parsestate_T *ps, const wchar_t *command) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_group(parsestate_T *ps, commandtype_T type) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_if(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_for(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_while(parsestate_T *ps, bool whltype) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_case(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static caseitem_T *parse_case_list(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static void **parse_case_patterns(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *parse_function(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static command_T *tryparse_function(parsestate_T *ps) __attribute__((nonnull,malloc,warn_unused_result)); static void read_heredoc_contents(parsestate_T *ps, redir_T *redir) __attribute__((nonnull)); static void read_heredoc_contents_without_expansion( parsestate_T *ps, redir_T *r) __attribute__((nonnull)); static void read_heredoc_contents_with_expansion(parsestate_T *ps, redir_T *r) __attribute__((nonnull)); static bool is_end_of_heredoc_contents( parsestate_T *ps, const wchar_t *eoc, bool skiptab) __attribute__((nonnull)); static wordunit_T **parse_string_without_quotes( parsestate_T *ps, bool backquote, bool stoponnewline, wordunit_T **lastp) __attribute__((nonnull)); static const char *get_errmsg_unexpected_token(const wchar_t *t) __attribute__((nonnull)); static void print_errmsg_token_missing(parsestate_T *ps, const wchar_t *t) __attribute__((nonnull)); #define QUOTES L"\"'\\" /* The functions below may return non-NULL even on error. * The error condition must be tested by the `error' flag of the parsestate_T * structure. It is set to true when `serror' is called. */ /* Every function named `parse_*' advances the current position (the `index' * value of the parsestate_T structure) to the index of the first character * that has not yet been parsed. */ /* The main entry point to the parser. * This function reads at least one line of input and parses it. * All the members of `info' except `lastinputresult' must have been initialized * beforehand. * The resulting parse tree is assigned to `*resultp' if successful. If there is * no command in the next line or the shell was interrupted while reading input, * `*resultp' is assigned NULL. * Returns PR_OK if successful, * PR_SYNTAX_ERROR if a syntax error occurred, * PR_INPUT_ERROR if an input error occurred, or * PR_EOF if the input reached the end of file (EOF). * If PR_SYNTAX_ERROR or PR_INPUT_ERROR is returned, at least one error message * has been printed in this function. * Note that `*resultp' is assigned if and only if the return value is PR_OK. */ parseresult_T read_and_parse(parseparam_T *info, and_or_T **restrict resultp) { parsestate_T ps = { .info = info, .error = false, .index = 0, #if YASH_ENABLE_ALIAS .enable_alias = info->enable_alias, .reparse = false, .aliases = NULL, #endif }; if (ps.info->interactive) { struct input_interactive_info_T *intrinfo = ps.info->inputinfo; intrinfo->prompttype = 1; } ps.info->lastinputresult = INPUT_OK; wb_init(&ps.src); pl_init(&ps.pending_heredocs); and_or_T *r = parse_command_list(&ps, true); wb_destroy(&ps.src); pl_destroy(&ps.pending_heredocs); #if YASH_ENABLE_ALIAS destroy_aliaslist(ps.aliases); #endif switch (ps.info->lastinputresult) { case INPUT_OK: case INPUT_EOF: if (ps.error) { andorsfree(r); return PR_SYNTAX_ERROR; } else if (ps.src.length == 0) { andorsfree(r); return PR_EOF; } else { assert(ps.index == ps.src.length); *resultp = r; return PR_OK; } case INPUT_INTERRUPTED: andorsfree(r); *resultp = NULL; return PR_OK; case INPUT_ERROR: andorsfree(r); return PR_INPUT_ERROR; } assert(false); } /* Prints the specified error message to the standard error. * `format' is passed to `gettext' in this function. * `format' need not to have a trailing newline since a newline is automatically * appended in this function. * The `ps->error' flag is set to true in this function. */ void serror(parsestate_T *restrict ps, const char *restrict format, ...) { va_list ap; if (ps->info->print_errmsg && ps->info->lastinputresult != INPUT_INTERRUPTED) { if (ps->info->filename != NULL) fprintf(stderr, "%s:%lu: ", ps->info->filename, ps->info->lineno); fprintf(stderr, gt("syntax error: ")); va_start(ap, format); vfprintf(stderr, gt(format), ap); va_end(ap); fputc('\n', stderr); fflush(stderr); } ps->error = true; } /* Reads the next line of input and returns the result type, which is assigned * to `ps->info->lastinputresult'. * If `ps->info->lastinputresult' is not INPUT_OK, it is simply returned * without reading any input. * If input is from an interactive terminal and `ps->error' is true, no input * is read and INPUT_INTERRUPTED is returned. */ inputresult_T read_more_input(parsestate_T *ps) { if (ps->error && ps->info->interactive) return INPUT_INTERRUPTED; if (ps->info->lastinputresult == INPUT_OK) { size_t savelength = ps->src.length; ps->info->lastinputresult = ps->info->input(&ps->src, ps->info->inputinfo); if (ps->info->enable_verbose && shopt_verbose) #if YASH_ENABLE_LINEEDIT if (!(le_state & LE_STATE_ACTIVE)) #endif fprintf(stderr, "%ls", &ps->src.contents[savelength]); } return ps->info->lastinputresult; } /* Removes a line continuation at the specified index in `ps->src', increments * line number, and reads the next line. */ void line_continuation(parsestate_T *ps, size_t index) { assert(ps->src.contents[index] == L'\\' && ps->src.contents[index + 1] == L'\n'); wb_remove(&ps->src, index, 2); ps->info->lineno++; if (ps->src.contents[index] == L'\0') read_more_input(ps); } /* If a line continuation is found within `n' characters from the current * position `ps->index', removes the backslash-newline pair and reads the next * line. * If a backslash that is not a line continuation is found within `n' characters * from the current position, this function does nothing. */ /* For quickness, `n' should be as small as possible. */ void ensure_buffer(parsestate_T *ps, size_t n) { size_t index = ps->index; if (ps->src.contents[index] == L'\0') read_more_input(ps); while (index - ps->index < n) { switch (ps->src.contents[index]) { case L'\0': case L'\'': return; case L'\\': if (ps->src.contents[index + 1] != L'\n') return; line_continuation(ps, index); if (ps->info->lastinputresult != INPUT_OK) return; break; default: index++; break; } } } /* Returns the length of the name at the current position. * Whether a character can be part of the name is determined by `isnamechar'. * This function processes line continuations and reads so many lines that the * variable/alias name under the current position is fully available. */ size_t count_name_length(parsestate_T *ps, bool isnamechar(wchar_t c)) { size_t saveindex = ps->index; while (ensure_buffer(ps, 1), isnamechar(ps->src.contents[ps->index])) ps->index++; size_t result = ps->index - saveindex; ps->index = saveindex; return result; } /* Advances the current position `ps->index', skipping blank characters, * comments, and line continuations. * This function calls `read_more_input' if the current line has not been read * or when a line continuation is encountered. * The current position is advanced to the next non-blank character. * Line continuations are actually removed rather than skipped. */ /* Note that a newline is not a blank character. After a comment was skipped, * the position will be at the newline character (or EOF) that follows. */ void skip_blanks_and_comment(parsestate_T *ps) { if (ps->src.contents[ps->index] == L'\0') if (read_more_input(ps) != INPUT_OK) return; start: /* skip blanks */ while (iswblank(ps->src.contents[ps->index])) ps->index++; /* skip a comment */ if (ps->src.contents[ps->index] == L'#') { do { ps->index++; } while (ps->src.contents[ps->index] != L'\n' && ps->src.contents[ps->index] != L'\0'); } /* remove line continuation */ if (ps->src.contents[ps->index] == L'\\' && ps->src.contents[ps->index + 1] == L'\n') { line_continuation(ps, ps->index); goto start; } } /* Advances the current position `ps->index', skipping blank characters, * comments and newlines, up to the next token. * This function calls `read_more_input' if the next token cannot be found in * the current line. * Returns true iff at least one newline token is skipped. */ bool skip_to_next_token(parsestate_T *ps) { bool newline = false; skip_blanks_and_comment(ps); while (ps->info->lastinputresult == INPUT_OK && ps->src.contents[ps->index] == L'\n') { newline = true; next_line(ps); skip_blanks_and_comment(ps); } return newline; } /* Parses the newline token at the current position and proceeds to the next * line. The contents of pending here-documents are read if any. */ void next_line(parsestate_T *ps) { assert(ps->src.contents[ps->index] == L'\n'); ps->index++; ps->info->lineno++; for (size_t i = 0; i < ps->pending_heredocs.length; i++) read_heredoc_contents(ps, ps->pending_heredocs.contents[i]); pl_clear(&ps->pending_heredocs, 0); } /* Checks if the specified character is a token separator. */ bool is_token_delimiter_char(wchar_t c) { switch (c) { case L'\0': case L'\n': case L';': case L'&': case L'|': case L'<': case L'>': case L'(': case L')': return true; default: return iswblank(c); } } /* Checks if the specified character delimits a simple command. */ bool is_command_delimiter_char(wchar_t c) { switch (c) { case L'\0': case L'\n': case L';': case L'&': case L'|': case L'(': case L')': return true; default: return false; } } bool is_comma_or_closing_bracket(wchar_t c) { return c == L']' || c == L','; } bool is_slash_or_closing_brace(wchar_t c) { return c == L'/' || c == L'}'; } bool is_closing_brace(wchar_t c) { return c == L'}'; } /* Checks if token `t' exists at the current position in `ps->src'. * `t' must not be a proper substring of another operator token. (For example, * `t' cannot be L"&" because it is a proper substring of another operator token * L"&&". However, L"do" is OK for `t' even though it is a substring of the * keyword L"done", which is not an operator token.) * This function does not handle line continuations. The caller may need to call * `ensure_buffer(wcslen(t))' before calling this function. */ bool has_token(const parsestate_T *ps, const wchar_t *t) { const wchar_t *c = matchwcsprefix(&ps->src.contents[ps->index], t); return c != NULL && is_token_delimiter_char(*c); } /* Checks if there is an 'opening' token such as "(", "{", and "if" at the * current position. If there is one, the token string is returned. * Otherwise, NULL is returned. * This function calls `ensure_buffer(ps, 9)'. */ const wchar_t *check_opening_token(parsestate_T *ps) { ensure_buffer(ps, 9); if (ps->src.contents[ps->index] == L'(') return L"("; if (has_token(ps, L"{")) return L"{"; if (has_token(ps, L"if")) return L"if"; if (has_token(ps, L"for")) return L"for"; if (has_token(ps, L"while")) return L"while"; if (has_token(ps, L"until")) return L"until"; if (has_token(ps, L"case")) return L"case"; if (has_token(ps, L"function")) return L"function"; return NULL; } /* Checks if there is a 'closing' token such as ")", "}", and "fi" at the * current position. If there is one, the token string is returned. * Otherwise, NULL is returned. * This function calls `ensure_buffer(ps, 5)'. */ /* Closing tokens delimit and/or lists. */ const wchar_t *check_closing_token(parsestate_T *ps) { ensure_buffer(ps, 5); if (ps->src.contents[ps->index] == L')') return L")"; if (ps->src.contents[ps->index] == L';' && ps->src.contents[ps->index + 1] == L';') return L";;"; if (has_token(ps, L"}")) return L"}"; if (has_token(ps, L"then")) return L"then"; if (has_token(ps, L"else")) return L"else"; if (has_token(ps, L"elif")) return L"elif"; if (has_token(ps, L"fi")) return L"fi"; if (has_token(ps, L"do")) return L"do"; if (has_token(ps, L"done")) return L"done"; if (has_token(ps, L"esac")) return L"esac"; return NULL; } /* Parses commands. * If `toeol' is true, commands are parsed up to the end of the current input; * otherwise, up to the next closing token. * You don't have to call `skip_blanks_and_comment' beforehand. */ and_or_T *parse_command_list(parsestate_T *ps, bool toeol) { and_or_T *first = NULL, **lastp = &first; bool saveerror = ps->error; bool need_separator = false; /* For a command to be parsed after another, it must be separated by L"&", * L";", or newlines. */ if (!toeol && !ps->info->interactive) ps->error = false; while (!ps->error) { if (toeol) { skip_blanks_and_comment(ps); if (ps->src.contents[ps->index] == L'\n') { next_line(ps); need_separator = false; if (ps->src.contents[ps->index] != L'\0') continue; } if (ps->src.contents[ps->index] == L'\0') { break; } else if (ps->src.contents[ps->index] == L')') { serror(ps, get_errmsg_unexpected_token(L")"), L")"); break; } else if (need_separator) { serror(ps, Ngt("`;' or `&' is missing")); break; } } else { if (skip_to_next_token(ps)) need_separator = false; if (need_separator || ps->src.contents[ps->index] == L'\0' || check_closing_token(ps)) break; } and_or_T *ao = parse_and_or_list(ps); if (ao != NULL) { *lastp = ao; lastp = &ao->next; } #if YASH_ENABLE_ALIAS if (ps->reparse) { assert(ao == NULL); continue; } #endif need_separator = true; ensure_buffer(ps, 2); if (ps->src.contents[ps->index] == L'&' || (ps->src.contents[ps->index] == L';' && ps->src.contents[ps->index + 1] != L';')) { ps->index++; need_separator = false; } } if (!toeol) ps->error |= saveerror; #if YASH_ENABLE_ALIAS ps->reparse = false; #endif return first; } /* Parses commands until a closing token is found. * You don't have to call `skip_blanks_and_comment' beforehand. */ and_or_T *parse_compound_list(parsestate_T *ps) { return parse_command_list(ps, false); } /* Parses one and/or list. * The result reflects the trailing "&" or ";", but `ps->index' points to the * delimiter "&" or ";" when the function returns. * If the first word was alias-substituted, the `ps->reparse' flag is set and * NULL is returned. */ and_or_T *parse_and_or_list(parsestate_T *ps) { pipeline_T *p = parse_pipelines_in_and_or(ps); #if YASH_ENABLE_ALIAS if (ps->reparse) { assert(p == NULL); return NULL; } #endif and_or_T *result = xmalloc(sizeof *result); result->next = NULL; result->ao_pipelines = p; result->ao_async = (ps->src.contents[ps->index] == L'&'); return result; } /* Parses all pipelines in one and/or list. * If the first word was alias-substituted, the `ps->reparse' flag is set and * NULL is returned. */ pipeline_T *parse_pipelines_in_and_or(parsestate_T *ps) { pipeline_T *first = NULL, **lastp = &first; bool cond = false; for (;;) { pipeline_T *p = parse_pipeline(ps); if (p != NULL) { p->pl_cond = cond; *lastp = p; lastp = &p->next; } #if YASH_ENABLE_ALIAS if (ps->reparse) { assert(p == NULL); if (first != NULL) goto next; else break; } #endif ensure_buffer(ps, 2); if (ps->src.contents[ps->index] == L'&' && ps->src.contents[ps->index + 1] == L'&') { cond = true; } else if (ps->src.contents[ps->index] == L'|' && ps->src.contents[ps->index + 1] == L'|') { cond = false; } else { break; } ps->index += 2; #if YASH_ENABLE_ALIAS next: #endif skip_to_next_token(ps); } return first; } /* Parses one pipeline. * If the first word was alias-substituted, the `ps->reparse' flag is set and * NULL is returned. */ pipeline_T *parse_pipeline(parsestate_T *ps) { bool neg; command_T *c; ensure_buffer(ps, 2); if (has_token(ps, L"!")) { neg = true; ps->index += 1; #if YASH_ENABLE_ALIAS do { #endif skip_blanks_and_comment(ps); c = parse_commands_in_pipeline(ps); #if YASH_ENABLE_ALIAS if (ps->reparse) assert(c == NULL); } while (ps->reparse); #endif } else { neg = false; c = parse_commands_in_pipeline(ps); #if YASH_ENABLE_ALIAS if (ps->reparse) { assert(c == NULL); return NULL; } #endif } pipeline_T *result = xmalloc(sizeof *result); result->next = NULL; result->pl_commands = c; result->pl_neg = neg; result->pl_cond = false; return result; } /* Parses the body of the pipeline. * If the first word was alias-substituted, the `ps->reparse' flag is set and * NULL is returned. */ command_T *parse_commands_in_pipeline(parsestate_T *ps) { command_T *first = NULL, **lastp = &first; for (;;) { command_T *c = parse_command(ps); if (c != NULL) { *lastp = c; lastp = &c->next; } #if YASH_ENABLE_ALIAS if (ps->reparse) { assert(c == NULL); if (first != NULL) goto next; else break; } #endif ensure_buffer(ps, 2); if (ps->src.contents[ps->index] == L'|' && ps->src.contents[ps->index + 1] != L'|') { ps->index++; } else { break; } #if YASH_ENABLE_ALIAS next: #endif skip_to_next_token(ps); } return first; } /* Parses one command. * If the first word was alias-substituted, the `ps->reparse' flag is set and * NULL is returned. */ command_T *parse_command(parsestate_T *ps) { #if YASH_ENABLE_ALIAS ps->reparse = false; #endif /* Note: `check_closing_token' calls `ensure_buffer(ps, 5)'. */ const wchar_t *t = check_closing_token(ps); if (t != NULL) { serror(ps, get_errmsg_unexpected_token(t), t); return NULL; } else if (has_token(ps, L"!")) { serror(ps, get_errmsg_unexpected_token(L"!"), L"!"); return NULL; } else if (has_token(ps, L"in")) { serror(ps, get_errmsg_unexpected_token(L"in"), L"in"); return NULL; } else if (ps->src.contents[ps->index] == L'(') { return parse_compound_command(ps, L"("); } else if (is_command_delimiter_char(ps->src.contents[ps->index])) { if (ps->src.contents[ps->index] == L'\0' || ps->src.contents[ps->index] == L'\n') serror(ps, Ngt("a command is missing at the end of input")); else serror(ps, Ngt("a command is missing before `%lc'"), (wint_t) ps->src.contents[ps->index]); return NULL; } t = check_opening_token(ps); if (t != NULL) return parse_compound_command(ps, t); #if YASH_ENABLE_ALIAS if (ps->enable_alias && count_name_length(ps, is_alias_name_char) > 0) { substaliasflags_T flags = AF_NONGLOBAL | AF_NORECUR; if (substitute_alias(&ps->src, ps->index, &ps->aliases, flags)) { ps->reparse = true; return NULL; } } #endif command_T *result = tryparse_function(ps); if (result != NULL) return result; /* parse as a simple command */ redir_T **redirlastp; result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_lineno = ps->info->lineno; result->c_type = CT_SIMPLE; redirlastp = parse_assignments_and_redirects(ps, result); result->c_words = parse_words_and_redirects(ps, redirlastp, true); ensure_buffer(ps, 1); if (ps->src.contents[ps->index] == L'(') serror(ps, Ngt("invalid use of `%lc'"), (wint_t) L'('); return result; } /* Parses assignments and redirections. * Tokens but the first one are subject to any-type alias substitution, * including the word just after the parsed assignments and redirections. * The results are assigned to `c->c_assigns' and `c->c_redirs'. * The return value is a pointer to the `next' member of the last resultant * redirection (redir_T). If no redirections were parsed, the result value is a * pointer to `c->c_redirs'. */ redir_T **parse_assignments_and_redirects(parsestate_T *ps, command_T *c) { assign_T **assgnlastp = &c->c_assigns; redir_T **redirlastp = &c->c_redirs; assign_T *assgn; redir_T *redir; c->c_assigns = NULL; c->c_redirs = NULL; while (ensure_buffer(ps, 1), !is_command_delimiter_char(ps->src.contents[ps->index])) { if ((redir = tryparse_redirect(ps)) != NULL) { *redirlastp = redir; redirlastp = &redir->next; } else if ((assgn = tryparse_assignment(ps)) != NULL) { *assgnlastp = assgn; assgnlastp = &assgn->next; } else { break; } #if YASH_ENABLE_ALIAS if (ps->enable_alias && count_name_length(ps, is_alias_name_char) > 0) { substitute_alias( &ps->src, ps->index, &ps->aliases, AF_NONGLOBAL); skip_blanks_and_comment(ps); } #endif } return redirlastp; } /* Parses words and redirections. * The parsing result of redirections is assigned to `*redirlastp' * The parsing result of assignments is returned as an array of pointers to * word units that are cast to (void *). * `*redirlastp' must have been initialized to NULL beforehand. * All words are subject to global alias substitution. If `first' is true, * however, alias substitution is not performed on the first word. */ void **parse_words_and_redirects( parsestate_T *ps, redir_T **redirlastp, bool first) { plist_T wordlist; redir_T *redir; wordunit_T *word; assert(*redirlastp == NULL); pl_init(&wordlist); while (ensure_buffer(ps, 1), !is_command_delimiter_char(ps->src.contents[ps->index])) { #if YASH_ENABLE_ALIAS if (!first && ps->enable_alias) { if (count_name_length(ps, is_alias_name_char) > 0) { substitute_alias(&ps->src, ps->index, &ps->aliases, 0); skip_blanks_and_comment(ps); } } #else (void) first; #endif if ((redir = tryparse_redirect(ps)) != NULL) { *redirlastp = redir; redirlastp = &redir->next; } else if ((word = parse_word(ps, AT_NONE)) != NULL) { pl_add(&wordlist, word); skip_blanks_and_comment(ps); first = false; } else { break; } } return pl_toary(&wordlist); } /* Parses as many redirections as possible. * The parsing result is assigned to `*redirlastp' * `*redirlastp' must have been initialized to NULL beforehand. */ void parse_redirect_list(parsestate_T *ps, redir_T **lastp) { for (;;) { #if YASH_ENABLE_ALIAS if (!posixly_correct && ps->enable_alias) if (count_name_length(ps, is_alias_name_char) > 0) substitute_alias(&ps->src, ps->index, &ps->aliases, 0); #endif redir_T *redir = tryparse_redirect(ps); if (redir == NULL) break; *lastp = redir; lastp = &redir->next; } } /* If there is an assignment at the current position, parses and returns it. * Otherwise, returns NULL without moving the position. */ assign_T *tryparse_assignment(parsestate_T *ps) { if (iswdigit(ps->src.contents[ps->index])) return NULL; size_t namelen = count_name_length(ps, is_name_char); if (namelen == 0 || ps->src.contents[ps->index + namelen] != L'=') return NULL; assign_T *result = xmalloc(sizeof *result); result->next = NULL; result->a_name = xwcsndup(&ps->src.contents[ps->index], namelen); ps->index += namelen + 1; ensure_buffer(ps, 1); if (posixly_correct || ps->src.contents[ps->index] != L'(') { result->a_type = A_SCALAR; result->a_scalar = parse_word(ps, AT_NONE); } else { ps->index++; skip_to_next_token(ps); result->a_type = A_ARRAY; result->a_array = parse_words_to_paren(ps); if (ps->src.contents[ps->index] == L')') ps->index++; else serror(ps, Ngt("`%ls' is missing"), L")"); } skip_blanks_and_comment(ps); return result; } /* Parses words until the next closing parentheses. * Delimiter characters other than ')' and '\n' are not allowed. * Returns a newly malloced array of pointers to newly malloced `wordunit_T's.*/ void **parse_words_to_paren(parsestate_T *ps) { plist_T list; pl_init(&list); while (ps->src.contents[ps->index] != L')') { wordunit_T *word = parse_word(ps, AT_GLOBAL); if (word != NULL) pl_add(&list, word); else break; skip_to_next_token(ps); } return pl_toary(&list); } /* If there is a redirection at the current position, parses and returns it. * Otherwise, returns NULL without moving the position. */ redir_T *tryparse_redirect(parsestate_T *ps) { int fd; ensure_buffer(ps, 2); if (iswdigit(ps->src.contents[ps->index])) { unsigned long lfd; wchar_t *endptr; reparse: errno = 0; lfd = wcstoul(&ps->src.contents[ps->index], &endptr, 10); if (errno != 0 || lfd > INT_MAX) fd = -1; /* invalid fd */ else fd = (int) lfd; if (endptr[0] == L'\\' && endptr[1] == L'\n') { line_continuation(ps, endptr - ps->src.contents); goto reparse; } else if (endptr[0] != L'<' && endptr[0] != L'>') { return NULL; } ps->index = endptr - ps->src.contents; } else if (ps->src.contents[ps->index] == L'<') { fd = STDIN_FILENO; } else if (ps->src.contents[ps->index] == L'>') { fd = STDOUT_FILENO; } else { return NULL; } redir_T *result = xmalloc(sizeof *result); result->next = NULL; result->rd_fd = fd; ensure_buffer(ps, 3); switch (ps->src.contents[ps->index]) { case L'<': switch (ps->src.contents[ps->index + 1]) { case L'<': if (ps->src.contents[ps->index + 2] == L'-') { result->rd_type = RT_HERERT; ps->index += 3; } else if (!posixly_correct && ps->src.contents[ps->index + 2] == L'<') { result->rd_type = RT_HERESTR; ps->index += 3; } else { result->rd_type = RT_HERE; ps->index += 2; } break; case L'(': if (!posixly_correct) { result->rd_type = RT_PROCIN; goto parse_command; } else { result->rd_type = RT_INPUT; ps->index += 1; } break; case L'>': result->rd_type = RT_INOUT; ps->index += 2; break; case L'&': result->rd_type = RT_DUPIN; ps->index += 2; break; default: result->rd_type = RT_INPUT; ps->index += 1; break; } break; case L'>': switch (ps->src.contents[ps->index + 1]) { case L'(': if (!posixly_correct) { result->rd_type = RT_PROCOUT; goto parse_command; } else { result->rd_type = RT_OUTPUT; ps->index += 1; } break; case L'>': if (!posixly_correct && ps->src.contents[ps->index + 2] == L'|') { result->rd_type = RT_PIPE; ps->index += 3; } else { result->rd_type = RT_APPEND; ps->index += 2; } break; case L'|': result->rd_type = RT_CLOBBER; ps->index += 2; break; case L'&': result->rd_type = RT_DUPOUT; ps->index += 2; break; default: result->rd_type = RT_OUTPUT; ps->index += 1; break; } break; default: assert(false); } skip_blanks_and_comment(ps); if (result->rd_type != RT_HERE && result->rd_type != RT_HERERT) { result->rd_filename = parse_word(ps, AT_GLOBAL); if (result->rd_filename == NULL) { serror(ps, Ngt("the redirection target is missing")); free(result); return NULL; } } else { wchar_t *endofheredoc = parse_word_as_wcs(ps); if (endofheredoc[0] == L'\0') { serror(ps, Ngt("the end-of-here-document indicator is missing")); free(endofheredoc); free(result); return NULL; } result->rd_hereend = endofheredoc; result->rd_herecontent = NULL; pl_add(&ps->pending_heredocs, result); } skip_blanks_and_comment(ps); return result; parse_command: ps->index += 1; result->rd_command = extract_command_in_paren(ps); ensure_buffer(ps, 1); if (ps->src.contents[ps->index] == L')') ps->index++; skip_blanks_and_comment(ps); return result; } /* Expands an alias, if any, and parses a word at the current position. * `type' specifies the type of aliases to be expanded. */ wordunit_T *parse_word(parsestate_T *ps, aliastype_T type) { #if YASH_ENABLE_ALIAS if (ps->enable_alias) { switch (type) { case AT_NONE: break; case AT_GLOBAL: case AT_ALL: if (count_name_length(ps, is_alias_name_char) > 0) { substaliasflags_T flags = (type == AT_GLOBAL) ? 0 : AF_NONGLOBAL; substitute_alias(&ps->src, ps->index, &ps->aliases, flags); } skip_blanks_and_comment(ps); break; } } #else /* !YASH_ENABLE_ALIAS */ (void) type; #endif return parse_word_to(ps, is_token_delimiter_char); } /* Parses a word at the current position. * `testfunc' is a function that determines if a character is a word delimiter. * The parsing proceeds up to an unescaped character for which `testfunc' * returns false. * It is not an error if there is no characters to be a word, in which case * NULL is returned. */ wordunit_T *parse_word_to(parsestate_T *ps, bool testfunc(wchar_t c)) { wordunit_T *first = NULL, **lastp = &first; bool indq = false; /* in double quotes? */ size_t startindex = ps->index; /* appends the substring from `startindex' to `index' as a new word unit * to `*lastp' */ #define MAKE_WORDUNIT_STRING \ do { \ size_t len = ps->index - startindex; \ if (len > 0) { \ wordunit_T *w = xmalloc(sizeof *w); \ w->next = NULL; \ w->wu_type = WT_STRING; \ w->wu_string = xwcsndup(&ps->src.contents[startindex], len); \ *lastp = w; \ lastp = &w->next; \ } \ } while (0) while (ensure_buffer(ps, 1), indq || !testfunc(ps->src.contents[ps->index])) { switch (ps->src.contents[ps->index]) { case L'\0': goto done; // reached EOF case L'\\': if (ps->src.contents[ps->index + 1] != L'\0') { assert(ps->src.contents[ps->index + 1] != L'\n'); ps->index += 2; continue; } break; case L'\n': ps->info->lineno++; break; case L'$': case L'`': MAKE_WORDUNIT_STRING; wordunit_T *wu = parse_special_word_unit(ps); startindex = ps->index; if (wu != NULL) { *lastp = wu; lastp = &wu->next; continue; } else if (ps->src.contents[ps->index] == L'\0') { continue; } break; case L'\'': if (!indq) { ps->index++; skip_to_next_single_quote(ps); if (ps->src.contents[ps->index] == L'\'') ps->index++; continue; } break; case L'"': indq = !indq; /* falls thru! */ default: break; } ps->index++; } done: MAKE_WORDUNIT_STRING; if (indq) serror(ps, Ngt("the double quotation is not closed")); return first; } /* Skips to the next single quote. * If the current position is already at a single quote, the position is not * moved. * It is an error if there is no single quote before the end of file. */ void skip_to_next_single_quote(parsestate_T *ps) { for (;;) { switch (ps->src.contents[ps->index]) { case L'\'': return; case L'\0': if (read_more_input(ps) != INPUT_OK) { serror(ps, Ngt("the single quotation is not closed")); return; } continue; case L'\n': ps->info->lineno++; break; default: break; } ps->index++; } } /* Parses a parameter expansion or command substitution that starts with '$' or * '`'. The character at the current position must be '$' or '`' when this * function is called and the position is advanced to right after the expansion * or substitution. * If the character at the current position is '$' but it is not an expansion, * the position is not moved and the return value is NULL. Otherwise, The * position is advanced by at least one character. */ wordunit_T *parse_special_word_unit(parsestate_T *ps) { switch (ps->src.contents[ps->index++]) { case L'$': ensure_buffer(ps, 2); switch (ps->src.contents[ps->index]) { case L'{': return parse_paramexp_in_brace(ps); case L'(': if (ps->src.contents[ps->index + 1] == L'(') { wordunit_T *wu = tryparse_arith(ps); if (wu != NULL) return wu; } return parse_cmdsubst_in_paren(ps); default: return tryparse_paramexp_raw(ps); } case L'`': return parse_cmdsubst_in_backquote(ps); default: assert(false); } } /* Parses a parameter that is not enclosed by { }. * The current position must be at the first character of the parameter name * that follows L'$'. The position is advanced to right after the name. * If there is no parameter, the position is put back to L'$'. */ wordunit_T *tryparse_paramexp_raw(parsestate_T *ps) { paramexp_T *pe; size_t namelen; /* parameter name length */ ensure_buffer(ps, 1); switch (ps->src.contents[ps->index]) { case L'@': case L'*': case L'#': case L'?': case L'-': case L'$': case L'!': namelen = 1; goto success; } if (!is_portable_name_char(ps->src.contents[ps->index])) goto error; if (iswdigit(ps->src.contents[ps->index])) namelen = 1; else namelen = count_name_length(ps, is_portable_name_char); success: pe = xmalloc(sizeof *pe); pe->pe_type = PT_NONE; pe->pe_name = xwcsndup(&ps->src.contents[ps->index], namelen); pe->pe_start = pe->pe_end = pe->pe_match = pe->pe_subst = NULL; wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_PARAM; result->wu_param = pe; ps->index += namelen; return result; error: ps->index--; assert(ps->src.contents[ps->index] == L'$'); return NULL; } /* Parses a parameter expansion that starts with "${". * The current position must be at the opening brace L'{' when this function is * called and the position is advanced to the closing brace L'}'. */ wordunit_T *parse_paramexp_in_brace(parsestate_T *ps) { paramexp_T *pe = xmalloc(sizeof *pe); pe->pe_type = 0; pe->pe_name = NULL; pe->pe_start = pe->pe_end = pe->pe_match = pe->pe_subst = NULL; assert(ps->src.contents[ps->index] == L'{'); ps->index++; /* parse PT_NUMBER */ ensure_buffer(ps, 3); if (ps->src.contents[ps->index] == L'#') { switch (ps->src.contents[ps->index + 1]) { case L'\0': case L'}': case L'+': case L'=': case L':': case L'/': case L'%': break; case L'-': case L'?': case L'#': if (ps->src.contents[ps->index + 2] != L'}') break; /* falls thru! */ default: pe->pe_type |= PT_NUMBER; ps->index++; break; } } /* parse nested expansion */ // ensure_buffer(2); // we've already called `ensure_buffer' if (!posixly_correct && ps->src.contents[ps->index] == L'{') { pe->pe_type |= PT_NEST; pe->pe_nest = parse_paramexp_in_brace(ps); } else if (!posixly_correct && (ps->src.contents[ps->index] == L'`' || (ps->src.contents[ps->index] == L'$' && (ps->src.contents[ps->index + 1] == L'{' || ps->src.contents[ps->index + 1] == L'(')))) { size_t neststartindex = ps->index; pe->pe_nest = parse_special_word_unit(ps); if (ps->index != neststartindex) pe->pe_type |= PT_NEST; else goto parse_name; } else { parse_name:; /* no nesting: parse parameter name normally */ size_t namestartindex = ps->index; switch (ps->src.contents[ps->index]) { case L'@': case L'*': case L'#': case L'?': case L'-': case L'$': case L'!': ps->index++; break; default: while (ensure_buffer(ps, 1), is_name_char(ps->src.contents[ps->index])) ps->index++; break; } size_t namelen = ps->index - namestartindex; if (namelen == 0) { serror(ps, Ngt("the parameter name is missing or invalid")); goto end; } pe->pe_name = xwcsndup(&ps->src.contents[namestartindex], namelen); } /* parse indices */ ensure_buffer(ps, 3); if (!posixly_correct && ps->src.contents[ps->index] == L'[') { ps->index++; pe->pe_start = parse_word_to(ps, is_comma_or_closing_bracket); if (pe->pe_start == NULL) serror(ps, Ngt("the index is missing")); if (ps->src.contents[ps->index] == L',') { ps->index++; pe->pe_end = parse_word_to(ps, is_comma_or_closing_bracket); if (pe->pe_end == NULL) serror(ps, Ngt("the index is missing")); } if (ps->src.contents[ps->index] == L']') ps->index++; else serror(ps, Ngt("`%ls' is missing"), L"]"); ensure_buffer(ps, 3); } /* parse PT_COLON */ if (ps->src.contents[ps->index] == L':') { pe->pe_type |= PT_COLON; ps->index++; } /* parse '-', '+', '#', etc. */ switch (ps->src.contents[ps->index]) { case L'-': pe->pe_type |= PT_MINUS; goto parse_subst; case L'+': pe->pe_type |= PT_PLUS; goto parse_subst; case L'=': pe->pe_type |= PT_ASSIGN; goto parse_subst; case L'?': pe->pe_type |= PT_ERROR; goto parse_subst; case L'#': pe->pe_type |= PT_MATCH | PT_MATCHHEAD; goto parse_match; case L'%': pe->pe_type |= PT_MATCH | PT_MATCHTAIL; goto parse_match; case L'/': pe->pe_type |= PT_SUBST | PT_MATCHLONGEST; goto parse_match; case L'\0': case L'\n': case L'}': pe->pe_type |= PT_NONE; if (pe->pe_type & PT_COLON) serror(ps, Ngt("invalid use of `%lc' in parameter expansion"), (wint_t) L':'); goto check_closing_brace; default: serror(ps, Ngt("invalid character `%lc' in parameter expansion"), (wint_t) ps->src.contents[ps->index]); goto end; } parse_match: if (pe->pe_type & PT_COLON) { if ((pe->pe_type & PT_MASK) == PT_SUBST) pe->pe_type |= PT_MATCHHEAD | PT_MATCHTAIL; else serror(ps, Ngt("invalid use of `%lc' in parameter expansion"), (wint_t) L':'); ps->index += 1; } else if (ps->src.contents[ps->index] == ps->src.contents[ps->index + 1]) { if ((pe->pe_type & PT_MASK) == PT_MATCH) pe->pe_type |= PT_MATCHLONGEST; else pe->pe_type |= PT_SUBSTALL; ps->index += 2; } else if (ps->src.contents[ps->index] == L'/') { if (ps->src.contents[ps->index + 1] == L'#') { pe->pe_type |= PT_MATCHHEAD; ps->index += 2; } else if (ps->src.contents[ps->index + 1] == L'%') { pe->pe_type |= PT_MATCHTAIL; ps->index += 2; } else { ps->index += 1; } } else { ps->index += 1; } if ((pe->pe_type & PT_MASK) == PT_MATCH) { pe->pe_match = parse_word_to(ps, is_closing_brace); goto check_closing_brace; } else { pe->pe_match = parse_word_to(ps, is_slash_or_closing_brace); ensure_buffer(ps, 1); if (ps->src.contents[ps->index] != L'/') goto check_closing_brace; } parse_subst: ps->index++; pe->pe_subst = parse_word_to(ps, is_closing_brace); check_closing_brace: ensure_buffer(ps, 1); if (ps->src.contents[ps->index] == L'}') ps->index++; else serror(ps, Ngt("`%ls' is missing"), L"}"); if ((pe->pe_type & PT_NUMBER) && (pe->pe_type & PT_MASK) != PT_NONE) serror(ps, Ngt("invalid use of `%lc' in parameter expansion"), (wint_t) L'#'); end:; wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_PARAM; result->wu_param = pe; return result; } /* Parses a command substitution that starts with "$(". * The current position must be at the opening parenthesis L'(' when this * function is called and the position is advanced to the closing parenthesis * L')'. */ wordunit_T *parse_cmdsubst_in_paren(parsestate_T *ps) { wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_CMDSUB; result->wu_cmdsub = extract_command_in_paren(ps); ensure_buffer(ps, 1); if (ps->src.contents[ps->index] == L')') ps->index++; else serror(ps, Ngt("`%ls' is missing"), L")"); return result; } /* Extracts commands between '(' and ')'. * The current position must be at the opening parenthesis L'(' when this * function is called. The position is advanced to the closing parenthesis * L')'. */ embedcmd_T extract_command_in_paren(parsestate_T *ps) { plist_T save_pending_heredocs; embedcmd_T result; assert(ps->src.contents[ps->index] == L'('); save_pending_heredocs = ps->pending_heredocs; pl_init(&ps->pending_heredocs); #if YASH_ENABLE_ALIAS if (posixly_correct && ps->info->enable_alias) { result.is_preparsed = false; result.value.unparsed = extract_command_in_paren_unparsed(ps); } else #endif { ps->index++; result.is_preparsed = true; result.value.preparsed = parse_compound_list(ps); } pl_destroy(&ps->pending_heredocs); ps->pending_heredocs = save_pending_heredocs; return result; } #if YASH_ENABLE_ALIAS /* Parses commands between '(' and ')'. * The current position must be at the opening parenthesis L'(' when this * function is called. The position is advanced to the closing parenthesis * L')'. */ wchar_t *extract_command_in_paren_unparsed(parsestate_T *ps) { bool save_enable_alias = ps->enable_alias; ps->enable_alias = false; size_t startindex = ++ps->index; andorsfree(parse_compound_list(ps)); assert(startindex <= ps->index); wchar_t *result = xwcsndup( &ps->src.contents[startindex], ps->index - startindex); ps->enable_alias = save_enable_alias; return result; } #endif /* Parses a command substitution enclosed by backquotes. * When this function is called, the current position must be at the character * that just follows the opening backquote L'`'. This function advances the * position to the character that just follows the closing backquote L'~'. */ wordunit_T *parse_cmdsubst_in_backquote(parsestate_T *ps) { xwcsbuf_T buf; wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_CMDSUB; result->wu_cmdsub.is_preparsed = false; assert(ps->src.contents[ps->index - 1] == L'`'); wb_init(&buf); for (;;) { ensure_buffer(ps, 1); switch (ps->src.contents[ps->index]) { case L'\0': serror(ps, Ngt("the backquoted command substitution is not closed")); goto end; case L'`': ps->index++; goto end; case L'\\': ps->index++; switch (ps->src.contents[ps->index]) { case L'$': case L'`': case L'\\': goto default_; default: wb_wccat(&buf, L'\\'); continue; } case L'\n': ps->info->lineno++; /* falls thru! */ default: default_: wb_wccat(&buf, ps->src.contents[ps->index]); ps->index++; break; } } end: result->wu_cmdsub.value.unparsed = wb_towcs(&buf); return result; } /* Parses an arithmetic expansion. * The current position must be at the first opening parenthesis L'(' when this * function is called and the position is advanced to the character that just * follows the last closing parenthesis L')'. If there is no arithmetic * expansion, the return value is NULL and the position is not moved. */ wordunit_T *tryparse_arith(parsestate_T *ps) { size_t saveindex = ps->index; assert(ps->src.contents[ps->index] == L'(' && ps->src.contents[ps->index + 1] == L'('); ps->index += 2; wordunit_T *first = NULL, **lastp = &first; size_t startindex = ps->index; int nestparen = 0; for (;;) { ensure_buffer(ps, 1); switch (ps->src.contents[ps->index]) { case L'\0': goto fail; case L'\\': if (ps->src.contents[ps->index + 1] != L'\0') { assert(ps->src.contents[ps->index + 1] != L'\n'); ps->index += 2; continue; } break; case L'$': case L'`': MAKE_WORDUNIT_STRING; wordunit_T *wu = parse_special_word_unit(ps); startindex = ps->index; if (wu != NULL) { *lastp = wu; lastp = &wu->next; continue; } else if (ps->src.contents[ps->index] == L'\0') { continue; } break; case L'(': nestparen++; break; case L')': nestparen--; if (nestparen < 0) { ensure_buffer(ps, 2); if (ps->src.contents[ps->index + 1] == L')') goto end; else goto fail; } break; default: break; } ps->index++; } end: MAKE_WORDUNIT_STRING; ps->index += 2; wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_ARITH; result->wu_arith = first; return result; fail: wordfree(first); ps->index = saveindex; return NULL; } /* Returns a word token at the current index as a newly malloced string. * The current position is advanced to the character that just follows the word. * This function never returns NULL, but may return an empty string. */ wchar_t *parse_word_as_wcs(parsestate_T *ps) { size_t startindex = ps->index; wordfree(parse_word(ps, AT_GLOBAL)); assert(startindex <= ps->index); return xwcsndup(&ps->src.contents[startindex], ps->index - startindex); } /* Parses a compound command. * `command' is the name of the command to parse such as "(" and "if". */ command_T *parse_compound_command(parsestate_T *ps, const wchar_t *command) { /* `parse_group', `parse_if', etc. don't call `skip_blanks_and_comment' * before they return nor parse redirections. */ command_T *result; switch (command[0]) { case L'(': result = parse_group(ps, CT_SUBSHELL); break; case L'{': result = parse_group(ps, CT_GROUP); break; case L'i': result = parse_if(ps); break; case L'f': switch (command[1]) { case L'o': result = parse_for(ps); break; case L'u': result = parse_function(ps); break; default: assert(false); } break; case L'w': result = parse_while(ps, true); break; case L'u': result = parse_while(ps, false); break; case L'c': result = parse_case(ps); break; default: assert(false); } skip_blanks_and_comment(ps); parse_redirect_list(ps, &result->c_redirs); return result; } /* Parses a command group. * `type' must be either CT_GROUP or CT_SUBSHELL. */ command_T *parse_group(parsestate_T *ps, commandtype_T type) { const wchar_t *start, *end; switch (type) { case CT_GROUP: start = L"{", end = L"}"; assert(has_token(ps, start)); break; case CT_SUBSHELL: start = L"(", end = L")"; assert(ps->src.contents[ps->index] == start[0]); break; default: assert(false); } ps->index++; command_T *result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_type = type; result->c_lineno = ps->info->lineno; result->c_redirs = NULL; result->c_subcmds = parse_compound_list(ps); if (posixly_correct && result->c_subcmds == NULL) serror(ps, Ngt("commands are missing between `%ls' and `%ls'"), start, end); if (ps->src.contents[ps->index] == end[0]) ps->index++; else print_errmsg_token_missing(ps, end); return result; } /* Parses a if command */ command_T *parse_if(parsestate_T *ps) { assert(has_token(ps, L"if")); ps->index += 2; command_T *result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_type = CT_IF; result->c_lineno = ps->info->lineno; result->c_redirs = NULL; result->c_ifcmds = NULL; ifcommand_T **lastp = &result->c_ifcmds; bool after_else = false; while (!ps->error) { ifcommand_T *ic = xmalloc(sizeof *ic); *lastp = ic; lastp = &ic->next; ic->next = NULL; if (!after_else) { ic->ic_condition = parse_compound_list(ps); if (posixly_correct && ic->ic_condition == NULL) serror(ps, Ngt("commands are missing between `%ls' and `%ls'"), (result->c_ifcmds->next == NULL) ? L"if" : L"elif", L"then"); ensure_buffer(ps, 5); if (has_token(ps, L"then")) ps->index += 4; else print_errmsg_token_missing(ps, L"then"); } else { ic->ic_condition = NULL; } ic->ic_commands = parse_compound_list(ps); if (posixly_correct && ic->ic_commands == NULL) serror(ps, Ngt("commands are missing after `%ls'"), after_else ? L"else" : L"then"); ensure_buffer(ps, 5); if (!after_else) { if (has_token(ps, L"else")) { ps->index += 4; after_else = true; } else if (has_token(ps, L"elif")) { ps->index += 4; } else if (has_token(ps, L"fi")) { ps->index += 2; break; } else { print_errmsg_token_missing(ps, L"fi"); } } else { if (has_token(ps, L"fi")) ps->index += 2; else print_errmsg_token_missing(ps, L"fi"); break; } } return result; } /* Parses a for command. */ command_T *parse_for(parsestate_T *ps) { assert(has_token(ps, L"for")); ps->index += 3; skip_blanks_and_comment(ps); command_T *result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_type = CT_FOR; result->c_lineno = ps->info->lineno; result->c_redirs = NULL; wchar_t *name = parse_word_as_wcs(ps); if (!is_name(name)) { if (name[0] == L'\0') serror(ps, Ngt("an identifier is required after `for'")); else serror(ps, Ngt("`%ls' is not a valid identifier"), name); } result->c_forname = name; skip_to_next_token(ps); ensure_buffer(ps, 3); if (has_token(ps, L"in")) { redir_T *redirs = NULL; ps->index += 2; skip_blanks_and_comment(ps); result->c_forwords = parse_words_and_redirects(ps, &redirs, false); if (redirs != NULL) { serror(ps, Ngt("redirections are not allowed after `in'")); redirsfree(redirs); } if (ps->src.contents[ps->index] == L';') ps->index++; } else { result->c_forwords = NULL; if (ps->src.contents[ps->index] == L';') { ps->index++; if (posixly_correct) serror(ps, Ngt("`;' is not allowed " "just after the identifier in a for loop")); } } skip_to_next_token(ps); ensure_buffer(ps, 3); if (has_token(ps, L"do")) ps->index += 2; else serror(ps, Ngt("`%ls' is missing"), L"do"); // print_errmsg_token_missing(ps, L"do"); result->c_forcmds = parse_compound_list(ps); if (posixly_correct && result->c_forcmds == NULL) serror(ps, Ngt("commands are missing between `%ls' and `%ls'"), L"do", L"done"); ensure_buffer(ps, 5); if (has_token(ps, L"done")) ps->index += 4; else print_errmsg_token_missing(ps, L"done"); return result; } /* Parses a while/until command. * `whltype' must be true for the while command and false for the until command. */ command_T *parse_while(parsestate_T *ps, bool whltype) { assert(has_token(ps, whltype ? L"while" : L"until")); ps->index += 5; command_T *result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_type = CT_WHILE; result->c_lineno = ps->info->lineno; result->c_redirs = NULL; result->c_whltype = whltype; result->c_whlcond = parse_compound_list(ps); if (posixly_correct && result->c_whlcond == NULL) serror(ps, Ngt("commands are missing after `%ls'"), whltype ? L"while" : L"until"); ensure_buffer(ps, 3); if (has_token(ps, L"do")) ps->index += 2; else print_errmsg_token_missing(ps, L"do"); result->c_whlcmds = parse_compound_list(ps); if (posixly_correct && result->c_whlcmds == NULL) serror(ps, Ngt("commands are missing between `%ls' and `%ls'"), L"do", L"done"); ensure_buffer(ps, 5); if (has_token(ps, L"done")) ps->index += 4; else print_errmsg_token_missing(ps, L"done"); return result; } /* Parses a case command. */ command_T *parse_case(parsestate_T *ps) { assert(has_token(ps, L"case")); ps->index += 4; skip_blanks_and_comment(ps); command_T *result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_type = CT_CASE; result->c_lineno = ps->info->lineno; result->c_redirs = NULL; result->c_casword = parse_word(ps, AT_GLOBAL); if (result->c_casword == NULL) serror(ps, Ngt("a word is required after `%ls'"), L"case"); skip_to_next_token(ps); ensure_buffer(ps, 3); if (has_token(ps, L"in")) { ps->index += 2; result->c_casitems = parse_case_list(ps); } else { serror(ps, Ngt("`%ls' is missing"), L"in"); // print_errmsg_token_missing(ps, L"in"); result->c_casitems = NULL; } ensure_buffer(ps, 5); if (has_token(ps, L"esac")) ps->index += 4; else print_errmsg_token_missing(ps, L"esac"); return result; } /* Parses the body of a case command (the part between "in" and "esac"). * You don't have to call `skip_to_next_token' before calling this function. */ caseitem_T *parse_case_list(parsestate_T *ps) { caseitem_T *first = NULL, **lastp = &first; do { skip_to_next_token(ps); ensure_buffer(ps, 5); if (has_token(ps, L"esac")) break; caseitem_T *ci = xmalloc(sizeof *ci); *lastp = ci; lastp = &ci->next; ci->next = NULL; ci->ci_patterns = parse_case_patterns(ps); ci->ci_commands = parse_compound_list(ps); /* `ci_commands' may be NULL unlike for and while commands */ ensure_buffer(ps, 2); if (ps->src.contents[ps->index] == L';' && ps->src.contents[ps->index + 1] == L';') { ps->index += 2; } else { break; } } while (!ps->error); return first; } /* Parses patterns of a case item. * The current position is advanced to the character that just follows ')', not * to the next token. * Call `skip_to_next_token' and `ensure_buffer(ps, 1)' before calling this * function. */ void **parse_case_patterns(parsestate_T *ps) { plist_T wordlist; pl_init(&wordlist); if (ps->src.contents[ps->index] == L'(') { /* ignore the first '(' */ ps->index++; skip_blanks_and_comment(ps); if (posixly_correct) { ensure_buffer(ps, 5); if (has_token(ps, L"esac")) serror(ps, Ngt( "an unquoted `esac' cannot be the first case pattern")); } } const wchar_t *predecessor = L"("; do { if (is_token_delimiter_char(ps->src.contents[ps->index])) { if (ps->src.contents[ps->index] != L'\0') { if (ps->src.contents[ps->index] == L'\n') serror(ps, Ngt("a word is required after `%ls'"), predecessor); else serror(ps, Ngt("encountered an invalid character `%lc' " "in the case pattern"), (wint_t) ps->src.contents[ps->index]); } break; } pl_add(&wordlist, parse_word(ps, AT_GLOBAL)); skip_blanks_and_comment(ps); ensure_buffer(ps, 1); if (ps->src.contents[ps->index] == L'|') { predecessor = L"|"; ps->index++; } else if (ps->src.contents[ps->index] == L')') { ps->index++; break; } else { serror(ps, Ngt("`%ls' is missing"), L")"); break; } skip_blanks_and_comment(ps); } while (!ps->error); return pl_toary(&wordlist); } /* Parses a function definition that starts with the "function" keyword. */ command_T *parse_function(parsestate_T *ps) { if (posixly_correct) serror(ps, Ngt("`%ls' cannot be used as a command name"), L"function"); assert(has_token(ps, L"function")); ps->index += 8; skip_blanks_and_comment(ps); command_T *result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_type = CT_FUNCDEF; result->c_lineno = ps->info->lineno; result->c_redirs = NULL; result->c_funcname = parse_word(ps, AT_GLOBAL); if (result->c_funcname == NULL) serror(ps, Ngt("a word is required after `%ls'"), L"function"); skip_blanks_and_comment(ps); /* parse parentheses */ size_t saveindex = ps->index; if (ps->src.contents[ps->index] == L'(') { ps->index++; skip_blanks_and_comment(ps); if (ps->src.contents[ps->index] == L')') ps->index++; else ps->index = saveindex; } skip_to_next_token(ps); /* parse function body */ const wchar_t *t = check_opening_token(ps); if (t == NULL) { serror(ps, Ngt("a function body must be a compound command")); result->c_funcbody = NULL; } else { result->c_funcbody = parse_compound_command(ps, t); } return result; } /* Parses a function definition if any. * This function may process line continuations, which increase the line * number. */ command_T *tryparse_function(parsestate_T *ps) { size_t saveindex = ps->index; unsigned long lineno = ps->info->lineno; if (iswdigit(ps->src.contents[ps->index])) goto fail; size_t namelen = count_name_length(ps, is_name_char); ps->index += namelen; if (namelen == 0 || !is_token_delimiter_char(ps->src.contents[ps->index])) goto fail; skip_blanks_and_comment(ps); /* parse parentheses */ if (ps->src.contents[ps->index] != L'(') goto fail; ps->index++; skip_blanks_and_comment(ps); if (ps->src.contents[ps->index] != L')') { serror(ps, Ngt("`(' must be followed by `)' in a function definition")); return NULL; } ps->index++; skip_to_next_token(ps); /* parse function body */ const wchar_t *t = check_opening_token(ps); if (t == NULL) { serror(ps, Ngt("a function body must be a compound command")); return NULL; } command_T *body = parse_compound_command(ps, t); command_T *result = xmalloc(sizeof *result); result->next = NULL; result->refcount = 1; result->c_type = CT_FUNCDEF; result->c_lineno = lineno; result->c_redirs = NULL; result->c_funcname = xmalloc(sizeof *result->c_funcname); result->c_funcname->next = NULL; result->c_funcname->wu_type = WT_STRING; result->c_funcname->wu_string = xwcsndup(&ps->src.contents[saveindex], namelen); result->c_funcbody = body; return result; fail: ps->index = saveindex; return NULL; } /* Reads the contents of a here-document. */ void read_heredoc_contents(parsestate_T *ps, redir_T *r) { if (wcschr(r->rd_hereend, L'\n') != NULL) { serror(ps, Ngt("the end-of-here-document indicator contains a newline")); return; } assert(r->rd_type == RT_HERE || r->rd_type == RT_HERERT); if (wcspbrk(r->rd_hereend, QUOTES) != NULL) read_heredoc_contents_without_expansion(ps, r); else read_heredoc_contents_with_expansion(ps, r); } /* Reads the contents of a here-document without any parameter expansions. */ void read_heredoc_contents_without_expansion(parsestate_T *ps, redir_T *r) { wchar_t *eoc = unquote(r->rd_hereend); // end-of-contents marker bool skiptab = (r->rd_type == RT_HERERT); xwcsbuf_T buf; wb_init(&buf); while (!is_end_of_heredoc_contents(ps, eoc, skiptab)) { const wchar_t *eol = wcschr(&ps->src.contents[ps->index], L'\n'); size_t linelen; if (eol != NULL) { linelen = eol - &ps->src.contents[ps->index] + 1; } else { /* encountered EOF before reading an end-of-contents marker! */ linelen = ps->src.length - ps->index; } wb_ncat_force(&buf, &ps->src.contents[ps->index], linelen); ps->index += linelen; if (eol != NULL) ps->info->lineno++; else break; } free(eoc); wordunit_T *wu = xmalloc(sizeof *wu); wu->next = NULL; wu->wu_type = WT_STRING; wu->wu_string = escape(buf.contents, L"\\"); r->rd_herecontent = wu; wb_destroy(&buf); } /* Reads the contents of a here-document that may contain parameter expansions, * command substitutions and arithmetic expansions. */ void read_heredoc_contents_with_expansion(parsestate_T *ps, redir_T *r) { wordunit_T **lastp = &r->rd_herecontent; const wchar_t *eoc = r->rd_hereend; bool skiptab = (r->rd_type == RT_HERERT); while (!is_end_of_heredoc_contents(ps, eoc, skiptab)) { lastp = parse_string_without_quotes(ps, true, true, lastp); if (ps->src.contents[ps->index - 1] != L'\n') { /* encountered EOF before reading an end-of-contents marker! */ break; } } } /* Checks if the whole current line is end-of-heredoc `eoc'. * Reads the current line if not yet read. * If `skiptab' is true, leading tabs in the line are skipped. * If an end-of-heredoc is found, returns true and advances the current position * to the next line. Otherwise, returns false with the position unchanged * (except that leading tabs are skipped). */ bool is_end_of_heredoc_contents( parsestate_T *ps, const wchar_t *eoc, bool skiptab) { assert(ps->src.length > 0 && ps->src.contents[ps->index - 1] == L'\n'); if (ps->src.contents[ps->index] == L'\0') if (read_more_input(ps) != INPUT_OK) return true; if (skiptab) while (ps->src.contents[ps->index] == L'\t') ps->index++; const wchar_t *m = matchwcsprefix(&ps->src.contents[ps->index], eoc); if (m != NULL) { size_t matchendindex = m - ps->src.contents; switch (ps->src.contents[matchendindex]) { case L'\0': ps->index = matchendindex; return true; case L'\n': ps->index = matchendindex + 1; ps->info->lineno++; return true; } } return false; } /* Parses a string. * Parameter expansions, command substitutions and arithmetic expansions are * recognized, but single and double quotes are not treated as quotes. * Command substitutions enclosed by backquotes are recognized iff `backquote' * is true. If `stoponnewline' is true, stops parsing right after the next * newline is parsed. Otherwise, parsing continues up to the end of file. * The results are assigned ot `*lastp'. * The return value is a pointer to the `next' member of the last resultant word * unit (or `lastp' if no word unit resulted). */ wordunit_T **parse_string_without_quotes( parsestate_T *ps, bool backquote, bool stoponnewline, wordunit_T **lastp) { size_t startindex = ps->index; for (;;) { ensure_buffer(ps, 1); switch (ps->src.contents[ps->index]) { case L'\0': goto done; case L'\\': if (ps->src.contents[ps->index + 1] != L'\0') { assert(ps->src.contents[ps->index + 1] != L'\n'); ps->index += 2; continue; } break; case L'\n': ps->info->lineno++; if (stoponnewline) { ps->index++; goto done; } break; case L'`': if (!backquote) break; /* falls thru! */ case L'$': MAKE_WORDUNIT_STRING; wordunit_T *wu = parse_special_word_unit(ps); startindex = ps->index; if (wu != NULL) { *lastp = wu; lastp = &wu->next; continue; } else if (ps->src.contents[ps->index] == L'\0') { continue; } break; default: break; } ps->index++; } done: MAKE_WORDUNIT_STRING; return lastp; } /* Parses a string recognizing parameter expansions, command substitutions of * the form "$(...)" and arithmetic expansions. * All the members of `info' except `lastinputresult' must have been initialized * beforehand. * This function reads and parses the input to the end of file. * Iff successful, the result is assigned to `*resultp' and true is returned. * If the input is empty, NULL is assigned. * On error, the value of `*resultp' is undefined. */ bool parse_string(parseparam_T *info, wordunit_T **restrict resultp) { parsestate_T ps = { .info = info, .error = false, .index = 0, #if YASH_ENABLE_ALIAS .enable_alias = false, .reparse = false, .aliases = NULL, #endif }; wb_init(&ps.src); ps.info->lastinputresult = INPUT_OK; read_more_input(&ps); pl_init(&ps.pending_heredocs); resultp = parse_string_without_quotes(&ps, false, false, resultp); *resultp = NULL; wb_destroy(&ps.src); pl_destroy(&ps.pending_heredocs); #if YASH_ENABLE_ALIAS assert(ps.aliases == NULL); //destroy_aliaslist(ps.aliases); #endif if (ps.info->lastinputresult != INPUT_EOF || ps.error) { wordfree(*resultp); return false; } else { return true; } } /***** Auxiliaries about Error Messages *****/ const char *get_errmsg_unexpected_token(const wchar_t *t) { switch (t[0]) { case L')': assert(wcscmp(t, L")") == 0); return Ngt("encountered `%ls' without a matching `('"); case L'}': assert(wcscmp(t, L"}") == 0); return Ngt("encountered `%ls' without a matching `{'"); case L';': assert(wcscmp(t, L";;") == 0); return Ngt("`%ls' is used outside `case'"); case L'!': assert(wcscmp(t, L"!") == 0); return Ngt("`%ls' cannot be used as a command name"); case L'i': assert(wcscmp(t, L"in") == 0); return Ngt("`%ls' cannot be used as a command name"); case L'f': assert(wcscmp(t, L"fi") == 0); return Ngt("encountered `%ls' " "without a matching `if' and/or `then'"); case L't': assert(wcscmp(t, L"then") == 0); return Ngt("encountered `%ls' without a matching `if' or `elif'"); case L'd': assert(t[1] == L'o'); if (t[2] == L'\0') { assert(wcscmp(t, L"do") == 0); return Ngt("encountered `%ls' " "without a matching `for', `while', or `until'"); } else { assert(wcscmp(t, L"done") == 0); return Ngt("encountered `%ls' without a matching `do'"); } case L'e': if (t[1] == L's') { assert(wcscmp(t, L"esac") == 0); return Ngt("encountered `%ls' without a matching `case'"); } else { assert(wcscmp(t, L"else") == 0 || wcscmp(t, L"elif") == 0); return Ngt("encountered `%ls' " "without a matching `if' and/or `then'"); } default: assert(false); } } void print_errmsg_token_missing(parsestate_T *ps, const wchar_t *t) { const wchar_t *atoken = check_closing_token(ps); if (atoken != NULL) { serror(ps, get_errmsg_unexpected_token(atoken), atoken); serror(ps, Ngt("(maybe you missed `%ls'?)"), t); } else { serror(ps, Ngt("`%ls' is missing"), t); } } /********** Functions that Convert Parse Trees into Strings **********/ struct print { xwcsbuf_T buffer; plist_T pending_heredocs; bool multiline; }; static void print_and_or_lists( struct print *restrict pr, const and_or_T *restrict andors, unsigned indent, bool omitsemicolon) __attribute__((nonnull(1))); static void print_pipelines( struct print *restrict er, const pipeline_T *restrict pipelines, unsigned indent) __attribute__((nonnull(1))); static void print_commands( struct print *restrict pr, const command_T *restrict commands, unsigned indent) __attribute__((nonnull(1))); static void print_one_command( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_simple_command( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_group( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_subshell( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_if( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_for( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_while( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_case( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_caseitems( struct print *restrict pr, const caseitem_T *restrict caseitems, unsigned indent) __attribute__((nonnull(1))); static void print_function_definition( struct print *restrict pr, const command_T *restrict command, unsigned indent) __attribute__((nonnull)); static void print_assignments( struct print *restrict pr, const assign_T *restrict assigns, unsigned indent) __attribute__((nonnull(1))); static void print_redirections( struct print *restrict pr, const redir_T *restrict redirections, unsigned indent) __attribute__((nonnull(1))); static void print_word( struct print *restrict pr, const wordunit_T *restrict wordunits, unsigned indent) __attribute__((nonnull(1))); static void print_parameter( struct print *restrict pr, const paramexp_T *restrict parameter, unsigned indent) __attribute__((nonnull)); static void print_embedded_command(struct print *pr, embedcmd_T command, unsigned indent) __attribute__((nonnull)); static void print_indent(struct print *pr, unsigned indent) __attribute__((nonnull)); static void print_space_or_newline(struct print* pr) __attribute__((nonnull)); static void trim_end_of_buffer(xwcsbuf_T *buf) __attribute__((nonnull)); /* Converts the specified pipelines into a newly malloced wide string. */ wchar_t *pipelines_to_wcs(const pipeline_T *pipelines) { struct print pr; wb_init(&pr.buffer); pl_init(&pr.pending_heredocs); pr.multiline = false; print_pipelines(&pr, pipelines, 0); trim_end_of_buffer(&pr.buffer); pl_destroy(&pr.pending_heredocs); return wb_towcs(&pr.buffer); } /* Converts the specified command into a newly malloced wide string. * If `multiline' is true, the result is pretty-formated with a terminating * newline. */ wchar_t *command_to_wcs(const command_T *command, bool multiline) { struct print pr; wb_init(&pr.buffer); pl_init(&pr.pending_heredocs); pr.multiline = multiline; print_one_command(&pr, command, 0); trim_end_of_buffer(&pr.buffer); if (pr.multiline) print_space_or_newline(&pr); pl_destroy(&pr.pending_heredocs); return wb_towcs(&pr.buffer); } void print_and_or_lists(struct print *restrict pr, const and_or_T *restrict ao, unsigned indent, bool omitsemicolon) { while (ao != NULL) { print_pipelines(pr, ao->ao_pipelines, indent); trim_end_of_buffer(&pr->buffer); if (ao->ao_async) wb_wccat(&pr->buffer, L'&'); else if (!pr->multiline && (ao->next != NULL || !omitsemicolon)) wb_wccat(&pr->buffer, L';'); if (ao->next != NULL || !omitsemicolon) print_space_or_newline(pr); ao = ao->next; } } void print_pipelines(struct print *restrict pr, const pipeline_T *restrict pl, unsigned indent) { if (pl == NULL) return; for (;;) { print_indent(pr, indent); if (pl->pl_neg) wb_cat(&pr->buffer, L"! "); print_commands(pr, pl->pl_commands, indent); pl = pl->next; if (pl == NULL) break; wb_cat(&pr->buffer, pl->pl_cond ? L"&&" : L"||"); print_space_or_newline(pr); } } void print_commands( struct print *restrict pr, const command_T *restrict c, unsigned indent) { if (c == NULL) return; for (;;) { print_one_command(pr, c, indent); c = c->next; if (c == NULL) break; wb_cat(&pr->buffer, L"| "); } } void print_one_command( struct print *restrict pr, const command_T *restrict c, unsigned indent) { switch (c->c_type) { case CT_SIMPLE: print_simple_command(pr, c, indent); break; case CT_GROUP: print_group(pr, c, indent); break; case CT_SUBSHELL: print_subshell(pr, c, indent); break; case CT_IF: print_if(pr, c, indent); break; case CT_FOR: print_for(pr, c, indent); break; case CT_WHILE: print_while(pr, c, indent); break; case CT_CASE: print_case(pr, c, indent); break; case CT_FUNCDEF: print_function_definition(pr, c, indent); assert(c->c_redirs == NULL); return; // break; } print_redirections(pr, c->c_redirs, indent); } void print_simple_command( struct print *restrict pr, const command_T *restrict c, unsigned indent) { assert(c->c_type == CT_SIMPLE); print_assignments(pr, c->c_assigns, indent); for (void **w = c->c_words; *w != NULL; w++) { print_word(pr, *w, indent); wb_wccat(&pr->buffer, L' '); } } void print_group( struct print *restrict pr, const command_T *restrict c, unsigned indent) { assert(c->c_type == CT_GROUP); wb_wccat(&pr->buffer, L'{'); print_space_or_newline(pr); print_and_or_lists(pr, c->c_subcmds, indent + 1, false); print_indent(pr, indent); wb_cat(&pr->buffer, L"} "); } void print_subshell( struct print *restrict pr, const command_T *restrict c, unsigned indent) { assert(c->c_type == CT_SUBSHELL); wb_wccat(&pr->buffer, L'('); print_and_or_lists(pr, c->c_subcmds, indent + 1, true); trim_end_of_buffer(&pr->buffer); wb_cat(&pr->buffer, L") "); } void print_if( struct print *restrict pr, const command_T *restrict c, unsigned indent) { const ifcommand_T *ic; assert(c->c_type == CT_IF); wb_cat(&pr->buffer, L"if "); ic = c->c_ifcmds; for (;;) { print_and_or_lists(pr, ic->ic_condition, indent + 1, false); print_indent(pr, indent); wb_cat(&pr->buffer, L"then"); print_space_or_newline(pr); print_and_or_lists(pr, ic->ic_commands, indent + 1, false); ic = ic->next; if (ic == NULL) { break; } else if (!ic->ic_condition && ic->next == NULL) { print_indent(pr, indent); wb_cat(&pr->buffer, L"else"); print_space_or_newline(pr); print_and_or_lists(pr, ic->ic_commands, indent + 1, false); break; } else { print_indent(pr, indent); wb_cat(&pr->buffer, L"elif "); } } print_indent(pr, indent); wb_cat(&pr->buffer, L"fi "); } void print_for( struct print *restrict pr, const command_T *restrict c, unsigned indent) { assert(c->c_type == CT_FOR); wb_cat(&pr->buffer, L"for "); wb_cat(&pr->buffer, c->c_forname); if (c->c_forwords != NULL) { wb_cat(&pr->buffer, L" in"); for (void **w = c->c_forwords; *w != NULL; w++) { wb_wccat(&pr->buffer, L' '); print_word(pr, *w, indent); } if (!pr->multiline) wb_wccat(&pr->buffer, L';'); print_space_or_newline(pr); } else { wb_wccat(&pr->buffer, L' '); } print_indent(pr, indent); wb_cat(&pr->buffer, L"do"); print_space_or_newline(pr); print_and_or_lists(pr, c->c_forcmds, indent + 1, false); print_indent(pr, indent); wb_cat(&pr->buffer, L"done "); } void print_while( struct print *restrict pr, const command_T *restrict c, unsigned indent) { assert(c->c_type == CT_WHILE); wb_cat(&pr->buffer, c->c_whltype ? L"while " : L"until "); print_and_or_lists(pr, c->c_whlcond, indent + 1, false); print_indent(pr, indent); wb_cat(&pr->buffer, L"do"); print_space_or_newline(pr); print_and_or_lists(pr, c->c_whlcmds, indent + 1, false); print_indent(pr, indent); wb_cat(&pr->buffer, L"done "); } void print_case( struct print *restrict pr, const command_T *restrict c, unsigned indent) { assert(c->c_type == CT_CASE); wb_cat(&pr->buffer, L"case "); print_word(pr, c->c_casword, indent); wb_cat(&pr->buffer, L" in"); print_space_or_newline(pr); print_caseitems(pr, c->c_casitems, indent + 1); print_indent(pr, indent); wb_cat(&pr->buffer, L"esac "); } void print_caseitems(struct print *restrict pr, const caseitem_T *restrict ci, unsigned indent) { while (ci != NULL) { print_indent(pr, indent); wb_wccat(&pr->buffer, L'('); for (void **w = ci->ci_patterns; ; ) { print_word(pr, *w, indent); w++; if (*w == NULL) break; wb_cat(&pr->buffer, L" | "); } wb_wccat(&pr->buffer, L')'); print_space_or_newline(pr); if (ci->ci_commands != NULL) { print_and_or_lists(pr, ci->ci_commands, indent + 1, true); print_space_or_newline(pr); } print_indent(pr, indent + 1); wb_cat(&pr->buffer, L";;"); print_space_or_newline(pr); ci = ci->next; } } void print_function_definition( struct print *restrict pr, const command_T *restrict c, unsigned indent) { assert(c->c_type == CT_FUNCDEF); if (c->c_funcname->next != NULL || c->c_funcname->wu_type != WT_STRING || !is_name(c->c_funcname->wu_string)) wb_cat(&pr->buffer, L"function "); print_word(pr, c->c_funcname, indent); wb_cat(&pr->buffer, L"()"); print_space_or_newline(pr); print_indent(pr, indent); assert(c->c_funcbody->next == NULL); print_one_command(pr, c->c_funcbody, indent); } void print_assignments( struct print *restrict pr, const assign_T *restrict a, unsigned indent) { while (a != NULL) { wb_cat(&pr->buffer, a->a_name); wb_wccat(&pr->buffer, L'='); switch (a->a_type) { case A_SCALAR: print_word(pr, a->a_scalar, indent); break; case A_ARRAY: wb_wccat(&pr->buffer, L'('); for (void **w = a->a_array; *w != NULL; w++) { print_word(pr, *w, indent); wb_wccat(&pr->buffer, L' '); } trim_end_of_buffer(&pr->buffer); wb_wccat(&pr->buffer, L')'); break; } wb_wccat(&pr->buffer, L' '); a = a->next; } } void print_redirections( struct print *restrict pr, const redir_T *restrict rd, unsigned indent) { while (rd != NULL) { const wchar_t *s; enum { file, here, proc, } type; switch (rd->rd_type) { case RT_INPUT: s = L"<"; type = file; break; case RT_OUTPUT: s = L">"; type = file; break; case RT_CLOBBER: s = L">|"; type = file; break; case RT_APPEND: s = L">>"; type = file; break; case RT_INOUT: s = L"<>"; type = file; break; case RT_DUPIN: s = L"<&"; type = file; break; case RT_DUPOUT: s = L">&"; type = file; break; case RT_PIPE: s = L">>|"; type = file; break; case RT_HERE: s = L"<<"; type = here; break; case RT_HERERT: s = L"<<-"; type = here; break; case RT_HERESTR: s = L"<<<"; type = file; break; case RT_PROCIN: s = L"<("; type = proc; break; case RT_PROCOUT: s = L">("; type = proc; break; default: assert(false); } wb_wprintf(&pr->buffer, L"%d%ls", rd->rd_fd, s); switch (type) { case file: print_word(pr, rd->rd_filename, indent); break; case here: wb_cat(&pr->buffer, rd->rd_hereend); pl_add(&pr->pending_heredocs, (void *) rd); break; case proc: print_embedded_command(pr, rd->rd_command, indent + 1); wb_wccat(&pr->buffer, L')'); break; } wb_wccat(&pr->buffer, L' '); rd = rd->next; } } void print_word(struct print *restrict pr, const wordunit_T *restrict wu, unsigned indent) { while (wu != NULL) { switch (wu->wu_type) { case WT_STRING: wb_cat(&pr->buffer, wu->wu_string); break; case WT_PARAM: print_parameter(pr, wu->wu_param, indent); break; case WT_CMDSUB: wb_cat(&pr->buffer, L"$("); print_embedded_command(pr, wu->wu_cmdsub, indent + 1); wb_wccat(&pr->buffer, L')'); break; case WT_ARITH: wb_cat(&pr->buffer, L"$(("); print_word(pr, wu->wu_arith, indent); wb_cat(&pr->buffer, L"))"); break; } wu = wu->next; } } void print_parameter(struct print *restrict pr, const paramexp_T *restrict pe, unsigned indent) { wb_cat(&pr->buffer, L"${"); if (pe->pe_type & PT_NUMBER) wb_wccat(&pr->buffer, L'#'); if (pe->pe_type & PT_NEST) print_word(pr, pe->pe_nest, indent); else wb_cat(&pr->buffer, pe->pe_name); if (pe->pe_start != NULL) { wb_wccat(&pr->buffer, L'['); print_word(pr, pe->pe_start, indent); if (pe->pe_end != NULL) { wb_wccat(&pr->buffer, L','); print_word(pr, pe->pe_end, indent); } wb_wccat(&pr->buffer, L']'); } if (pe->pe_type & PT_COLON) wb_wccat(&pr->buffer, L':'); switch (pe->pe_type & PT_MASK) { wchar_t c; case PT_PLUS: c = L'+'; goto append_subst; case PT_MINUS: c = L'-'; goto append_subst; case PT_ASSIGN: c = L'='; goto append_subst; case PT_ERROR: c = L'?'; goto append_subst; case PT_MATCH: if (pe->pe_type & PT_MATCHHEAD) { c = L'#'; } else { assert(pe->pe_type & PT_MATCHTAIL); c = L'%'; } wb_wccat(&pr->buffer, c); if (pe->pe_type & PT_MATCHLONGEST) wb_wccat(&pr->buffer, c); print_word(pr, pe->pe_match, indent); break; case PT_SUBST: wb_wccat(&pr->buffer, L'/'); if (pe->pe_type & PT_SUBSTALL) wb_wccat(&pr->buffer, L'/'); else if (pe->pe_type & PT_MATCHHEAD) wb_wccat(&pr->buffer, L'#'); else if (pe->pe_type & PT_MATCHTAIL) wb_wccat(&pr->buffer, L'%'); print_word(pr, pe->pe_match, indent); c = L'/'; append_subst: wb_wccat(&pr->buffer, c); print_word(pr, pe->pe_subst, indent); break; } wb_wccat(&pr->buffer, L'}'); } void print_embedded_command(struct print *pr, embedcmd_T ec, unsigned indent) { if (ec.is_preparsed) print_and_or_lists(pr, ec.value.preparsed, indent, true); else wb_cat(&pr->buffer, ec.value.unparsed); } void print_indent(struct print *pr, unsigned indent) { #ifndef FORMAT_INDENT_WIDTH #define FORMAT_INDENT_WIDTH 3 #endif if (pr->multiline) { xwcsbuf_T *buf = &pr->buffer; if (buf->length > 0 && buf->contents[buf->length - 1] != L'\n') return; indent *= FORMAT_INDENT_WIDTH; while (indent > 0) { wb_wccat(buf, L' '); indent--; } } } void print_space_or_newline(struct print* pr) { if (pr->multiline) { wb_wccat(&pr->buffer, L'\n'); for (size_t i = 0; i < pr->pending_heredocs.length; i++) { const redir_T *rd = pr->pending_heredocs.contents[i]; print_word(pr, rd->rd_herecontent, 1); wb_catfree(&pr->buffer, unquote(rd->rd_hereend)); wb_wccat(&pr->buffer, L'\n'); } pl_clear(&pr->pending_heredocs, 0); } else { wb_wccat(&pr->buffer, L' '); } } void trim_end_of_buffer(xwcsbuf_T *buf) { size_t i = buf->length; while (i > 0 && buf->contents[i - 1] == L' ') i--; wb_truncate(buf, i); } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/arith.h0000644000175000017500000000212212154557026014023 0ustar magicantmagicant/* Yash: yet another shell */ /* arith.h: arithmetic expansion */ /* (C) 2007-2009 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_ARITH_H #define YASH_ARITH_H #include #include extern wchar_t *evaluate_arithmetic(wchar_t *exp) __attribute__((nonnull,malloc,warn_unused_result)); extern _Bool evaluate_index(wchar_t *exp, ssize_t *valuep) __attribute__((nonnull)); #endif /* YASH_ARITH_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/input.c0000644000175000017500000002653512154557026014064 0ustar magicantmagicant/* Yash: yet another shell */ /* input.c: functions for input of command line */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "input.h" #include #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include "exec.h" #include "expand.h" #if YASH_ENABLE_HISTORY # include "history.h" #endif #include "job.h" #include "mail.h" #include "option.h" #include "parser.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" #include "yash.h" #if YASH_ENABLE_LINEEDIT # include "lineedit/display.h" # include "lineedit/lineedit.h" #endif static wchar_t *expand_ps1_posix(wchar_t *s) __attribute__((nonnull,malloc,warn_unused_result)); static inline wchar_t get_euid_marker(void) __attribute__((pure)); /* An input function that inputs from a wide string. * `inputinfo' must be a pointer to a `struct input_wcs_info_T'. * Reads all characters from `inputinfo->src' and appends it to buffer `buf'. * `inputinfo->src' is assigned NULL. */ inputresult_T input_wcs(struct xwcsbuf_T *buf, void *inputinfo) { struct input_wcs_info_T *info = inputinfo; const wchar_t *src = info->src; if (src == NULL) return INPUT_EOF; bool isempty = (src[0] == L'\0'); wb_cat(buf, src); info->src = NULL; return isempty ? INPUT_EOF : INPUT_OK; } /* An input function that reads input from a file stream. * `inputinfo' is a pointer to a `struct input_file_info_T'. * Reads one line from `inputinfo->fd' and appends it to the buffer. */ inputresult_T input_file(struct xwcsbuf_T *buf, void *inputinfo) { return read_input(buf, inputinfo, true); } /* Reads one line from file descriptor `info->fd' and appends it to `buf'. * If `trap' is true, traps are handled while reading and the `sigint_received' * flag is cleared when this function returns. * Returns: * INPUT_OK if at least one character was appended * INPUT_EOF if reached the end of file without reading any characters * INPUT_ERROR if an error occurred before reading any characters */ inputresult_T read_input( xwcsbuf_T *buf, struct input_file_info_T *info, bool trap) { size_t initlen = buf->length; bool ok = true; if (trap) { handle_signals(); reset_sigint(); } for (;;) { if (info->bufpos >= info->bufmax) { read_input: /* if there's nothing in the buffer, read the next input */ ok = wait_for_input(info->fd, trap, -1); if (!ok) goto end; ssize_t readcount = read(info->fd, info->buf, info->bufsize); if (readcount < 0) switch (errno) { case EINTR: case EAGAIN: #if EAGAIN != EWOULDBLOCK case EWOULDBLOCK: #endif goto read_input; /* try again */ default: goto error; } else if (readcount == 0) { goto end; } info->bufpos = 0; info->bufmax = readcount; } /* convert bytes in `info->buf' into a wide character and * append it to `buf' */ wb_ensuremax(buf, buf->length + 1); assert(info->bufpos < info->bufmax); size_t convcount = mbrtowc(&buf->contents[buf->length], &info->buf[info->bufpos], info->bufmax - info->bufpos, &info->state); switch (convcount) { case 0: /* read null character */ goto end; case (size_t) -1: /* not a valid character */ goto error; case (size_t) -2: /* needs more input */ goto read_input; default: info->bufpos += convcount; buf->contents[++buf->length] = L'\0'; if (buf->contents[buf->length - 1] == L'\n') goto end; break; } } error: xerror(errno, Ngt("cannot read input")); ok = false; end: if (initlen != buf->length) return INPUT_OK; else if (ok) return INPUT_EOF; else return INPUT_ERROR; } /* An input function that prints a prompt and reads input. * `inputinfo' is a pointer to a `struct input_interactive_info'. * `inputinfo->type' must be either 1 or 2, which specifies the prompt type. * For example, $PS1 is printed if `inputinfo->type' is 1. * If `inputinfo->type' is 1, this function changes it to 2 after a successful * read. * The line is added to the history. */ inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo) { struct input_interactive_info_T *info = inputinfo; struct promptset_T prompt; if (info->prompttype == 1) { if (!posixly_correct) exec_variable_as_auxiliary_(VAR_PROMPT_COMMAND); check_mail(); } prompt = get_prompt(info->prompttype); if (do_job_control) print_job_status_all(); /* Note: no commands must be executed between `print_job_status_all' here * and `le_readline', or the "notifyle" option won't work. More precisely, * `handle_sigchld' must not be called from any other function until it is * called from `wait_for_input' during the line-editing. */ #if YASH_ENABLE_LINEEDIT /* read a line using line editing */ if (info->fileinfo->fd == STDIN_FILENO && shopt_lineedit != SHOPT_NOLINEEDIT) { wchar_t *line; inputresult_T result; result = le_readline(prompt, &line); if (result != INPUT_ERROR) { free_prompt(prompt); if (result == INPUT_OK) { if (info->prompttype == 1) info->prompttype = 2; #if YASH_ENABLE_HISTORY add_history(line); #endif wb_catfree(buf, line); } return result; } } #endif /* YASH_ENABLE_LINEEDIT */ /* read a line without line editing */ print_prompt(prompt.main); print_prompt(prompt.styler); if (info->prompttype == 1) info->prompttype = 2; int result; #if YASH_ENABLE_HISTORY size_t oldlen = buf->length; #endif result = input_file(buf, info->fileinfo); print_prompt(PROMPT_RESET); free_prompt(prompt); #if YASH_ENABLE_HISTORY add_history(buf->contents + oldlen); #endif return result; } /* Returns the prompt string, possibly containing backslash escapes. * `type' must be 1, 2 or 4. * This function never fails: A newly malloced string is always returned. * `save_parse_state' must be called before calling this function because this * function calls `parse_string'. */ struct promptset_T get_prompt(int type) { struct promptset_T result; wchar_t name[5] = { L'P', L'S', L'\0', L'\0', L'\0' }; switch (type) { case 1: name[2] = L'1'; break; case 2: name[2] = L'2'; break; case 4: name[2] = L'4'; break; default: assert(false); } const wchar_t *ps = getvar(name); if (ps == NULL) ps = L""; wchar_t *prompt = parse_and_expand_string(ps, gt("prompt"), false); if (prompt == NULL) prompt = xwcsdup(L""); if (posixly_correct) { if (type == 1) result.main = expand_ps1_posix(prompt); else result.main = escapefree(prompt, L"\\"); result.right = xwcsdup(L""); result.styler = xwcsdup(L""); } else { result.main = prompt; name[3] = L'R'; ps = getvar(name); if (ps == NULL) ps = L""; prompt = parse_and_expand_string(ps, gt("prompt"), false); if (prompt == NULL) prompt = xwcsdup(L""); result.right = prompt; name[3] = L'S'; ps = getvar(name); if (ps == NULL) ps = L""; prompt = parse_and_expand_string(ps, gt("prompt"), false); if (prompt == NULL) prompt = xwcsdup(L""); result.styler = prompt; } return result; } /* Expands the contents of the PS1 variable in the posixly correct way. * The argument is `free'd in this function. * The return value must be `free'd by the caller. */ /* In this function, "!" is replaced with "\!", "!!" with "!", and "\" with * "\\". */ wchar_t *expand_ps1_posix(wchar_t *s) { xwcsbuf_T buf; wb_init(&buf); for (size_t i = 0; s[i] != L'\0'; i++) { if (s[i] == L'\\') { wb_wccat(&buf, L'\\'); wb_wccat(&buf, L'\\'); } else if (s[i] == L'!') { if (s[i + 1] == L'!') { wb_wccat(&buf, L'!'); i++; } else { wb_wccat(&buf, L'\\'); wb_wccat(&buf, L'!'); } } else { wb_wccat(&buf, s[i]); } } free(s); return wb_towcs(&buf); } /* Prints the specified prompt string to the standard error. * If the argument is NULL, the "sgr0" terminfo capability is printed, which * resets the terminal's font style. * * Escape sequences are handled: * \a a bell character: L'\a' (L'\07') * \e an escape code: L'\033' * \j the number of jobs * \n newline: L'\n' * \r carriage return: L'\r' * \! next history number * \$ L'#' if the effective user ID is 0, L'$' otherwise * \\ a backslash * * If line-editing is enabled, the followings are also available: * \fX change color * \[ start of substring not to be counted as printable characters * \] end of substring not to be counted as printable characters * "X" in "\fX" can be any number of flags from the following: * (foreground color) * k (black) r (red) g (green) y (yellow) * b (blue) m (magenta) c (cyan) w (white) * (background color) * K R G Y B M C W * t (brighter color: used just after a color flag above) * d (default foreground/background color) * D (default foreground/background color and style) * s (standout) * u (underline) * v (reverse) * n (blink) * i (dim) * o (bold) * x (invisible) * . (end: omittable) * These are ignored in this function. */ void print_prompt(const wchar_t *s) { #if YASH_ENABLE_LINEEDIT if (le_try_print_prompt(s)) return; #endif xwcsbuf_T buf; wb_init(&buf); while (*s != L'\0') { if (*s != L'\\') { wb_wccat(&buf, *s); } else switch (*++s) { default: wb_wccat(&buf, *s); break; case L'\0': wb_wccat(&buf, L'\\'); goto done; // case L'\\': wb_wccat(&buf, L'\\'); break; case L'a': wb_wccat(&buf, L'\a'); break; case L'e': wb_wccat(&buf, L'\033'); break; case L'n': wb_wccat(&buf, L'\n'); break; case L'r': wb_wccat(&buf, L'\r'); break; case L'$': wb_wccat(&buf, get_euid_marker()); break; case L'j': wb_wprintf(&buf, L"%zu", job_count()); break; #if YASH_ENABLE_HISTORY case L'!': wb_wprintf(&buf, L"%u", next_history_number()); break; #endif case L'[': case L']': break; case L'f': while (iswalnum(*++s)); if (*s == L'.') s++; continue; } s++; } done: fprintf(stderr, "%ls", buf.contents); fflush(stderr); wb_destroy(&buf); } wchar_t get_euid_marker(void) { return geteuid() == 0 ? L'#' : L'$'; } /* Unsets O_NONBLOCK flag of the specified file descriptor. * If `fd' is negative, does nothing. * Returns true if successful. On error, `errno' is set and false is returned.*/ bool unset_nonblocking(int fd) { if (fd >= 0) { int flags = fcntl(fd, F_GETFL); if (flags < 0) return false; if (flags & O_NONBLOCK) return fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) != -1; } return true; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/arith.c0000644000175000017500000010715412154557026014031 0ustar magicantmagicant/* Yash: yet another shell */ /* arith.c: arithmetic expansion */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "arith.h" #include #include #include #include #include #include #include #include #include #include #include /* #include */ #include "option.h" #include "strbuf.h" #include "util.h" #include "variable.h" /* Must not include or because symbol names conflict. * (to[a-z]*) */ /* we declare these functions instead of including */ extern int iswalpha(wint_t wc); extern int iswalnum(wint_t wc); extern int iswdigit(wint_t wc); extern int iswspace(wint_t wc); typedef struct word_T { const wchar_t *contents; size_t length; } word_T; typedef enum valuetype_T { VT_INVALID, VT_LONG, VT_DOUBLE, VT_VAR, } valuetype_T; typedef struct value_T { valuetype_T type; union { long longvalue; double doublevalue; word_T varvalue; } value; } value_T; #define v_long value.longvalue #define v_double value.doublevalue #define v_var value.varvalue typedef enum tokentype_T { TT_NULL, TT_INVALID, /* symbols */ TT_LPAREN, TT_RPAREN, TT_TILDE, TT_EXCL, TT_PERCENT, TT_PLUS, TT_MINUS, TT_PLUSPLUS, TT_MINUSMINUS, TT_ASTER, TT_SLASH, TT_LESS, TT_GREATER, TT_LESSLESS, TT_GREATERGREATER, TT_LESSEQUAL, TT_GREATEREQUAL, TT_EQUALEQUAL, TT_EXCLEQUAL, TT_AMP, TT_AMPAMP, TT_HAT, TT_PIPE, TT_PIPEPIPE, TT_QUESTION, TT_COLON, TT_EQUAL, TT_PLUSEQUAL, TT_MINUSEQUAL, TT_ASTEREQUAL, TT_SLASHEQUAL, TT_PERCENTEQUAL, TT_LESSLESSEQUAL, TT_GREATERGREATEREQUAL, TT_AMPEQUAL, TT_HATEQUAL, TT_PIPEEQUAL, /* numbers */ TT_NUMBER, /* identifiers */ TT_IDENTIFIER, } tokentype_T; typedef struct token_T { tokentype_T type; word_T word; /* valid only for numbers and identifiers */ } token_T; typedef struct evalinfo_T { const wchar_t *exp; /* expression to parse and calculate */ size_t index; /* index of next token */ token_T token; /* current token */ bool parseonly; /* only parse the expression: don't calculate */ bool error; /* true if there is an error */ char *savelocale; /* original LC_NUMERIC locale */ } evalinfo_T; static void evaluate( const wchar_t *exp, value_T *result, evalinfo_T *info, bool coerce) __attribute__((nonnull)); static void parse_assignment(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static bool do_assignment(const word_T *word, const value_T *value) __attribute__((nonnull)); static wchar_t *value_to_string(const value_T *value) __attribute__((nonnull)); static long do_long_calculation(tokentype_T ttype, long v1, long v2) __attribute__((nonnull)); static double do_double_calculation(tokentype_T ttype, double v1, double v2) __attribute__((nonnull)); static long do_double_comparison(tokentype_T ttype, double v1, double v2) __attribute__((nonnull)); static void parse_conditional(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_logical_or(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_logical_and(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_inclusive_or(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_exclusive_or(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_and(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_equality(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_relational(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_shift(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_additive(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_multiplicative(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_prefix(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_postfix(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void do_increment_or_decrement(tokentype_T ttype, value_T *value) __attribute__((nonnull)); static void parse_primary(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void parse_as_number(evalinfo_T *info, value_T *result) __attribute__((nonnull)); static void coerce_number(evalinfo_T *info, value_T *value) __attribute__((nonnull)); static void coerce_integer(evalinfo_T *info, value_T *value) __attribute__((nonnull)); static valuetype_T coerce_type(evalinfo_T *info, value_T *value1, value_T *value2) __attribute__((nonnull)); static void next_token(evalinfo_T *info) __attribute__((nonnull)); /* Evaluates the specified string as an arithmetic expression. * The argument string is freed in this function. * The result is converted into a string and returned as a newly-malloced * string. On error, an error message is printed to the standard error and NULL * is returned. */ wchar_t *evaluate_arithmetic(wchar_t *exp) { value_T result; evalinfo_T info; evaluate(exp, &result, &info, posixly_correct); wchar_t *resultstr; if (info.error) { resultstr = NULL; } else if (info.token.type == TT_NULL) { resultstr = value_to_string(&result); } else { if (info.token.type != TT_INVALID) xerror(0, Ngt("arithmetic: invalid syntax")); resultstr = NULL; } free(exp); return resultstr; } /* Evaluates the specified string as an arithmetic expression. * The argument string is freed in this function. * The expression must yield a valid integer value, which is assigned to * `*valuep'. Otherwise, an error message is printed. * Returns true iff successful. */ bool evaluate_index(wchar_t *exp, ssize_t *valuep) { value_T result; evalinfo_T info; evaluate(exp, &result, &info, true); bool ok; if (info.error) { ok = false; } else if (info.token.type == TT_NULL) { if (result.type == VT_LONG) { #if LONG_MAX > SSIZE_MAX if (result.v_long > (long) SSIZE_MAX) *valuep = SSIZE_MAX; else #endif #if LONG_MIN < -SSIZE_MAX if (result.v_long < (long) -SSIZE_MAX) *valuep = -SSIZE_MAX; else #endif *valuep = (ssize_t) result.v_long; ok = true; } else { xerror(0, Ngt("the index is not an integer")); ok = false; } } else { if (info.token.type != TT_INVALID) xerror(0, Ngt("arithmetic: invalid syntax")); ok = false; } free(exp); return ok; } void evaluate( const wchar_t *exp, value_T *result, evalinfo_T *info, bool coerce) { info->exp = exp; info->index = 0; info->parseonly = false; info->error = false; info->savelocale = xstrdup(setlocale(LC_NUMERIC, NULL)); next_token(info); parse_assignment(info, result); if (coerce) coerce_number(info, result); free(info->savelocale); } /* Parses an assignment expression. * AssignmentExp := ConditionalExp * | ConditionalExp AssignmentOperator AssignmentExp */ void parse_assignment(evalinfo_T *info, value_T *result) { parse_conditional(info, result); tokentype_T ttype = info->token.type; switch (ttype) { case TT_EQUAL: case TT_PLUSEQUAL: case TT_MINUSEQUAL: case TT_ASTEREQUAL: case TT_SLASHEQUAL: case TT_PERCENTEQUAL: case TT_LESSLESSEQUAL: case TT_GREATERGREATEREQUAL: case TT_AMPEQUAL: case TT_HATEQUAL: case TT_PIPEEQUAL: { value_T rhs; next_token(info); parse_assignment(info, &rhs); if (result->type == VT_VAR) { word_T saveword = result->v_var; switch (coerce_type(info, result, &rhs)) { case VT_LONG: result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); break; case VT_DOUBLE: result->v_double = do_double_calculation(ttype, result->v_double, rhs.v_double); break; case VT_INVALID: result->type = VT_INVALID; break; case VT_VAR: assert(false); } if (!do_assignment(&saveword, result)) info->error = true, result->type = VT_INVALID; } else if (result->type != VT_INVALID) { /* TRANSLATORS: This error message is shown when the target * of an assignment is not a variable. */ xerror(0, Ngt("arithmetic: cannot assign to a number")); info->error = true; result->type = VT_INVALID; } break; } default: break; } } /* Assigns the specified `value' to the variable specified by `word'. * Returns false on error. */ bool do_assignment(const word_T *word, const value_T *value) { wchar_t *vstr = value_to_string(value); if (vstr == NULL) return false; wchar_t name[word->length + 1]; wmemcpy(name, word->contents, word->length); name[word->length] = L'\0'; return set_variable(name, vstr, SCOPE_GLOBAL, false); } /* Converts `value' to a newly-malloced wide string. * Returns NULL for VT_INVALID. */ wchar_t *value_to_string(const value_T *value) { switch (value->type) { case VT_INVALID: return NULL; case VT_LONG: return malloc_wprintf(L"%ld", value->v_long); case VT_DOUBLE: return malloc_wprintf(L"%.*g", DBL_DIG, value->v_double); case VT_VAR: { wchar_t name[value->v_var.length + 1]; wmemcpy(name, value->v_var.contents, value->v_var.length); name[value->v_var.length] = L'\0'; const wchar_t *var = getvar(name); return (var != NULL) ? xwcsdup(var) : NULL; } } assert(false); } /* Does unary or binary long calculation according to the specified operator * token. Division by zero is not allowed. */ long do_long_calculation(tokentype_T ttype, long v1, long v2) { switch (ttype) { case TT_PLUS: case TT_PLUSEQUAL: return v1 + v2; case TT_MINUS: case TT_MINUSEQUAL: return v1 - v2; case TT_ASTER: case TT_ASTEREQUAL: return v1 * v2; case TT_SLASH: case TT_SLASHEQUAL: return v1 / v2; case TT_PERCENT: case TT_PERCENTEQUAL: return v1 % v2; case TT_LESSLESS: case TT_LESSLESSEQUAL: return v1 << v2; case TT_GREATERGREATER: case TT_GREATERGREATEREQUAL: return v1 >> v2; case TT_LESS: return v1 < v2; case TT_LESSEQUAL: return v1 <= v2; case TT_GREATER: return v1 > v2; case TT_GREATEREQUAL: return v1 >= v2; case TT_EQUALEQUAL: return v1 == v2; case TT_EXCLEQUAL: return v1 != v2; case TT_AMP: case TT_AMPEQUAL: return v1 & v2; case TT_HAT: case TT_HATEQUAL: return v1 ^ v2; case TT_PIPE: case TT_PIPEEQUAL: return v1 | v2; case TT_EQUAL: return v2; default: assert(false); } } /* Does unary or binary double calculation according to the specified operator * token. */ double do_double_calculation(tokentype_T ttype, double v1, double v2) { switch (ttype) { case TT_PLUS: case TT_PLUSEQUAL: return v1 + v2; case TT_MINUS: case TT_MINUSEQUAL: return v1 - v2; case TT_ASTER: case TT_ASTEREQUAL: return v1 * v2; case TT_SLASH: case TT_SLASHEQUAL: return v1 / v2; case TT_PERCENT: case TT_PERCENTEQUAL: return fmod(v1, v2); default: assert(false); } } /* Does double comparison according to the specified operator token. */ long do_double_comparison(tokentype_T ttype, double v1, double v2) { switch (ttype) { case TT_LESS: return v1 < v2; case TT_LESSEQUAL: return v1 <= v2; case TT_GREATER: return v1 > v2; case TT_GREATEREQUAL: return v1 >= v2; case TT_EQUALEQUAL: return v1 == v2; case TT_EXCLEQUAL: return v1 != v2; default: assert(false); } } /* Parses a conditional expression. * ConditionalExp := LogicalOrExp * | LogicalOrExp "?" AssignmentExp ":" ConditionalExp */ void parse_conditional(evalinfo_T *info, value_T *result) { bool saveparseonly = info->parseonly; for (;;) { value_T dummy; value_T *result2; result2 = info->parseonly ? &dummy : result; parse_logical_or(info, result2); if (info->token.type != TT_QUESTION) break; bool cond, valid = true; coerce_number(info, result2); next_token(info); switch (result2->type) { case VT_INVALID: valid = false, cond = true; break; case VT_LONG: cond = result2->v_long; break; case VT_DOUBLE: cond = result2->v_double; break; default: assert(false); } bool saveparseonly2 = info->parseonly || !valid; info->parseonly = saveparseonly2 || !cond; result2 = info->parseonly ? &dummy : result; parse_assignment(info, result2); if (info->token.type != TT_COLON) { xerror(0, Ngt("arithmetic: `%ls' is missing"), L":"); info->error = true; result->type = VT_INVALID; break; } next_token(info); info->parseonly = saveparseonly2 || cond; } info->parseonly = saveparseonly; if (info->parseonly) result->type = VT_INVALID; } /* Parses a logical OR expression. * LogicalOrExp := LogicalAndExp | LogicalOrExp "||" LogicalAndExp */ void parse_logical_or(evalinfo_T *info, value_T *result) { bool saveparseonly = info->parseonly; parse_logical_and(info, result); while (info->token.type == TT_PIPEPIPE) { bool value, valid = true; coerce_number(info, result); next_token(info); switch (result->type) { case VT_INVALID: valid = false, value = true; break; case VT_LONG: value = result->v_long; break; case VT_DOUBLE: value = result->v_double; break; default: assert(false); } info->parseonly |= value; parse_logical_and(info, result); coerce_number(info, result); if (!value) switch (result->type) { case VT_INVALID: valid = false; break; case VT_LONG: value = result->v_long; break; case VT_DOUBLE: value = result->v_double; break; default: assert(false); } if (valid) result->type = VT_LONG, result->v_long = value; else result->type = VT_INVALID; } info->parseonly = saveparseonly; } /* Parses a logical AND expression. * LogicalAndExp := InclusiveOrExp | LogicalAndExp "&&" InclusiveOrExp */ void parse_logical_and(evalinfo_T *info, value_T *result) { bool saveparseonly = info->parseonly; parse_inclusive_or(info, result); while (info->token.type == TT_AMPAMP) { bool value, valid = true; coerce_number(info, result); next_token(info); switch (result->type) { case VT_INVALID: valid = false, value = false; break; case VT_LONG: value = result->v_long; break; case VT_DOUBLE: value = result->v_double; break; default: assert(false); } info->parseonly |= !value; parse_inclusive_or(info, result); coerce_number(info, result); if (value) switch (result->type) { case VT_INVALID: valid = false; break; case VT_LONG: value = result->v_long; break; case VT_DOUBLE: value = result->v_double; break; default: assert(false); } if (valid) result->type = VT_LONG, result->v_long = value; else result->type = VT_INVALID; } info->parseonly = saveparseonly; } /* Parses an inclusive OR expression. * InclusiveOrExp := ExclusiveOrExp | InclusiveOrExp "|" ExclusiveOrExp */ void parse_inclusive_or(evalinfo_T *info, value_T *result) { parse_exclusive_or(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_PIPE: next_token(info); parse_exclusive_or(info, &rhs); coerce_integer(info, result); coerce_integer(info, &rhs); if (result->type == VT_LONG && rhs.type == VT_LONG) { result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); } else { result->type = VT_INVALID; } break; default: return; } } } /* Parses an exclusive OR expression. * ExclusiveOrExp := AndExp | ExclusiveOrExp "^" AndExp */ void parse_exclusive_or(evalinfo_T *info, value_T *result) { parse_and(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_HAT: next_token(info); parse_and(info, &rhs); coerce_integer(info, result); coerce_integer(info, &rhs); if (result->type == VT_LONG && rhs.type == VT_LONG) { result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); } else { result->type = VT_INVALID; } break; default: return; } } } /* Parses an AND expression. * AndExp := EqualityExp | AndExp "&" EqualityExp */ void parse_and(evalinfo_T *info, value_T *result) { parse_equality(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_AMP: next_token(info); parse_equality(info, &rhs); coerce_integer(info, result); coerce_integer(info, &rhs); if (result->type == VT_LONG && rhs.type == VT_LONG) { result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); } else { result->type = VT_INVALID; } break; default: return; } } } /* Parses an equality expression. * EqualityExp := RelationalExp * | EqualityExp "==" RelationalExp * | EqualityExp "!=" RelationalExp */ void parse_equality(evalinfo_T *info, value_T *result) { parse_relational(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_EQUALEQUAL: case TT_EXCLEQUAL: next_token(info); parse_relational(info, &rhs); switch (coerce_type(info, result, &rhs)) { case VT_LONG: result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); break; case VT_DOUBLE: result->v_long = do_double_comparison(ttype, result->v_double, rhs.v_double); result->type = VT_LONG; break; case VT_INVALID: result->type = VT_INVALID; break; case VT_VAR: assert(false); } break; default: return; } } } /* Parses a relational expression. * RelationalExp := ShiftExp * | RelationalExp "<" ShiftExp * | RelationalExp ">" ShiftExp * | RelationalExp "<=" ShiftExp * | RelationalExp ">=" ShiftExp */ void parse_relational(evalinfo_T *info, value_T *result) { parse_shift(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_LESS: case TT_LESSEQUAL: case TT_GREATER: case TT_GREATEREQUAL: next_token(info); parse_shift(info, &rhs); switch (coerce_type(info, result, &rhs)) { case VT_LONG: result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); break; case VT_DOUBLE: result->v_long = do_double_comparison(ttype, result->v_double, rhs.v_double); result->type = VT_LONG; break; case VT_INVALID: result->type = VT_INVALID; break; case VT_VAR: assert(false); } break; default: return; } } } /* Parses a shift expression. * ShiftExp := AdditiveExp * | ShiftExp "<<" AdditiveExp | ShiftExp ">>" AdditiveExp */ void parse_shift(evalinfo_T *info, value_T *result) { parse_additive(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_LESSLESS: case TT_GREATERGREATER: next_token(info); parse_additive(info, &rhs); coerce_integer(info, result); coerce_integer(info, &rhs); if (result->type == VT_LONG && rhs.type == VT_LONG) { result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); } else { result->type = VT_INVALID; } break; default: return; } } } /* Parses an additive expression. * AdditiveExp := MultiplicativeExp * | AdditiveExp "+" MultiplicativeExp * | AdditiveExp "-" MultiplicativeExp */ void parse_additive(evalinfo_T *info, value_T *result) { parse_multiplicative(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_PLUS: case TT_MINUS: next_token(info); parse_multiplicative(info, &rhs); switch (coerce_type(info, result, &rhs)) { case VT_LONG: result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); break; case VT_DOUBLE: result->v_double = do_double_calculation(ttype, result->v_double, rhs.v_double); break; case VT_INVALID: result->type = VT_INVALID; break; case VT_VAR: assert(false); } break; default: return; } } } /* Parses a multiplicative expression. * MultiplicativeExp := PrefixExp * | MultiplicativeExp "*" PrefixExp * | MultiplicativeExp "/" PrefixExp * | MultiplicativeExp "%" PrefixExp */ void parse_multiplicative(evalinfo_T *info, value_T *result) { parse_prefix(info, result); for (;;) { tokentype_T ttype = info->token.type; value_T rhs; switch (ttype) { case TT_ASTER: case TT_SLASH: case TT_PERCENT: next_token(info); parse_prefix(info, &rhs); switch (coerce_type(info, result, &rhs)) { case VT_LONG: if (ttype != TT_ASTER && rhs.v_long == 0) { xerror(0, Ngt("arithmetic: division by zero")); info->error = true; result->type = VT_INVALID; break; } result->v_long = do_long_calculation(ttype, result->v_long, rhs.v_long); break; case VT_DOUBLE: #if DOUBLE_DIVISION_BY_ZERO_ERROR if (ttype != TT_ASTER && rhs.v_double == 0.0) { xerror(0, Ngt("arithmetic: division by zero")); info->error = true; result->type = VT_INVALID; break; } #endif result->v_double = do_double_calculation(ttype, result->v_double, rhs.v_double); break; case VT_INVALID: result->type = VT_INVALID; break; case VT_VAR: assert(false); } break; default: return; } } } /* Parses a prefix expression. * PrefixExp := PostfixExp * | "++" PrefixExp | "--" PrefixExp * | "+" PrefixExp | "-" PrefixExp * | "~" PrefixExp | "!" PrefixExp */ void parse_prefix(evalinfo_T *info, value_T *result) { tokentype_T ttype = info->token.type; switch (ttype) { case TT_PLUSPLUS: case TT_MINUSMINUS: next_token(info); parse_prefix(info, result); if (posixly_correct) { xerror(0, Ngt("arithmetic: operator `%ls' is not supported"), (ttype == TT_PLUSPLUS) ? L"++" : L"--"); info->error = true; result->type = VT_INVALID; } else if (result->type == VT_VAR) { word_T saveword = result->v_var; coerce_number(info, result); do_increment_or_decrement(ttype, result); if (!do_assignment(&saveword, result)) info->error = true, result->type = VT_INVALID; } else if (result->type != VT_INVALID) { /* TRANSLATORS: This error message is shown when the operand of * the "++" or "--" operator is not a variable. */ xerror(0, Ngt("arithmetic: operator `%ls' requires a variable"), (info->token.type == TT_PLUSPLUS) ? L"++" : L"--"); info->error = true; result->type = VT_INVALID; } break; case TT_PLUS: case TT_MINUS: next_token(info); parse_prefix(info, result); coerce_number(info, result); if (ttype == TT_MINUS) { switch (result->type) { case VT_LONG: result->v_long = -result->v_long; break; case VT_DOUBLE: result->v_double = -result->v_double; break; case VT_INVALID: break; default: assert(false); } } break; case TT_TILDE: next_token(info); parse_prefix(info, result); coerce_integer(info, result); if (result->type == VT_LONG) result->v_long = ~result->v_long; break; case TT_EXCL: next_token(info); parse_prefix(info, result); coerce_number(info, result); switch (result->type) { case VT_LONG: result->v_long = !result->v_long; break; case VT_DOUBLE: result->type = VT_LONG; result->v_long = !result->v_double; break; case VT_INVALID: break; default: assert(false); } break; default: parse_postfix(info, result); break; } } /* Parses a postfix expression. * PostfixExp := PrimaryExp * | PostfixExp "++" | PostfixExp "--" */ void parse_postfix(evalinfo_T *info, value_T *result) { parse_primary(info, result); for (;;) { switch (info->token.type) { case TT_PLUSPLUS: case TT_MINUSMINUS: if (posixly_correct) { xerror(0, Ngt("arithmetic: operator `%ls' is not supported"), (info->token.type == TT_PLUSPLUS) ? L"++" : L"--"); info->error = true; result->type = VT_INVALID; } else if (result->type == VT_VAR) { word_T saveword = result->v_var; coerce_number(info, result); value_T value = *result; do_increment_or_decrement(info->token.type, &value); if (!do_assignment(&saveword, &value)) { info->error = true; result->type = VT_INVALID; } } else if (result->type != VT_INVALID) { xerror(0, Ngt("arithmetic: " "operator `%ls' requires a variable"), (info->token.type == TT_PLUSPLUS) ? L"++" : L"--"); info->error = true; result->type = VT_INVALID; } next_token(info); break; default: return; } } } /* Increment or decrement the specified value. * `ttype' must be either TT_PLUSPLUS or TT_MINUSMINUS and the `value' must be * `coerce_number'ed. */ void do_increment_or_decrement(tokentype_T ttype, value_T *value) { if (ttype == TT_PLUSPLUS) { switch (value->type) { case VT_LONG: value->v_long++; break; case VT_DOUBLE: value->v_double++; break; case VT_INVALID: break; default: assert(false); } } else { switch (value->type) { case VT_LONG: value->v_long--; break; case VT_DOUBLE: value->v_double--; break; case VT_INVALID: break; default: assert(false); } } } /* Parses a primary expression. * PrimaryExp := "(" AssignmentExp ")" | Number | Identifier */ void parse_primary(evalinfo_T *info, value_T *result) { switch (info->token.type) { case TT_LPAREN: next_token(info); parse_assignment(info, result); if (info->token.type == TT_RPAREN) { next_token(info); } else { xerror(0, Ngt("arithmetic: `%ls' is missing"), L")"); info->error = true; result->type = VT_INVALID; } break; case TT_NUMBER: parse_as_number(info, result); next_token(info); break; case TT_IDENTIFIER: result->type = VT_VAR; result->v_var = info->token.word; next_token(info); break; default: xerror(0, Ngt("arithmetic: a value is missing")); info->error = true; result->type = VT_INVALID; break; } if (info->parseonly) result->type = VT_INVALID; } /* Parses the current word as a number literal. */ void parse_as_number(evalinfo_T *info, value_T *result) { word_T *word = &info->token.word; wchar_t wordstr[word->length + 1]; wcsncpy(wordstr, word->contents, word->length); wordstr[word->length] = L'\0'; long longresult; if (xwcstol(wordstr, 0, &longresult)) { result->type = VT_LONG; result->v_long = longresult; return; } if (!posixly_correct) { double doubleresult; wchar_t *end; setlocale(LC_NUMERIC, "C"); errno = 0; doubleresult = wcstod(wordstr, &end); bool ok = (errno == 0 && *end == L'\0'); setlocale(LC_NUMERIC, info->savelocale); if (ok) { result->type = VT_DOUBLE; result->v_double = doubleresult; return; } } xerror(0, Ngt("arithmetic: `%ls' is not a valid number"), wordstr); info->error = true; result->type = VT_INVALID; } /* If the value is of the VT_VAR type, change it into VT_LONG/VT_DOUBLE. * If the variable specified by the value is unset, it is assumed 0. * On parse error, false is returned and the value is unspecified. */ void coerce_number(evalinfo_T *info, value_T *value) { if (value->type != VT_VAR) return; const wchar_t *varvalue; { word_T *name = &value->v_var; wchar_t namestr[name->length + 1]; wmemcpy(namestr, name->contents, name->length); namestr[name->length] = L'\0'; varvalue = getvar(namestr); } if (varvalue == NULL || varvalue[0] == L'\0') { value->type = VT_LONG; value->v_long = 0; return; } long longresult; if (xwcstol(varvalue, 0, &longresult)) { value->type = VT_LONG; value->v_long = longresult; return; } if (!posixly_correct) { double doubleresult; wchar_t *end; errno = 0; doubleresult = wcstod(varvalue, &end); if (errno == 0 && *end == L'\0') { value->type = VT_DOUBLE; value->v_double = doubleresult; return; } } xerror(0, Ngt("arithmetic: `%ls' is not a valid number"), varvalue); info->error = true; value->type = VT_INVALID; return; } /* Does `coerce_number' and if the result is of VT_DOUBLE, converts into * VT_LONG. */ void coerce_integer(evalinfo_T *info, value_T *value) { coerce_number(info, value); if (value->type == VT_DOUBLE) { value->type = VT_LONG; value->v_long = (long) value->v_double; } } /* Unifies the types of the numeric values. * First, the given values are `coerce_number'ed. * Then, if one of the values is of VT_LONG and the other is of VT_DOUBLE, the * VT_LONG value is converted into VT_DOUBLE. * If the both values are of VT_LONG, VT_LONG is returned without conversion. * If either value is of VT_DOUBLE and the other is not VT_INVALID, VT_DOUBLE * is returned after conversion. If either value is VT_INVALID, the return * value is VT_INVALID. This function never returns VT_VAR. */ valuetype_T coerce_type(evalinfo_T *info, value_T *value1, value_T *value2) { coerce_number(info, value1); coerce_number(info, value2); if (value1->type == value2->type) return value1->type; if (value1->type == VT_INVALID || value2->type == VT_INVALID) return VT_INVALID; assert(value1->type == VT_LONG || value1->type == VT_DOUBLE); assert(value2->type == VT_LONG || value2->type == VT_DOUBLE); value_T *value_to_coerce = (value1->type == VT_LONG) ? value1 : value2; value_to_coerce->type = VT_DOUBLE; value_to_coerce->v_double = (double) value_to_coerce->v_long; return VT_DOUBLE; } /* Moves to the next token. * The contents of `*info' is updated. * If there is no more token, `info->index' indicates the terminating null char * and a TT_NULL token is returned. On error, TT_INVALID is returned. */ void next_token(evalinfo_T *info) { /* skip spaces */ while (iswspace(info->exp[info->index])) info->index++; wchar_t c = info->exp[info->index]; switch (c) { case L'\0': info->token.type = TT_NULL; return; case L'(': info->token.type = TT_LPAREN; info->index++; break; case L')': info->token.type = TT_RPAREN; info->index++; break; case L'~': info->token.type = TT_TILDE; info->index++; break; case L'!': switch (info->exp[info->index + 1]) { case L'=': info->token.type = TT_EXCLEQUAL; info->index += 2; break; default: info->token.type = TT_EXCL; info->index += 1; break; } break; case L'%': switch (info->exp[info->index + 1]) { case L'=': info->token.type = TT_PERCENTEQUAL; info->index += 2; break; default: info->token.type = TT_PERCENT; info->index += 1; break; } break; case L'+': switch (info->exp[info->index + 1]) { case L'+': info->token.type = TT_PLUSPLUS; info->index += 2; break; case L'=': info->token.type = TT_PLUSEQUAL; info->index += 2; break; default: info->token.type = TT_PLUS; info->index += 1; break; } break; case L'-': switch (info->exp[info->index + 1]) { case L'-': info->token.type = TT_MINUSMINUS; info->index += 2; break; case L'=': info->token.type = TT_MINUSEQUAL; info->index += 2; break; default: info->token.type = TT_MINUS; info->index += 1; break; } break; case L'*': switch (info->exp[info->index + 1]) { case L'=': info->token.type = TT_ASTEREQUAL; info->index += 2; break; default: info->token.type = TT_ASTER; info->index += 1; break; } break; case L'/': switch (info->exp[info->index + 1]) { case L'=': info->token.type = TT_SLASHEQUAL; info->index += 2; break; default: info->token.type = TT_SLASH; info->index += 1; break; } break; case L'<': { info->index++; bool twin = info->exp[info->index] == L'<'; if (twin) info->index++; bool equal = info->exp[info->index] == L'='; if (equal) info->index++; info->token.type = twin ? equal ? TT_LESSLESSEQUAL : TT_LESSLESS : equal ? TT_LESSEQUAL : TT_LESS; } break; case L'>': { info->index++; bool twin = info->exp[info->index] == L'>'; if (twin) info->index++; bool equal = info->exp[info->index] == L'='; if (equal) info->index++; info->token.type = twin ? equal ? TT_GREATERGREATEREQUAL : TT_GREATERGREATER : equal ? TT_GREATEREQUAL : TT_GREATER; } break; case L'=': switch (info->exp[info->index + 1]) { case L'=': info->token.type = TT_EQUALEQUAL; info->index += 2; break; default: info->token.type = TT_EQUAL; info->index += 1; break; } break; case L'&': switch (info->exp[info->index + 1]) { case L'&': info->token.type = TT_AMPAMP; info->index += 2; break; case L'=': info->token.type = TT_AMPEQUAL; info->index += 2; break; default: info->token.type = TT_AMP; info->index += 1; break; } break; case L'|': switch (info->exp[info->index + 1]) { case L'|': info->token.type = TT_PIPEPIPE; info->index += 2; break; case L'=': info->token.type = TT_PIPEEQUAL; info->index += 2; break; default: info->token.type = TT_PIPE; info->index += 1; break; } break; case L'^': switch (info->exp[info->index + 1]) { case L'=': info->token.type = TT_HATEQUAL; info->index += 2; break; default: info->token.type = TT_HAT; info->index += 1; break; } break; case L'?': info->token.type = TT_QUESTION; info->index++; break; case L':': info->token.type = TT_COLON; info->index++; break; case L'_': goto parse_identifier; default: assert(!iswspace(c)); if (c == L'.' || iswdigit(c)) { /* number */ size_t startindex = info->index; parse_num: do c = info->exp[++info->index]; while (c == L'.' || iswalnum(c)); if (c == L'+' || c == L'-') { c = info->exp[info->index - 1]; if (c == L'E' || c == L'e') goto parse_num; } info->token.type = TT_NUMBER; info->token.word.contents = &info->exp[startindex]; info->token.word.length = info->index - startindex; } else if (iswalpha(c)) { parse_identifier:; size_t startindex = info->index; do c = info->exp[++info->index]; while (c == L'_' || iswalnum(c)); info->token.type = TT_IDENTIFIER; info->token.word.contents = &info->exp[startindex]; info->token.word.length = info->index - startindex; } else { xerror(0, Ngt("arithmetic: `%lc' is not " "a valid number or operator"), (wint_t) c); info->error = true; info->token.type = TT_INVALID; } break; } } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtin.c0000644000175000017500000004465412154557026014375 0ustar magicantmagicant/* Yash: yet another shell */ /* builtin.c: built-in commands */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "builtin.h" #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #if YASH_ENABLE_ALIAS # include "alias.h" #endif #include "exec.h" #include "hashtable.h" #if YASH_ENABLE_HISTORY # include "history.h" #endif #include "job.h" #include "option.h" #include "path.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" #include "xfnmatch.h" #include "yash.h" #if YASH_ENABLE_PRINTF # include "builtins/printf.h" #endif #if YASH_ENABLE_TEST # include "builtins/test.h" #endif #if YASH_ENABLE_ULIMIT # include "builtins/ulimit.h" #endif #if YASH_ENABLE_LINEEDIT # include "lineedit/complete.h" # include "lineedit/keymap.h" #endif /* Rules about built-in commands: * - `argc' passed to a built-in is at least one; The command name is given in * `argv[0]'. * - `argv' may be rearranged and the values of the argument strings may be * changed in the built-in. However, the argument strings may not be `free'd * or `realloc'ed. * - Built-ins may sleep or wait, but cannot be stopped. */ /* A hashtable from names of built-ins (const char *) to built-in info * structures (const builtin_T *). */ static hashtable_T builtins; /* Initializes `builtins' */ void init_builtin(void) { assert(builtins.capacity == 0); ht_initwithcapacity(&builtins, hashstr, htstrcmp, 53); #if YASH_ENABLE_HELP # define DEFBUILTIN(name,func,type,help,syntax,options) \ do { \ static const builtin_T bi = { func, type, help, syntax, options, }; \ ht_set(&builtins, name, &bi); \ } while (0) #else # define DEFBUILTIN(name,func,type,help,syntax,options) \ do { \ static const builtin_T bi = { func, type, }; \ ht_set(&builtins, name, &bi); \ } while (0) #endif /* defined in "builtin.c" */ DEFBUILTIN(":", true_builtin, BI_SPECIAL, colon_help, colon_syntax, NULL); DEFBUILTIN("true", true_builtin, BI_SEMISPECIAL, true_help, true_syntax, NULL); DEFBUILTIN("false", false_builtin, BI_SEMISPECIAL, false_help, false_syntax, NULL); #if YASH_ENABLE_HELP DEFBUILTIN("help", help_builtin, BI_REGULAR, help_help, help_syntax, help_option); #endif /* defined in "option.c" */ DEFBUILTIN("set", set_builtin, BI_SPECIAL, set_help, set_syntax, NULL); /* defined in "path.c" */ DEFBUILTIN("cd", cd_builtin, BI_SEMISPECIAL, cd_help, cd_syntax, cd_options); DEFBUILTIN("pwd", pwd_builtin, BI_SEMISPECIAL, pwd_help, pwd_syntax, pwd_options); DEFBUILTIN("hash", hash_builtin, BI_REGULAR, hash_help, hash_syntax, hash_options); DEFBUILTIN("umask", umask_builtin, BI_SEMISPECIAL, umask_help, umask_syntax, umask_options); /* defined in "alias.c" */ #if YASH_ENABLE_ALIAS DEFBUILTIN("alias", alias_builtin, BI_SEMISPECIAL, alias_help, alias_syntax, alias_options); DEFBUILTIN("unalias", unalias_builtin, BI_SEMISPECIAL, unalias_help, unalias_syntax, all_help_options); #endif /* defined in "variable.c" */ DEFBUILTIN("typeset", typeset_builtin, BI_REGULAR, typeset_help, typeset_syntax, typeset_options); DEFBUILTIN("export", typeset_builtin, BI_SPECIAL, export_help, export_syntax, typeset_options); DEFBUILTIN("readonly", typeset_builtin, BI_SPECIAL, readonly_help, readonly_syntax, typeset_options); #if YASH_ENABLE_ARRAY DEFBUILTIN("array", array_builtin, BI_REGULAR, array_help, array_syntax, array_options); #endif DEFBUILTIN("unset", unset_builtin, BI_SPECIAL, unset_help, unset_syntax, unset_options); DEFBUILTIN("shift", shift_builtin, BI_SPECIAL, shift_help, shift_syntax, help_option); DEFBUILTIN("getopts", getopts_builtin, BI_SEMISPECIAL, getopts_help, getopts_syntax, help_option); DEFBUILTIN("read", read_builtin, BI_SEMISPECIAL, read_help, read_syntax, read_options); #if YASH_ENABLE_DIRSTACK DEFBUILTIN("pushd", pushd_builtin, BI_REGULAR, pushd_help, pushd_syntax, pushd_options); DEFBUILTIN("popd", popd_builtin, BI_REGULAR, popd_help, popd_syntax, help_option); DEFBUILTIN("dirs", dirs_builtin, BI_REGULAR, dirs_help, dirs_syntax, dirs_options); #endif /* defined in "sig.c" */ DEFBUILTIN("trap", trap_builtin, BI_SPECIAL, trap_help, trap_syntax, trap_options); DEFBUILTIN("kill", kill_builtin, BI_SEMISPECIAL, kill_help, kill_syntax, NULL); /* defined in "job.c" */ DEFBUILTIN("jobs", jobs_builtin, BI_SEMISPECIAL, jobs_help, jobs_syntax, jobs_options); DEFBUILTIN("fg", fg_builtin, BI_SEMISPECIAL, fg_help, fg_syntax, help_option); DEFBUILTIN("bg", fg_builtin, BI_SEMISPECIAL, bg_help, bg_syntax, help_option); DEFBUILTIN("wait", wait_builtin, BI_SEMISPECIAL, wait_help, wait_syntax, help_option); DEFBUILTIN("disown", disown_builtin, BI_REGULAR, disown_help, disown_syntax, all_help_options); /* defined in "history.c" */ #if YASH_ENABLE_HISTORY DEFBUILTIN("fc", fc_builtin, BI_SEMISPECIAL, fc_help, fc_syntax, fc_options); DEFBUILTIN("history", history_builtin, BI_REGULAR, history_help, history_syntax, history_options); #endif /* defined in "exec.c" */ DEFBUILTIN("return", return_builtin, BI_SPECIAL, return_help, return_syntax, return_options); DEFBUILTIN("break", break_builtin, BI_SPECIAL, break_help, break_syntax, iter_options); DEFBUILTIN("continue", break_builtin, BI_SPECIAL, continue_help, continue_syntax, iter_options); DEFBUILTIN("eval", eval_builtin, BI_SPECIAL, eval_help, eval_syntax, iter_options); DEFBUILTIN(".", dot_builtin, BI_SPECIAL, dot_help, dot_syntax, dot_options); DEFBUILTIN("exec", exec_builtin, BI_SPECIAL, exec_help, exec_syntax, exec_options); DEFBUILTIN("command", command_builtin, BI_SEMISPECIAL, command_help, command_syntax, command_options); DEFBUILTIN("type", command_builtin, BI_REGULAR, type_help, type_syntax, command_options); DEFBUILTIN("times", times_builtin, BI_SPECIAL, times_help, times_syntax, help_option); /* defined in "yash.c" */ DEFBUILTIN("exit", exit_builtin, BI_SPECIAL, exit_help, exit_syntax, force_help_options); DEFBUILTIN("suspend", suspend_builtin, BI_REGULAR, suspend_help, suspend_syntax, force_help_options); /* defined in "builtins/ulimit.c" */ #if YASH_ENABLE_ULIMIT DEFBUILTIN("ulimit", ulimit_builtin, BI_REGULAR, ulimit_help, ulimit_syntax, ulimit_options); #endif /* defined in "builtins/printf.c" */ #if YASH_ENABLE_PRINTF DEFBUILTIN("echo", echo_builtin, BI_REGULAR, echo_help, echo_syntax, NULL); DEFBUILTIN("printf", printf_builtin, BI_REGULAR, printf_help, printf_syntax, help_option); #endif /* defined in "builtins/test.c" */ #if YASH_ENABLE_TEST DEFBUILTIN("test", test_builtin, BI_REGULAR, test_help, test_syntax, NULL); DEFBUILTIN("[", test_builtin, BI_REGULAR, test_help, test_syntax, NULL); #endif /* defined in "lineedit/complete.c" */ #if YASH_ENABLE_LINEEDIT DEFBUILTIN("complete", complete_builtin, BI_REGULAR, complete_help, complete_syntax, complete_options); #endif /* defined in "lineedit/keymap.c" */ #if YASH_ENABLE_LINEEDIT DEFBUILTIN("bindkey", bindkey_builtin, BI_REGULAR, bindkey_help, bindkey_syntax, bindkey_options); #endif #undef DEFBUILTIN } /* Returns the built-in command of the specified name or NULL if not found. */ const builtin_T *get_builtin(const char *name) { return ht_get(&builtins, name).value; } /* Prints the following error message and returns Exit_ERROR: * "the -X option cannot be used with the -Y option", * where X and Y are `opt1' and `opt2', respectively. */ int mutually_exclusive_option_error(wchar_t opt1, wchar_t opt2) { xerror(0, Ngt("the -%lc option cannot be used with the -%lc option"), (wint_t) opt1, (wint_t) opt2); return Exit_ERROR; } /* Checks if the number of operands is in an acceptable range. * `max' must not be less than `min'. * If `min <= count <= max', returns true. * Otherwise, prints an error message and returns false. */ bool validate_operand_count(size_t count, size_t min, size_t max) { assert(min <= max); if (count < min) { insufficient_operands_error(min); return false; } else if (count > max) { too_many_operands_error(max); return false; } return true; } /* Prints the "this command requires an operand" error message and returns * Exit_ERROR. */ int insufficient_operands_error(size_t min_required_operand_count) { xerror(0, ngt("this command requires an operand", "this command requires %zu operands", min_required_operand_count), min_required_operand_count); return Exit_ERROR; } /* Prints the "too many operands" error message and returns Exit_ERROR. */ int too_many_operands_error(size_t max_accepted_operand_count) { if (max_accepted_operand_count == 0) /* TRANSLATORS: This message is printed when a command that takes no * operand was invoked with some operands. */ xerror(0, Ngt("no operand is expected")); else /* TRANSLATORS: This message is printed when a command was invoked with * the wrong number of operands. */ xerror(0, Ngt("too many operands are specified")); return Exit_ERROR; } /* This function is called when a syntax error occurred while executing a * special built-in. If `posixly_correct' and `special_builtin_executed' are * true and `is_interactive_now' is false, `exit_shell_with_status' is called * with `exitstatus'. Otherwise, this function just returns `exitstatus'. */ /* Even though this function is called only while executing a special built-in, * checking `special_builtin_executed' is necessary because * `exit_shell_with_status' should not be called if the special built-in is * being executed indirectly by a non-special built-in. */ int special_builtin_syntax_error(int exitstatus) { if (posixly_correct && special_builtin_executed && !is_interactive_now) exit_shell_with_status(exitstatus); return exitstatus; } #if YASH_ENABLE_HELP static int print_builtin_helps(void *const *builtin_names) __attribute__((nonnull)); static int print_builtin_help_body(const wchar_t *name) __attribute__((nonnull)); static bool print_builtin_options(const struct xgetopt_T *options); static bool there_is_any_short_option(const struct xgetopt_T *options) __attribute__((nonnull,pure)); static void format_option_list_entry( const struct xgetopt_T *restrict opt, xstrbuf_T *restrict buf, bool print_short_option) __attribute__((nonnull)); /* Prints description of the specified built-in to the standard output. * Returns Exit_SUCCESS if the built-in was found and the help was printed. * Returns Exit_FAILURE if the built-in was not found or an error occurred. */ int print_builtin_help(const wchar_t *name) { return print_builtin_helps((void *[]) { (void *) name, NULL, }); } /* Prints description of built-ins to the standard output. * `builtin_names' must point to a NULL-terminated array of pointers to wide * strings specifying the names of built-ins. * Returns Exit_SUCCESS if the built-in was found and the help was printed. * Returns Exit_FAILURE if the built-in was not found or an error occurred. */ int print_builtin_helps(void *const *builtin_names) { for (; *builtin_names != NULL; builtin_names++) if (print_builtin_help_body(*builtin_names) != Exit_SUCCESS) return Exit_FAILURE; if (!xprintf(gt("Try `man yash' for details.\n"))) return Exit_FAILURE; return Exit_SUCCESS; } /* Prints description of the specified built-in to the standard output. * Returns Exit_SUCCESS if the built-in was found and the help was printed. * Returns Exit_FAILURE if the built-in was not found or an error occurred. */ int print_builtin_help_body(const wchar_t *name) { char *mbsname = malloc_wcstombs(name); const builtin_T *bi = get_builtin(mbsname); free(mbsname); if (bi == NULL) { xerror(0, Ngt("no such built-in `%ls'"), name); return Exit_FAILURE; } if (!xprintf("%ls: %s\n\n", name, gt(bi->help_text))) return Exit_FAILURE; /* TRANSLATORS: This is printed before syntax info of a built-in. */ if (!xprintf(gt("Syntax:\n%s\n"), gt(bi->syntax_text))) return Exit_FAILURE; if (wcscmp(name, L"set") == 0) { if (!print_shopts(false)) return Exit_FAILURE; } else { if (!print_builtin_options(bi->options)) return Exit_FAILURE; } return Exit_SUCCESS; } /* Prints a list of all shell options to the standard output. * Returns true iff successful. */ bool print_shopts(bool include_normal_options) { /* TRANSLATORS: This text is printed before a list of options. */ if (!xprintf(gt("Options:\n"))) return false; if (!print_shopts_body(include_normal_options)) return false; if (!xprintf("\n")) return false; return true; } /* Prints a list of options for a built-in to the standard output. * Returns true iff successful. */ bool print_builtin_options(const struct xgetopt_T *options) { if (options == NULL || options[0].shortopt == L'\0') return true; /* TRANSLATORS: This text is printed before a list of options. */ if (!xprintf(gt("Options:\n"))) return false; if (!print_option_list(options)) return false; if (!xprintf("\n")) return false; return true; } /* Prints a list of options to the standard output. * Returns true iff successful. */ bool print_option_list(const struct xgetopt_T *options) { bool print_short_option = there_is_any_short_option(options); xstrbuf_T line; sb_init(&line); for (const struct xgetopt_T *opt = options; opt->shortopt != L'\0'; opt++) { if (posixly_correct && !opt->posix) continue; sb_clear(&line); format_option_list_entry(opt, &line, print_short_option); if (!xprintf("%s\n", line.contents)) { sb_destroy(&line); return false; } } sb_destroy(&line); return true; } bool there_is_any_short_option(const struct xgetopt_T *options) { for (const struct xgetopt_T *opt = options; opt->shortopt != L'\0'; opt++) if (opt->shortopt != L'-') return true; return false; } /* Formats a line that describes the specified option. * The results are appended to buffer `buf'. `buf' must have been initialized * before calling this function. `buf' must be destroyed by the caller. * If `print_short_option' is false, the single-character option is omitted. */ void format_option_list_entry( const struct xgetopt_T *restrict opt, xstrbuf_T *restrict buf, bool print_short_option) { sb_ccat(buf, '\t'); if (print_short_option && opt->shortopt != L'-') { const char *INIT(optargmark); switch (opt->optarg) { case OPTARG_NONE: optargmark = ""; break; case OPTARG_REQUIRED: optargmark = " ..."; break; case OPTARG_OPTIONAL: optargmark = "[...]"; break; } sb_printf(buf, "-%lc%s", opt->shortopt, optargmark); } if (opt->longopt != NULL) { if (print_short_option && buf->length < 10) sb_ccat_repeat(buf, ' ', 10 - buf->length); const char *INIT(optargmark); switch (opt->optarg) { case OPTARG_NONE: optargmark = ""; break; case OPTARG_REQUIRED: optargmark = "=..."; break; case OPTARG_OPTIONAL: optargmark = "[=...]"; break; } sb_printf(buf, "--%ls%s", opt->longopt, optargmark); } } #endif /* YASH_ENABLE_HELP */ #if YASH_ENABLE_LINEEDIT /* Generates completion candidates for built-in command names matching the * pattern. The CGT_SBUILTIN, CGT_SSBUILTIN, and CGT_RBUILTIN flags in * `compopt->type' specify what candidate to generate. The other flags are * ignored. */ /* The prototype of this function is declared in "lineedit/complete.h". */ void generate_builtin_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_BUILTIN)) return; le_compdebug("adding built-in command name candidates"); if (!le_compile_cpatterns(compopt)) return; size_t i = 0; kvpair_T kv; while ((kv = ht_next(&builtins, &i)).key != NULL) { le_candgentype_T type; switch (((const builtin_T *) kv.value)->type) { case BI_SPECIAL: type = CGT_SBUILTIN; break; case BI_SEMISPECIAL: type = CGT_SSBUILTIN; break; case BI_REGULAR: type = CGT_RBUILTIN; break; default: assert(false); } if (!(compopt->type & type)) continue; if (le_match_comppatterns(compopt, kv.key)) le_new_candidate(CT_COMMAND, malloc_mbstowcs(kv.key), NULL, compopt); } } #endif /* YASH_ENABLE_LINEEDIT */ /* The ":"/"true" built-in. */ int true_builtin( int argc __attribute__((unused)), void **argv __attribute__((unused))) { return EXIT_SUCCESS; } /* The "false" built-in. */ int false_builtin( int argc __attribute__((unused)), void **argv __attribute__((unused))) { return EXIT_FAILURE; } #if YASH_ENABLE_HELP const char colon_help[] = Ngt( "do nothing" ); const char colon_syntax[] = Ngt( "\t: [...]\n" ); const char true_help[] = Ngt( "do nothing successfully" ); const char true_syntax[] = Ngt( "\ttrue\n" ); const char false_help[] = Ngt( "do nothing unsuccessfully" ); const char false_syntax[] = Ngt( "\tfalse\n" ); /* The "help" built-in. */ int help_builtin(int argc, void **argv) { const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, 0)) != NULL) { switch (opt->shortopt) { case L'-': goto print_help; default: return Exit_ERROR; } } if (xoptind == argc) print_help: return print_builtin_help(ARGV(0)); return print_builtin_helps(&argv[xoptind]); } const char help_help[] = Ngt( "print usage of built-in commands" ); const char help_syntax[] = Ngt( "\thelp [built-in...]\n" ); #endif /* YASH_ENABLE_HELP */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/mail.d0000644000175000017500000000020712154557026013634 0ustar magicantmagicantmail.o: mail.c common.h config.h mail.h expand.h hashtable.h option.h \ xgetopt.h parser.h input.h plist.h strbuf.h util.h variable.h yash-2.35/xfnmatch.h0000644000175000017500000000421012154557026014524 0ustar magicantmagicant/* Yash: yet another shell */ /* xfnmatch.h: regex matching wrapper as a replacement for fnmatch */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_XFNMATCH_H #define YASH_XFNMATCH_H #include typedef struct xfnmatch_T xfnmatch_T; typedef enum { XFNM_SHORTEST = 1 << 0, XFNM_HEADONLY = 1 << 1, XFNM_TAILONLY = 1 << 2, XFNM_PERIOD = 1 << 3, XFNM_CASEFOLD = 1 << 4, XFNM_compiled = 1 << 5, XFNM_headstar = 1 << 6, XFNM_tailstar = 1 << 7, } xfnmflags_T; typedef struct { size_t start, end; } xfnmresult_T; extern _Bool is_matching_pattern(const wchar_t *pat) __attribute__((pure,nonnull)); extern _Bool is_pathname_matching_pattern(const wchar_t *pat) __attribute__((pure,nonnull)); extern xfnmatch_T *xfnm_compile(const wchar_t *pat, xfnmflags_T flags) __attribute__((malloc,warn_unused_result,nonnull)); extern int xfnm_match( const xfnmatch_T *restrict xfnm, const char *restrict s) __attribute__((nonnull)); extern xfnmresult_T xfnm_wmatch( const xfnmatch_T *restrict xfnm, const wchar_t *restrict s) __attribute__((nonnull)); extern wchar_t *xfnm_subst( const xfnmatch_T *restrict xfnm, const wchar_t *restrict s, const wchar_t *restrict repl, _Bool substall) __attribute__((malloc,warn_unused_result,nonnull)); extern void xfnm_free(xfnmatch_T *xfnm); #if YASH_ENABLE_TEST extern _Bool match_regex(const wchar_t *s, const wchar_t *regex) __attribute__((nonnull)); #endif #endif /* YASH_XFNMATCH_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/mail.h0000644000175000017500000000155712154557026013651 0ustar magicantmagicant/* Yash: yet another shell */ /* mail.h: mail checking */ /* (C) 2007-2009 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_MAIL_H #define YASH_MAIL_H void check_mail(void); #endif /* YASH_MAIL_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/xgetopt.h0000644000175000017500000000251512154557026014414 0ustar magicantmagicant/* Yash: yet another shell */ /* xgetopt.h: command option parser */ /* (C) 2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_XGETOPT_H #define YASH_XGETOPT_H #include extern wchar_t *xoptarg; extern int xoptind; enum xgetoptopt_T { XGETOPT_POSIX = 1 << 0, XGETOPT_DIGIT = 1 << 1, }; enum optarg_T { OPTARG_NONE, OPTARG_REQUIRED, OPTARG_OPTIONAL, }; struct xgetopt_T { wchar_t shortopt; const wchar_t *longopt; enum optarg_T optarg; _Bool posix; void *ptr; }; extern struct xgetopt_T *xgetopt( void **restrict argv_, const struct xgetopt_T *restrict opts_, enum xgetoptopt_T getoptopt_) __attribute__((nonnull)); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/history.h0000644000175000017500000000624712154557026014431 0ustar magicantmagicant/* Yash: yet another shell */ /* history.h: command history management */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_HISTORY_H #define YASH_HISTORY_H #include #include #include "xgetopt.h" /* The structure type of doubly-linked list node. */ typedef struct histlink_T { struct histlink_T *prev, *next; } histlink_T; /* `prev' and `next' are always non-NULL: the newest entry's `next' and the * oldest entry's `prev' point to `histlist'. */ /* The structure type of history entries. */ typedef struct histentry_T { histlink_T link; unsigned number; time_t time; char value[]; } histentry_T; #define Prev link.prev #define Next link.next /* The value is stored as a multibyte string rather than a wide string to save * memory space. The value must not contain newlines. */ /* Basically the `number' is increased for each entry, but the numbers are * limited to some extent. If the number exceeds the limit, it is wrapped * around to 1, so a newer entry may have a smaller number than an older entry. * The limit is no less than $HISTSIZE, so all the entries have different * numbers anyway. */ /* When the time is unknown, `time' is -1. */ /* The structure type of the history list. */ typedef struct histlist_T { histlink_T link; unsigned count; } histlist_T; #define Newest link.prev #define Oldest link.next extern histlist_T histlist; #define Histlist (&histlist.link) /* Casts a pointer to `histlink_T' into a pointer to `histentry_T'. */ static inline histentry_T *ashistentry(const histlink_T *link) { #ifdef assert assert(link != &histlist.link); #endif return (histentry_T *) link; } extern unsigned next_history_number(void) __attribute__((pure)); extern void maybe_init_history(void); extern void finalize_history(void); extern void close_history_file(void); extern void add_history(const wchar_t *line) __attribute__((nonnull)); const histlink_T *get_history_entry(unsigned number) __attribute__((pure)); #if YASH_ENABLE_LINEEDIT extern void start_using_history(void); extern void end_using_history(void); #endif extern int fc_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char fc_help[], fc_syntax[]; #endif extern const struct xgetopt_T fc_options[]; extern int history_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char history_help[], history_syntax[]; #endif extern const struct xgetopt_T history_options[]; #endif /* YASH_HISTORY_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/redir.d0000644000175000017500000000020612154557026014016 0ustar magicantmagicantredir.o: redir.c common.h config.h redir.h exec.h xgetopt.h expand.h \ input.h option.h parser.h path.h sig.h strbuf.h util.h yash.h yash-2.35/README.ja0000644000175000017500000000742512154557026014027 0ustar magicantmagicantYash: yet another shell http://yash.sourceforge.jp/ ======================= Yash 㯠POSIX.1 (IEEE Std 1003.1, 2008 Edition) è¦æ ¼ã« (ã»ã¼) 準拠ã—㦠ã„るコマンドラインシェルã§ã™ã€‚Bash ã‚„ ksh ãªã©ã®ä»–ã®ã‚·ã‚§ãƒ«ã‚ˆã‚Šã‚‚より厳 密ã«è¦æ ¼ã«æº–æ‹ ã—ã¦ã„ã¾ã™ã€‚ POSIX ã§å®šã‚ã‚‰ã‚ŒãŸæ©Ÿèƒ½ã®ä»–ã«ã‚‚ yash ã¯ä»¥ä¸‹ã®ã‚ˆã†ãªæ©Ÿèƒ½ã‚’å‚™ãˆã¦ã„ã¾ã™ * グローãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ * 乱数 * ソケットリダイレクト等ã®ç‰¹æ®Šãªãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ * å³ãƒ—ロンプト * コマンドライン補完 Yash 㯠GNU General Public License (GPL) version 2 ã®å…ƒã§é…布ã•れるフ リーソフトウェアã§ã™ã€‚GPL ã«å¾“ã†é™ã‚Šã‚ãªãŸã¯æœ¬ã‚½ãƒ•トウェアを自由ã«è¤‡è£½ ・改変・使用・é…布ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ãŒã€ä¸€åˆ‡ã®ä¿è¨¼ã¯ã‚りã¾ã›ã‚“。 GPL ã®æœ¬æ–‡ã«ã¤ã„ã¦ã¯ COPYING ファイルをå‚ç…§ã—ã¦ãã ã•ã„。 Yash をビルドã—インストールã™ã‚‹æ–¹æ³•ã«ã¤ã„ã¦ã¯ INSTALL.ja ãƒ•ã‚¡ã‚¤ãƒ«ã‚’å‚ ç…§ã—ã¦ãã ã•ã„。 ===== å®Ÿè£…ä¸Šã®æ³¨æ„事項 ===== * C 言語ã§ã¯ã€ãƒŠãƒ«æ–‡å­—ã¯æ–‡å­—列ã®çµ‚ã‚りを表ã—ã¾ã™ã€‚ãã®ãŸã‚ã€å…¥åŠ›ã—㟠ファイルã®å†…容や文字列ã«ãƒŠãƒ«æ–‡å­—ãŒå«ã¾ã‚Œã¦ã„ã‚‹ã¨ãれ以é™ã®éƒ¨åˆ†ãŒæ­£ ã—ã処ç†ã•れãªããªã£ã¦ã—ã¾ã„ã¾ã™ã€‚ * 符å·ä»˜ãæ•´æ•°ã®æ¼”算・型変æ›ã«ãŠã„ã¦ã‚ªãƒ¼ãƒãƒ¼ãƒ•ローãŒç™ºç”Ÿã—ãŸå ´åˆã§ã‚‚ エラーã«ãªã‚‰ãšã« (処ç†ç³»å®šç¾©ã®) 何らã‹ã®æ•´æ•°å€¤ãŒè¿”ã•れるã“ã¨ã‚’仮定 ã—ã¦ã„ã¾ã™ã€‚ * ソース内ã®éšæ‰€ã§ GCC ã®æ‹¡å¼µæ©Ÿèƒ½ã§ã‚ã‚‹ __attribute__ キーワードを使 用ã—ã¦ã„ã¾ã™ã€‚GCC 以外ã®ç’°å¢ƒã§ã¯ãƒ—リプロセッサã«ã‚ˆã£ã¦æ¶ˆåŽ»ã™ã‚‹ã‚ˆã† ã«ã—ã¦ã„ã¾ã™ãŒã€__attribute__ 識別å­ã‚’ä»–ã®ç”¨é€”ã§ä½¿ç”¨ã—ã¦ã„る処ç†ç³» ã§ã¯ã‚³ãƒ³ãƒ‘ã‚¤ãƒ«ã«æ”¯éšœã‚’ããŸã™ã‹ã‚‚ã—れã¾ã›ã‚“。他ã«ã‚‚ã„ãã¤ã‹ '_' ã§å§‹ ã¾ã‚‹è­˜åˆ¥å­ã‚’使用ã—ã¦ã„ã‚‹ãŸã‚ã€éžå¸¸ã«ç‰¹æ®Šãªç’°å¢ƒã§ã¯æ­£ã—ãコンパイル ã§ããªã„ã‹ã‚‚ã—れã¾ã›ã‚“。 * ã„ãã¤ã‹ã®ã‚·ã‚°ãƒŠãƒ«ã¯ç‰¹å®šã®ç•ªå·ã‚’æŒã£ã¦ã„ã‚‹ã¨ä»®å®šã—ã¦ã„ã¾ã™: SIGHUP=1 SIGINT=2 SIGQUIT=3 SIGABRT=6 SIGKILL=9 SIGALRM=14 SIGTERM=15 * ファイルアクセス権フラグã¯ç‰¹å®šã®å€¤ã‚’æŒã£ã¦ã„ã‚‹ã¨ä»®å®šã—ã¦ã„ã¾ã™: 0400=user read 0200=user write 0100=user execute 0040=group read 0020=group write 0010=group execute 0004=other read 0002=other write 0001=other execute * POSIX ロケール以外ã®ãƒ­ã‚±ãƒ¼ãƒ«ã§ã®æ–‡å­—クラスã®åˆ†é¡žã¯ POSIX ロケール㧠ã®åˆ†é¡žã¨ä¸Šä½äº’æ›ã§ã‚ã‚‹ã¨ä»®å®šã—ã¦ã„ã¾ã™ã€‚ * -e (-o errexit) ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€and/or ãƒªã‚¹ãƒˆã®æœ€å¾Œã®ã‚³ãƒžãƒ³ãƒ‰ ãŒã‚¨ãƒ©ãƒ¼ã‚’è¿”ã™ã¨ã‚·ã‚§ãƒ«ã¯çµ‚了ã—ã¾ã™ã€‚ã“ã®æŒ™å‹•ã¯å޳坆ã«ã¯ POSIX ã«å¾“㣠ã¦ã„ã¾ã›ã‚“ãŒã€ä»–ã®æ—¢å­˜ã®ã‚·ã‚§ãƒ«ã®æŒ™å‹•ã«åˆã‚ã›ã¦ã“ã®ã‚ˆã†ã«ã—ã¦ã„ã¾ã™ã€‚ * -o nolog オプションã«ã¯å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“。(無視ã•れã¾ã™) * POSIX ã«ã‚ˆã‚‹ã¨ã€PS1 変数ã®å€¤ã¯ãƒ‘ラメータ展開ã•れるã“ã¨ã«ãªã£ã¦ã„ã¾ ã™ã€‚Yash ã§ã¯ã•ら㫠PS1 変数ã®å€¤ã«å¯¾ã—ã¦ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã¨æ•°å¼å±•開も行 ã„ã¾ã™ã€‚ã“れã¯å®Ÿè£…上ã®éƒ½åˆã«ã‚ˆã‚‹ã‚‚ã®ã§ã™ã€‚ * POSIX ã«ã‚ˆã‚‹ã¨ã€ã‚³ãƒžãƒ³ãƒ‰ `printf %c foo' ã¯æ–‡å­—列 `foo' ã®æœ€åˆã®ãƒ イトを出力ã™ã‚‹ã“ã¨ã«ãªã£ã¦ã„ã¾ã™ã€‚Yash ã§ã¯ `foo' ã®æœ€åˆã®æ–‡å­—を出 力ã™ã‚‹ã®ã§ã€å‡ºåŠ›ãŒè¤‡æ•°ãƒã‚¤ãƒˆã«ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ã€‚ ====================== Magicant æ„Ÿæƒ³ãƒ»ææ¡ˆãƒ»ãƒã‚°å ±å‘Šç­‰ã‚’歓迎ã—ã¾ã™ã€‚ãŸã ã—ã€å…¨ã¦ã®ææ¡ˆã‚„ãƒã‚°å ±å‘Šã« 応ã˜ã‚‹ã“ã¨ã‚’ç´„æŸã™ã‚‹ã‚‚ã®ã§ã¯ã‚りã¾ã›ã‚“。 yash-2.35/variable.h0000644000175000017500000001613012154557026014505 0ustar magicantmagicant/* Yash: yet another shell */ /* variable.h: deals with shell variables and parameters */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_VARIABLE_H #define YASH_VARIABLE_H #include #include "xgetopt.h" extern char **environ; /* variable names */ #define VAR_CDPATH "CDPATH" #define VAR_COLUMNS "COLUMNS" #define VAR_COMMAND_NOT_FOUND_HANDLER "COMMAND_NOT_FOUND_HANDLER" #define VAR_DIRSTACK "DIRSTACK" #define VAR_ECHO_STYLE "ECHO_STYLE" #define VAR_ENV "ENV" #define VAR_FCEDIT "FCEDIT" #define VAR_HANDLED "HANDLED" #define VAR_HISTFILE "HISTFILE" #define VAR_HISTRMDUP "HISTRMDUP" #define VAR_HISTSIZE "HISTSIZE" #define VAR_HOME "HOME" #define VAR_IFS "IFS" #define VAR_LANG "LANG" #define VAR_LC_ALL "LC_ALL" #define VAR_LC_COLLATE "LC_COLLATE" #define VAR_LC_CTYPE "LC_CTYPE" #define VAR_LC_MESSAGES "LC_MESSAGES" #define VAR_LC_MONETARY "LC_MONETARY" #define VAR_LC_NUMERIC "LC_NUMERIC" #define VAR_LC_TIME "LC_TIME" #define VAR_LINENO "LINENO" #define VAR_LINES "LINES" #define VAR_MAIL "MAIL" #define VAR_MAILCHECK "MAILCHECK" #define VAR_MAILPATH "MAILPATH" #define VAR_NLSPATH "NLSPATH" #define VAR_OLDPWD "OLDPWD" #define VAR_OPTARG "OPTARG" #define VAR_OPTIND "OPTIND" #define VAR_PATH "PATH" #define VAR_PPID "PPID" #define VAR_PROMPT_COMMAND "PROMPT_COMMAND" #define VAR_PS1 "PS1" #define VAR_PS2 "PS2" #define VAR_PS4 "PS4" #define VAR_PWD "PWD" #define VAR_RANDOM "RANDOM" #define VAR_TARGETWORD "TARGETWORD" #define VAR_TERM "TERM" #define VAR_WORDS "WORDS" #define VAR_YASH_AFTER_CD "YASH_AFTER_CD" #define VAR_YASH_LE_TIMEOUT "YASH_LE_TIMEOUT" #define VAR_YASH_LOADPATH "YASH_LOADPATH" #define VAR_YASH_VERSION "YASH_VERSION" #define L L"" struct variable_T; struct assign_T; struct command_T; typedef enum path_T { PA_PATH, PA_CDPATH, PA_LOADPATH, PA_count, } path_T; extern unsigned long current_lineno; extern void init_environment(void); extern void init_variables(void); extern char *get_exported_value(const wchar_t *name) __attribute__((nonnull,malloc,warn_unused_result)); typedef enum scope_T { SCOPE_GLOBAL, SCOPE_LOCAL, SCOPE_TEMP, } scope_T; extern _Bool set_variable( const wchar_t *name, wchar_t *value, scope_T scope, _Bool export) __attribute__((nonnull(1))); extern struct variable_T *set_array( const wchar_t *name, size_t count, void **values, scope_T scope, _Bool export) __attribute__((nonnull)); extern _Bool set_array_element( const wchar_t *name, size_t index, wchar_t *value) __attribute__((nonnull)); extern void set_positional_parameters(void *const *values) __attribute__((nonnull)); extern _Bool do_assignments( const struct assign_T *assigns, _Bool temp, _Bool export); struct get_variable_T { enum { GV_NOTFOUND, GV_SCALAR, GV_ARRAY, GV_ARRAY_CONCAT, } type; size_t count; void **values; _Bool freevalues; }; extern const wchar_t *getvar(const wchar_t *name) __attribute__((pure,nonnull)); extern struct get_variable_T get_variable(const wchar_t *name) __attribute__((nonnull,warn_unused_result)); extern void save_get_variable_values(struct get_variable_T *gv) __attribute__((nonnull)); extern void open_new_environment(_Bool temp); extern void close_current_environment(void); extern char **decompose_paths(const wchar_t *paths) __attribute__((malloc,warn_unused_result)); extern char *const *get_path_array(path_T name); extern _Bool define_function(const wchar_t *name, struct command_T *body) __attribute__((nonnull)); extern struct command_T *get_function(const wchar_t *name) __attribute__((nonnull)); #if YASH_ENABLE_DIRSTACK extern _Bool parse_dirstack_index( const wchar_t *restrict indexstr, size_t *restrict indexp, const wchar_t **restrict entryp, _Bool printerror) __attribute__((nonnull)); #endif extern int typeset_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char typeset_help[], typeset_syntax[], export_help[], export_syntax[], readonly_help[], readonly_syntax[]; #endif extern const struct xgetopt_T typeset_options[]; extern int array_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char array_help[], array_syntax[]; #endif extern const struct xgetopt_T array_options[]; extern int unset_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char unset_help[], unset_syntax[]; #endif extern const struct xgetopt_T unset_options[]; extern int shift_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char shift_help[], shift_syntax[]; #endif extern int getopts_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char getopts_help[], getopts_syntax[]; #endif extern int read_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char read_help[], read_syntax[]; #endif extern const struct xgetopt_T read_options[]; extern int pushd_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char pushd_help[], pushd_syntax[]; #endif extern const struct xgetopt_T pushd_options[]; #if YASH_ENABLE_DIRSTACK # define cd_options (&pushd_options[1]) # define pwd_options (&pushd_options[2]) #else # define cd_options pushd_options # define pwd_options (&pushd_options[1]) #endif extern int popd_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char popd_help[], popd_syntax[]; #endif extern int dirs_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char dirs_help[], dirs_syntax[]; #endif extern const struct xgetopt_T dirs_options[]; #endif /* YASH_VARIABLE_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/hashtable.h0000644000175000017500000001043112154557026014651 0ustar magicantmagicant/* Yash: yet another shell */ /* hashtable.h: hashtable library */ /* (C) 2007-2010 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_HASHTABLE_H #define YASH_HASHTABLE_H #include #include #if defined UINT64_MAX && UINT64_MAX == UINT_FAST32_MAX typedef uint64_t hashval_T; # define FNVPRIME 1099511628211 #elif defined UINT128_MAX && UINT128_MAX == UINT_FAST32_MAX typedef uint128_t hashval_T; # define FNVPRIME 309485009821345068724781401 #else typedef uint32_t hashval_T; # define FNVPRIME 16777619 #endif /* The type of hash functions. * Hash functions must return the same value for two keys that compare equal. */ typedef hashval_T hashfunc_T(const void *key); /* The type of functions that compare two keys. * Returns zero if two keys are equal, or non-zero if unequal. */ typedef int keycmp_T(const void *key1, const void *key2); typedef struct hashtable_T { size_t capacity, count; hashfunc_T *hashfunc; keycmp_T *keycmp; size_t emptyindex, tailindex; size_t *indices; struct hash_entry *entries; } hashtable_T; typedef struct kvpair_T { void *key, *value; } kvpair_T; static inline hashtable_T *ht_init( hashtable_T *ht, hashfunc_T *hashfunc, keycmp_T *keycmp) __attribute__((nonnull)); extern hashtable_T *ht_initwithcapacity( hashtable_T *ht, hashfunc_T *hashfunc, keycmp_T *keycmp, size_t capacity) __attribute__((nonnull)); static inline void ht_destroy(hashtable_T *ht) __attribute__((nonnull)); extern hashtable_T *ht_setcapacity(hashtable_T *ht, size_t newcapacity) __attribute__((nonnull)); extern hashtable_T *ht_ensurecapacity(hashtable_T *ht, size_t capacity) __attribute__((nonnull)); extern hashtable_T *ht_clear(hashtable_T *ht, void freer(kvpair_T kv)) __attribute__((nonnull(1))); extern kvpair_T ht_get(const hashtable_T *ht, const void *key) __attribute__((nonnull(1))); extern kvpair_T ht_set(hashtable_T *ht, const void *key, const void *value) __attribute__((nonnull(1,2))); extern kvpair_T ht_remove(hashtable_T *ht, const void *key) __attribute__((nonnull(1))); extern int ht_each(const hashtable_T *ht, int f(kvpair_T kv)) __attribute__((nonnull)); extern kvpair_T ht_next(const hashtable_T *restrict ht, size_t *restrict indexp) __attribute__((nonnull)); extern kvpair_T *ht_tokvarray(const hashtable_T *ht) __attribute__((nonnull,malloc,warn_unused_result)); extern hashval_T hashstr(const void *s) __attribute__((pure)); //extern int htstrcmp(const void *s1, const void *s2) __attribute__((pure)); // Also include to use `htstrcmp'. #define htstrcmp ((keycmp_T *) strcmp) extern hashval_T hashwcs(const void *s) __attribute__((pure)); extern int htwcscmp(const void *s1, const void *s2) __attribute__((pure)); extern int keystrcoll(const void *kv1, const void *kv2) __attribute__((pure)); extern int keywcscoll(const void *kv1, const void *kv2) __attribute__((pure)); extern void kfree(kvpair_T kv); extern void vfree(kvpair_T kv); extern void kvfree(kvpair_T kv); #ifndef HASHTABLE_DEFAULT_INIT_CAPACITY #define HASHTABLE_DEFAULT_INIT_CAPACITY 5 #endif /* Initializes the specified hashtable with the default capacity. * `hashfunc' is the hash function to hash keys. * `keycmp' is the function that compares two keys. */ hashtable_T *ht_init(hashtable_T *ht, hashfunc_T *hashfunc, keycmp_T *keycmp) { return ht_initwithcapacity( ht, hashfunc, keycmp, HASHTABLE_DEFAULT_INIT_CAPACITY); } /* Destroys the specified hashtable. * Note that this function doesn't `free' any keys or values. */ void ht_destroy(hashtable_T *ht) { free(ht->indices); free(ht->entries); } #endif /* YASH_HASHTABLE_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/path.h0000644000175000017500000001011712154557026013653 0ustar magicantmagicant/* Yash: yet another shell */ /* path.h: filename-related utilities */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_PATH_H #define YASH_PATH_H #include #include #include "xgetopt.h" struct stat; extern _Bool is_file(const char *path) __attribute__((nonnull)); extern _Bool is_regular_file(const char *path) __attribute__((nonnull)); extern _Bool is_irregular_file(const char *path) __attribute__((nonnull)); extern _Bool is_readable(const char *path) __attribute__((nonnull)); extern _Bool is_writable(const char *path) __attribute__((nonnull)); extern _Bool is_executable(const char *path) __attribute__((nonnull)); extern _Bool is_readable_regular(const char *path) __attribute__((nonnull)); extern _Bool is_executable_regular(const char *path) __attribute__((nonnull)); extern _Bool is_directory(const char *path) __attribute__((nonnull)); extern _Bool stat_result_same_file( const struct stat *stat1, const struct stat *stat2) __attribute__((nonnull,pure)); extern _Bool is_same_file(const char *path1, const char *path2) __attribute__((nonnull)); extern wchar_t *canonicalize_path(const wchar_t *path) __attribute__((nonnull,malloc,warn_unused_result)); extern _Bool is_normalized_path(const wchar_t *path) __attribute__((nonnull)); extern char *xgetcwd(void) __attribute__((malloc,warn_unused_result)); extern char *which( const char *restrict name, char *const *restrict dirs, _Bool cond(const char *path)) __attribute__((nonnull(1),malloc,warn_unused_result)); extern int create_temporary_file(char **filename, mode_t mode) __attribute__((nonnull)); /********** Command Hashtable **********/ extern void init_cmdhash(void); extern void clear_cmdhash(void); extern const char *get_command_path(const char *name, _Bool forcelookup) __attribute__((nonnull)); extern void fill_cmdhash(const char *prefix, _Bool ignorecase); extern const char *get_command_path_default(const char *name) __attribute__((nonnull)); /********** Home Directory Cache **********/ extern void init_homedirhash(void); extern const wchar_t *get_home_directory( const wchar_t *username, _Bool forcelookup) __attribute__((nonnull)); /********** wglob **********/ enum wglobflags_T { WGLB_MARK = 1 << 0, WGLB_CASEFOLD = 1 << 1, WGLB_PERIOD = 1 << 2, WGLB_NOSORT = 1 << 3, WGLB_RECDIR = 1 << 4, }; struct plist_T; extern _Bool wglob(const wchar_t *restrict pattern, enum wglobflags_T flags, struct plist_T *restrict list) __attribute__((nonnull)); /********** Built-ins **********/ extern int cd_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char cd_help[], cd_syntax[]; #endif extern int pwd_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char pwd_help[], pwd_syntax[]; #endif extern int hash_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char hash_help[], hash_syntax[]; #endif extern const struct xgetopt_T hash_options[]; extern int umask_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char umask_help[], umask_syntax[]; #endif extern const struct xgetopt_T umask_options[]; extern int change_directory( const wchar_t *newpwd, _Bool printnewdir, _Bool logical) __attribute__((nonnull,warn_unused_result)); #endif /* YASH_PATH_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/siglist.h0000644000175000017500000000730712154557026014404 0ustar magicantmagicant/* Yash: yet another shell */ /* siglist.h: defines list of signals */ /* (C) 2007-2009 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_SIGLIST_H #define YASH_SIGLIST_H #include #include /* signal number and name */ typedef struct signal_T { int no; const wchar_t *name; } signal_T; /* list of signals */ static const signal_T signals[] = { /* signals defined by SUSv2 & POSIX.1-2001 (SUSv3) */ { SIGHUP, L"HUP", }, { SIGINT, L"INT", }, { SIGQUIT, L"QUIT", }, { SIGILL, L"ILL", }, { SIGABRT, L"ABRT", }, { SIGBUS, L"BUS", }, { SIGFPE, L"FPE", }, { SIGKILL, L"KILL", }, { SIGSEGV, L"SEGV", }, { SIGPIPE, L"PIPE", }, { SIGALRM, L"ALRM", }, { SIGTERM, L"TERM", }, { SIGUSR1, L"USR1", }, { SIGUSR2, L"USR2", }, { SIGCHLD, L"CHLD", }, { SIGCONT, L"CONT", }, { SIGSTOP, L"STOP", }, { SIGTSTP, L"TSTP", }, { SIGTTIN, L"TTIN", }, { SIGTTOU, L"TTOU", }, { SIGURG, L"URG", }, #ifdef SIGTRAP { SIGTRAP, L"TRAP", }, #endif #ifdef SIGXCPU { SIGXCPU, L"XCPU", }, #endif #ifdef SIGXFSZ { SIGXFSZ, L"XFSZ", }, #endif #ifdef SIGVTALRM { SIGVTALRM, L"VTALRM", }, #endif #ifdef SIGPROF { SIGPROF, L"PROF", }, #endif #ifdef SIGPOLL { SIGPOLL, L"POLL", }, #endif #ifdef SIGSYS { SIGSYS, L"SYS", }, #endif /* below are non-standardized signals */ #ifdef SIGIOT { SIGIOT, L"IOT", }, #endif #ifdef SIGEMT { SIGEMT, L"EMT", }, #endif #ifdef SIGSTKFLT { SIGSTKFLT, L"STKFLT", }, #endif #ifdef SIGIO { SIGIO, L"IO", }, #endif #ifdef SIGCLD { SIGCLD, L"CLD", }, #endif #ifdef SIGPWR { SIGPWR, L"PWR", }, #endif #ifdef SIGLOST { SIGLOST, L"LOST", }, #endif #ifdef SIGWINCH { SIGWINCH, L"WINCH", }, #endif #ifdef SIGWINDOW { SIGWINDOW, L"WINDOW", }, #endif /* from BSD */ #ifdef SIGINFO { SIGINFO, L"INFO", }, #endif #ifdef SIGTHR { SIGTHR, L"THR", }, #endif /* from AIX */ #ifdef SIGMSG { SIGMSG, L"MSG", }, #endif #ifdef SIGDANGER { SIGDANGER, L"DANGER", }, #endif #ifdef SIGMIGRATE { SIGMIGRATE, L"MIGRATE", }, #endif #ifdef SIGPRE { SIGPRE, L"PRE", }, #endif #ifdef SIGVIRT { SIGVIRT, L"VIRT", }, #endif #ifdef SIGALRM1 { SIGALRM1, L"ALRM1", }, #endif #ifdef SIGWAITING { SIGWAITING, L"WAITING", }, #endif #ifdef SIGKAP { SIGKAP, L"KAP", }, #endif #ifdef SIGGRANT { SIGGRANT, L"GRANT", }, #endif #ifdef SIGRETRACT { SIGRETRACT, L"RETRACT", }, #endif #ifdef SIGSOUND { SIGSOUND, L"SOUND", }, #endif #ifdef SIGSAK { SIGSAK, L"SAK", }, #endif /* from SunOS5 */ #ifdef SIGLWP { SIGLWP, L"LWP", }, #endif #ifdef SIGFREEZE { SIGFREEZE, L"FREEZE", }, #endif #ifdef SIGTHAW { SIGTHAW, L"THAW", }, #endif #ifdef SIGCANCEL { SIGCANCEL, L"CANCEL", }, #endif #ifdef SIGXRES { SIGXRES, L"XRES", }, #endif /* from HP-UX */ #ifdef SIGRESERVE { SIGRESERVE, L"RESERVE", }, #endif #ifdef SIGDIL { SIGDIL, L"DIL", }, #endif #ifdef SIGUNUSED { SIGUNUSED, L"UNUSED", }, #endif /* end of array: any signal number is non-zero (C99 7.14) */ { 0, NULL, }, }; #endif /* YASH_SIGLIST_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/alias.h0000644000175000017500000000370212154557026014012 0ustar magicantmagicant/* Yash: yet another shell */ /* alias.h: alias substitution */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_ALIAS_H #define YASH_ALIAS_H #include #include "xgetopt.h" struct xwcsbuf_T; struct aliaslist_T; typedef enum { AF_NONGLOBAL = 1 << 0, AF_NORECUR = 1 << 1, } substaliasflags_T; extern void init_alias(void); extern _Bool is_alias_name_char(wchar_t c) __attribute__((pure)); extern const wchar_t *get_alias_value(const wchar_t *aliasname) __attribute__((nonnull,pure)); extern void destroy_aliaslist(struct aliaslist_T *list); extern _Bool substitute_alias( struct xwcsbuf_T *restrict buf, size_t i, struct aliaslist_T **restrict list, substaliasflags_T flags) __attribute__((nonnull)); extern _Bool print_alias_if_defined( const wchar_t *aliasname, _Bool user_friendly) __attribute__((nonnull)); extern int alias_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char alias_help[], alias_syntax[]; #endif extern const struct xgetopt_T alias_options[]; extern int unalias_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char unalias_help[], unalias_syntax[]; #endif extern const struct xgetopt_T unalias_options[]; #endif /* YASH_ALIAS_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/README0000644000175000017500000000542412154557026013433 0ustar magicantmagicantYash: yet another shell http://yash.sourceforge.jp/ ======================= Yash is a command line shell that conforms to the POSIX.1 standard (IEEE Std 1003.1, 2008 Edition) for the most part. Actually, it is much more POSIX-compliant than other shell like bash and zsh. Yash also has its own features beyond POSIX, such as: * global aliases * random numbers * socket redirections and other special redirections * right prompt * command completion Yash is free software distributed under the terms of GNU General Public License (GPL) version 2. You can copy, modify, use, and/or distribute this software as long as you obey the terms of GPL, but note that there is NO WARRANTY. See the "COPYING" file for the full text of GPL. See the "INSTALL" file to see how to build and install yash. ===== Implementation Notes ===== * In C, a null character represents the end of a string. If input to the shell itself contains a null character, characters following the null character will be ignored. * We assume that an overflow in signed integer arithmetic or type conversion silently yields an implementation-defined integer value rather than resulting in an error. * The GCC extension keyword `__attribute__' is used in the source code. When not compiled with GCC, this keyword is removed by the preprocessor, so generally there is no harm. But if your compiler uses this keyword for any other purpose, compilation may fail. Additionally, some other identifiers starting with '_' may cause compilation errors on some rare environments. * Some signals are assumed to have the specific numbers: SIGHUP=1 SIGINT=2 SIGQUIT=3 SIGABRT=6 SIGKILL=9 SIGALRM=14 SIGTERM=15 * File permission flags are assumed to have the specific values: 0400=user read 0200=user write 0100=user execute 0040=group read 0020=group write 0010=group execute 0004=other read 0002=other write 0001=other execute * The character categorization in locales other than the POSIX locale is assumed upward compatible with the POSIX locale. * When the -e (-o errexit) option is set, failure of the last command of an and/or list makes the shell exit. This behavior is not strictly POSIX-compliant, but most existing shells behave this way. * The -o nolog option is not supported: it is silently ignored. * According to POSIX, the value of variable `PS1' is subject to parameter expansion. Yash performs command substitution and arithmetic expansion as well on the `PS1' value. * According to POSIX, the command `printf %c foo' should print the first byte of string `foo'. Yash prints the first character of `foo', which may be more than one byte. ====================== Magicant Comments, suggestions, and bug reports are welcome. yash-2.35/mail.c0000644000175000017500000001702712154557026013643 0ustar magicantmagicant/* Yash: yet another shell */ /* mail.c: mail checking */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "mail.h" #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include "expand.h" #include "hashtable.h" #include "option.h" #include "parser.h" #include "plist.h" #include "strbuf.h" #include "util.h" #include "variable.h" /* The type of objects used to remember the status of files for mail checking.*/ typedef struct mailfile_T { #if HAVE_ST_MTIM || HAVE_ST_MTIMESPEC struct timespec mf_mtim; # define mf_mtime mf_mtim.tv_sec #else time_t mf_mtime; # if HAVE_ST_MTIMENSEC || HAVE___ST_MTIMENSEC unsigned long mf_mtimensec; # endif #endif char mf_filename[]; } mailfile_T; static void activate(void); static void inactivate(void); static bool is_time_to_check_mail(void); static void check_mail_and_print_message(void); static void handle_mailpath(wchar_t *paths) __attribute__((nonnull)); static void handle_mailpath_element(const wchar_t *s) __attribute__((nonnull)); static bool is_update(const char *path) __attribute__((nonnull)); static void print_message(const wchar_t *message) __attribute__((nonnull)); /* A hashtable that contains `mailfile_T' objects. * The keys are pointers to the `mf_filename' member of `mailfile_T' objects, * and the values are pointers to the `mailfile_T' objects. * When mail checking is not activated, the capacity of the hashtable is set to * zero. */ static hashtable_T mailfiles; /* The time of last mail check. */ static time_t lastchecktime = 0; /* If it is time to check mail, checks if the mail file is updated, and if so * prints a message. The parsing state must be saved with `save_parse_state' * before calling this function. */ void check_mail(void) { if (is_time_to_check_mail()) check_mail_and_print_message(); } /* Activates `mailfiles'. */ void activate(void) { if (mailfiles.capacity == 0) ht_init(&mailfiles, hashstr, htstrcmp); } /* Inactivates `mailfiles'. */ void inactivate(void) { if (mailfiles.capacity > 0) { ht_destroy(ht_clear(&mailfiles, vfree)); mailfiles.capacity = 0; lastchecktime = 0; } } /* Decides if it is time to check mail now. * Inactivates mail checking and returns false if the $MAILCHECK variable is not * a valid integer. * Sets `lastchecktime' to now if the return value is true. */ bool is_time_to_check_mail(void) { const wchar_t *mailcheck = getvar(L VAR_MAILCHECK); if (mailcheck == NULL || mailcheck[0] == L'\0') { inactivate(); return false; } long interval; if (!xwcstol(mailcheck, 10, &interval) || interval < 0) { inactivate(); return false; } time_t now = time(NULL); if (now == -1 || now - lastchecktime < interval) return false; lastchecktime = now; return true; } /* Checks if the mail file is updated and prints a message if so. */ void check_mail_and_print_message(void) { /* Firstly, check the $MAILPATH variable */ struct get_variable_T mailpath = get_variable(L VAR_MAILPATH); switch (mailpath.type) { case GV_NOTFOUND: break; case GV_SCALAR: activate(); handle_mailpath(mailpath.values[0]); goto mailpath_handled; case GV_ARRAY: case GV_ARRAY_CONCAT: activate(); for (size_t i = 0; i < mailpath.count; i++) handle_mailpath_element(mailpath.values[i]); mailpath_handled: if (mailpath.freevalues) plfree(mailpath.values, free); return; } /* Next, check the $MAIL variable */ const wchar_t *mail = getvar(L VAR_MAIL); if (mail != NULL) { activate(); char *path = malloc_wcstombs(mail); if (path != NULL) { if (is_update(path)) fprintf(stderr, "%s\n", gt("You have new mail.")); free(path); } return; } /* disable mail check since the variables are not set */ inactivate(); } /* Splits the specified string at colons and calls `handle_mailpath_element' for * each component. * This function directly modifies the string. */ void handle_mailpath(wchar_t *paths) { const wchar_t *start; next: start = paths; for (;;) { switch (*paths) { case L'\0': handle_mailpath_element(start); return; case L':': *paths = L'\0'; handle_mailpath_element(start); paths++; goto next; case L'\\': paths++; if (*paths == L'\0') { handle_mailpath_element(start); return; } /* falls thru! */ default: paths++; continue; } } } /* Parses the specified $MAILPATH component and checks for update. */ void handle_mailpath_element(const wchar_t *s) { xstrbuf_T path; mbstate_t state; sb_init(&path); memset(&state, 0, sizeof state); for (;;) { switch (*s) { case L'\0': goto check; case L'%': s++; goto check; case L'\\': s++; if (*s == L'\0') goto check; /* falls thru! */ default: sb_wccat(&path, *s, &state); s++; continue; } } check: sb_wccat(&path, L'\0', &state); if (is_update(path.contents)) { if (*s == L'\0') fprintf(stderr, "%s\n", gt("You have new mail.")); else print_message(s); } sb_destroy(&path); } /* Checks if the specified file is updated. */ bool is_update(const char *path) { struct stat st; if (stat(path, &st) < 0) { st.st_size = 0; st.st_mtime = 0; #if HAVE_ST_MTIM st.st_mtim.tv_nsec = 0; #elif HAVE_ST_MTIMESPEC st.st_mtimespec.tv_nsec = 0; #elif HAVE_ST_MTIMENSEC st.st_mtimensec = 0; #elif HAVE___ST_MTIMENSEC st.__st_mtimensec = 0; #endif } bool result; mailfile_T *mf = ht_get(&mailfiles, path).value; if (mf != NULL) { result = (st.st_size > 0 || posixly_correct) && (st.st_mtime != 0) && (st.st_mtime != mf->mf_mtime #if HAVE_ST_MTIM || st.st_mtim.tv_nsec != mf->mf_mtim.tv_nsec #elif HAVE_ST_MTIMESPEC || st.st_mtimespec.tv_nsec != mf->mf_mtim.tv_nsec #elif HAVE_ST_MTIMENSEC || (unsigned long) st.st_mtimensec != mf->mf_mtimensec #elif HAVE___ST_MTIMENSEC || (unsigned long) st.__st_mtimensec != mf->mf_mtimensec #endif ); } else { mf = xmallocs(sizeof *mf, strlen(path) + 1, sizeof *mf->mf_filename); strcpy(mf->mf_filename, path); ht_set(&mailfiles, mf->mf_filename, mf); result = false; } #if HAVE_ST_MTIM mf->mf_mtim = st.st_mtim; #elif HAVE_ST_MTIMESPEC mf->mf_mtim = st.st_mtimespec; #else mf->mf_mtime = st.st_mtime; # if HAVE_ST_MTIMENSEC mf->mf_mtimensec = (unsigned long) st.st_mtimensec; # elif HAVE___ST_MTIMENSEC mf->mf_mtimensec = (unsigned long) st.__st_mtimensec; # endif #endif return result; } /* Prints the specified `message' after performing parameter expansion on it. */ void print_message(const wchar_t *message) { /* assuming the parse state is saved */ wchar_t *msg = parse_and_expand_string(message, NULL, true); if (msg != NULL) { fprintf(stderr, "%ls\n", msg); free(msg); } } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/hashtable.d0000644000175000017500000000007612154557026014651 0ustar magicantmagicanthashtable.o: hashtable.c common.h config.h hashtable.h util.h yash-2.35/expand.c0000644000175000017500000014564412154557026014207 0ustar magicantmagicant/* Yash: yet another shell */ /* expand.c: word expansion */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "expand.h" #include #include #include #include #include #include #include #include #include #include #include "arith.h" #include "exec.h" #include "input.h" #include "option.h" #include "parser.h" #include "path.h" #include "plist.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" #include "xfnmatch.h" #include "yash.h" static bool expand_and_split_words( const wordunit_T *restrict w, plist_T *restrict list) __attribute__((nonnull(2))); /* data passed between expansion functions */ struct expand_word_T { plist_T *valuelist, *splitlist; xwcsbuf_T valuebuf; xstrbuf_T splitbuf; bool putempty; }; static bool expand_word( const wordunit_T *restrict w, tildetype_T tilde, bool quoted, plist_T *restrict valuelist, plist_T *restrict splitlist) __attribute__((nonnull(4))); static bool expand_word_inner(const wordunit_T *restrict w, tildetype_T tilde, bool quoted, bool rec, struct expand_word_T *restrict e) __attribute__((nonnull(5))); static wchar_t *expand_tilde(const wchar_t **ss, bool hasnextwordunit, tildetype_T tt) __attribute__((nonnull,malloc,warn_unused_result)); enum indextype_T { IDX_NONE, IDX_ALL, IDX_CONCAT, IDX_NUMBER, }; static bool expand_param(const paramexp_T *restrict p, bool indq, struct expand_word_T *restrict e) __attribute__((nonnull)); static wchar_t *expand_param_simple(const paramexp_T *p) __attribute__((nonnull,malloc,warn_unused_result)); static enum indextype_T parse_indextype(const wchar_t *indexstr) __attribute__((nonnull,pure)); static wchar_t *trim_wstring(wchar_t *s, ssize_t startindex, ssize_t endindex) __attribute__((nonnull)); static void **trim_array(void **a, ssize_t startindex, ssize_t endindex) __attribute__((nonnull)); static void print_subst_as_error(const paramexp_T *p) __attribute__((nonnull)); static void match_each(void **restrict slist, const wchar_t *restrict pattern, paramexptype_T type) __attribute__((nonnull)); static void subst_each(void **restrict slist, const wchar_t *pattern, const wchar_t *subst, paramexptype_T type) __attribute__((nonnull)); static void **concatenate_values(void **values) __attribute__((nonnull,malloc,warn_unused_result)); static void subst_length_each(void **slist) __attribute__((nonnull)); static void expand_brace_each(void **restrict values, void **restrict splits, plist_T *restrict valuelist, plist_T *restrict splitlist) __attribute__((nonnull)); static void expand_brace(wchar_t *restrict word, char *restrict split, plist_T *restrict valuelist, plist_T *restrict splitlist) __attribute__((nonnull)); static bool try_expand_brace_sequence( wchar_t *word, char *restrict split, wchar_t *startc, plist_T *restrict valuelist, plist_T *restrict splitlist) __attribute__((nonnull)); static bool has_leading_zero(const wchar_t *restrict s, bool *restrict sign) __attribute__((nonnull)); static void fieldsplit(wchar_t *restrict s, char *restrict split, const wchar_t *restrict ifs, plist_T *restrict dest) __attribute__((nonnull)); static void fieldsplit_all(void **restrict valuelist, void **restrict splitlist, plist_T *restrict dest) __attribute__((nonnull)); static inline void add_sq( const wchar_t *restrict *ss, xwcsbuf_T *restrict buf, bool escape) __attribute__((nonnull)); static wchar_t *escaped_wcspbrk(const wchar_t *s, const wchar_t *accept) __attribute__((nonnull)); static void glob_all(void **restrict patterns, plist_T *restrict list) __attribute__((nonnull)); static enum wglobflags_T get_wglobflags(void) __attribute__((pure)); static void maybe_exit_on_error(void); /********** Entry Points **********/ /* Expands a command line. * `args' is a NULL-terminated array of pointers to `const wordunit_T' * to expand. * If successful, the number of resulting words is assigned to `*argcp', a * pointer to a newly malloced array of the expanded words is assigned to * `*argvp', and true is returned. The array is NULL-terminated and its elements * are newly malloced wide strings. * If unsuccessful, false is returned and the values of `*argcp' and `*argvp' * are indeterminate. * On error in a non-interactive shell, the shell exits. */ bool expand_line(void *const *restrict args, int *restrict argcp, void ***restrict argvp) { plist_T list; pl_init(&list); for (; *args != NULL; args++) { if (!expand_multiple(*args, &list)) { plfree(pl_toary(&list), free); return false; } } *argcp = list.length; *argvp = pl_toary(&list); return true; } /* Expands a word. * The results, which are added to `list' as newly-malloced wide strings, may * be multiple words. * The return value is true iff successful. * On error in a non-interactive shell, the shell exits. */ bool expand_multiple(const wordunit_T *w, plist_T *list) { plist_T templist; /* four expansions, brace expansions and field splitting */ if (!expand_and_split_words(w, pl_init(&templist))) { maybe_exit_on_error(); plfree(pl_toary(&templist), free); return false; } /* glob */ if (shopt_glob) { glob_all(pl_toary(&templist), list); } else { for (size_t i = 0; i < templist.length; i++) pl_add(list, unescapefree(templist.contents[i])); pl_destroy(&templist); } return true; } /* Performs the four expansions, brace expansion and field splitting in a word. * The four expansions are tilde expansion, parameter expansion, command * substitution and arithmetic expansion. * Returns true iff successful. The resulting words are added to `list', which * may include backslash escapes. * Tilde expansion is performed with TT_SINGLE. */ bool expand_and_split_words( const wordunit_T *restrict w, plist_T *restrict list) { plist_T valuelist1, valuelist2, splitlist1, splitlist2; pl_init(&valuelist1); pl_init(&splitlist1); /* four expansions (w -> list1) */ if (!expand_word(w, TT_SINGLE, false, &valuelist1, &splitlist1)) { plfree(pl_toary(&valuelist1), free); plfree(pl_toary(&splitlist1), free); return false; } /* brace expansion (list1 -> list2) */ if (shopt_braceexpand) { pl_init(&valuelist2); pl_init(&splitlist2); expand_brace_each(valuelist1.contents, splitlist1.contents, &valuelist2, &splitlist2); pl_destroy(&valuelist1); pl_destroy(&splitlist1); } else { valuelist2 = valuelist1; splitlist2 = splitlist1; } /* field splitting (list2 -> list) */ fieldsplit_all(pl_toary(&valuelist2), pl_toary(&splitlist2), list); return true; } /* Expands a single word: the four expansions and quote removal. * This function doesn't perform brace expansion, field splitting, globbing and * unescaping. * If successful, the resulting word is returned as a newly malloced string * that may include backslash escapes. * On error, an error message is printed and NULL is returned. * On error in a non-interactive shell, the shell exits. */ wchar_t *expand_single(const wordunit_T *arg, tildetype_T tilde) { wchar_t *result; plist_T list; pl_init(&list); if (!expand_word(arg, tilde, false, &list, NULL)) { maybe_exit_on_error(); plfree(pl_toary(&list), free); return NULL; } if (list.length != 1) { /* concatenate multiple words to a single */ const wchar_t *ifs = getvar(L VAR_IFS); wchar_t padding[] = { ifs != NULL ? ifs[0] : L' ', L'\0' }; result = joinwcsarray(list.contents, padding); plfree(pl_toary(&list), free); } else { result = list.contents[0]; pl_destroy(&list); } return result; } /* Expands a single word: the four expansions, glob, quote removal and unescape. * This function doesn't perform brace expansion and field splitting. * If the result of glob is more than one word, * - returns the pre-glob pattern string if in the POSIXly correct mode * - treats as an error otherwise. * If the "glob" shell option is off, glob is not performed. * The "nullglob" shell option is ignored. * If successful, the resulting word is returned as a newly malloced string. * On error, an error message is printed and NULL is returned. * On error in a non-interactive shell, the shell exits. */ char *expand_single_with_glob(const wordunit_T *arg, tildetype_T tilde) { wchar_t *exp = expand_single(arg, tilde); char *result; if (exp == NULL) return NULL; /* glob */ if (shopt_glob && is_pathname_matching_pattern(exp)) { plist_T list; bool ok; pl_init(&list); set_interruptible_by_sigint(true); ok = wglob(exp, get_wglobflags(), &list); set_interruptible_by_sigint(false); if (!ok) { free(exp); plfree(pl_toary(&list), free); xerror(EINTR, Ngt("redirection")); result = NULL; } else if (list.length == 1) { free(exp); result = realloc_wcstombs(list.contents[0]); if (result == NULL) xerror(EILSEQ, Ngt("redirection")); pl_destroy(&list); } else { plfree(pl_toary(&list), free); if (posixly_correct) { goto noglob; } else { exp = unescapefree(exp); xerror(0, Ngt("filename `%ls' matches more than one file"), exp); free(exp); result = NULL; } } } else { noglob: result = realloc_wcstombs(unescapefree(exp)); if (result == NULL) xerror(EILSEQ, Ngt("redirection")); } return result; } /* Performs expansions in a string: parameter/arithmetic/command expansions. * Brace expansion, field splitting and globbing are not performed. * If `esc' is true, backslashes preceding $, `, \ are removed. Otherwise, * no quotations are removed. * The result is a newly malloced string. * On error, an error message is printed and NULL is returned. */ wchar_t *expand_string(const wordunit_T *w, bool esc) { bool ok = true; xwcsbuf_T buf; wchar_t *s; wb_init(&buf); for (; w != NULL; w = w->next) { switch (w->wu_type) { case WT_STRING: for (const wchar_t *ss = w->wu_string; *ss != L'\0'; ss++) { if (esc && ss[0] == L'\\' && ss[1] != L'\0' && wcschr(L"$`\\", ss[1]) != NULL) { ss++; if (*ss != L'\0') wb_wccat(&buf, *ss); } else { wb_wccat(&buf, *ss); } } break; case WT_PARAM: s = expand_param_simple(w->wu_param); goto cat_s; case WT_CMDSUB: s = exec_command_substitution(&w->wu_cmdsub); goto cat_s; case WT_ARITH: s = expand_single(w->wu_arith, TT_NONE); if (s != NULL) s = evaluate_arithmetic(unescapefree(s)); cat_s: if (s != NULL) { wb_catfree(&buf, s); } else { ok = false; } break; } } if (ok) { return wb_towcs(&buf); } else { wb_destroy(&buf); maybe_exit_on_error(); return NULL; } } /********** Four Expansions **********/ /* Performs the four expansions in the specified single word. * The four expansions are tilde expansion, parameter expansion, command * substitution and arithmetic expansion. * `w' is the word in which expansions occur. * `tilde' is type of tilde expansion that is performed. * If `quoted' is true, the expanded words are all backslashed as if the entire * expansion is quoted. * The expanded word is added to `valuelist' as a newly malloced wide string. * The splittability string is added to `splitlist' if `splitlist' is non-NULL. * Single- or double-quoted characters are unquoted and backslashed. * In most cases, one string is added to each of `valuelist' and `splitlist'. * If the word contains "$@", the result may be any number of strings. * The return value is true iff successful. */ /* A splittability string is an array of Boolean values that specifies where * the word can be split in field splitting. The word can be split at the nth * character iff the nth value of the splittability string is non-zero. */ bool expand_word( const wordunit_T *restrict w, tildetype_T tilde, bool quoted, plist_T *restrict valuelist, plist_T *restrict splitlist) { struct expand_word_T expand; expand.valuelist = valuelist; wb_init(&expand.valuebuf); expand.splitlist = splitlist; if (expand.splitlist != NULL) sb_init(&expand.splitbuf); expand.putempty = false; bool ok = expand_word_inner(w, tilde, quoted, false, &expand); if (expand.splitlist != NULL) assert(expand.valuebuf.length == expand.splitbuf.length); /* A quoted empty word, if any, is added to the list here. It is indicated * by the `putempty' flag that is set when a quote is found. */ if (expand.valuebuf.length > 0 || expand.putempty) { pl_add(expand.valuelist, wb_towcs(&expand.valuebuf)); if (expand.splitlist != NULL) pl_add(expand.splitlist, sb_tostr(&expand.splitbuf)); } else { wb_destroy(&expand.valuebuf); if (expand.splitlist != NULL) sb_destroy(&expand.splitbuf); } return ok; } /* Performs the four expansions in the specified single word. * `w' is the word in which expansions occur. * `tilde' specifies the type of tilde expansion that is performed. * If `quoted' is true, the expanded words are all backslashed as if the entire * expansion is quoted. * `rec' must be true iff this expansion is part of another expansion. * `e->valuebuf' must be initialized before calling this function and is used to * expand the current word. If `w' expands to multiple words, the last word is * put in `e->valuebuf' and the others are inserted to `e->valuelist'. * The splittability strings are put in `e->splitbuf' and `e->splitlist' * accordingly if `e->splitlist' is non-NULL. * Single- or double-quoted characters are unquoted and backslashed. * The return value is true iff successful. */ bool expand_word_inner(const wordunit_T *restrict w, tildetype_T tilde, bool quoted, bool rec, struct expand_word_T *restrict e) { bool ok = true; bool indq = false; /* in a double quote? */ bool first = true; /* is the first word unit? */ const wchar_t *ss; wchar_t *s; #define FILL_SBUF(c) \ do { \ if (e->splitlist != NULL) \ sb_ccat_repeat(&e->splitbuf, c, \ e->valuebuf.length - e->splitbuf.length); \ } while (false) #define FILL_SBUF_SPLITTABLE FILL_SBUF(true) #define FILL_SBUF_UNSPLITTABLE FILL_SBUF(false) for (; w != NULL; w = w->next, first = false) { switch (w->wu_type) { case WT_STRING: ss = w->wu_string; if (first && tilde != TT_NONE) { s = expand_tilde(&ss, w->next, tilde); if (s != NULL) { wb_catfree(&e->valuebuf, escapefree(s, NULL)); FILL_SBUF_UNSPLITTABLE; } } while (*ss != L'\0') { switch (*ss) { case L'"': indq = !indq; e->putempty |= indq; break; case L'\'': if (indq) goto default_case; e->putempty = true; add_sq(&ss, &e->valuebuf, true); FILL_SBUF_UNSPLITTABLE; break; case L'\\': if (indq && wcschr(CHARS_ESCAPABLE, ss[1]) == NULL) { goto default_case; } else { wb_wccat(&e->valuebuf, L'\\'); if (*++ss != L'\0') wb_wccat(&e->valuebuf, *ss++); FILL_SBUF_UNSPLITTABLE; continue; } case L':': if (!indq && tilde == TT_MULTI) { /* perform tilde expansion after a colon */ wb_wccat(&e->valuebuf, L':'); ss++; s = expand_tilde(&ss, w->next, tilde); if (s != NULL) { wb_catfree(&e->valuebuf, escapefree(s, NULL)); FILL_SBUF_UNSPLITTABLE; } continue; } /* falls thru! */ default: default_case: if (indq || quoted) wb_wccat(&e->valuebuf, L'\\'); wb_wccat(&e->valuebuf, *ss); FILL_SBUF(rec && !indq && !quoted); break; } ss++; } break; case WT_PARAM: if (!expand_param(w->wu_param, indq || quoted, e)) ok = false; break; case WT_CMDSUB: s = exec_command_substitution(&w->wu_cmdsub); goto cat_s; case WT_ARITH: s = expand_single(w->wu_arith, TT_NONE); if (s != NULL) s = evaluate_arithmetic(unescapefree(s)); cat_s: if (s != NULL) { wb_catfree(&e->valuebuf, escapefree(s, (indq || quoted) ? NULL : CHARS_ESCAPED)); FILL_SBUF(!(indq || quoted)); } else { ok = false; } break; } } return ok; } /* Performs tilde expansion. * `ss' is a pointer to a pointer to the tilde character. The pointer is * increased so that it points to the character right after the expanded string. * The string pointed by the pointer pointed by `ss' should be contents of a * word unit of type WT_STRING. Iff there is a next word unit, `hasnextwordunit' * must be true. * If `**ss' is not L'~' or expansion fails, this function has no side effects * and returns NULL. If successful, `*ss' is incremented and the result is * returned as a newly malloced string. */ wchar_t *expand_tilde(const wchar_t **ss, bool hasnextwordunit, tildetype_T tt) { const wchar_t *s = *ss; if (*s != L'~') return NULL; s++; const wchar_t *end = wcspbrk(s, tt == TT_SINGLE ? L"/" : L"/:"); wchar_t *username; const wchar_t *home; size_t usernamelen; if (end != NULL) { usernamelen = end - s; } else { if (hasnextwordunit) return NULL; usernamelen = wcslen(s); } username = xwcsndup(s, usernamelen); if (username[0] == L'\0') { /* empty user name: use $HOME */ home = getvar(L VAR_HOME); goto finish; } else if (wcspbrk(username, L"\"'\\") != 0) { /* don't expand if the user name is quoted */ free(username); return NULL; } if (!posixly_correct) { size_t INIT(index); if (username[0] == L'+') { if (username[1] == L'\0') { home = getvar(L VAR_PWD); goto finish; #if YASH_ENABLE_DIRSTACK } else if (parse_dirstack_index(username, &index, &home, false) && index != SIZE_MAX) { goto finish; #endif } } else if (username[0] == L'-') { if (username[1] == L'\0') { home = getvar(L VAR_OLDPWD); goto finish; #if YASH_ENABLE_DIRSTACK } else if (parse_dirstack_index(username, &index, &home, false) && index != SIZE_MAX) { goto finish; #endif } } } home = get_home_directory(username, false); finish: free(username); if (home == NULL) return NULL; *ss = s + usernamelen; return xwcsdup(home); } /* Performs parameter expansion. * The result is put in `e'. * Returns true iff successful. */ bool expand_param(const paramexp_T *restrict p, bool indq, struct expand_word_T *restrict e) { /* parse indices first */ ssize_t startindex, endindex; enum indextype_T indextype; if (p->pe_start == NULL) { startindex = 0, endindex = SSIZE_MAX, indextype = IDX_NONE; } else { wchar_t *start = expand_single(p->pe_start, TT_NONE); if (start == NULL) return false; indextype = parse_indextype(start); if (indextype != IDX_NONE) { startindex = 0, endindex = SSIZE_MAX; free(start); if (p->pe_end != NULL) { xerror(0, Ngt("the parameter index is invalid")); return false; } } else if (!evaluate_index(start, &startindex)) { return false; } else { if (p->pe_end == NULL) { endindex = (startindex == -1) ? SSIZE_MAX : startindex; } else { wchar_t *end = expand_single(p->pe_end, TT_NONE); if (end == NULL || !evaluate_index(end, &endindex)) return false; } if (startindex == 0) startindex = SSIZE_MAX; else if (startindex >= 0) startindex--; } } /* Here, `startindex' and `endindex' are zero-based. `startindex' is * included in the range but `endindex' is not. A negative index will be * wrapped around the length. */ /* get the value of parameter or nested expansion */ struct get_variable_T v; bool unset; /* parameter is not set? */ if (p->pe_type & PT_NEST) { plist_T plist; pl_init(&plist); if (!expand_word(p->pe_nest, TT_NONE, true, &plist, NULL)) { plfree(pl_toary(&plist), free); return false; } v.type = (plist.length == 1) ? GV_SCALAR : GV_ARRAY; v.count = plist.length; v.values = pl_toary(&plist); v.freevalues = true; unset = false; for (size_t i = 0; v.values[i] != NULL; i++) v.values[i] = unescapefree(v.values[i]); } else { v = get_variable(p->pe_name); if (v.type == GV_NOTFOUND) { /* if the variable is not set, return empty string */ v.type = GV_SCALAR; v.count = 1; v.values = xmallocn(2, sizeof *v.values); v.values[0] = xwcsdup(L""); v.values[1] = NULL; v.freevalues = true; unset = true; } else { unset = false; } } /* here, the contents of `v.values' are not escaped by backslashes. */ /* modify the elements of `v.values' according to the indices */ void **values; /* the result */ bool concat; /* concatenate array elements? */ switch (v.type) { case GV_SCALAR: assert(v.values != NULL && v.count == 1); save_get_variable_values(&v); if (indextype != IDX_NUMBER) { trim_wstring(v.values[0], startindex, endindex); } else { size_t len = wcslen(v.values[0]); free(v.values[0]); v.values[0] = malloc_wprintf(L"%zu", len); } values = v.values, concat = false; break; case GV_ARRAY: concat = false; goto treat_array; case GV_ARRAY_CONCAT: concat = true; treat_array: switch (indextype) { case IDX_CONCAT: concat = true; /* falls thru! */ case IDX_NONE: case IDX_ALL: if (startindex >= 0) { #if SIZE_MAX >= SSIZE_MAX if ((size_t) startindex > v.count) #else if (startindex > (ssize_t) v.count) #endif startindex = v.count; } else { startindex += v.count; if (startindex < 0) startindex = 0; } if (endindex < 0) endindex += v.count + 1; if (endindex < startindex) endindex = startindex; #if SSIZE_MAX > SIZE_MAX else if (endindex > (ssize_t) SIZE_MAX) endindex = SIZE_MAX; #endif assert(0 <= startindex && startindex <= endindex); values = v.freevalues ? trim_array(v.values, startindex, endindex) : plndup(v.values + startindex, endindex - startindex, copyaswcs); break; case IDX_NUMBER: if (v.freevalues) plfree(v.values, free); values = xmallocn(2, sizeof *values); values[0] = malloc_wprintf(L"%zu", v.count); values[1] = NULL; concat = false; break; default: assert(false); } break; default: assert(false); } /* if `PT_COLON' is true, empty string is treated as unset */ if (p->pe_type & PT_COLON) if (values[0] == NULL || (((wchar_t *) values[0])[0] == L'\0' && values[1] == NULL)) unset = true; /* PT_PLUS, PT_MINUS, PT_ASSIGN, PT_ERROR */ wchar_t *subst; switch (p->pe_type & PT_MASK) { case PT_PLUS: if (!unset) goto subst; unset = false; break; case PT_MINUS: if (unset) { subst: plfree(values, free); return expand_word_inner(p->pe_subst, TT_SINGLE, indq, true, e); } break; case PT_ASSIGN: if (unset) { plfree(values, free); if (p->pe_type & PT_NEST) { xerror(0, Ngt("a nested parameter expansion cannot be assigned")); return false; } else if (!is_name(p->pe_name)) { xerror(0, Ngt("cannot assign to parameter `%ls' " "in parameter expansion"), p->pe_name); return false; } else if ((v.type == GV_ARRAY_CONCAT) || (v.type == GV_ARRAY && startindex + 1 != endindex)) { xerror(0, Ngt("the specified index does not support assignment " "in the parameter expansion of array `%ls'"), p->pe_name); return false; } subst = expand_single(p->pe_subst, TT_SINGLE); if (subst == NULL) return false; subst = unescapefree(subst); if (v.type != GV_ARRAY) { assert(v.type == GV_NOTFOUND || v.type == GV_SCALAR); if (!set_variable( p->pe_name, xwcsdup(subst), SCOPE_GLOBAL, false)) { free(subst); return false; } } else { assert(0 <= startindex && (size_t) startindex <= v.count); if (!set_array_element(p->pe_name, startindex, xwcsdup(subst))){ free(subst); return false; } } values = xmallocn(2, sizeof *values); values[0] = subst; values[1] = NULL; unset = false; } break; case PT_ERROR: if (unset) { plfree(values, free); print_subst_as_error(p); return false; } break; } if (unset && !shopt_unset) { plfree(values, free); xerror(0, Ngt("parameter `%ls' is not set"), p->pe_name); return false; } /* PT_MATCH, PT_SUBST */ wchar_t *match; switch (p->pe_type & PT_MASK) { case PT_MATCH: match = expand_single(p->pe_match, TT_SINGLE); if (match == NULL) { plfree(values, free); return false; } match_each(values, match, p->pe_type); free(match); break; case PT_SUBST: match = expand_single(p->pe_match, TT_SINGLE); subst = expand_single(p->pe_subst, TT_SINGLE); if (match == NULL || subst == NULL) { free(match); free(subst); plfree(values, free); return false; } subst = unescapefree(subst); subst_each(values, match, subst, p->pe_type); free(match); free(subst); break; } /* concatenate the elements of `values' */ if (concat) values = concatenate_values(values); /* PT_NUMBER */ if (p->pe_type & PT_NUMBER) subst_length_each(values); /* concatenate the elements of `values' */ if (!indq) values = concatenate_values(values); /* backslash escape */ for (size_t i = 0; values[i] != NULL; i++) values[i] = escapefree(values[i], indq ? NULL : CHARS_ESCAPED); /* add the elements of `values' to `e->valuelist' */ if (values[0] == NULL) { e->putempty = false; } else { /* add the first element */ wb_catfree(&e->valuebuf, values[0]); FILL_SBUF(!indq); if (values[1] != NULL) { pl_add(e->valuelist, wb_towcs(&e->valuebuf)); if (e->splitlist != NULL) pl_add(e->splitlist, sb_tostr(&e->splitbuf)); /* add the remaining but last */ size_t i; for (i = 1; values[i + 1] != NULL; i++) { pl_add(e->valuelist, values[i]); if (e->splitlist != NULL) { size_t len = wcslen(values[i]); pl_add(e->splitlist, memset(xmalloc(len), !indq, len)); } } /* add the last element */ wb_initwith(&e->valuebuf, values[i]); if (e->splitlist != NULL) { sb_init(&e->splitbuf); FILL_SBUF(!indq); } } } free(values); return true; } /* Performs parameter expansion and returns the resulting word. * If multiple words result, they are concatenated into a single string, each * separated by a space. * If successful, returns a newly-malloced wide string. * On error, returns NULL. */ wchar_t *expand_param_simple(const paramexp_T *p) { plist_T valuelist; struct expand_word_T expand; expand.valuelist = pl_init(&valuelist); wb_init(&expand.valuebuf); expand.splitlist = NULL; expand.putempty = false; bool ok = expand_param(p, false, &expand); /* A quoted empty word, if any, is added to the list here. It is indicated * by the `putempty' flag, which is set when a quote is found. */ if (expand.valuebuf.length > 0 || expand.putempty) { pl_add(expand.valuelist, wb_towcs(&expand.valuebuf)); } else { wb_destroy(&expand.valuebuf); } for (size_t i = 0; i < valuelist.length; i++) valuelist.contents[i] = unescapefree(valuelist.contents[i]); void **results = pl_toary(expand.valuelist); wchar_t *result = ok ? joinwcsarray(results, L" ") : NULL; plfree(results, free); return result; } /* Returns IDX_ALL, IDX_CONCAT, IDX_NUMBER if `indexstr' is L"@", L"*", * L"#" respectively. Otherwise returns IDX_NONE. */ enum indextype_T parse_indextype(const wchar_t *indexstr) { if (indexstr[0] != L'\0' && indexstr[1] == L'\0') { switch (indexstr[0]) { case L'@': return IDX_ALL; case L'*': return IDX_CONCAT; case L'#': return IDX_NUMBER; } } return IDX_NONE; } /* Trims some leading and trailing characters of the wide string. * Characters in the range [`startindex', `endindex') remain. * Returns the string `s'. */ wchar_t *trim_wstring(wchar_t *s, ssize_t startindex, ssize_t endindex) { if (startindex == 0 && endindex == SSIZE_MAX) return s; if (startindex < 0 || endindex < 0) { ssize_t len = wcslen(s); if (startindex < 0) { startindex += len; if (startindex < 0) startindex = 0; } if (endindex < 0) { endindex += len + 1; if (endindex <= startindex) goto return_empty; } } assert(startindex >= 0 && endindex >= 0); if (startindex >= endindex) goto return_empty; for (ssize_t i = 0; i < startindex; i++) if (s[i] == L'\0') goto return_empty; for (ssize_t i = 0; i < endindex - startindex; i++) if ((s[i] = s[startindex + i]) == L'\0') return s; s[endindex - startindex] = L'\0'; return s; return_empty: s[0] = L'\0'; return s; } /* Trims some leading and trailing elements of the NULL-terminated array of * pointers. * Elements in the range [`startindex', `endindex') remain. `startindex' must * not be negative and `endindex' must not be less than `startindex'. * Removed elements are freed. * Returns the array `a'. */ /* `startindex' and/or `endindex' may be >= the length of the array. */ void **trim_array(void **a, ssize_t startindex, ssize_t endindex) { assert(0 <= startindex && startindex <= endindex); if (startindex == 0 && endindex == SSIZE_MAX) return a; ssize_t len = endindex - startindex; for (ssize_t i = 0; i < startindex; i++) { if (a[i] == NULL) { a[0] = NULL; return a; } free(a[i]); } for (ssize_t i = 0; i < len; i++) if ((a[i] = a[startindex + i]) == NULL) return a; for (ssize_t i = endindex; a[i] != NULL; i++) free(a[i]); a[len] = NULL; return a; } /* Expands `p->pe_subst' and prints it as an error message. */ void print_subst_as_error(const paramexp_T *p) { if (p->pe_subst != NULL) { wchar_t *subst = expand_single(p->pe_subst, TT_SINGLE); if (subst != NULL) { subst = unescapefree(subst); if (p->pe_type & PT_NEST) xerror(0, "%ls", subst); else xerror(0, "%ls: %ls", p->pe_name, subst); free(subst); } } else { /* use the default error message */ if (p->pe_type & PT_NEST) xerror(0, Ngt("the parameter value is empty")); else xerror(0, (p->pe_type & PT_COLON) ? Ngt("parameter `%ls' is not set or has an empty value") : Ngt("parameter `%ls' is not set"), p->pe_name); } } /* Matches each string in array `slist' to pattern `pattern' and removes the * matching part of the string. * `slist' is a NULL-terminated array of pointers to `free'able wide strings. * `type' must contain at least one of PT_MATCHHEAD, PT_MATCHTAIL and * PT_MATCHLONGEST. If both of PT_MATCHHEAD and PT_MATCHTAIL are specified, * PT_MATCHLONGEST must be specified too. * Elements of `slist' may be modified and/or `realloc'ed in this function. */ void match_each(void **restrict slist, const wchar_t *restrict pattern, paramexptype_T type) { xfnmflags_T flags = 0; assert(type & (PT_MATCHHEAD | PT_MATCHTAIL | PT_MATCHLONGEST)); if (type & PT_MATCHHEAD) flags |= XFNM_HEADONLY; if (type & PT_MATCHTAIL) flags |= XFNM_TAILONLY; if (!(type & PT_MATCHLONGEST)) flags |= XFNM_SHORTEST; xfnmatch_T *xfnm = xfnm_compile(pattern, flags); if (xfnm == NULL) return; for (size_t i = 0; slist[i] != NULL; i++) { wchar_t *s = slist[i]; xfnmresult_T result = xfnm_wmatch(xfnm, s); if (result.start != (size_t) -1) { xwcsbuf_T buf; wb_initwith(&buf, s); wb_remove(&buf, result.start, result.end - result.start); slist[i] = wb_towcs(&buf); } } xfnm_free(xfnm); } /* Matches each string in array `slist' to pattern `pattern' and substitutes * the matching portions with `subst'. * `slist' is a NULL-terminated array of pointers to `free'able wide strings. * `type' may contain PT_MATCHHEAD, PT_MATCHTAIL and PT_SUBSTALL. * PT_MATCHLONGEST is always assumed to be specified. * Elements of `slist' may be modified and/or `realloc'ed in this function. */ void subst_each(void **restrict slist, const wchar_t *pattern, const wchar_t *subst, paramexptype_T type) { xfnmflags_T flags = 0; if (type & PT_MATCHHEAD) flags |= XFNM_HEADONLY; if (type & PT_MATCHTAIL) flags |= XFNM_TAILONLY; xfnmatch_T *xfnm = xfnm_compile(pattern, flags); if (xfnm == NULL) return; for (size_t i = 0; slist[i] != NULL; i++) { wchar_t *s = slist[i]; slist[i] = xfnm_subst(xfnm, s, subst, type & PT_SUBSTALL); free(s); } xfnm_free(xfnm); } /* Concatenates the wide strings in the specified array. * Array `*values' must be a NULL-terminated array of pointers to wide strings. * The strings are concatenated into one, each separated by the first $IFS * character. * The array and its element strings are all freed in this function. * The return value is a pointer to a newly malloced NULL-terminated array that * contains exactly one element: a pointer to the newly malloced wide string * that is the result of concatenation. */ void **concatenate_values(void **values) { /* If the array contains just one string, simply return it. */ if (values[0] != NULL && values[1] == NULL) return values; const wchar_t *ifs = getvar(L VAR_IFS); wchar_t padding[] = { ifs != NULL ? ifs[0] : L' ', L'\0' }; wchar_t *result = joinwcsarray(values, padding); plfree(values, free); values = xmallocn(2, sizeof *values); values[0] = result; values[1] = NULL; return values; } /* Substitutes each string in the specified array with a string that contains * the number of characters in the original string. * `slist' is a NULL-terminated array of pointers to `free'able wide strings. * The strings are `realloc'ed and modified in this function. */ void subst_length_each(void **slist) { for (size_t i = 0; slist[i] != NULL; i++) { size_t len = wcslen(slist[i]); free(slist[i]); slist[i] = malloc_wprintf(L"%zu", len); } } /********** Brace Expansions **********/ /* Performs brace expansion in each element of the specified array. * `values' is an array of pointers to `free'able wide strings to be expanded. * `splits' is an array of pointers to `free'able splittability strings. * `values' and 'splits' must contain the same number of elements. * Both the arrays must be NULL-terminated and their elements are freed in this * function. The arrays themselves are not freed. * Newly malloced results are added to `valuelist' and `splitlist'. */ void expand_brace_each(void **restrict values, void **restrict splits, plist_T *restrict valuelist, plist_T *restrict splitlist) { while (*values != NULL) { expand_brace(*values, *splits, valuelist, splitlist); values++, splits++; } } /* Performs brace expansion in the specified single word. * `split' is the splittability string corresponding to `word'. * `word' and `split' are freed in this function. * `Free'able results are added to `valuelist' and `splitlist'. */ void expand_brace(wchar_t *restrict const word, char *restrict const split, plist_T *restrict valuelist, plist_T *restrict splitlist) { wchar_t *c = word; start: c = escaped_wcspbrk(c, L"{"); if (c == NULL || *++c == L'\0') { /* don't expand if there is no L'{' or L'{' is at the end of string */ pl_add(valuelist, word); pl_add(splitlist, split); return; } else if (try_expand_brace_sequence(word, split, c, valuelist, splitlist)){ return; } plist_T splitpoints; unsigned nest; /* collect pointers to characters where the word is split */ /* The pointers point to the character just after L'{', L',' or L'}'. */ pl_init(&splitpoints); pl_add(&splitpoints, c); nest = 0; while ((c = escaped_wcspbrk(c, L"{,}")) != L'\0') { switch (*c++) { case L'{': nest++; break; case L',': if (nest == 0) pl_add(&splitpoints, c); break; case L'}': if (nest > 0) { nest--; break; } else if (splitpoints.length == 1) { goto restart; } else { pl_add(&splitpoints, c); goto done; } } } restart: /* if there is no L',' or L'}' corresponding to L'{', * find the next L'{' and try again */ c = splitpoints.contents[0]; pl_destroy(&splitpoints); goto start; done:; #define idx(p) ((wchar_t *) (p) - word) #define wtos(p) (split + idx(p)) size_t lastelemindex = splitpoints.length - 1; size_t headlen = idx(splitpoints.contents[0]) - 1; size_t taillen = wcslen(splitpoints.contents[lastelemindex]); for (size_t i = 0; i < lastelemindex; i++) { xwcsbuf_T buf; xstrbuf_T sbuf; wb_init(&buf); sb_init(&sbuf); wb_ncat_force(&buf, word, headlen); sb_ncat_force(&sbuf, split, headlen); size_t len = (wchar_t *) splitpoints.contents[i + 1] - (wchar_t *) splitpoints.contents[i ] - 1; wb_ncat_force(&buf, splitpoints.contents[i], len); sb_ncat_force(&sbuf, wtos(splitpoints.contents[i]), len); wb_ncat_force(&buf, splitpoints.contents[lastelemindex], taillen); sb_ncat_force(&sbuf, wtos(splitpoints.contents[lastelemindex]), taillen); assert(buf.length == sbuf.length); /* expand the remaining portion recursively */ expand_brace(wb_towcs(&buf), sb_tostr(&sbuf), valuelist, splitlist); } pl_destroy(&splitpoints); free(word); free(split); #undef idx #undef wtos } /* Tries numeric brace expansion like "{01..05}". * If unsuccessful, this function returns false without any side effects. * If successful, `word' and `split' are freed and the full expansion results * are added to `valuelist' and `splitlist'. * `startc' is a pointer to the character right after L'{' in `word'. */ bool try_expand_brace_sequence( wchar_t *word, char *restrict split, wchar_t *startc, plist_T *restrict valuelist, plist_T *restrict splitlist) { long start, end, delta, value; wchar_t *dotp, *dotbracep, *bracep, *c; int startlen, endlen, len, wordlen; bool sign = false; assert(startc[-1] == L'{'); c = startc; /* parse the starting point */ dotp = wcschr(c, L'.'); if (dotp == NULL || c == dotp || dotp[1] != L'.') return false; startlen = has_leading_zero(c, &sign) ? (dotp - c) : 0; errno = 0; start = wcstol(c, &c, 0); if (errno != 0 || c != dotp) return false; c = dotp + 2; /* parse the ending point */ dotbracep = wcspbrk(c, L".}"); if (dotbracep == NULL || c == dotbracep || (dotbracep[0] == L'.' && dotbracep[1] != L'.')) return false; endlen = has_leading_zero(c, &sign) ? (dotbracep - c) : 0; errno = 0; end = wcstol(c, &c, 0); if (errno != 0 || c != dotbracep) return false; /* parse the delta */ if (dotbracep[0] == L'.') { assert(dotbracep[1] == L'.'); c = dotbracep + 2; bracep = wcschr(c, L'}'); if (bracep == NULL || c == bracep) return false; errno = 0; delta = wcstol(c, &c, 0); if (delta == 0 || errno != 0 || c != bracep) return false; } else { assert(dotbracep[0] == L'}'); bracep = dotbracep; if (start <= end) delta = 1; else delta = -1; } /* expand the sequence */ value = start; len = (startlen > endlen) ? startlen : endlen; wordlen = wcslen(word); do { xwcsbuf_T buf; xstrbuf_T sbuf; wb_init(&buf); sb_init(&sbuf); wb_ncat_force(&buf, word, startc - 1 - word); sb_ncat_force(&sbuf, split, startc - 1 - word); int plen = wb_wprintf(&buf, sign ? L"%0+*ld" : L"%0*ld", len, value); if (plen >= 0) sb_ccat_repeat(&sbuf, 0, plen); wb_ncat_force(&buf, bracep + 1, wordlen - (bracep + 1 - word)); sb_ncat_force(&sbuf, split + (bracep + 1 - word), wordlen - (bracep + 1 - word)); assert(buf.length == sbuf.length); /* expand the remaining portion recursively */ expand_brace(wb_towcs(&buf), sb_tostr(&sbuf), valuelist, splitlist); if (delta >= 0) { if (LONG_MAX - delta < value) break; } else { if (LONG_MIN - delta > value) break; } value += delta; } while (delta >= 0 ? value <= end : value >= end); free(word); free(split); return true; } /* Checks if the specified numeral starts with a L'0'. * Leading spaces are ignored. * If the numeral has a plus sign L'+', true is assigned to `*sign'. * If not, false is assigned. */ bool has_leading_zero(const wchar_t *restrict s, bool *restrict sign) { while (iswspace(*s)) s++; if (*s == L'+') { *sign = true; s++; } else if (*s == L'-') { s++; } return *s == L'0'; } /********** Field Splitting **********/ /* Performs field splitting. * `s' is the word to split and freed in this function. * `split' is the splittability string corresponding to `s' and also freed. * The results are added to `dest' as newly-malloced wide strings. * `ifs' must not be NULL. * The word is split at characters that are contained in `ifs' and whose * corresponding character in the splittability string is non-zero. */ /* Field are split at characters that are contained in `ifs'. If an empty field * is split by white spaces, the field is ignored. * Split examples (assuming `ifs' = L" -") * " abc 123 " -> "abc" "123" * " abc 123 " -> "abc" "123" * "-abc-123-" -> "" "abc" "123" "" * " - abc - 123 - " -> "" "abc" "123" "" * "abc--123" -> "abc" "" "123" * "abc - - 123" -> "abc" "" "123" */ void fieldsplit(wchar_t *restrict s, char *restrict split, const wchar_t *restrict ifs, plist_T *restrict dest) { size_t index = 0; size_t lwstart = 0, lwend; /* start/end index of last word */ for (;;) { lwend = index; if (s[index] == L'\\') index++; if (s[index] == L'\0') break; if (split[index] && wcschr(ifs, s[index]) != NULL) { /* the character is in `ifs', so do splitting */ bool splitatnonspace = false, nonspace = false; if (lwstart < lwend) pl_add(dest, xwcsndup(s + lwstart, lwend - lwstart)); else splitatnonspace = true; do { if (!iswspace(s[index])) { if (splitatnonspace) pl_add(dest, xwcsdup(L"")); splitatnonspace = true; nonspace = true; } index++; if (s[index] == L'\\') index++; if (s[index] == L'\0') { if (nonspace) pl_add(dest, xwcsdup(L"")); break; } } while (split[index] && wcschr(ifs, s[index]) != NULL); lwstart = index; } else { index++; } } if (lwstart < lwend || lwend == 0) { /* if we have some leftover or the string is empty at all, add it. */ if (lwstart > 0) { xwcsbuf_T buf; s = wb_towcs(wb_remove(wb_initwith(&buf, s), 0, lwstart)); } pl_add(dest, s); } else { free(s); } free(split); } /* Performs field splitting. * `valuelist' is a NULL-terminated array of pointers to wide strings to split. * `splitlist' is an array of pointers to corresponding splittability strings. * `valuelist' and `splitlist' are `plfree'ed in this function. * The results are added to `dest'. */ void fieldsplit_all(void **restrict valuelist, void **restrict splitlist, plist_T *restrict dest) { void **restrict s; void **restrict t; const wchar_t *ifs; ifs = getvar(L VAR_IFS); if (ifs == NULL) ifs = DEFAULT_IFS; for (s = valuelist, t = splitlist; *s != NULL; s++, t++) fieldsplit(*s, *t, ifs, dest); free(valuelist); free(splitlist); } /* Extracts a field starting at `**sp'. * Pointer `*sp' is advanced to the first character of the next field or * to the end of string (L'\0') if none. If `**sp' is already L'\0', an empty * string is returned. * If `ifs' is NULL, the default separator is used. * If `noescape' is false, backslashes are treaded as escape characters. * The returned string is a newly malloced string. */ wchar_t *split_next_field(const wchar_t **sp, const wchar_t *ifs, bool noescape) { size_t i = 0, length = 0; const wchar_t *s = *sp; wchar_t *result; if (ifs == NULL) ifs = DEFAULT_IFS; while (*s != L'\0' && wcschr(ifs, *s) != NULL && iswspace(*s)) s++; if (*s != L'\0' && wcschr(ifs, *s) != NULL && !iswspace(*s)) { assert(length == 0); i = 1; goto end; } while (s[i] != L'\0') { if (!noescape && s[i] == L'\\') { i++; if (s[i] == L'\0') { length = i; break; } i++; } else if (wcschr(ifs, s[i]) != NULL) { length = i; do { if (!iswspace(s[i])) { i++; while (wcschr(ifs, s[i]) != NULL && iswspace(s[i])) i++; break; } } while (wcschr(ifs, s[++i]) != NULL); break; } else { i++; length = i; } } end: result = xwcsndup(s, length); if (!noescape) result = unescapefree(result); *sp = s + i; return result; } /* Removes IFS white spaces at the end of the string `s' by replacing them with * null characters. The default IFS is used if `ifs' is NULL. */ void trim_trailing_spaces(wchar_t *restrict s, const wchar_t *restrict ifs) { if (ifs == NULL) ifs = DEFAULT_IFS; for (size_t i = wcslen(s); i-- > 0; ) { if (wcschr(ifs, s[i]) != NULL && iswspace(s[i])) s[i] = L'\0'; else break; } } /********** Escaping **********/ /* Unquotes the specified single-quoted string and adds it to the specified * buffer. * `ss' is a pointer to a pointer to the opening quote in the string. * `*ss' is incremented so that it points to the closing quote. * If `escape' is true, all the characters added are backslashed. */ void add_sq(const wchar_t *restrict *ss, xwcsbuf_T *restrict buf, bool escape) { assert(**ss == L'\''); for (;;) { (*ss)++; switch (**ss) { case L'\0': assert(false); case L'\'': return; default: if (escape) wb_wccat(buf, L'\\'); wb_wccat(buf, **ss); break; } } } /* Backslashes characters in `s' that are contained in `t'. * Returns a newly-malloced wide string. * `t' may be NULL, in which case all the characters are backslashed. */ wchar_t *escape(const wchar_t *restrict s, const wchar_t *restrict t) { xwcsbuf_T buf; wb_init(&buf); for (size_t i = 0; s[i] != L'\0'; i++) { if (t == NULL || wcschr(t, s[i]) != NULL) wb_wccat(&buf, L'\\'); wb_wccat(&buf, s[i]); } return wb_towcs(&buf); } /* Same as `escape', except that the first argument is freed. */ wchar_t *escapefree(wchar_t *restrict s, const wchar_t *restrict t) { if (t != NULL && wcspbrk(s, t) == NULL) { return s; } else { wchar_t *result = escape(s, t); free(s); return result; } } /* Removes backslash escapes. The result is a newly malloced string. * If there is an unescaped backslash before the null character, the backslash * is ignored. */ wchar_t *unescape(const wchar_t *s) { xwcsbuf_T buf; wb_init(&buf); for (size_t i = 0; s[i] != L'\0'; i++) { if (s[i] == L'\\') { if (s[i + 1] == L'\0') break; else i++; } wb_wccat(&buf, s[i]); } return wb_towcs(&buf); } /* Same as `unescape', except that the first argument is freed. */ wchar_t *unescapefree(wchar_t *s) { if (wcschr(s, L'\\') == NULL) { return s; } else { wchar_t *result = unescape(s); free(s); return result; } } /* Quotes the specified string by single quotes. * If the string contains single quotes, they are backslashed. */ wchar_t *quote_sq(const wchar_t *s) { xwcsbuf_T buf; wb_init(&buf); wb_wccat(&buf, L'\''); for (size_t i = 0; s[i] != L'\0'; i++) { if (s[i] != L'\'') { wb_wccat(&buf, s[i]); } else { wb_ncat_force(&buf, L"'\\''", 4); } } wb_wccat(&buf, L'\''); return wb_towcs(&buf); } /* Removes quotes (', ", \). The result is a newly malloced string. */ wchar_t *unquote(const wchar_t *s) { bool indq = false; xwcsbuf_T buf; wb_init(&buf); for (;;) { switch (*s) { case L'\0': return wb_towcs(&buf); case L'\'': if (indq) goto default_case; add_sq(&s, &buf, false); break; case L'"': indq = !indq; break; case L'\\': if (s[1] != L'\0' && (!indq || wcschr(CHARS_ESCAPABLE, s[1]))) { wb_wccat(&buf, s[1]); s += 2; continue; } /* falls thru! */ default: default_case: wb_wccat(&buf, *s); break; } s++; } } /* Like `wcspbrk', but ignores backslashed characters in `s'. */ wchar_t *escaped_wcspbrk(const wchar_t *s, const wchar_t *accept) { for (; *s != L'\0'; s++) { if (*s == L'\\') { s++; if (*s == L'\0') break; continue; } if (wcschr(accept, *s) != NULL) return (wchar_t *) s; } return NULL; } /********** File Name Expansion (Glob) **********/ /* Makes a option value from the current shell settings. */ enum wglobflags_T get_wglobflags(void) { enum wglobflags_T flags = 0; if (!shopt_caseglob) flags |= WGLB_CASEFOLD; if (shopt_dotglob) flags |= WGLB_PERIOD; if (shopt_markdirs) flags |= WGLB_MARK; if (shopt_extendedglob) flags |= WGLB_RECDIR; return flags; } /* Performs file name expansion to the specified patterns. * `patterns' is a NULL-terminated array of pointers to `free'able wide strings * cast to (void *). `patterns' is `plfree'd in this function. * The results are added to `list' as newly-malloced wide strings. */ void glob_all(void **restrict patterns, plist_T *restrict list) { enum wglobflags_T flags = get_wglobflags(); bool unblock = false; for (size_t i = 0; patterns[i] != NULL; i++) { wchar_t *pat = patterns[i]; if (is_pathname_matching_pattern(pat)) { if (!unblock) { set_interruptible_by_sigint(true); unblock = true; } size_t oldlen = list->length; wglob(pat, flags, list); if (!shopt_nullglob && oldlen == list->length) goto addpattern; free(pat); } else { /* If the pattern doesn't contain characters like L'*' and L'?', * we don't need to glob. */ addpattern: pl_add(list, unescapefree(pat)); } } if (unblock) set_interruptible_by_sigint(false); free(patterns); } /********** Auxiliary functions **********/ /* Performs parameter expansion, command substitution of the form "$(...)", and * arithmetic expansion in the specified string. * If `name' is non-NULL, it is printed in error messages on error. * If `esc' is true, backslashes preceding $, `, \ are removed. Otherwise, * no quotations are removed. * Returns a newly malloced string if successful. Otherwise NULL is returned. * This function uses the parser, so the parser state must have been saved if * this function is called during another parse. */ wchar_t *parse_and_expand_string(const wchar_t *s, const char *name, bool esc) { struct input_wcs_info_T winfo = { .src = s, }; parseparam_T info = { .print_errmsg = true, .enable_verbose = false, #if YASH_ENABLE_ALIAS .enable_alias = true, #endif .filename = name, .lineno = 1, .input = input_wcs, .inputinfo = &winfo, .interactive = false, }; wordunit_T *word; wchar_t *result; if (!parse_string(&info, &word)) return NULL; result = expand_string(word, esc); wordfree(word); return result; } /* This function is called when an expansion error occurred. * The shell exits if it is non-interactive. */ void maybe_exit_on_error(void) { if (shell_initialized && !is_interactive_now) exit_shell_with_status(Exit_EXPERROR); } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/variable.c0000644000175000017500000025716212154557026014514 0ustar magicantmagicant/* Yash: yet another shell */ /* variable.c: deals with shell variables and parameters */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "variable.h" #include #include #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include #include #include #include "builtin.h" #include "configm.h" #include "exec.h" #include "expand.h" #include "hashtable.h" #include "input.h" #include "option.h" #include "parser.h" #include "path.h" #include "plist.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "xfnmatch.h" #include "yash.h" #if YASH_ENABLE_LINEEDIT # include "lineedit/complete.h" # include "lineedit/lineedit.h" # include "lineedit/terminfo.h" #endif static const wchar_t *const path_variables[PA_count] = { [PA_PATH] = L VAR_PATH, [PA_CDPATH] = L VAR_CDPATH, [PA_LOADPATH] = L VAR_YASH_LOADPATH, }; /* variable environment (= set of variables) */ /* not to be confused with environment variables */ typedef struct environ_T { struct environ_T *parent; /* parent environment */ struct hashtable_T contents; /* hashtable containing variables */ bool is_temporary; /* for temporary assignment? */ char **paths[PA_count]; } environ_T; /* `contents' is a hashtable from (wchar_t *) to (variable_T *). * A variable name may contain any characters except L'\0' and L'=', though * assignment syntax disallows other characters. * Variable names starting with L'=' are used for special purposes. * The positional parameter is treated as an array whose name is L"=". * Note that the number of positional parameters is offset by 1 against the * array index. * An environment whose `is_temporary' is true is used for temporary variables. * The elements of `paths' are arrays of the pathnames contained in the * $PATH, $CDPATH and $YASH_LOADPATH variables. They are NULL if the * corresponding variables are not set. */ #define VAR_positional "=" /* flags for variable attributes */ typedef enum vartype_T { VF_SCALAR, VF_ARRAY, VF_EXPORT = 1 << 2, VF_READONLY = 1 << 3, VF_NODELETE = 1 << 4, } vartype_T; #define VF_MASK ((1 << 2) - 1) /* For any variable, the variable type is either VF_SCALAR or VF_ARRAY, * possibly OR'ed with other flags. */ /* type of variables */ typedef struct variable_T { vartype_T v_type; union { wchar_t *value; struct { void **vals; size_t valc; } array; } v_contents; void (*v_getter)(struct variable_T *var); } variable_T; #define v_value v_contents.value #define v_vals v_contents.array.vals #define v_valc v_contents.array.valc /* `v_vals' is a NULL-terminated array of pointers to wide strings. * `v_valc' is, of course, the number of elements in `v_vals'. * `v_value', `v_vals' and the elements of `v_vals' are `free'able. * `v_value' is NULL if the variable is declared but not yet assigned. * `v_vals' is always non-NULL, but it may contain no elements. * `v_getter' is the setter function, which is reset to NULL on reassignment.*/ /* type of shell functions (defined later) */ typedef struct function_T function_T; static void varvaluefree(variable_T *v) __attribute__((nonnull)); static void varfree(variable_T *v); static void varkvfree(kvpair_T kv); static void varkvfree_reexport(kvpair_T kv); static void init_pwd(void); static variable_T *search_variable(const wchar_t *name) __attribute__((pure,nonnull)); static variable_T *search_array_and_check_if_changeable(const wchar_t *name) __attribute__((pure,nonnull)); static void update_environment(const wchar_t *name) __attribute__((nonnull)); static void reset_locale(const wchar_t *name) __attribute__((nonnull)); static void reset_locale_category(const wchar_t *name, int category) __attribute__((nonnull)); static variable_T *new_global(const wchar_t *name) __attribute__((nonnull)); static variable_T *new_local(const wchar_t *name) __attribute__((nonnull)); static variable_T *new_temporary(const wchar_t *name) __attribute__((nonnull)); static variable_T *new_variable(const wchar_t *name, scope_T scope) __attribute__((nonnull)); static void xtrace_variable(const wchar_t *name, const wchar_t *value) __attribute__((nonnull)); static void xtrace_array(const wchar_t *name, void *const *values) __attribute__((nonnull)); static size_t make_array_of_all_variables(bool global, kvpair_T **resultp) __attribute__((nonnull)); static void get_all_variables_rec( hashtable_T *table, environ_T *env, bool global) __attribute__((nonnull)); static void lineno_getter(variable_T *var) __attribute__((nonnull)); static void random_getter(variable_T *var) __attribute__((nonnull)); static unsigned next_random(void); static void variable_set(const wchar_t *name, variable_T *var) __attribute__((nonnull(1))); static char **convert_path_array(void **ary) __attribute__((malloc,warn_unused_result)); static void add_to_list_no_dup(plist_T *list, char *s) __attribute__((nonnull(1))); static void reset_path(path_T name, variable_T *var); static void funcfree(function_T *f); static void funckvfree(kvpair_T kv); static void hash_all_commands_recursively(const command_T *c); static void hash_all_commands_in_and_or(const and_or_T *ao); static void hash_all_commands_in_if(const ifcommand_T *ic); static void hash_all_commands_in_case(const caseitem_T *ci); static void tryhash_word_as_command(const wordunit_T *w); /* the current environment */ static environ_T *current_env; /* the top-level environment (the farthest from the current) */ static environ_T *first_env; /* whether $RANDOM is functioning as a random number */ static bool random_active; /* hashtable from function names (wchar_t *) to functions (function_T *). */ static hashtable_T functions; /* Frees the value of the specified variable (but not the variable itself). */ /* This function does not change the value of `*v'. */ void varvaluefree(variable_T *v) { switch (v->v_type & VF_MASK) { case VF_SCALAR: free(v->v_value); break; case VF_ARRAY: plfree(v->v_vals, free); break; } } /* Frees the specified variable. */ void varfree(variable_T *v) { if (v != NULL) { varvaluefree(v); free(v); } } /* Frees the specified key-value pair of a variable name and a variable. */ void varkvfree(kvpair_T kv) { free(kv.key); varfree(kv.value); } /* Calls `variable_set' and `update_environment' for `kv.key' and * calls `varkvfree'. */ void varkvfree_reexport(kvpair_T kv) { variable_set(kv.key, NULL); if (((variable_T *) kv.value)->v_type & VF_EXPORT) update_environment(kv.key); varkvfree(kv); } /* Initializes the top-level environment. */ void init_environment(void) { assert(first_env == NULL && current_env == NULL); first_env = current_env = xmalloc(sizeof *current_env); current_env->parent = NULL; current_env->is_temporary = false; ht_init(¤t_env->contents, hashwcs, htwcscmp); // for (size_t i = 0; i < PA_count; i++) // current_env->paths[i] = NULL; ht_init(&functions, hashwcs, htwcscmp); /* add all the existing environment variables to the variable environment */ for (char **e = environ; *e != NULL; e++) { wchar_t *we = malloc_mbstowcs(*e); if (we == NULL) continue; wchar_t *eqp = wcschr(we, L'='); variable_T *v = xmalloc(sizeof *v); v->v_type = VF_SCALAR | VF_EXPORT; v->v_value = (eqp != NULL) ? xwcsdup(&eqp[1]) : NULL; v->v_getter = NULL; if (eqp != NULL) { *eqp = L'\0'; we = xreallocn(we, eqp - we + 1, sizeof *we); } varkvfree(ht_set(¤t_env->contents, we, v)); } /* initialize path according to $PATH etc. */ for (size_t i = 0; i < PA_count; i++) current_env->paths[i] = decompose_paths(getvar(path_variables[i])); } /* Initializes the default variables. * This function must be called after the shell options have been set. */ void init_variables(void) { /* set $IFS */ set_variable(L VAR_IFS, xwcsdup(DEFAULT_IFS), SCOPE_GLOBAL, false); /* set $LINENO */ { variable_T *v = new_variable(L VAR_LINENO, SCOPE_GLOBAL); assert(v != NULL); v->v_type = VF_SCALAR | (v->v_type & VF_EXPORT); v->v_value = NULL; v->v_getter = lineno_getter; // variable_set(VAR_LINENO, v); if (v->v_type & VF_EXPORT) update_environment(L VAR_LINENO); } /* set $MAILCHECK */ if (getvar(L VAR_MAILCHECK) == NULL) set_variable(L VAR_MAILCHECK, xwcsdup(L"600"), SCOPE_GLOBAL, false); /* set $PS1~4 */ { const wchar_t *ps1 = !posixly_correct ? L"\\$ " : (geteuid() != 0) ? L"$ " : L"# "; set_variable(L VAR_PS1, xwcsdup(ps1), SCOPE_GLOBAL, false); set_variable(L VAR_PS2, xwcsdup(L"> "), SCOPE_GLOBAL, false); set_variable(L VAR_PS4, xwcsdup(L"+ "), SCOPE_GLOBAL, false); } /* set $PWD */ init_pwd(); /* export $OLDPWD */ { variable_T *v = new_global(L VAR_OLDPWD); assert(v != NULL); v->v_type |= VF_EXPORT; variable_set(L VAR_OLDPWD, v); } /* set $PPID */ set_variable(L VAR_PPID, malloc_wprintf(L"%jd", (intmax_t) getppid()), SCOPE_GLOBAL, false); /* set $OPTIND */ set_variable(L VAR_OPTIND, xwcsdup(L"1"), SCOPE_GLOBAL, false); /* set $RANDOM */ if (!posixly_correct) { variable_T *v = new_variable(L VAR_RANDOM, SCOPE_GLOBAL); assert(v != NULL); v->v_type = VF_SCALAR; v->v_value = NULL; v->v_getter = random_getter; random_active = true; srand(shell_pid); } else { random_active = false; } /* set $YASH_LOADPATH */ set_variable(L VAR_YASH_LOADPATH, xwcsdup(L DEFAULT_LOADPATH), SCOPE_GLOBAL, false); /* set $YASH_VERSION */ set_variable(L VAR_YASH_VERSION, xwcsdup(L PACKAGE_VERSION), SCOPE_GLOBAL, false); } /* Reset the value of $PWD if * - $PWD is not set, or * - the value of $PWD isn't an absolute path, or * - the value of $PWD isn't the actual current directory, or * - the value of $PWD isn't canonicalized. */ void init_pwd(void) { const char *pwd = getenv(VAR_PWD); if (pwd == NULL || pwd[0] != '/' || !is_same_file(pwd, ".")) goto set; const wchar_t *wpwd = getvar(L VAR_PWD); if (wpwd == NULL || !is_normalized_path(wpwd)) goto set; return; char *newpwd; wchar_t *wnewpwd; set: newpwd = xgetcwd(); if (newpwd == NULL) { xerror(errno, Ngt("failed to set $PWD")); return; } wnewpwd = realloc_mbstowcs(newpwd); if (wnewpwd == NULL) { xerror(0, Ngt("failed to set $PWD")); return; } set_variable(L VAR_PWD, wnewpwd, SCOPE_GLOBAL, true); } /* Searches for a variable with the specified name. * Returns NULL if none was found. */ variable_T *search_variable(const wchar_t *name) { for (environ_T *env = current_env; env != NULL; env = env->parent) { variable_T *var = ht_get(&env->contents, name).value; if (var != NULL) return var; } return NULL; } /* Searches for an array with the specified name and checks if it is not read- * only. If unsuccessful, prints an error message and returns NULL. */ variable_T *search_array_and_check_if_changeable(const wchar_t *name) { variable_T *array = search_variable(name); if (array == NULL || (array->v_type & VF_MASK) != VF_ARRAY) { xerror(0, Ngt("no such array $%ls"), name); return NULL; } else if (array->v_type & VF_READONLY) { xerror(0, Ngt("$%ls is read-only"), name); return NULL; } return array; } /* Update the value in `environ' for the variable with the specified name. * `name' must not contain '='. */ void update_environment(const wchar_t *name) { char *mname = malloc_wcstombs(name); if (mname == NULL) return; char *value = get_exported_value(name); if (value == NULL) { if (xunsetenv(mname) < 0) xerror(errno, Ngt("failed to unset environment variable $%s"), mname); } else { if (setenv(mname, value, true) < 0) xerror(errno, Ngt("failed to set environment variable $%s"), mname); } free(mname); free(value); } /* Returns the value of variable `name' that should be exported. * If the variable is not exported or the variable value cannot be converted to * a multibyte string, NULL is returned. */ char *get_exported_value(const wchar_t *name) { for (environ_T *env = current_env; env != NULL; env = env->parent) { const variable_T *var = ht_get(&env->contents, name).value; if (var != NULL && (var->v_type & VF_EXPORT)) { switch (var->v_type & VF_MASK) { case VF_SCALAR: if (var->v_value == NULL) continue; return malloc_wcstombs(var->v_value); case VF_ARRAY: return realloc_wcstombs(joinwcsarray(var->v_vals, L":")); default: assert(false); } } } return NULL; } /* Resets the locate settings for the specified variable. * If `name' is not any of "LANG", "LC_ALL", etc., does nothing. */ void reset_locale(const wchar_t *name) { if (wcscmp(name, L VAR_LANG) == 0) { goto reset_locale_all; } else if (wcsncmp(name, L"LC_", 3) == 0) { /* POSIX forbids resetting LC_CTYPE even if the value of the variable * is changed, but we do reset LC_CTYPE if the shell is interactive and * not in the POSIXly-correct mode. */ if (wcscmp(name + 3, L VAR_LC_ALL + 3) == 0) { reset_locale_all: reset_locale_category(L VAR_LC_COLLATE, LC_COLLATE); if (!posixly_correct && is_interactive_now) reset_locale_category(L VAR_LC_CTYPE, LC_CTYPE); reset_locale_category(L VAR_LC_MESSAGES, LC_MESSAGES); reset_locale_category(L VAR_LC_MONETARY, LC_MONETARY); reset_locale_category(L VAR_LC_NUMERIC, LC_NUMERIC); reset_locale_category(L VAR_LC_TIME, LC_TIME); } else if (wcscmp(name + 3, L VAR_LC_COLLATE + 3) == 0) { reset_locale_category(L VAR_LC_COLLATE, LC_COLLATE); } else if (wcscmp(name + 3, L VAR_LC_CTYPE + 3) == 0) { if (!posixly_correct && is_interactive_now) reset_locale_category(L VAR_LC_CTYPE, LC_CTYPE); } else if (wcscmp(name + 3, L VAR_LC_MESSAGES + 3) == 0) { reset_locale_category(L VAR_LC_MESSAGES, LC_MESSAGES); } else if (wcscmp(name + 3, L VAR_LC_MONETARY + 3) == 0) { reset_locale_category(L VAR_LC_MONETARY, LC_MONETARY); } else if (wcscmp(name + 3, L VAR_LC_NUMERIC + 3) == 0) { reset_locale_category(L VAR_LC_NUMERIC, LC_NUMERIC); } else if (wcscmp(name + 3, L VAR_LC_TIME + 3) == 0) { reset_locale_category(L VAR_LC_TIME, LC_TIME); } } } /* Resets the locale of the specified category. * `name' must be one of the `LC_*' constants except LC_ALL. */ void reset_locale_category(const wchar_t *name, int category) { const wchar_t *locale = getvar(L VAR_LC_ALL); if (locale == NULL) { locale = getvar(name); if (locale == NULL) { locale = getvar(L VAR_LANG); if (locale == NULL) locale = L""; } } char *wlocale = malloc_wcstombs(locale); if (wlocale != NULL) { setlocale(category, wlocale); free(wlocale); } } /* Creates a new scalar variable that has no value. * If the variable already exists, it is returned without change. So the return * value may be an array variable or it may be a scalar variable with a value. * Temporary variables with the `name' are cleared if any. */ variable_T *new_global(const wchar_t *name) { variable_T *var; for (environ_T *env = current_env; env != NULL; env = env->parent) { var = ht_get(&env->contents, name).value; if (var != NULL) { if (env->is_temporary) { assert(!(var->v_type & VF_NODELETE)); varkvfree_reexport(ht_remove(&env->contents, name)); continue; } return var; } } var = xmalloc(sizeof *var); var->v_type = VF_SCALAR; var->v_value = NULL; var->v_getter = NULL; ht_set(&first_env->contents, xwcsdup(name), var); return var; } /* Creates a new scalar variable that has no value. * If the variable already exists, it is returned without change. So the return * value may be an array variable or it may be a scalar variable with a value. * Temporary variables with the `name' are cleared if any. */ variable_T *new_local(const wchar_t *name) { environ_T *env = current_env; while (env->is_temporary) { varkvfree_reexport(ht_remove(&env->contents, name)); env = env->parent; } variable_T *var = ht_get(&env->contents, name).value; if (var != NULL) return var; var = xmalloc(sizeof *var); var->v_type = VF_SCALAR; var->v_value = NULL; var->v_getter = NULL; ht_set(&env->contents, xwcsdup(name), var); return var; } /* Creates a new scalar variable that has no value. * If the variable already exists, it is returned without change. So the return * value may be an array variable or it may be a scalar variable with a value. * The current environment must be a temporary environment. * If there is a read-only non-temporary variable with the specified name, it is * returned (no new temporary variable is created). */ variable_T *new_temporary(const wchar_t *name) { environ_T *env = current_env; assert(env->is_temporary); /* check if read-only */ variable_T *var = search_variable(name); if (var != NULL && (var->v_type & VF_READONLY)) return var; var = ht_get(&env->contents, name).value; if (var != NULL) return var; var = xmalloc(sizeof *var); var->v_type = VF_SCALAR; var->v_value = NULL; var->v_getter = NULL; ht_set(&env->contents, xwcsdup(name), var); return var; } /* Creates a new variable with the specified name if there is none. * If the variable already exists, it is cleared and returned. * * On error, an error message is printed to the standard error and NULL is * returned. Otherwise, the (new) variable is returned. * `v_type' is the only valid member of the returned variable and all the * members of the variable (including `v_type') must be initialized by the * caller. If `v_type' of the return value includes the VF_EXPORT flag, the * caller must call `update_environment'. */ variable_T *new_variable(const wchar_t *name, scope_T scope) { variable_T *var; switch (scope) { case SCOPE_GLOBAL: var = new_global(name); break; case SCOPE_LOCAL: var = new_local(name); break; case SCOPE_TEMP: var = new_temporary(name); break; default: assert(false); } if (var->v_type & VF_READONLY) { xerror(0, Ngt("$%ls is read-only"), name); return NULL; } else { varvaluefree(var); return var; } } /* Creates a scalar variable with the specified name and value. * `value' must be a `free'able string or NULL. The caller must not modify or * free `value' hereafter, whether or not this function is successful. * If `export' is true, the variable is exported (i.e., the VF_EXPORT flag is * set to the variable). But this function does not reset an existing VF_EXPORT * flag if `export' is false. * Returns true iff successful. On error, an error message is printed to the * standard error. */ bool set_variable( const wchar_t *name, wchar_t *value, scope_T scope, bool export) { variable_T *var = new_variable(name, scope); if (var == NULL) { free(value); return false; } var->v_type = VF_SCALAR | (var->v_type & (VF_EXPORT | VF_NODELETE)) | (export ? VF_EXPORT : 0); var->v_value = value; var->v_getter = NULL; variable_set(name, var); if (var->v_type & VF_EXPORT) update_environment(name); return true; } /* Creates an array variable with the specified name and values. * `values' is a NULL-terminated array of pointers to wide strings. It is used * as the contents of the array variable hereafter, so you must not modify or * free the array or its elements whether or not this function succeeds. * `values' and its elements must be `free'able. * `count' is the number of elements in `values'. If `count' is zero, the * number is counted in this function. * If `export' is true, the variable is exported (i.e., the VF_EXPORT flag is * set to the variable). But this function does not reset an existing VF_EXPORT * flag if `export' is false. * Returns the set array iff successful. On error, an error message is printed * to the standard error and NULL is returned. */ variable_T *set_array(const wchar_t *name, size_t count, void **values, scope_T scope, bool export) { variable_T *var = new_variable(name, scope); if (var == NULL) { plfree(values, free); return NULL; } var->v_type = VF_ARRAY | (var->v_type & (VF_EXPORT | VF_NODELETE)) | (export ? VF_EXPORT : 0); var->v_vals = values; var->v_valc = (count != 0) ? count : plcount(var->v_vals); var->v_getter = NULL; variable_set(name, var); if (var->v_type & VF_EXPORT) update_environment(name); return var; } /* Changes the value of the specified array element. * `name' must be the name of an existing array. * `index' is the index of the element (counted from zero). * `value' is the new value, which must be a `free'able string. Since `value' is * used as the contents of the array element, you must not modify or free * `value' after this function returned (whether successful or not). * Returns true iff successful. An error message is printed on failure. */ bool set_array_element(const wchar_t *name, size_t index, wchar_t *value) { variable_T *array = search_array_and_check_if_changeable(name); if (array == NULL) goto fail; if (array->v_valc <= index) goto invalid_index; free(array->v_vals[index]); array->v_vals[index] = value; if (array->v_type & VF_EXPORT) update_environment(name); return true; invalid_index: xerror(0, Ngt("index %zu is out of range " "(the actual size of array $%ls is %zu)"), index + 1, name, array->v_valc); fail: free(value); return false; } /* Sets the positional parameters of the current environment. * The existent parameters are cleared. * `values' is an NULL-terminated array of pointers to wide strings. * `values[0]' will be the new $1, `values[1]' $2, and so on. * When a new non-temporary environment is created, this function must be called * at least once before the environment is used by the user. */ void set_positional_parameters(void *const *values) { set_array(L VAR_positional, 0, pldup(values, copyaswcs), SCOPE_LOCAL, false); } /* Performs the specified assignments. * If `shopt_xtrace' is true, traces are printed to the standard error. * If `temp' is true, the variables are assigned in the current environment, * which must be a temporary environment. Otherwise, they are assigned globally. * If `export' is true, the variables are exported (i.e., the VF_EXPORT flag is * set to the variables). But this function does not reset any existing * VF_EXPORT flag if `export' is false. * Returns true iff successful. On error, already-assigned variables are not * restored to the previous values. */ bool do_assignments(const assign_T *assign, bool temp, bool export) { if (temp) assert(current_env->is_temporary); scope_T scope = temp ? SCOPE_TEMP : SCOPE_GLOBAL; while (assign != NULL) { wchar_t *value; int count; void **values; switch (assign->a_type) { case A_SCALAR: value = expand_single(assign->a_scalar, TT_MULTI); if (value == NULL) return false; value = unescapefree(value); if (shopt_xtrace) xtrace_variable(assign->a_name, value); if (!set_variable(assign->a_name, value, scope, export)) return false; break; case A_ARRAY: if (!expand_line(assign->a_array, &count, &values)) return false; assert(values != NULL); if (shopt_xtrace) xtrace_array(assign->a_name, values); if (!set_array(assign->a_name, count, values, scope, export)) return false; break; } assign = assign->next; } return true; } /* Pushes a trace of the specified variable assignment to the xtrace buffer. */ void xtrace_variable(const wchar_t *name, const wchar_t *value) { xwcsbuf_T *buf = get_xtrace_buffer(); wb_wprintf(buf, L" %ls=%ls", name, value); } /* Pushes a trace of the specified array assignment to the xtrace buffer. */ void xtrace_array(const wchar_t *name, void *const *values) { xwcsbuf_T *buf = get_xtrace_buffer(); wb_wprintf(buf, L" %ls=(", name); if (*values != NULL) { for (;;) { wb_cat(buf, *values); values++; if (*values == NULL) break; wb_wccat(buf, L' '); } } wb_wccat(buf, L')'); } /* Gets the value of the specified scalar variable. * Cannot be used for special parameters such as $$ and $@. * Returns the value of the variable, or NULL if not found. * The return value must not be modified or `free'ed by the caller and * is valid until the variable is re-assigned or unset. */ const wchar_t *getvar(const wchar_t *name) { variable_T *var = search_variable(name); if (var != NULL && (var->v_type & VF_MASK) == VF_SCALAR) { if (var->v_getter) { var->v_getter(var); if ((var->v_type & VF_MASK) != VF_SCALAR) return NULL; } return var->v_value; } return NULL; } /* Returns the value(s) of the specified variable/array as an array. * The return value's type is `struct get_variable_T'. It has three members: * `type', `count' and `values'. * `type' is the type of the result: * GV_NOTFOUND: no such variable/array * GV_SCALAR: a normal scalar variable * GV_ARRAY: an array of zero or more values * GV_ARRAY_CONCAT: an array whose values should be concatenated by caller * `values' is an array containing the value(s) of the variable/array. * A scalar value (GV_SCALAR) is returned as a NULL-terminated array containing * exactly one wide string. An array (GV_ARRAY*) is returned as a NULL- * terminated array of pointers to wide strings. If no such variable is found * (GV_NOTFOUND), `values' is NULL. The caller must free the `values' array and * its element strings iff `freevalues' is true. If `freevalues' is false, the * caller must not modify the array or its elements. * `count' is the number of elements in `values'. */ struct get_variable_T get_variable(const wchar_t *name) { struct get_variable_T result; wchar_t *value; variable_T *var; if (name[0] == L'\0') { goto not_found; } else if (name[1] == L'\0') { /* `name' is one-character long: check if it's a special parameter */ switch (name[0]) { case L'*': result.type = GV_ARRAY_CONCAT; goto positional_parameters; case L'@': result.type = GV_ARRAY; positional_parameters: var = search_variable(L VAR_positional); assert(var != NULL && (var->v_type & VF_MASK) == VF_ARRAY); result.count = var->v_valc; result.values = var->v_vals; result.freevalues = false; return result; case L'#': var = search_variable(L VAR_positional); assert(var != NULL && (var->v_type & VF_MASK) == VF_ARRAY); value = malloc_wprintf(L"%zu", var->v_valc); goto return_single; case L'?': value = malloc_wprintf(L"%d", laststatus); goto return_single; case L'-': value = get_hyphen_parameter(); goto return_single; case L'$': value = malloc_wprintf(L"%jd", (intmax_t) shell_pid); goto return_single; case L'!': value = malloc_wprintf(L"%jd", (intmax_t) lastasyncpid); goto return_single; case L'0': value = xwcsdup(command_name); goto return_single; } } if (iswdigit(name[0])) { /* `name' starts with a digit: a positional parameter */ wchar_t *nameend; errno = 0; uintmax_t v = wcstoumax(name, &nameend, 10); if (errno != 0 || *nameend != L'\0') goto not_found; /* not a number or overflow */ var = search_variable(L VAR_positional); assert(var != NULL && (var->v_type & VF_MASK) == VF_ARRAY); if (v == 0 || var->v_valc < v) goto not_found; /* index out of bounds */ value = xwcsdup(var->v_vals[v - 1]); goto return_single; } /* now it should be a normal variable */ var = search_variable(name); if (var != NULL) { if (var->v_getter) var->v_getter(var); switch (var->v_type & VF_MASK) { case VF_SCALAR: value = var->v_value ? xwcsdup(var->v_value) : NULL; goto return_single; case VF_ARRAY: result.type = GV_ARRAY; result.count = var->v_valc; result.values = var->v_vals; result.freevalues = false; return result; } } goto not_found; return_single: /* return a scalar as a one-element array */ if (value != NULL) { result.type = GV_SCALAR; result.count = 1; result.values = xmallocn(2, sizeof *result.values); result.values[0] = value; result.values[1] = NULL; result.freevalues = true; return result; } not_found: return (struct get_variable_T) { .type = GV_NOTFOUND }; } /* If `gv->freevalues' is false, substitutes `gv->values' with a newly-malloced * copy of it and turns `gv->freevalues' to true. */ void save_get_variable_values(struct get_variable_T *gv) { if (!gv->freevalues) { gv->values = plndup(gv->values, gv->count, copyaswcs); gv->freevalues = true; } } /* Makes a new array that contains all the variables in the current environment. * The elements of the array are key-value pairs of names (const wchar_t *) and * values (const variable_T *). * If `global' is true, variables in all the ancestor environments are also * included (except the ones hidden by local variables). * The resultant array is assigned to `*resultp' and the number of the key-value * pairs is returned. The array contents must not be modified or freed. */ size_t make_array_of_all_variables(bool global, kvpair_T **resultp) { if (current_env->parent == NULL || (!global && current_env->is_temporary)) { *resultp = ht_tokvarray(¤t_env->contents); return current_env->contents.count; } else { hashtable_T variables; size_t count; ht_init(&variables, hashwcs, htwcscmp); get_all_variables_rec(&variables, current_env, global); *resultp = ht_tokvarray(&variables); count = variables.count; ht_destroy(&variables); return count; } } /* Gathers all variables in the specified environment and adds them to the * specified hashtable. * If `global' is true, variables in all the ancestor environments are also * included (except the ones hidden by local variables). * Keys and values added to the hashtable must not be modified or freed by the * caller. */ void get_all_variables_rec(hashtable_T *table, environ_T *env, bool global) { if (env->parent != NULL && (global || env->is_temporary)) get_all_variables_rec(table, env->parent, global); size_t i = 0; kvpair_T kv; while ((kv = ht_next(&env->contents, &i)).key != NULL) ht_set(table, kv.key, kv.value); } /* Creates a new variable environment. * `temp' specifies whether the new environment is for temporary assignments. * The current environment will be the parent of the new environment. */ /* Don't forget to call `set_positional_parameters'! */ void open_new_environment(bool temp) { environ_T *newenv = xmalloc(sizeof *newenv); newenv->parent = current_env; newenv->is_temporary = temp; ht_init(&newenv->contents, hashwcs, htwcscmp); for (size_t i = 0; i < PA_count; i++) newenv->paths[i] = NULL; current_env = newenv; } /* Destroys the current variable environment. * The parent of the current becomes the new current. */ void close_current_environment(void) { environ_T *oldenv = current_env; assert(oldenv != first_env); current_env = oldenv->parent; ht_clear(&oldenv->contents, varkvfree_reexport); ht_destroy(&oldenv->contents); for (size_t i = 0; i < PA_count; i++) plfree((void **) oldenv->paths[i], free); free(oldenv); } /********** Getters **********/ /* line number of the currently executing command */ unsigned long current_lineno; /* getter for $LINENO */ void lineno_getter(variable_T *var) { assert((var->v_type & VF_MASK) == VF_SCALAR); free(var->v_value); var->v_value = malloc_wprintf(L"%lu", current_lineno); // variable_set(VAR_LINENO, var); if (var->v_type & VF_EXPORT) update_environment(L VAR_LINENO); } /* getter for $RANDOM */ void random_getter(variable_T *var) { assert((var->v_type & VF_MASK) == VF_SCALAR); free(var->v_value); var->v_value = malloc_wprintf(L"%u", next_random()); // variable_set(VAR_RANDOM, var); if (var->v_type & VF_EXPORT) update_environment(L VAR_RANDOM); } /* Returns a random number between 0 and 32767 using `rand'. */ unsigned next_random(void) { #if RAND_MAX == 32767 return (unsigned) rand(); #elif RAND_MAX == 65535 return (unsigned) rand() >> 1; #elif RAND_MAX == 2147483647 return (unsigned) rand() >> 16; #elif RAND_MAX == 4294967295 return (unsigned) rand() >> 17; #else unsigned rem = RAND_MAX % 32768 + 1; if (rem == 32768) { return (unsigned) rand() & 32767; } else { unsigned value; do value = rand(); while (value > RAND_MAX - rem); return value; } #endif } /********** Setter **********/ /* General callback function that is called after an assignment. * `var' is NULL when the variable is unset. */ void variable_set(const wchar_t *name, variable_T *var) { switch (name[0]) { case L'C': if (wcscmp(name, L VAR_CDPATH) == 0) reset_path(PA_CDPATH, var); #if YASH_ENABLE_LINEEDIT else if (wcscmp(name, L VAR_COLUMNS) == 0) le_need_term_update = true; #endif break; case L'L': if (wcscmp(name, L VAR_LANG) == 0 || wcsncmp(name, L"LC_", 3) == 0) reset_locale(name); #if YASH_ENABLE_LINEEDIT else if (wcscmp(name, L VAR_LINES) == 0) le_need_term_update = true; #endif break; case L'P': if (wcscmp(name, L VAR_PATH) == 0) { clear_cmdhash(); reset_path(PA_PATH, var); } break; case L'R': if (random_active && wcscmp(name, L VAR_RANDOM) == 0) { random_active = false; if (var != NULL && (var->v_type & VF_MASK) == VF_SCALAR && var->v_value != NULL) { unsigned long seed; if (xwcstoul(var->v_value, 0, &seed)) { srand((unsigned) seed); var->v_getter = random_getter; random_active = true; } } } break; #if YASH_ENABLE_LINEEDIT case L'T': if (wcscmp(name, L VAR_TERM) == 0) le_need_term_update = true; break; #endif /* YASH_ENABLE_LINEEDIT */ case L'Y': if (wcscmp(name, L VAR_YASH_LOADPATH) == 0) reset_path(PA_LOADPATH, var); break; } } /********** Path Array Manipulation **********/ /* Splits the specified string at colons. * If `paths' is non-NULL, a newly-malloced NULL-terminated array of pointers to * newly-malloced multibyte strings is returned. * If `paths' is NULL, NULL is returned. */ char **decompose_paths(const wchar_t *paths) { if (paths == NULL) return NULL; plist_T list; pl_init(&list); const wchar_t *colon; while ((colon = wcschr(paths, L':')) != NULL) { add_to_list_no_dup(&list, malloc_wcsntombs(paths, colon - paths)); paths = &colon[1]; } add_to_list_no_dup(&list, malloc_wcstombs(paths)); return (char **) pl_toary(&list); } /* Converts an array of wide strings into an newly-malloced array of multibyte * strings. * If `paths' is NULL, NULL is returned. */ char **convert_path_array(void **ary) { if (ary == NULL) return NULL; plist_T list; pl_init(&list); while (*ary != NULL) { add_to_list_no_dup(&list, malloc_wcstombs(*ary)); ary++; } return (char **) pl_toary(&list); } /* If `s' is non-NULL and not contained in `list', adds `s' to list. * Otherwise, frees `s'. */ void add_to_list_no_dup(plist_T *list, char *s) { if (s != NULL) { for (size_t i = 0; i < list->length; i++) { if (strcmp(s, list->contents[i]) == 0) { free(s); return; } } pl_add(list, s); } } /* Reconstructs the path array of the specified variable in the environment. * `var' may be NULL. */ void reset_path(path_T name, variable_T *var) { for (environ_T *env = current_env; env != NULL; env = env->parent) { plfree((void **) env->paths[name], free); variable_T *v = ht_get(&env->contents, path_variables[name]).value; if (v != NULL) { switch (v->v_type & VF_MASK) { case VF_SCALAR: env->paths[name] = decompose_paths(v->v_value); break; case VF_ARRAY: env->paths[name] = convert_path_array(v->v_vals); break; } if (v == var) break; } else { env->paths[name] = NULL; } } } /* Returns the path array of the specified variable. * The return value is NULL if the variable is not set. * The caller must not make any change to the returned array. */ char *const *get_path_array(path_T name) { for (environ_T *env = current_env; env != NULL; env = env->parent) if (env->paths[name] != NULL) return env->paths[name]; return NULL; } /********** Shell Functions **********/ /* type of functions */ struct function_T { vartype_T f_type; /* only VF_READONLY and VF_NODELETE are valid */ command_T *f_body; /* body of function */ }; /* Frees the specified function. */ void funcfree(function_T *f) { if (f != NULL) { comsfree(f->f_body); free(f); } } /* Frees the specified key-value pair of a function name and a function. */ void funckvfree(kvpair_T kv) { free(kv.key); funcfree(kv.value); } /* Defines function `name' as command `body'. * It is an error to re-define a read-only function. * Returns true iff successful. */ bool define_function(const wchar_t *name, command_T *body) { function_T *f = ht_get(&functions, name).value; if (f != NULL && (f->f_type & VF_READONLY)) { xerror(0, Ngt("function `%ls' cannot be redefined " "because it is read-only"), name); return false; } f = xmalloc(sizeof *f); f->f_type = 0; f->f_body = comsdup(body); if (shopt_hashondef) hash_all_commands_recursively(body); funckvfree(ht_set(&functions, xwcsdup(name), f)); return true; } /* Gets the body of the function with the specified name. * Returns NULL if there is no such a function. */ command_T *get_function(const wchar_t *name) { function_T *f = ht_get(&functions, name).value; if (f != NULL) return f->f_body; else return NULL; } /* Registers all the commands in the argument to the command hashtable. */ void hash_all_commands_recursively(const command_T *c) { for (; c != NULL; c = c->next) { switch (c->c_type) { case CT_SIMPLE: if (c->c_words) tryhash_word_as_command(c->c_words[0]); break; case CT_GROUP: case CT_SUBSHELL: hash_all_commands_in_and_or(c->c_subcmds); break; case CT_IF: hash_all_commands_in_if(c->c_ifcmds); break; case CT_FOR: hash_all_commands_in_and_or(c->c_forcmds); break; case CT_WHILE: hash_all_commands_in_and_or(c->c_whlcond); hash_all_commands_in_and_or(c->c_whlcmds); break; case CT_CASE: hash_all_commands_in_case(c->c_casitems); break; case CT_FUNCDEF: break; } } } void hash_all_commands_in_and_or(const and_or_T *ao) { for (; ao != NULL; ao = ao->next) { for (pipeline_T *p = ao->ao_pipelines; p != NULL; p = p->next) { hash_all_commands_recursively(p->pl_commands); } } } void hash_all_commands_in_if(const ifcommand_T *ic) { for (; ic != NULL; ic = ic->next) { hash_all_commands_in_and_or(ic->ic_condition); hash_all_commands_in_and_or(ic->ic_commands); } } void hash_all_commands_in_case(const caseitem_T *ci) { for (; ci != NULL; ci = ci->next) { hash_all_commands_in_and_or(ci->ci_commands); } } void tryhash_word_as_command(const wordunit_T *w) { if (w != NULL && w->next == NULL && w->wu_type == WT_STRING) { wchar_t *cmdname = unquote(w->wu_string); if (wcschr(cmdname, L'/') == NULL) { char *mbsname = malloc_wcstombs(cmdname); get_command_path(mbsname, false); free(mbsname); } free(cmdname); } } #if YASH_ENABLE_LINEEDIT /* Generates completion candidates for variable names matching the pattern. */ /* The prototype of this function is declared in "lineedit/complete.h". */ void generate_variable_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_VARIABLE)) return; le_compdebug("adding variable name candidates"); if (!le_compile_cpatterns(compopt)) return; size_t i = 0; kvpair_T kv; while ((kv = ht_next(&first_env->contents, &i)).key != NULL) { const wchar_t *name = kv.key; const variable_T *var = kv.value; switch (var->v_type & VF_MASK) { case VF_SCALAR: if (!(compopt->type & CGT_SCALAR)) continue; break; case VF_ARRAY: if (!(compopt->type & CGT_ARRAY)) continue; break; } if (name[0] != L'=' && le_wmatch_comppatterns(compopt, name)) le_new_candidate(CT_VAR, xwcsdup(name), NULL, compopt); } } /* Generates completion candidates for function names matching the pattern. */ /* The prototype of this function is declared in "lineedit/complete.h". */ void generate_function_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_FUNCTION)) return; le_compdebug("adding function name candidates"); if (!le_compile_cpatterns(compopt)) return; size_t i = 0; const wchar_t *name; while ((name = ht_next(&functions, &i).key) != NULL) if (le_wmatch_comppatterns(compopt, name)) le_new_candidate(CT_COMMAND, xwcsdup(name), NULL, compopt); } #endif /* YASH_ENABLE_LINEEDIT */ /********** Directory Stack **********/ #if YASH_ENABLE_DIRSTACK /* Parses the specified string as the index of a directory stack entry. * The index string must start with the plus or minus sign. * If the corresponding entry is found, the entry is assigned to `*entryp' and * the index value is assigned to `*indexp'. If the index is out of range, it is * an error. If the string is not a valid integer, `indexstr' is assigned to * `*entryp' and SIZE_MAX is assigned to `*indexp'. * If the index denotes $PWD, the number of the entries in $DIRSTACK is assigned * to `*indexp'. * Returns true if successful (`*entryp' and `*indexp' are assigned). * Returns false on error, in which case an error message is printed iff * `printerror' is true. */ bool parse_dirstack_index( const wchar_t *restrict indexstr, size_t *restrict indexp, const wchar_t **restrict entryp, bool printerror) { long num; if (indexstr[0] != L'-' && indexstr[0] != L'+') goto not_index; if (!xwcstol(indexstr, 10, &num)) goto not_index; variable_T *var = search_variable(L VAR_DIRSTACK); if (var == NULL || ((var->v_type & VF_MASK) != VF_ARRAY)) { if (num == 0) goto return_pwd; if (printerror) xerror(0, Ngt("the directory stack is empty")); return false; } #if LONG_MAX > SIZE_MAX if (num > SIZE_MAX || num < -(long) SIZE_MAX) goto out_of_range; #endif if (indexstr[0] == L'+' && num >= 0) { if (num == 0) { num = var->v_valc; goto return_pwd; } if ((size_t) num > var->v_valc) goto out_of_range; *indexp = var->v_valc - (size_t) num; *entryp = var->v_vals[*indexp]; return true; } else if (indexstr[0] == L'-' && num <= 0) { if (num == LONG_MIN) goto out_of_range; num = -num; assert(num >= 0); if ((size_t) num > var->v_valc) goto out_of_range; if ((size_t) num == var->v_valc) goto return_pwd; *indexp = (size_t) num; *entryp = var->v_vals[*indexp]; return true; } else { goto not_index; } const wchar_t *pwd; return_pwd: pwd = getvar(L VAR_PWD); if (pwd == NULL) { if (printerror) xerror(0, Ngt("$PWD is not set")); return false; } *entryp = pwd; *indexp = (size_t) num; return true; not_index: *entryp = indexstr; *indexp = SIZE_MAX; return true; out_of_range: if (printerror) xerror(0, Ngt("index %ls is out of range"), indexstr); return false; } #endif /* YASH_ENABLE_DIRSTACK */ #if YASH_ENABLE_LINEEDIT /* Generates candidates to complete a directory stack index. */ /* The prototype of this function is declared in "lineedit/complete.h". */ void generate_dirstack_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_DIRSTACK)) return; le_compdebug("adding directory stack index candidates"); #if YASH_ENABLE_DIRSTACK if (!le_compile_cpatterns(compopt)) return; variable_T *dirstack = search_variable(L VAR_DIRSTACK); size_t totalcount = 1; wchar_t *index; if (dirstack != NULL && (dirstack->v_type & VF_MASK) == VF_ARRAY) { size_t count = dirstack->v_valc; for (size_t i = 0; i < count; i++) { switch (compopt->src[0]) { case L'+': index = malloc_wprintf(L"+%zu", count - i); break; case L'-': index = malloc_wprintf(L"-%zu", i); break; default: return; } if (le_wmatch_comppatterns(compopt, index)) le_new_candidate( CT_WORD, index, xwcsdup(dirstack->v_vals[i]), compopt); else free(index); } totalcount += count; } switch (compopt->src[0]) { case L'+': index = malloc_wprintf(L"+%zu", 0); break; case L'-': index = malloc_wprintf(L"-%zu", totalcount - 1); break; default: return; } if (le_wmatch_comppatterns(compopt, index)) { const wchar_t *pwd = getvar(L VAR_PWD); wchar_t *duppwd = (pwd != NULL) ? xwcsdup(pwd) : NULL; le_new_candidate(CT_WORD, index, duppwd, compopt); } else { free(index); } #else /* YASH_ENABLE_DIRSTACK */ le_compdebug(" directory stack is disabled"); #endif } #endif /* YASH_ENABLE_LINEEDIT */ /********** Built-ins **********/ static void print_variable( const wchar_t *name, const variable_T *var, const wchar_t *argv0, bool readonly, bool export) __attribute__((nonnull)); static void print_scalar(const wchar_t *name, bool namequote, const variable_T *var, const wchar_t *argv0) __attribute__((nonnull)); static void print_array( const wchar_t *name, const variable_T *var, const wchar_t *argv0) __attribute__((nonnull)); static void print_function( const wchar_t *name, const function_T *func, const wchar_t *argv0, bool readonly) __attribute__((nonnull)); #if YASH_ENABLE_ARRAY static int array_dump_all(const wchar_t *argv0); static void array_remove_elements( variable_T *array, size_t count, void *const *indexwcss) __attribute__((nonnull)); static int compare_long(const void *lp1, const void *lp2) __attribute__((nonnull,pure)); static void array_insert_elements( variable_T *array, size_t count, void *const *values) __attribute__((nonnull)); static void array_set_element(const wchar_t *name, variable_T *array, const wchar_t *indexword, const wchar_t *value) __attribute__((nonnull)); #endif /* YASH_ENABLE_ARRAY */ static bool unset_function(const wchar_t *name) __attribute__((nonnull)); static bool unset_variable(const wchar_t *name) __attribute__((nonnull)); static bool check_options(const wchar_t *options) __attribute__((nonnull,pure)); static bool set_optind(unsigned long optind, unsigned long optsubind); static inline bool set_optarg(const wchar_t *value); static bool set_variable_single_char(const wchar_t *varname, wchar_t value) __attribute__((nonnull)); static bool read_with_prompt(xwcsbuf_T *buf, bool noescape) __attribute__((nonnull)); static void split_and_assign_array(const wchar_t *name, wchar_t *values, const wchar_t *ifs, bool raw) __attribute__((nonnull)); /* Options for the "typeset" built-in. */ const struct xgetopt_T typeset_options[] = { { L'f', L"functions", OPTARG_NONE, false, NULL, }, { L'g', L"global", OPTARG_NONE, false, NULL, }, { L'p', L"print", OPTARG_NONE, true, NULL, }, { L'r', L"readonly", OPTARG_NONE, false, NULL, }, { L'x', L"export", OPTARG_NONE, false, NULL, }, { L'X', L"unexport", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "typeset" built-in, which accepts the following options: * -f: affect functions rather than variables * -g: global * -p: print variables * -r: make variables readonly * -x: export variables * -X: cancel exportation of variables * Equivalent built-ins: * export: typeset -gx * readonly: typeset -gr * The "set" built-in without any arguments is redirected to this built-in. */ int typeset_builtin(int argc, void **argv) { bool function = false, global = false, print = false; bool readonly = false, export = false, unexport = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, typeset_options, 0)) != NULL) { switch (opt->shortopt) { case L'f': function = true; break; case L'g': global = true; break; case L'p': print = true; break; case L'r': readonly = true; break; case L'x': export = true; break; case L'X': unexport = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (wcscmp(ARGV(0), L"export") == 0) { global = true; if (!unexport) export = true; } else if (wcscmp(ARGV(0), L"readonly") == 0) { global = readonly = true; } else { assert(wcscmp(ARGV(0), L"typeset") == 0 || wcscmp(ARGV(0), L"set") == 0); } if (function && export) return special_builtin_syntax_error( mutually_exclusive_option_error(L'f', L'x')); if (function && unexport) return special_builtin_syntax_error( mutually_exclusive_option_error(L'f', L'X')); if (export && unexport) return special_builtin_syntax_error( mutually_exclusive_option_error(L'x', L'X')); if (xoptind == argc) { kvpair_T *kvs; size_t count; if (!function) { /* print all variables */ count = make_array_of_all_variables(global, &kvs); qsort(kvs, count, sizeof *kvs, keywcscoll); for (size_t i = 0; yash_error_message_count == 0 && i < count; i++) print_variable( kvs[i].key, kvs[i].value, ARGV(0), readonly, export); } else { /* print all functions */ kvs = ht_tokvarray(&functions); count = functions.count; qsort(kvs, count, sizeof *kvs, keywcscoll); for (size_t i = 0; yash_error_message_count == 0 && i < count; i++) print_function(kvs[i].key, kvs[i].value, ARGV(0), readonly); } free(kvs); } else { do { wchar_t *arg = ARGV(xoptind); if (!function) { wchar_t *wequal = wcschr(arg, L'='); if (wequal != NULL) *wequal = L'\0'; if (wequal != NULL || !print) { /* create/assign variable */ variable_T *var = global ? new_global(arg) : new_local(arg); vartype_T saveexport = var->v_type & VF_EXPORT; if (wequal != NULL) { if (var->v_type & VF_READONLY) { xerror(0, Ngt("$%ls is read-only"), arg); } else { varvaluefree(var); var->v_type = VF_SCALAR | (var->v_type & ~VF_MASK); var->v_value = xwcsdup(&wequal[1]); var->v_getter = NULL; } } if (readonly) var->v_type |= VF_READONLY | VF_NODELETE; if (export) var->v_type |= VF_EXPORT; else if (unexport) var->v_type &= ~VF_EXPORT; variable_set(arg, var); if (saveexport != (var->v_type & VF_EXPORT) || (wequal != NULL && (var->v_type & VF_EXPORT))) update_environment(arg); } else { /* print the variable */ variable_T *var = search_variable(arg); if (var != NULL) { print_variable(arg, var, ARGV(0), readonly, export); } else { xerror(0, Ngt("no such variable $%ls"), arg); } } } else { /* treat function */ function_T *f = ht_get(&functions, arg).value; if (f != NULL) { if (readonly) f->f_type |= VF_READONLY | VF_NODELETE; if (print) print_function(arg, f, ARGV(0), readonly); } else { xerror(0, Ngt("no such function `%ls'"), arg); } } } while (++xoptind < argc); } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Prints the specified variable to the standard output. * This function does not print special variables whose name begins with an '='. * If `readonly' or `export' is true, the variable is printed only if it is * read-only or exported, respectively. The `name' is quoted if `is_name(name)' * is not true. * An error message is printed to the standard error on error. */ void print_variable( const wchar_t *name, const variable_T *var, const wchar_t *argv0, bool readonly, bool export) { wchar_t *qname = NULL; if (name[0] == L'=') return; if (readonly && !(var->v_type & VF_READONLY)) return; if (export && !(var->v_type & VF_EXPORT)) return; if (!is_name(name)) name = qname = quote_sq(name); switch (var->v_type & VF_MASK) { case VF_SCALAR: print_scalar(name, qname != NULL, var, argv0); break; case VF_ARRAY: print_array(name, var, argv0); break; } free(qname); } /* Prints the specified scalar variable to the standard output. * If `is_name(name)' is not true, the quoted name must be given as `qname'; * otherwise, `qname' must be NULL. * An error message is printed to the standard error on error. */ void print_scalar(const wchar_t *name, bool namequote, const variable_T *var, const wchar_t *argv0) { wchar_t *quotedvalue; const char *format; xstrbuf_T opts; if (var->v_value != NULL) quotedvalue = quote_sq(var->v_value); else quotedvalue = NULL; switch (argv0[0]) { case L's': assert(wcscmp(argv0, L"set") == 0); if (!namequote && quotedvalue != NULL) xprintf("%ls=%ls\n", name, quotedvalue); break; case L'e': case L'r': assert(wcscmp(argv0, L"export") == 0 || wcscmp(argv0, L"readonly") == 0); format = (quotedvalue != NULL) ? "%ls %ls=%ls\n" : "%ls %ls\n"; xprintf(format, argv0, name, quotedvalue); break; case L't': assert(wcscmp(argv0, L"typeset") == 0); sb_init(&opts); if (var->v_type & VF_EXPORT) sb_ccat(&opts, 'x'); if (var->v_type & VF_READONLY) sb_ccat(&opts, 'r'); if (opts.length > 0) sb_insert(&opts, 0, " -"); format = (quotedvalue != NULL) ? "%ls%s %ls=%ls\n" : "%ls%s %ls\n"; xprintf(format, argv0, opts.contents, name, quotedvalue); sb_destroy(&opts); break; default: assert(false); } free(quotedvalue); } /* Prints the specified array variable to the standard output. * An error message is printed to the standard error on error. */ void print_array( const wchar_t *name, const variable_T *var, const wchar_t *argv0) { xstrbuf_T opts; if (!xprintf("%ls=(", name)) return; if (var->v_valc > 0) { for (size_t i = 0; ; ) { wchar_t *qvalue = quote_sq(var->v_vals[i]); bool ok = xprintf("%ls", qvalue); free(qvalue); if (!ok) return; i++; if (i >= var->v_valc) break; if (!xprintf(" ")) return; } } if (!xprintf(")\n")) return; switch (argv0[0]) { case L'a': assert(wcscmp(argv0, L"array") == 0); break; case L's': assert(wcscmp(argv0, L"set") == 0); break; case L'e': case L'r': assert(wcscmp(argv0, L"export") == 0 || wcscmp(argv0, L"readonly") == 0); xprintf("%ls %ls\n", argv0, name); break; case L't': assert(wcscmp(argv0, L"typeset") == 0); sb_init(&opts); if (var->v_type & VF_EXPORT) sb_ccat(&opts, 'x'); if (var->v_type & VF_READONLY) sb_ccat(&opts, 'r'); if (opts.length > 0) sb_insert(&opts, 0, " -"); xprintf("%ls%s %ls\n", argv0, opts.contents, name); sb_destroy(&opts); break; default: assert(false); } } /* Prints the specified function to the standard output. * If `readonly' is true, the function is printed only if it is read-only. * An error message is printed to the standard error if failed to print to the * standard output. */ void print_function( const wchar_t *name, const function_T *func, const wchar_t *argv0, bool readonly) { if (readonly && !(func->f_type & VF_READONLY)) return; wchar_t *qname = NULL; if (!is_name(name)) name = qname = quote_sq(name); wchar_t *value = command_to_wcs(func->f_body, true); const char *format = (qname == NULL) ? "%ls()\n%ls" : "function %ls()\n%ls"; bool ok = xprintf(format, name, value); free(value); if (!ok) goto end; switch (argv0[0]) { case L'r': assert(wcscmp(argv0, L"readonly") == 0); if (func->f_type & VF_READONLY) xprintf("%ls -f %ls\n", argv0, name); break; case L't': assert(wcscmp(argv0, L"typeset") == 0); if (func->f_type & VF_READONLY) xprintf("%ls -fr %ls\n", argv0, name); break; default: assert(false); } end: free(qname); } #if YASH_ENABLE_HELP const char typeset_help[] = Ngt( "set or print variables" ); const char typeset_syntax[] = Ngt( "\ttypeset [-fgprxX] [name[=value]...]\n" ); const char export_help[] = Ngt( "export variables as environment variables" ); const char export_syntax[] = Ngt( "\texport [-prX] [name[=value]...]\n" ); const char readonly_help[] = Ngt( "make variables read-only" ); const char readonly_syntax[] = Ngt( "\treadonly [-fpxX] [name[=value]...]\n" ); #endif #if YASH_ENABLE_ARRAY /* Options for the "array" built-in. */ const struct xgetopt_T array_options[] = { { L'd', L"delete", OPTARG_NONE, true, NULL, }, { L'i', L"insert", OPTARG_NONE, true, NULL, }, { L's', L"set", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "array" built-in, which accepts the following options: * -d: delete an array element * -i: insert an array element * -s: set an array element value */ int array_builtin(int argc, void **argv) { enum { NONE = 0, DELETE = 1 << 0, INSERT = 1 << 1, SET = 1 << 2, } options = NONE; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, array_options, XGETOPT_DIGIT)) != NULL) { switch (opt->shortopt) { case L'd': options |= DELETE; break; case L'i': options |= INSERT; break; case L's': options |= SET; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } /* error checks */ if (options != NONE && (options & (options - 1)) != 0) { xerror(0, Ngt("more than one option cannot be used at once")); return Exit_ERROR; } size_t min, max; switch (options) { case NONE: min = 0; max = SIZE_MAX; break; case DELETE: min = 1; max = SIZE_MAX; break; case INSERT: min = 2; max = SIZE_MAX; break; case SET: min = 3; max = 3; break; default: assert(false); } if (!validate_operand_count(argc - xoptind, min, max)) return Exit_ERROR; if (xoptind == argc) return array_dump_all(ARGV(0)); const wchar_t *name = ARGV(xoptind++); if (wcschr(name, L'=') != NULL) { xerror(0, Ngt("`%ls' is not a valid array name"), name); return Exit_FAILURE; } if (options == 0) { set_array(name, argc - xoptind, pldup(&argv[xoptind], copyaswcs), SCOPE_GLOBAL, false); } else { variable_T *array = search_array_and_check_if_changeable(name); if (array == NULL) return Exit_FAILURE; switch (options) { case DELETE: array_remove_elements(array, argc - xoptind, &argv[xoptind]); break; case INSERT: array_insert_elements(array, argc - xoptind, &argv[xoptind]); break; case SET: array_set_element( name, array, ARGV(xoptind), ARGV(xoptind + 1)); break; default: assert(false); } } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } #if LONG_MAX < SIZE_MAX # define LONG_LT_SIZE(longvalue,sizevalue) \ ((size_t) (longvalue) < (sizevalue)) #else # define LONG_LT_SIZE(longvalue,sizevalue) \ ((longvalue) < (long) (sizevalue)) #endif /* Prints all existing arrays. * Returns an exit status to be returned by the array built-in. */ int array_dump_all(const wchar_t *argv0) { kvpair_T *kvs; size_t count = make_array_of_all_variables(true, &kvs); qsort(kvs, count, sizeof *kvs, keywcscoll); for (size_t i = 0; yash_error_message_count == 0 && i < count; i++) { variable_T *var = kvs[i].value; if ((var->v_type & VF_MASK) == VF_ARRAY) print_variable(kvs[i].key, var, argv0, false, false); } free(kvs); return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Removes elements from `array'. * `indexwcss' is an NULL-terminated array of pointers to wide strings, * which are parsed as indices of elements to be removed. * `count' is the number of elements in `indexwcss'. * An error message is printed to the standard error on error. */ void array_remove_elements( variable_T *array, size_t count, void *const *indexwcss) { long indices[count]; assert((array->v_type & VF_MASK) == VF_ARRAY); /* convert all the strings into long integers */ for (size_t i = 0; i < count; i++) { const wchar_t *indexwcs = indexwcss[i]; if (!xwcstol(indexwcs, 10, &indices[i])) { xerror(errno, Ngt("`%ls' is not a valid integer"), indexwcs); return; } if (indices[i] >= 0) { indices[i] -= 1; } else { #if LONG_MAX < SIZE_MAX if (!LONG_LT_SIZE(LONG_MAX, array->v_valc)) #endif indices[i] += array->v_valc; } } /* sort all the indices. */ qsort(indices, count, sizeof *indices, compare_long); /* remove elements in descending order so that an earlier removal does not * affect the indices for later removals. */ plist_T list; long lastindex = LONG_MIN; pl_initwith(&list, array->v_vals, array->v_valc); for (size_t i = count; i-- != 0; ) { long index = indices[i]; if (index == lastindex) continue; if (0 <= index && LONG_LT_SIZE(index, list.length)) { free(list.contents[index]); pl_remove(&list, index, 1); } lastindex = index; } array->v_valc = list.length; array->v_vals = pl_toary(&list); } int compare_long(const void *lp1, const void *lp2) { long l1 = *(const long *) lp1, l2 = *(const long *) lp2; return l1 == l2 ? 0 : l1 < l2 ? -1 : 1; } /* Inserts the specified elements into the specified array. * `values' is an NULL-terminated array of pointers to wide strings. * The first string in `values' is parsed as the integer index that specifies * where to insert the elements. The other strings are inserted to the array. * `count' is the number of strings in `values' including the first index * string. * An error message is printed to the standard error on error. */ void array_insert_elements( variable_T *array, size_t count, void *const *values) { long index; assert((array->v_type & VF_MASK) == VF_ARRAY); assert(count > 0); assert(values[0] != NULL); { const wchar_t *indexword = *values; if (!xwcstol(indexword, 10, &index)) { xerror(errno, Ngt("`%ls' is not a valid integer"), indexword); return; } } count--, values++; assert(plcount(values) == count); if (index < 0) { index += array->v_valc + 1; if (index < 0) index = 0; } size_t uindex; if (LONG_LT_SIZE(index, array->v_valc)) uindex = (size_t) index; else uindex = array->v_valc; plist_T list; pl_initwith(&list, array->v_vals, array->v_valc); pl_insert(&list, uindex, values); for (size_t i = 0; i < count; i++) list.contents[uindex + i] = xwcsdup(list.contents[uindex + i]); array->v_valc = list.length; array->v_vals = pl_toary(&list); } /* Sets the value of the specified element of the array. * `name' is the name of the array variable. * `indexword' is parsed as the integer index of the element. * An error message is printed to the standard error on error. */ void array_set_element(const wchar_t *name, variable_T *array, const wchar_t *indexword, const wchar_t *value) { assert((array->v_type & VF_MASK) == VF_ARRAY); long index; if (!xwcstol(indexword, 10, &index)) { xerror(errno, Ngt("`%ls' is not a valid integer"), indexword); return; } size_t uindex; if (index < 0) { index += array->v_valc; if (index < 0) goto invalid_index; assert(LONG_LT_SIZE(index, array->v_valc)); uindex = (size_t) index; } else if (index > 0) { if (!LONG_LT_SIZE(index - 1, array->v_valc)) goto invalid_index; uindex = (size_t) index - 1; } else { goto invalid_index; } assert(uindex < array->v_valc); free(array->v_vals[uindex]); array->v_vals[uindex] = xwcsdup(value); return; invalid_index: xerror(0, Ngt("index %ls is out of range " "(the actual size of array $%ls is %zu)"), indexword, name, array->v_valc); } #if YASH_ENABLE_HELP const char array_help[] = Ngt( "manipulate an array" ); const char array_syntax[] = Ngt( "\tarray # print arrays\n" "\tarray name [value...] # set array values\n" "\tarray -d name [index...]\n" "\tarray -i name index [value...]\n" "\tarray -s name index value\n" ); #endif #endif /* YASH_ENABLE_ARRAY */ /* Options for the "unset" built-in. */ const struct xgetopt_T unset_options[] = { { L'f', L"functions", OPTARG_NONE, true, NULL, }, { L'v', L"variables", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "unset" built-in, which accepts the following options: * -f: deletes functions * -v: deletes variables (default) */ int unset_builtin(int argc, void **argv) { bool function = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, unset_options, 0)) != NULL) { switch (opt->shortopt) { case L'f': function = true; break; case L'v': function = false; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (posixly_correct && xoptind == argc) return insufficient_operands_error(1); for (; xoptind < argc; xoptind++) { const wchar_t *name = ARGV(xoptind); if (function) { unset_function(name); } else { if (wcschr(name, L'=')) { xerror(0, Ngt("`%ls' is not a valid variable name"), name); continue; } unset_variable(name); } } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Unsets the specified function. * On error, an error message is printed to the standard error and TRUE is * returned. */ bool unset_function(const wchar_t *name) { kvpair_T kv = ht_remove(&functions, name); function_T *f = kv.value; if (f != NULL) { if (!(f->f_type & VF_NODELETE)) { funckvfree(kv); } else { xerror(0, Ngt("function `%ls' is read-only"), name); ht_set(&functions, kv.key, kv.value); return true; } } return false; } /* Unsets the specified variable. * On error, an error message is printed to the standard error and TRUE is * returned. */ bool unset_variable(const wchar_t *name) { for (environ_T *env = current_env; env != NULL; env = env->parent) { kvpair_T kv = ht_remove(&env->contents, name); variable_T *var = kv.value; if (var != NULL) { if (!(var->v_type & VF_NODELETE)) { bool exported = var->v_type & VF_EXPORT; varkvfree(kv); variable_set(name, NULL); if (exported) update_environment(name); return false; } else { xerror(0, Ngt("$%ls is read-only"), name); ht_set(&env->contents, kv.key, kv.value); return true; } } } return false; } #if YASH_ENABLE_HELP const char unset_help[] = Ngt( "remove variables or functions" ); const char unset_syntax[] = Ngt( "\tunset [-fv] [name...]\n" ); #endif /* The "shift" built-in */ int shift_builtin(int argc, void **argv) { const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, 0)) != NULL) { switch (opt->shortopt) { #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (!validate_operand_count(argc - xoptind, 0, 1)) return special_builtin_syntax_error(Exit_ERROR); size_t scount; if (xoptind < argc) { long count; if (!xwcstol(ARGV(xoptind), 10, &count)) { xerror(errno, Ngt("`%ls' is not a valid integer"), ARGV(xoptind)); return special_builtin_syntax_error(Exit_ERROR); } else if (count < 0) { xerror(0, Ngt("%ls: the operand value must not be negative"), ARGV(xoptind)); return special_builtin_syntax_error(Exit_ERROR); } #if LONG_MAX > SIZE_MAX if (count > (long) SIZE_MAX) scount = SIZE_MAX; else #endif scount = (size_t) count; } else { scount = 1; } variable_T *var = search_variable(L VAR_positional); assert(var != NULL && (var->v_type & VF_MASK) == VF_ARRAY); if (scount > var->v_valc) { xerror(0, ngt("%zu: cannot shift so many " "(there is only one positional parameter)", "%zu: cannot shift so many " "(there are only %zu positional parameters)", var->v_valc), scount, var->v_valc); return Exit_FAILURE; } plist_T list; pl_initwith(&list, var->v_vals, var->v_valc); for (size_t i = 0; i < scount; i++) free(list.contents[i]); pl_remove(&list, 0, scount); var->v_valc = list.length; var->v_vals = pl_toary(&list); return Exit_SUCCESS; } #if YASH_ENABLE_HELP const char shift_help[] = Ngt( "remove some positional parameters" ); const char shift_syntax[] = Ngt( "\tshift [count]\n" ); #endif /* The "getopts" built-in */ int getopts_builtin(int argc, void **argv) { const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, XGETOPT_POSIX)) != NULL) { switch (opt->shortopt) { #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (!validate_operand_count(argc - xoptind, 2, SIZE_MAX)) return Exit_ERROR; const wchar_t *options = ARGV(xoptind++); const wchar_t *varname = ARGV(xoptind++); void *const *args; unsigned long optind, optsubind; const wchar_t *arg, *optp; wchar_t optchar; if (wcschr(varname, L'=')) { xerror(0, Ngt("`%ls' is not a valid variable name"), varname); return Exit_FAILURE; } else if (!check_options(options)) { xerror(0, Ngt("`%ls' is not a valid option specification"), options); return Exit_FAILURE; } /* Parse $OPTIND */ { const wchar_t *varoptind = getvar(L VAR_OPTIND); wchar_t *endp; if (varoptind == NULL || varoptind[0] == L'\0') goto optind_invalid; errno = 0; optind = wcstoul(varoptind, &endp, 10); if (errno != 0 || varoptind == endp) goto optind_invalid; optind -= 1; if (*endp == L':') { endp++; if (!xwcstoul(endp, 10, &optsubind) || optsubind == 0) goto optind_invalid; } else { optsubind = 1; } } if (xoptind < argc) { if (optind >= (unsigned long) (argc - xoptind)) goto no_more_options; args = &argv[xoptind]; } else { variable_T *var = search_variable(L VAR_positional); assert(var != NULL && (var->v_type & VF_MASK) == VF_ARRAY); if (optind >= var->v_valc) goto no_more_options; args = var->v_vals; } #define TRY(exp) do { if (!(exp)) return Exit_FAILURE; } while (0) parse_arg: arg = args[optind]; if (arg == NULL || arg[0] != L'-' || arg[1] == L'\0') { goto no_more_options; } else if (arg[1] == L'-' && arg[2] == L'\0') { /* arg == "--" */ optind++; goto no_more_options; } else if (xwcsnlen(arg, optsubind + 1) <= optsubind) { optind++, optsubind = 1; goto parse_arg; } optchar = arg[optsubind++]; assert(optchar != L'\0'); if (optchar == L':' || (optp = wcschr(options, optchar)) == NULL) { /* invalid option */ TRY(set_variable_single_char(varname, L'?')); if (options[0] == L':') { TRY(set_variable_single_char(L VAR_OPTARG, optchar)); } else { fprintf(stderr, gt("%ls: `-%lc' is not a valid option\n"), command_name, (wint_t) optchar); TRY(!unset_variable(L VAR_OPTARG)); } } else { /* valid option */ if (optp[1] != L':') { /* option without an argument */ TRY(!unset_variable(L VAR_OPTARG)); } else { /* option with an argument */ const wchar_t *optarg = &arg[optsubind]; optsubind = 1; optind++; if (optarg[0] == L'\0') { optarg = args[optind++]; if (optarg == NULL) { /* argument is missing */ if (options[0] == L':') { TRY(set_variable_single_char(varname, L':')); TRY(set_variable_single_char(L VAR_OPTARG, optchar)); } else { fprintf(stderr, gt("%ls: the -%lc option's argument is missing\n"), command_name, (wint_t) optchar); TRY(set_variable_single_char(varname, L'?')); TRY(!unset_variable(L VAR_OPTARG)); } goto finish; } } TRY(set_optarg(optarg)); } TRY(set_variable_single_char(varname, optchar)); } finish: TRY(set_optind(optind, optsubind)); return Exit_SUCCESS; #undef TRY no_more_options: set_optind(optind, 0); set_variable_single_char(varname, L'?'); unset_variable(L VAR_OPTARG); return Exit_FAILURE; optind_invalid: xerror(0, Ngt("$OPTIND has an invalid value")); return Exit_FAILURE; } /* Checks if the `options' is valid. Returns true iff OK. */ bool check_options(const wchar_t *options) { if (options[0] == L':') options++; for (;;) switch (*options) { case L'\0': return true; case L':': return false; case L'?': if (posixly_correct) return false; /* falls thru! */ default: if (posixly_correct && !iswalpha(*options)) return false; options++; if (*options == L':') options++; continue; } } /* Sets $OPTIND to `optind' plus 1, followed by `optsubind' (if > 1). */ bool set_optind(unsigned long optind, unsigned long optsubind) { wchar_t *value = malloc_wprintf( optsubind > 1 ? L"%lu:%lu" : L"%lu", optind + 1, optsubind); return set_variable(L VAR_OPTIND, value, SCOPE_GLOBAL, shopt_allexport); } /* Sets $OPTARG to `value'. */ bool set_optarg(const wchar_t *value) { return set_variable(L VAR_OPTARG, xwcsdup(value), SCOPE_GLOBAL, shopt_allexport); } /* Sets the specified variable to the single character `value'. */ bool set_variable_single_char(const wchar_t *varname, wchar_t value) { wchar_t *v = xmallocn(2, sizeof *v); v[0] = value; v[1] = L'\0'; return set_variable(varname, v, SCOPE_GLOBAL, shopt_allexport); } #if YASH_ENABLE_HELP const char getopts_help[] = Ngt( "parse command options" ); const char getopts_syntax[] = Ngt( "\tgetopts options variable [argument...]\n" ); #endif /* Options for the "read" built-in. */ const struct xgetopt_T read_options[] = { { L'A', L"array", OPTARG_NONE, false, NULL, }, { L'r', L"raw-mode", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "read" built-in, which accepts the following options: * -A: assign values to array * -r: don't treat backslashes specially */ int read_builtin(int argc, void **argv) { bool array = false, raw = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, read_options, 0)) != NULL) { switch (opt->shortopt) { case L'A': array = true; break; case L'r': raw = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (xoptind == argc) return insufficient_operands_error(1); /* check if the identifiers are valid */ for (int i = xoptind; i < argc; i++) { if (wcschr(ARGV(i), L'=') != NULL) { xerror(0, Ngt("`%ls' is not a valid variable name"), ARGV(i)); return Exit_FAILURE; } } bool eof; xwcsbuf_T buf; /* read input and remove trailing newline */ wb_init(&buf); if (!read_with_prompt(&buf, raw)) { wb_destroy(&buf); return Exit_FAILURE; } if (buf.length > 0 && buf.contents[buf.length - 1] == L'\n') { wb_truncate(&buf, buf.length - 1); eof = false; } else { /* no newline means the EOF was encountered */ eof = true; } const wchar_t *s = buf.contents; const wchar_t *ifs = getvar(L VAR_IFS); plist_T list; /* split fields */ pl_init(&list); for (int i = xoptind; i < argc - 1; i++) pl_add(&list, split_next_field(&s, ifs, raw)); pl_add(&list, (raw || array) ? xwcsdup(s) : unescape(s)); wb_destroy(&buf); /* assign variables */ assert(xoptind + list.length == (size_t) argc); for (size_t i = 0; i < list.length; i++) { const wchar_t *name = ARGV(xoptind + i); if (i + 1 == list.length) trim_trailing_spaces(list.contents[i], ifs); if (array && i + 1 == list.length) split_and_assign_array(name, list.contents[i], ifs, raw); else set_variable(name, list.contents[i], SCOPE_GLOBAL, shopt_allexport); } pl_destroy(&list); return (!eof && yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Reads input from the standard input and, if `noescape' is false, remove line * continuations. * The trailing newline and all other backslashes are not removed. */ bool read_with_prompt(xwcsbuf_T *buf, bool noescape) { bool first = true; size_t index; bool use_prompt = is_interactive_now && isatty(STDIN_FILENO); struct promptset_T prompt; read_input: index = buf->length; if (use_prompt) { if (first) { prompt.main = xwcsdup(L""); prompt.right = xwcsdup(L""); prompt.styler = xwcsdup(L""); } else { prompt = get_prompt(2); } #if YASH_ENABLE_LINEEDIT if (shopt_lineedit != SHOPT_NOLINEEDIT) { wchar_t *line; inputresult_T result = le_readline(prompt, &line); if (result != INPUT_ERROR) { free_prompt(prompt); switch (result) { case INPUT_OK: wb_catfree(buf, line); /* falls thru! */ case INPUT_EOF: goto done; case INPUT_INTERRUPTED: set_interrupted(); return false; case INPUT_ERROR: assert(false); } } } #endif /* YASH_ENABLE_LINEEDIT */ print_prompt(prompt.main); print_prompt(prompt.styler); } inputresult_T result2 = read_input(buf, stdin_input_file_info, false); if (use_prompt) { print_prompt(PROMPT_RESET); free_prompt(prompt); } if (result2 == INPUT_ERROR) return false; #if YASH_ENABLE_LINEEDIT done: #endif first = false; if (!noescape) { /* treat escapes */ while (index < buf->length) { if (buf->contents[index] == L'\\') { if (buf->contents[index + 1] == L'\n') { wb_remove(buf, index, 2); if (index >= buf->length) goto read_input; else continue; } else { index += 2; continue; } } index++; } } return true; } /* Word-splits `values' and assigns them to the array named `name'. * `values' is freed in this function. */ void split_and_assign_array(const wchar_t *name, wchar_t *values, const wchar_t *ifs, bool raw) { plist_T list; pl_init(&list); if (values[0] != L'\0') { const wchar_t *v = values; while (*v != L'\0') pl_add(&list, split_next_field(&v, ifs, raw)); if (list.length > 0 && ((wchar_t *) list.contents[list.length - 1])[0] == L'\0') { free(list.contents[list.length - 1]); pl_remove(&list, list.length - 1, 1); } } set_array(name, list.length, pl_toary(&list), SCOPE_GLOBAL, false); free(values); } #if YASH_ENABLE_HELP const char read_help[] = Ngt( "read a line from the standard input" ); const char read_syntax[] = Ngt( "\tread [-Ar] variable...\n" ); #endif /* options for the "pushd" built-in */ const struct xgetopt_T pushd_options[] = { #if YASH_ENABLE_DIRSTACK { L'D', L"remove-duplicates", OPTARG_NONE, true, NULL, }, #endif { L'd', L"default-directory", OPTARG_REQUIRED, false, NULL, }, { L'L', L"logical", OPTARG_NONE, true, NULL, }, { L'P', L"physical", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* Note: `cd_options' and `pwd_options' are defined as part of `pushd_options'. */ #if YASH_ENABLE_DIRSTACK static variable_T *get_dirstack(void); static void push_dirstack(variable_T *var, wchar_t *value) __attribute__((nonnull)); static void remove_dirstack_entry_at(variable_T *var, size_t index) __attribute__((nonnull)); static void remove_dirstack_dups(variable_T *var) __attribute__((nonnull)); static bool print_dirstack_entry( bool verbose, size_t plusindex, size_t minusindex, const wchar_t *dir) __attribute__((nonnull)); /* The "pushd" built-in. * -L: don't resolve symbolic links (default) * -P: resolve symbolic links * --default-directory=: go to when the operand is missing * --remove-duplicates: remove duplicate entries in the directory stack. * -L and -P are mutually exclusive: the one specified last is used. */ int pushd_builtin(int argc __attribute__((unused)), void **argv) { bool logical = true, remove_dups = false; const wchar_t *newpwd = L"+1"; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, pushd_options, XGETOPT_DIGIT)) != NULL) { switch (opt->shortopt) { case L'L': logical = true; break; case L'P': logical = false; break; case L'd': newpwd = xoptarg; break; case L'D': remove_dups = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (!validate_operand_count(argc - xoptind, 0, 1)) return Exit_ERROR; const wchar_t *origpwd = getvar(L VAR_PWD); if (origpwd == NULL) { xerror(0, Ngt("$PWD is not set")); return Exit_FAILURE; } bool useoldpwd = false; if (xoptind < argc) { newpwd = ARGV(xoptind); if (wcscmp(newpwd, L"-") == 0) useoldpwd = true; } size_t stackindex; if (useoldpwd) { newpwd = getvar(L VAR_OLDPWD); stackindex = SIZE_MAX; if (newpwd == NULL || newpwd[0] == L'\0') { xerror(0, Ngt("$OLDPWD is not set")); return Exit_FAILURE; } } else { if (!parse_dirstack_index(newpwd, &stackindex, &newpwd, true)) return Exit_FAILURE; } assert(newpwd != NULL); wchar_t *saveorigpwd = xwcsdup(origpwd); int result = change_directory(newpwd, useoldpwd, logical); #ifndef NDEBUG newpwd = NULL; /* newpwd cannot be used anymore. */ #endif if (result != Exit_SUCCESS) { free(saveorigpwd); return result; } variable_T *var = get_dirstack(); if (var == NULL) { free(saveorigpwd); return Exit_FAILURE; } push_dirstack(var, saveorigpwd); if (stackindex != SIZE_MAX) remove_dirstack_entry_at(var, stackindex); if (remove_dups) remove_dirstack_dups(var); return Exit_SUCCESS; } /* Returns the directory stack. * If the stack is not yet created, it is initialized as an empty stack and * returned. * Fails if a non-array variable or a read-only array already exists, in which * case NULL is returned. */ variable_T *get_dirstack(void) { variable_T *var = search_variable(L VAR_DIRSTACK); if (var != NULL) { if ((var->v_type & VF_MASK) != VF_ARRAY) { xerror(0, Ngt("$DIRSTACK is not an array")); return NULL; } else if (var->v_type & VF_READONLY) { xerror(0, Ngt("$%ls is read-only"), L VAR_DIRSTACK); return NULL; } return var; } // void **ary = xmallocn(1, sizeof *ary); void **ary = xmalloc(sizeof *ary); ary[0] = NULL; return set_array(L VAR_DIRSTACK, 0, ary, SCOPE_GLOBAL, false); } /* Adds the specified value to the directory stack ($DIRSTACK). * `var' must be the return value of a `get_dirstack' call. * `value' is used as an element of the $DIRSTACK array, so the caller must not * modify or free `value' after calling this function. */ void push_dirstack(variable_T *var, wchar_t *value) { size_t index = var->v_valc++; var->v_vals = xreallocn(var->v_vals, index + 2, sizeof *var->v_vals); var->v_vals[index] = value; var->v_vals[index + 1] = NULL; } /* Removes the directory stack entry specified by `index'. * `var' must be the directory stack array and `index' must be less than * `var->v_valc'. */ void remove_dirstack_entry_at(variable_T *var, size_t index) { assert(index < var->v_valc); free(var->v_vals[index]); memmove(&var->v_vals[index], &var->v_vals[index + 1], (var->v_valc - index) * sizeof *var->v_vals); var->v_valc--; } /* Removes directory stack entries that are the same as the current working * directory ($PWD). * `var' must be the return value of a `get_dirstack' call. */ void remove_dirstack_dups(variable_T *var) { const wchar_t *pwd = getvar(L VAR_PWD); if (pwd == NULL) return; for (size_t index = var->v_valc; index-- > 0; ) if (wcscmp(pwd, var->v_vals[index]) == 0) remove_dirstack_entry_at(var, index); } #if YASH_ENABLE_HELP const char pushd_help[] = Ngt( "push a directory into the directory stack" ); const char pushd_syntax[] = Ngt( "\tpushd [-L|-P] [directory]\n" ); #endif /* The "popd" built-in. */ int popd_builtin(int argc, void **argv) { const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, XGETOPT_DIGIT)) != NULL) { switch (opt->shortopt) { #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } const wchar_t *arg; switch (argc - xoptind) { case 0: arg = L"+0"; break; case 1: arg = ARGV(xoptind); break; default: return too_many_operands_error(1); } variable_T *var = get_dirstack(); if (var == NULL) return Exit_FAILURE; if (var->v_valc == 0) { xerror(0, Ngt("the directory stack is empty")); return Exit_FAILURE; } size_t stackindex; const wchar_t *dummy; if (!parse_dirstack_index(arg, &stackindex, &dummy, true)) return Exit_FAILURE; if (stackindex == SIZE_MAX) { xerror(0, Ngt("`%ls' is not a valid index"), arg); return Exit_ERROR; } if (stackindex < var->v_valc) { remove_dirstack_entry_at(var, stackindex); return Exit_SUCCESS; } int result; wchar_t *newpwd; assert(var->v_valc > 0); var->v_valc--; newpwd = var->v_vals[var->v_valc]; var->v_vals[var->v_valc] = NULL; result = change_directory(newpwd, true, true); free(newpwd); return result; } #if YASH_ENABLE_HELP const char popd_help[] = Ngt( "pop a directory from the directory stack" ); const char popd_syntax[] = Ngt( "\tpopd [index]\n" ); #endif /* Options for the "dirs" built-in. */ const struct xgetopt_T dirs_options[] = { { L'c', L"clear", OPTARG_NONE, true, NULL, }, { L'v', L"verbose", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "dirs" built-in, which accepts the following options: * -c: clear the stack * -v: verbose */ int dirs_builtin(int argc, void **argv) { bool clear = false, verbose = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, dirs_options, XGETOPT_DIGIT)) != NULL) { switch (opt->shortopt) { case L'c': clear = true; break; case L'v': verbose = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (clear) return unset_variable(L VAR_DIRSTACK) ? Exit_FAILURE : Exit_SUCCESS; variable_T *var = search_variable(L VAR_DIRSTACK); bool dirvalid = (var != NULL && (var->v_type & VF_MASK) == VF_ARRAY); size_t size = dirvalid ? var->v_valc : 0; const wchar_t *dir; if (xoptind < argc) { /* print the specified only */ do { size_t index; if (!parse_dirstack_index(ARGV(xoptind), &index, &dir, true)) continue; if (index == SIZE_MAX) { xerror(0, Ngt("`%ls' is not a valid index"), ARGV(xoptind)); continue; } if (!print_dirstack_entry(verbose, size - index, index, dir)) break; } while (++xoptind < argc); } else { /* print all */ dir = getvar(L VAR_PWD); if (dir == NULL) { xerror(0, Ngt("$PWD is not set")); } else { print_dirstack_entry(verbose, 0, size, dir); } if (dirvalid && yash_error_message_count == 0) { for (size_t i = var->v_valc; i-- > 0; ) { if (!print_dirstack_entry(verbose, size - i, i, var->v_vals[i])) break; } } } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } bool print_dirstack_entry( bool verbose, size_t plusindex, size_t minusindex, const wchar_t *dir) { if (verbose) return xprintf("+%zu\t-%zu\t%ls\n", plusindex, minusindex, dir); else return xprintf("%ls\n", dir); } #if YASH_ENABLE_HELP const char dirs_help[] = Ngt( "print the directory stack" ); const char dirs_syntax[] = Ngt( "\tdirs [-cv] [index...]\n" ); #endif #endif /* YASH_ENABLE_DIRSTACK */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/makesignum.c0000644000175000017500000000543012154557026015054 0ustar magicantmagicant/* Yash: yet another shell */ /* makesignum.c: outputs string for 'signum.h' contents */ /* (C) 2007-2009 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include #include #include #include #include "siglist.h" int main(void) { setlocale(LC_ALL, ""); int min = 0; wprintf(L"/* signum.h: generated by makesignum */\n\n"); wprintf(L"#ifndef SIGNUM_H\n#define SIGNUM_H\n\n"); wprintf(L"#include \n\n"); for (const signal_T *s = signals; s->no; s++) if (min < s->no) min = s->no; if (min < 100) { wprintf(L"/* an injective function that returns an array index\n"); wprintf(L" * corresponding to the given signal number,\n"); wprintf(L" * which must be a valid non-realtime signal number\n"); wprintf(L" * or zero. */\n"); wprintf(L"__attribute__((const))\n"); wprintf(L"static inline size_t sigindex(int signum) {\n"); wprintf(L" return (size_t) signum;\n"); wprintf(L"}\n\n"); wprintf(L"/* max index returned by sigindex + 1 */\n"); wprintf(L"#define MAXSIGIDX %d\n\n", min + 1); } else { sigset_t ss; size_t v; wprintf(L"/* an injective function that returns an array index\n"); wprintf(L" * corresponding to the given signal number,\n"); wprintf(L" * which must be a valid non-realtime signal number\n"); wprintf(L" * or zero. */\n"); wprintf(L"__attribute__((const))\n"); wprintf(L"static inline size_t sigindex(int signum) {\n"); wprintf(L" switch (signum) {\n"); wprintf(L" case 0 : return 0;\n"); sigemptyset(&ss); v = 1; for (const signal_T *s = signals; s->no; s++) { if (!sigismember(&ss, s->no)) { sigaddset(&ss, s->no); wprintf(L" case SIG%-7s: return %zu;\n", s->name, v++); } } wprintf(L" }\n"); wprintf(L"}\n\n"); wprintf(L"/* max index returned by sigindex + 1 */\n"); wprintf(L"#define MAXSIGIDX %zu\n\n", v); } wprintf(L"/* number of realtime signals that can be handled by yash */\n"); wprintf(L"#define RTSIZE %d\n\n", #if defined SIGRTMIN && defined SIGRTMAX SIGRTMAX - SIGRTMIN + 10 #else 0 #endif ); wprintf(L"#endif\n"); return 0; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/util.h0000644000175000017500000001651312154557026013702 0ustar magicantmagicant/* Yash: yet another shell */ /* util.h: miscellaneous utility functions */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_UTIL_H #define YASH_UTIL_H #include #define Size_max ((size_t) -1) // = SIZE_MAX /********** Miscellaneous Functions **********/ extern size_t addmul(size_t mainsize, size_t count, size_t elemsize) __attribute__((pure)); static inline int xunsetenv(const char *name) __attribute__((nonnull)); /* Removes the environment variable of the specified name. * This function wraps the `unsetenv' function, which has an incompatible * prototype on some old environments. */ int xunsetenv(const char *name) { #if UNSETENV_RETURNS_INT return unsetenv(name); #else unsetenv(name); return 0; #endif } /********** Memory Functions **********/ static inline void *xcalloc(size_t nmemb, size_t size) __attribute__((malloc,warn_unused_result)); static inline void *xmalloc(size_t size) __attribute__((malloc,warn_unused_result)); static inline void *xmallocn(size_t count, size_t elemsize) __attribute__((malloc,warn_unused_result)); static inline void *xmallocs(size_t mainsize, size_t count, size_t elemsize) __attribute__((malloc,warn_unused_result)); static inline void *xrealloc(void *ptr, size_t size) __attribute__((malloc,warn_unused_result)); static inline void *xreallocn(void *ptr, size_t count, size_t elemsize) __attribute__((malloc,warn_unused_result)); static inline void *xreallocs(void *ptr, size_t mainsize, size_t count, size_t elemsize) __attribute__((malloc,warn_unused_result)); extern void alloc_failed(void) __attribute__((noreturn)); /* Attempts `calloc' and aborts the program on failure. */ void *xcalloc(size_t nmemb, size_t size) { void *result = calloc(nmemb, size); if (result == NULL && nmemb > 0 && size > 0) alloc_failed(); return result; } /* Attempts `malloc' and aborts the program on failure. */ void *xmalloc(size_t size) { void *result = malloc(size); if (result == NULL && size > 0) alloc_failed(); return result; } /* Like `xmalloc(count * elemsize)', but aborts the program if the size is too * large. `elemsize' must not be zero. */ void *xmallocn(size_t count, size_t elemsize) { return xmallocs(0, count, elemsize); } /* Like `xmalloc(mainsize + count * elemsize)', but aborts the program if the * size is too large. `elemsize' must not be zero. */ void *xmallocs(size_t mainsize, size_t count, size_t elemsize) { return xmalloc(addmul(mainsize, count, elemsize)); } /* Attempts `realloc' and aborts the program on failure. */ void *xrealloc(void *ptr, size_t size) { void *result = realloc(ptr, size); if (result == NULL && size > 0) alloc_failed(); return result; } /* Like `xrealloc(ptr, count * elemsize)', but aborts the program if the size is * too large. `elemsize' must not be zero. */ void *xreallocn(void *ptr, size_t count, size_t elemsize) { return xreallocs(ptr, 0, count, elemsize); } /* Like `xrealloc(mainsize + count * elemsize)', but aborts the program if the * size is too large. `elemsize' must not be zero. */ void *xreallocs(void *ptr, size_t mainsize, size_t count, size_t elemsize) { return xrealloc(ptr, addmul(mainsize, count, elemsize)); } /********** String Utilities **********/ extern size_t xstrnlen(const char *s, size_t maxlen) __attribute__((pure,nonnull)); extern char *xstrndup(const char *s, size_t maxlen) __attribute__((malloc,warn_unused_result,nonnull)); static inline char *xstrdup(const char *s) __attribute__((malloc,warn_unused_result,nonnull)); extern size_t xwcsnlen(const wchar_t *s, size_t maxlen) __attribute__((pure,nonnull)); extern wchar_t *xwcsndup(const wchar_t *s, size_t maxlen) __attribute__((malloc,warn_unused_result,nonnull)); static inline wchar_t *xwcsdup(const wchar_t *s) __attribute__((malloc,warn_unused_result,nonnull)); extern _Bool xstrtoi(const char *s, int base, int *resultp) __attribute__((warn_unused_result,nonnull)); extern _Bool xwcstoi(const wchar_t *s, int base, int *resultp) __attribute__((warn_unused_result,nonnull)); extern _Bool xwcstol(const wchar_t *s, int base, long *resultp) __attribute__((warn_unused_result,nonnull)); extern _Bool xwcstoul(const wchar_t *s, int base, unsigned long *resultp) __attribute__((warn_unused_result,nonnull)); extern char *matchstrprefix(const char *s, const char *prefix) __attribute__((pure,nonnull)); extern wchar_t *matchwcsprefix(const wchar_t *s, const wchar_t *prefix) __attribute__((pure,nonnull)); extern void *copyaswcs(const void *p) __attribute__((malloc,warn_unused_result,nonnull)); #if HAVE_STRNLEN # ifndef strnlen extern size_t strnlen(const char *s, size_t maxlen); # endif # define xstrnlen(s,maxlen) strnlen(s,maxlen) #endif #if HAVE_WCSNLEN # ifndef wcsnlen extern size_t wcsnlen(const wchar_t *s, size_t maxlen); # endif # define xwcsnlen(s,maxlen) wcsnlen(s,maxlen) #endif /* Returns a newly malloced copy of the specified string. * Aborts the program if failed to allocate memory. */ char *xstrdup(const char *s) { return xstrndup(s, Size_max); } /* Returns a newly malloced copy of the specified string. * Aborts the program if failed to allocate memory. */ wchar_t *xwcsdup(const wchar_t *s) { return xwcsndup(s, Size_max); } /* These macros are used to cast the argument properly. * We don't need such macros for wide characters. */ #define xisalnum(c) (isalnum((unsigned char) (c))) #define xisalpha(c) (isalpha((unsigned char) (c))) #define xisblank(c) (isblank((unsigned char) (c))) #define xiscntrl(c) (iscntrl((unsigned char) (c))) #define xisdigit(c) (isdigit((unsigned char) (c))) #define xisgraph(c) (isgraph((unsigned char) (c))) #define xislower(c) (islower((unsigned char) (c))) #define xisprint(c) (isprint((unsigned char) (c))) #define xispunct(c) (ispunct((unsigned char) (c))) #define xisspace(c) (isspace((unsigned char) (c))) #define xisupper(c) (isupper((unsigned char) (c))) #define xisxdigit(c) (isxdigit((unsigned char) (c))) #define xtoupper(c) (toupper((unsigned char) (c))) #define xtolower(c) (tolower((unsigned char) (c))) /* Casts scalar to char safely. */ #define TO_CHAR(value) \ ((union { char c; unsigned char uc; }) { .uc = (unsigned char) (value), }.c) /********** Error Utilities **********/ extern const wchar_t *yash_program_invocation_name; extern const wchar_t *yash_program_invocation_short_name; extern const wchar_t *current_builtin_name; extern unsigned yash_error_message_count; extern void xerror(int errno_, const char *restrict format, ...) __attribute__((format(printf,2,3))); extern _Bool xprintf(const char *restrict format, ...) __attribute__((format(printf,1,2))); #undef Size_max #endif /* YASH_UTIL_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/job.d0000644000175000017500000000033412154557026013465 0ustar magicantmagicantjob.o: job.c common.h config.h job.h xgetopt.h builtin.h exec.h option.h \ plist.h redir.h sig.h strbuf.h util.h yash.h xfnmatch.h \ lineedit/complete.h lineedit/../plist.h lineedit/../xgetopt.h \ lineedit/terminfo.h yash-2.35/NEWS.ja0000644000175000017500000010016312154557026013637 0ustar magicantmagicantYash 更新履歴 凡例: +: 新機能 -: 廃止機能 =: 仕様変更 *: ãƒã‚°ä¿®æ­£ x: æ–°ãŸã«åŠ ã‚ã£ã¦ã—ã¾ã£ãŸãƒã‚° ---------------------------------------------------------------------- Yash 2.35 + '--traceall' オプション + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: git-clean, git-grep, git-ls-remote, git-submodule, git-whatchanged + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを更新: git-cherry-pick, git-rebase (Git 1.8.1.4), ssh, ssh-add, ssh-keygen (OpenSSH 6.2) = -e ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã«ã‚·ã‚§ãƒ«ã‚’終了ã•ã›ã‚‹æ¡ä»¶ã‚’ POSIX.1-2008 ã® 2013 年版ã«åˆã‚ã›ã¦å¤‰æ›´ = "++" ãŠã‚ˆã³ "--" 演算å­ã‚’ POSIX 準拠モードã§ä½¿ãˆãªãã—㟠= $RANDOM 変数ã¯ç’°å¢ƒå¤‰æ•°ã‚’無視ã—ã¦å¸¸ã«ä¹±æ•°ã‚’è¿”ã™ã‚ˆã†ã«ã—㟠= 履歴ファイルã®ä¸­ã«ã¨ã¦ã‚‚é•·ã„行ãŒã‚ã‚‹ã¨ãã§ã‚‚ãれ以é™ã®å±¥æ­´ã‚’ 無視ã—ãªã„よã†ã«ã—㟠= éžå¸¸ã«é•·ã„コマンドã¯å±¥æ­´ãƒ•ァイルã«ä¿å­˜ã—ãªã„よã†ã«ã—㟠* 構文エラーメッセージを一部修正 * "git" 㨠"ssh" 㨠"rsync" ã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを修正 ---------------------------------------------------------------------- Yash 2.34 + "test" 組込ã¿ã®æ¼”ç®—å­è¿½åŠ : =~, -o (å˜é …) + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: configure, git-name-rev, git-request-pull, make, rsync = .yash_profile ã‚„ .yashrc ã§æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã¾ãŸã¯å±•開エラーã«ãªã£ãŸæ™‚ 対話シェルã§ãªãã¦ã‚‚シェルを終了ã•ã›ãªã„よã†ã«ã—㟠= 行編集ã§ã€ä¸Šæ›¸ãã—ãŸæ–‡å­—ã‚’ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ã§æˆ»ã›ã‚‹ã‚ˆã†ã«ãªã£ãŸ = 行編集ã§ã€ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ã®åº¦ã« undo 履歴をä¿å­˜ã—ãªã„よã†ã«ã—㟠* "git" ã®è£œå®Œã®ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.33 = "help" 組込ã¿ã®å‡ºåŠ›ã‚’å†…è”µã®èª¬æ˜Žæ–‡ã«å¤‰æ›´ = ã‚³ãƒžãƒ³ãƒ‰ã®æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã«é–¢ã™ã‚‹ä¸€éƒ¨ã®ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’変更 = ã„ãã¤ã‹ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã§æ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã‚’より厳密ã«ãƒã‚§ãƒƒã‚¯ã™ã‚‹ よã†ã«ãªã£ãŸ * "set" 組込ã¿ã®å¼•æ•°ã®æ§‹æ–‡ãŒé–“é•ã£ã¦ã„ã‚‹ã¨ãã€POSIX ã®è¦å®šã«å¾“ㄠシェルを終了ã•ã›ã‚‹ã‚ˆã†ã«ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.32 + Man page ãŠã‚ˆã³ HTML マニュアル (英語ãŠã‚ˆã³æ—¥æœ¬èªž) = "help" 組込ã¿ã¯ man page ã®å†…容を出力ã™ã‚‹ã‚ˆã†ã«å¤‰æ›´ * "git" ã®è£œå®Œã®ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.31 + æ‹¡å¼µãƒãƒ«ãƒ€å±•é–‹ã§ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®è£œå®Œã«å¯¾å¿œ + "complete" 組込ã¿ã« --dirstack-index オプション追加 + "svn" ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 1.7 ã®è£œå®Œã«å¯¾å¿œ * "git", "tar", "su" ã®è£œå®Œã®ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.30 * リダイレクトã®ãƒ•ァイルå補完を修正 + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: svn, git, gitg, gitk, and gitx. * 補完スクリプトã®ç´°ã‹ã„修正 ---------------------------------------------------------------------- Yash 2.29 + エイリアスã®å€¤ã«æ”¹è¡Œã‚’入れられるよã†ã«ãªã£ãŸ * 空ã®é…列を "typeset" 組込ã¿ã§è¡¨ç¤ºã—よã†ã¨ã—ãŸã¨ãã«ä¸æ­£ãƒ¡ãƒ¢ãƒª アクセスã—ã¦ã„㟠* 関数ã®ä¸­èº«ãŒ (...) ã®å½¢å¼ã®è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã¨ã—ã¦å®šç¾©ã•れã¦ã„ã‚‹ã¨ã コマンドを正ã—ãサブシェルã§å®Ÿè¡Œã™ã‚‹ã‚ˆã†ã« * 行編集ã§ã€undo コマンドã¯ç·¨é›†ä¸­ã®å±¥æ­´é …ç›®ã§ã®ã¿ä½¿ãˆã‚‹ã‚ˆã†ã«ã—㟠---------------------------------------------------------------------- Yash 2.28 = 対話シェルã§ã€ãƒ¡ãƒ¼ãƒ«ãƒã‚§ãƒƒã‚¯ã¯ã‚¸ãƒ§ãƒ–変化ã®å ±å‘Šã®å‰ã«è¡Œã†ã‚ˆã†ã« ãªã£ãŸ * æ•°å¼å±•é–‹ã§ã€è©•価ã™ã¹ã‹ã‚‰ã–ã‚‹å¼ã‚’評価ã—ã¦ã„ã‚‹ã“ã¨ãŒã‚ã£ãŸ * "array" 組込ã¿ã§ã€-d ã‚ªãƒ—ã‚·ãƒ§ãƒ³ä½¿ç”¨æ™‚ã«æ­£ã¨è² ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’混㜠るã¨èª¤ã£ãŸè¦ç´ ã‚’削除ã—ã¦ã„㟠* 実行ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ä»˜ã‹ã‚‰ãªã‹ã£ãŸã¨ã誤ã£ã¦ EXIT トラップを実行 ã—ã¦ã„㟠* 最後ã®ã‚³ãƒžãƒ³ãƒ‰ãŒãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã•れã¦ã„ãŸã¨ã EXIT トラップもãã®ãƒª ダイレクトã§å®Ÿè¡Œã•れã¦ã—ã¾ã†ã“ã¨ãŒã‚ã£ãŸ * é…列ã®ä»£å…¥ã‚’伴ㆠ"exec" 組込ã¿ã§é…列ã®å€¤ã‚’æ­£ã—ã export ã™ã‚‹ã‚ˆã† ã«ã—㟠* ${#@} ãŒé…列ã®è¦ç´ ã®é•·ã•ã®é…åˆ—ã«æ­£ã—ã展開ã•れã¦ã„ãªã‹ã£ãŸ * 整数列ã¸ã®ãƒ–レース展開ã§ç„¡é™ãƒ«ãƒ¼ãƒ—ã™ã‚‹ã“ã¨ãŒã‚ã£ãŸ * "ssh" コマンドã®è£œå®Œã§è¨­å®šãƒ•ァイルã®èª­ã¿è¾¼ã¿ã‚’修正 * "ln", "mv" コマンドã®è£œå®Œã§ -T オプションã«å¯¾å¿œ * "trap" 組込ã¿ã®è£œå®Œã§ EXIT ã®è£œå®Œã«å¯¾å¿œ ---------------------------------------------------------------------- Yash 2.27 * ç´°ã‹ã„ãƒã‚°ä¿®æ­£ + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: awk, chsh, gawk, nawk, pgawk, scp, sftp, ssh-add, ssh-agent, ssh-keygen, su, sudo, sudoedit, and useradd. * "set" 組込ã¿ã¨ "tar" コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを修正 ---------------------------------------------------------------------- Yash 2.26 + "return" 組込ã¿ã®æ–°ã—ã„オプション: -n (--no-return) = 英語ã®ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’書ãç›´ã—㟠= シェルオプションã®åå‰ã®æ‰±ã„を一般化ã—㟠. オプションåã®å¤§æ–‡å­—ãƒ»å°æ–‡å­—を区別ã—ãªããªã£ãŸ . オプションåã«å«ã¾ã‚Œã‚‹è‹±æ•°å­—ä»¥å¤–ã®æ–‡å­—を無視ã™ã‚‹ã‚ˆã†ã«ã—㟠. オプションåã« "no" を付ã‘ã‚‹ã“ã¨ã§æœ‰åŠ¹ãƒ»ç„¡åŠ¹ã‚’é€†è»¢ã§ãるよã†ã« ã—㟠= POSIX 準拠モードã§ã¯ "case foo in (esac) bar; esac" をエラー㫠ã™ã‚‹ã‚ˆã†ã«ãªã£ãŸ = 対話シェルã§ã¯ noexec オプションを無視ã™ã‚‹ã‚ˆã†ã«ãªã£ãŸ = æ–°ç€ãƒ¡ãƒ¼ãƒ«é€šçŸ¥ã¯ãƒ¡ãƒ¼ãƒ«ãƒœãƒƒã‚¯ã‚¹ãƒ•ァイルãŒç©ºã®ã¨ãã¯è¡¨ç¤ºã—ãªã„よㆠã«ã—㟠= "printf %c ''" 㯠"printf %c" ã¨åŒæ§˜ã«ä½•も出力ã—ãªããªã£ãŸ = "complete" 組込ã¿ã‚’ -A ã¾ãŸã¯ -R オプション付ãã§å‘¼ã³å‡ºã—ãŸå ´åˆã€ -f オプションã§ç”Ÿæˆã•れるファイルå候補ã«ã¤ã„ã¦ã¯ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªå 部分を除ã„ã¦ãƒ‘ターンマッãƒãƒ³ã‚°ã‚’行ã†ã‚ˆã†ã« * '=' ã‚’å«ã‚€é–¢æ•°åã‚’ typeset ãŠã‚ˆã³ unset 組込ã¿ã«æŒ‡å®šã§ãるよã†ã« ã—ãŸã€‚(-f オプション指定時) * SIGINT ã§ä¸­æ–­ã•れãŸå復実行ã®çµ‚了ステータスを修正 + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: bsdtar, eview, evim, gex, gnutar, gtar, return, rgview, rgvim, rview, rvim, slogin, ssh, tar, and which. * 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トã®ä¿®æ­£: bash, chmod, dash, less, mksh, set, sh, and umask. ---------------------------------------------------------------------- Yash 2.25 = 補完候補リストã«ãŠã„ã¦ã‚ªãƒ—ションã¯å¤§æ–‡å­—å°æ–‡å­—区別無ãã¾ã¨ã‚ã‚‹ よã†ã«ã—㟠= 補完関数を実行中㯠$IFS 変数ã®å€¤ã‚’ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã«æˆ»ã™ã‚ˆã†ã« + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: bash, csplit, dash, diff, ed, egrep, env, ex, expand, fgrep, file, find, fold, getconf, grep, gview, gvim, gvimdiff, head, iconv, id, join, ksh, less, ln, locale, man, mesg, mkdir, mkfifo, mksh, more, mv, newgrp, nice, nl, nohup, od, paste, patch, pathchk, pr, ps, renice, rm, rmdir, sed, sh, sort, split, stty, tail, tee, time, touch, tr, uname, uniq, vi, view, vim, vimdiff, wc, who, xargs, and yash. * 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トã®ä¿®æ­£: cat, cd, chgrp, chmod, chown, cmp, comm, cp, crontab, cut, date, df, du, exec, ls, and set. ---------------------------------------------------------------------- Yash 2.24 + "." 組込ã¿ã®æ–°ã—ã„オプション: -L + "command" 組込ã¿ã®æ–°ã—ã„オプション: -a, -f, -k - "command" 組込ã¿ã®å»ƒæ­¢ã•れãŸã‚ªãƒ—ション: -B = FreeBSD ã§å…¨ã¦ã®ç¨®é¡žã®ã‚·ã‚°ãƒŠãƒ«ãŒæ‰±ãˆã‚‹ã‚ˆã†ã« configure を修正 = æ–°ã—ã„補完メカニズム ("complete" 組込ã¿ã®å‹•作を変更。補完設定㮠$YASH_LOADPATH ã‹ã‚‰ã®è‡ªå‹•読ã¿è¾¼ã¿) + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: basename, bg, cat, chgrp, chmod, chown, cmp, comm, command, cp, crontab, cut, date, df, du, export, popd, pushd, readonly, type, ".", and "[". = 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを書ãç›´ã—: alias, array, bindkey, break, cd, complete, continue, dirs, disown, echo, eval, exec, exit, fc, fg, getopts, hash, help, history, jobs, kill, ls, printf, pwd, read, set, suspend, test, trap, typeset, ulimit, umask, unalias, unset, and wait. - "return" 組込ã¿ã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを削除 = 補完候補リストã§çŸ­ã„オプションãŒé•·ã„オプションã®å‰ã«æ¥ã‚‹ã‚ˆã†ã« 並ã³é †ã‚’変更 * 存在ã—ãªã„ファイルã¸ã®ã‚·ãƒ³ãƒœãƒªãƒƒã‚¯ãƒªãƒ³ã‚¯ã‚’æ­£ã—ã補完ã§ãるよã†ã« * 補完機能ã®ãã®ä»–ã®ä¿®æ­£ * リダイレクト内ã®ãƒ‘ラメータ展開ãŒã‚¨ãƒ©ãƒ¼ã«ãªã£ãŸã¨ãã«ä¸æ­£ãƒ¡ãƒ¢ãƒª アクセスã—ã¦ã„㟠---------------------------------------------------------------------- Yash 2.23 * コマンドライン補完ã®é€”中ã§ã¯ãƒˆãƒ©ãƒƒãƒ—を実行ã—ãªã„よã†ã«ã—㟠(予期ã›ã¬ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡Œã«ã‚ˆã‚Šè¡¨ç¤ºãŒä¹±ã‚Œã‚‹ã®ã‚’防ããŸã‚) * "-o notify" ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã€å€™è£œç”Ÿæˆé–¢æ•°ã‚’使用ã—ãŸè£œå®Œã® 最中ã«ã‚¸ãƒ§ãƒ–ã®çŠ¶æ…‹ã‚’å‡ºåŠ›ã—よã†ã¨ã—ã¦ä¸æ­£ãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ã—ã¦ã„㟠* "-o verbose" ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ã§ã‚‚ã€è£œå®Œè¨­å®šã®è‡ªå‹•読ã¿è¾¼ã¿æ™‚㯠読ã¿è¾¼ã‚“ã å†…容を出力ã—ãªã„よã†ã«ã—㟠* "kill" 組込ã¿ã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを修正 ---------------------------------------------------------------------- Yash 2.22 + "test" 組込ã¿ã®æ¼”ç®—å­è¿½åŠ : -G, -O, -N + $YASH_COMPPATH ã‹ã‚‰ã®è£œå®Œè¨­å®šã®è‡ªå‹•読ã¿è¾¼ã¿ * サブシェルãŒç”Ÿæˆã•れãŸç›´å¾Œã«ã‚·ã‚°ãƒŠãƒ«ã‚’å—ä¿¡ã—ãŸã¨ã誤ã£ã¦ãれを 無視ã—ã¦ã„ãŸã®ã‚’修正 * ãã®ä»–ã®ãƒã‚°ä¿®æ­£ + 下記コマンドã®è£œå®Œã‚¹ã‚¯ãƒªãƒ—トを追加: alias, array, bindkey, break, cd, complete, continue, dirs, disown, echo, eval, exec, exit, fc, fg, getopts, hash, help, history, jobs, kill, ls, printf, pwd, read, return, set, suspend, test, trap, typeset, ulimit, umask, unalias, unset, wait. ---------------------------------------------------------------------- Yash 2.21 + 行編集ã§ã®è£œå®Œæ©Ÿèƒ½ = 対話シェルã§ã¯ã€ãれãžã‚Œã®ã‚³ãƒžãƒ³ãƒ‰ã”ã¨ã« $LINENO ã‚’ 1 ã«ãƒªã‚»ãƒƒãƒˆ ã™ã‚‹ã‚ˆã†ã«ã—㟠* "function" キーワード㌠"command -v" ã§èªè­˜ã•れã¦ã„ãªã‹ã£ãŸ * 対話シェル㌠SIGINT ã‚’å—ã‘å–ã£ãŸå¾Œã®å¾©æ—§å‡¦ç†ã‚’修正 * シェルã¸ã®å…¥åŠ›ã‚’æ‰±ã†é–¢æ•°ã‚’書ãç›´ã— (ã„ãã¤ã‹ã®ãƒã‚°ä¿®æ­£å«ã‚€) ---------------------------------------------------------------------- Yash 2.20 + "function" キーワードã«ã‚ˆã‚‹é–¢æ•°ã®å®šç¾© = "test" 組込ã¿ã® "-nt", "-ot" 演算å­ã«ã‚ˆã‚‹æ¯”較ã§ã¯å­˜åœ¨ã—ãªã„ ファイルをよりå¤ã„ã¨ã¿ãªã™ã‚ˆã†ã«ãªã£ãŸ (Korn shell ã«å€£ã†) = 行編集: ã„ãã¤ã‹ã®ç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã®åå‰ã‚’変更 vi-change-all -> vi-change-line vi-yank-and-change-all -> vi-yank-all-change-line vi-append-end -> vi-append-to-eol * 行編集: clear-and-redraw-all ã‚³ãƒžãƒ³ãƒ‰ãŒæ­£ã—ãå‹•ã„ã¦ã„ãªã‹ã£ãŸ ---------------------------------------------------------------------- Yash 2.19 + FreeBSD ã§ã‚‚ "ulimit" 組込ã¿ãŒä½¿ãˆã‚‹ã‚ˆã†ã«ãªã£ãŸ + メールãƒã‚§ãƒƒã‚¯ã§ã€å¯èƒ½ãªã‚‰ãƒŠãƒŽç§’å˜ä½ã§ãƒ¡ãƒ¼ãƒ«ãƒ•ァイルをãƒã‚§ãƒƒã‚¯ ã™ã‚‹ã‚ˆã†ã«ã—㟠+ 行編集: æ–°ã—ã„コマンドã®è¿½åŠ : oldest-history-bol, newest-history-bol, return-history-bol, prev-history-bol, next-history-bol, beginning-search-forward, beginning-search-backward = ファイルåパターンマッãƒãƒ³ã‚°ã‚’高速化 = 行編集: 履歴検索中㮠accept-line コマンドã¯ã€æ¤œç´¢çµæžœãŒè¦‹ã¤ã‹ã‚‰ ãªã„ã¨ãã¯å¤±æ•—ã™ã‚‹ã‚ˆã†ã«ãªã£ãŸ = 行編集: 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚«ãƒ¼ã‚½ãƒ«ã‚’行頭ã«ç§»å‹•ã—ãªã„よã†ã«ãªã£ãŸ oldest-history, newest-history, return-history, prev-history, next-history カーソルを行頭ã«ç§»å‹•ã™ã‚‹å¤ã„挙動ã¯ã€åå‰ãŒ "-bol" ã§çµ‚ã‚ã‚‹ æ–°ã—ã„コマンドã«ã‚ˆã£ã¦å¾—られる * é…列ã®ä»£å…¥ã®ãƒˆãƒ¬ãƒ¼ã‚¹ã®å‡ºåŠ›ãŒãŠã‹ã—ã‹ã£ãŸã®ã‚’修正 * 行編集: vi-edit-and-accept コマンドã§ã‚«ã‚¦ãƒ³ãƒˆã‚’指定ã§ãるよã†ã« * 行編集: emacs モードã§ã® search-again-forward/backward コマンド㮠後ã®ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ã‚’修正 ---------------------------------------------------------------------- Yash 2.18 + "test" 組込ã¿: 文字列比較演算å­è¿½åŠ  (==, ===, !==, <, <=, >, >=) + "test" 組込ã¿: -nt, -ot 演算å­ã§å¯èƒ½ãªã‚‰ãƒŠãƒŽç§’å˜ä½ã§ãƒ•ァイル㮠更新日時を比較ã™ã‚‹ã‚ˆã†ã« + "cd", "pushd" 組込ã¿ã« --default-directory オプション追加 + "pushd" 組込ã¿ã« --remove-duplicates オプション追加 + å³ãƒ—ロンプトã¨ã‚¹ã‚¿ã‚¤ãƒ©ãƒ¼ãƒ—ロンプト + --le-alwaysrp オプション = $PS1 㨠$PS2 ã®ãƒ•ォント変更用エスケープシーケンスã®è§£é‡ˆã‚’変更 = $PS3 をデフォルトã§åˆæœŸåŒ–ã—ãªã„よã†ã« = $PS4 ã§ã‚‚ $PS1/$PS2 ã¨åŒæ§˜ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—シーケンスを解釈ã™ã‚‹ã‚ˆã†ã« = "echo"/"printf" 組込ã¿ã§ãƒŠãƒ«æ–‡å­—を出力ã§ãるよã†ã« * 行編集: $LINES 㨠$COLUMNS ãŒç„¡è¦–ã•れる場åˆãŒã‚ã£ãŸ * 行編集: ã„ãã¤ã‹ã®ç«¯æœ«ã§ã®æ–‡å­—ã®è‰²ã‚’修正 ---------------------------------------------------------------------- Yash 2.17 + --le-visiblebell オプション + "test" 組込ã¿: ãƒãƒ¼ã‚¸ãƒ§ãƒ³æ¯”è¼ƒæ¼”ç®—å­ (-veq, -vne, -vgt, -vge, -vlt, -vle) + 行編集: "eof" コマンド = "typeset" 組込ã¿ã‚’オペランドãªã—ã§å®Ÿè¡Œã—ãŸã¨ãã€-g オプション㌠ãªã‘れã°ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã®ã¿è¡¨ç¤ºã™ã‚‹ã‚ˆã†ã« = "typeset" 組込ã¿ã§é–¢æ•°ã‚’表示ã•ã›ã‚‹ã¨ãã®å‡ºåŠ›ã‚’æ•´å½¢ = POSIX 準拠モードã§ãªã„ã¨ãã¯ã€ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚„コマンドリダイレクト ã®ä¸­ã®ã‚³ãƒžãƒ³ãƒ‰ã‚‚ã‚らã‹ã˜ã‚å…ˆã«è§£æžã—ã¦ãŠãよã†ã«ãªã£ãŸ * パラメータ展開 "${#}" ãŒæ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã«ãªã£ã¦ã„㟠* サブシェル㧠"wait" 組込ã¿ã‚’実行ã™ã‚‹ã¨èª¤ã£ã¦è¦ªãƒ—ロセスã§ãªã„ プロセスを待ã¨ã†ã¨ã™ã‚‹ã“ã¨ãŒã‚ã£ãŸ * 行編集㮠vi-replace-char コマンドãŒå£Šã‚Œã¦ã„㟠* ãã®ä»–様々ãªãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.16 + --curbg 㨠--curstop オプション = --curasync オプションã¯ãƒ‡ãƒ•ォルトã§ã‚ªãƒ³ã« = 空㮠while/until ループã®çµ‚了ステータスを変更 = "return" ãŠã‚ˆã³ "exit" 組込ã¿ã§ 256 以上ã®çµ‚了ステータスを使ãˆã‚‹ よã†ã« = "echo" 組込ã¿ã®å…«é€²æ•°ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—㯠\0 ã§å§‹ã¾ã‚‹ã‚‚ã®ã—ã‹è§£é‡ˆã—ãªã„ よã†ã« * éžå¯¾è©±ã‚·ã‚§ãƒ«ã§ "command" 組込ã¿ã§ç‰¹æ®Šçµ„è¾¼ã¿ã‚’実行ã—ãŸã¨ãæ§‹æ–‡ エラーã«ãªã‚‹ã¨ã‚·ã‚§ãƒ«ãŒçµ‚了ã—ã¦ã—ã¾ã£ã¦ã„ãŸã®ã‚’修正。 * EXIT トラップ設定時ã®ã‚·ã‚§ãƒ«ã®çµ‚了ステータスを修正 * "read" 㨠"getopts" 組込ã¿ã§ --allexport オプションãŒåˆ©ã„㦠ã„ãªã‹ã£ãŸ * "getopts" 組込ã¿ã®ã‚»ã‚°ãƒ¡ãƒ³ãƒ†ãƒ¼ã‚·ãƒ§ãƒ³ãƒ•ォルトãã®ä»–エラー修正 * 行編集㮠vi-replace-char コマンドãŒä¸æ­£ãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ã‚’ 引ãèµ·ã“ã™ã“ã¨ãŒã‚ã£ãŸ * 行編集㮠emacs-just-one-space コマンドã®çµæžœãŒãŠã‹ã—ã‹ã£ãŸ ---------------------------------------------------------------------- Yash 2.15 + 対話シェルã®ã‚³ãƒžãƒ³ãƒ‰ã‚’ SIGINT ã§ä¸­æ–­ã§ãるよã†ã« + パスå展開ã§ã®ãƒ–ラケット記法ã«å®Œå…¨ã«å¯¾å¿œã—㟠(libc ã®æ­£è¦è¡¨ç¾ã® 実装ã«ä¾å­˜) = シェルãŒã‚»ãƒƒã‚·ãƒ§ãƒ³ãƒªãƒ¼ãƒ€ãƒ¼ã®ã¨ã "suspend" 組込ã¿ã§ã‚µã‚¹ãƒšãƒ³ãƒ‰ã™ã‚‹ ã«ã¯ -f オプションを付ã‘ãªã„ã¨ã„ã‘ãªã„よã†ã«ã—㟠= $YASH_LE_TIMEOUT 変数をデフォルトã§è¨­å®šã™ã‚‹ã®ã‚’ã‚„ã‚㟠= ジョブ制御有効ãªã‚·ã‚§ãƒ«ãŒãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§èµ·å‹•ã•れãŸã‚‰åœæ­¢ã™ã‚‹ よã†ã« = ジョブ制御有効ãªã‚·ã‚§ãƒ«ã¯ãƒ‡ãƒ•ォルトã§ã¯ SIGTTOU を無視ã—ãªã„よã†ã« = --nocaseglob ãŒã‚ªãƒ³ã§ã‚‚ "${var#xxx}" ãªã©ã®ãƒ‘ラメータ展開㮠マッãƒãƒ³ã‚°ã§ã¯å¤§æ–‡å­—å°æ–‡å­—を区別ã™ã‚‹ã‚ˆã†ã« * リダイレクトã«ãŠã‘るパスå展開を修正 * 対話シェル起動時ã«ç„¡è¦–ã•れã¦ã„ãŸã‚·ã‚°ãƒŠãƒ«ã‚’ "trap" 組込ã¿ã§ デフォルトã®ã‚·ã‚°ãƒŠãƒ«ãƒãƒ³ãƒ‰ãƒ©ã«å¤‰æ›´ã§ããªã‹ã£ãŸ * 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒèª¤ã£ã¦ã‚·ã‚°ãƒŠãƒ«ã«å‰²ã‚Šè¾¼ã¾ã‚Œã‚‹ã®ã‚’修正 * エイリアス置æ›ã®å¾Œã«è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ãªã©ãŒæ­£ã—ãè§£æžã•れるよã†ä¿®æ­£ * ãã®ä»–様々ãªãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.14 + "bindkey" 組込ã¿ã® -l オプション + é…列ã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã«è² æ•°ã‚’指定ã§ãるよã†ã«ãªã£ãŸ = "cd /.." ã®å¾Œ $PWD 㯠/.. ã§ã¯ãªã / ã«ã™ã‚‹ã‚ˆã†ã« = "command -vb" ã¯ã‚­ãƒ¼ãƒ¯ãƒ¼ãƒ‰ãƒ»ã‚¨ã‚¤ãƒªã‚¢ã‚¹ãƒ»é–¢æ•°ã‚’表示ã—ãªã„よã†ã« = ã»ã¨ã‚“ã©ã®çµ„è¾¼ã¿ã«ãŠã„ã¦ã€æ¨™æº–出力ã¸ã®æ›¸ãè¾¼ã¿ãŒã‚¨ãƒ©ãƒ¼ã«ãªã£ãŸã‚‰ メッセージをåã„ã¦éž 0 ã§çµ‚了ã™ã‚‹ã‚ˆã†ã«ã—㟠= "pwd", "times" 組込ã¿ã«ä½™è¨ˆãªå¼•数を与ãˆãŸã¨ãエラーã«ã™ã‚‹ã‚ˆã†ã« = POSIX 準拠モードã§ãªã„ã¨ã特殊組込ã¿ã§ã®å¤‰æ•°ä»£å…¥ãŒã‚¨ãƒ©ãƒ¼ã« ãªã£ã¦ã‚‚シェルを終了ã—ãªã„よã†ã« * 作業ディレクトリ㌠/ ã®ã¨ã "cd //" ã§ããªã‹ã£ãŸ * yashrc ã®ä¸­ã§ "bindkey" コマンドを使ã†ã¨ä¸æ­£ãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ãŒ 発生ã—ã¦ã„㟠* $PATH ã«ãªã„通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒ "command -vb" ã§æ¤œç´¢ ã§ããªã‹ã£ãŸ * "dirs" 組込ã¿ã«å¼•数を与ãˆãŸã¨ãç„¡é™ãƒ«ãƒ¼ãƒ—ã—ã¦ã„㟠* "ulimit" 組込ã¿ãŒ -c, -d オプションをå—ã‘付ã‘ã¦ã„ãªã‹ã£ãŸ * POSIX 準拠モードã§ã¯ "fg" 組込ã¿ã¯æœ€å¤§ä¸€ã¤ã—ã‹å¼•æ•°ã‚’å—ã‘付ã‘ãªã„ よã†ã« (ヘルプã«ã¯ãã†æ›¸ã„ã¦ã‚ã£ãŸãŒã€å®Ÿéš›ã«ã¯ãã†ãªã£ã¦ ã„ãªã‹ã£ãŸã®ã‚’修正) ---------------------------------------------------------------------- Yash 2.13 + "history" 組込㿠+ "eval", "break", "continue" 組込ã¿ã® -i オプション + コマンドãŒè¦‹ã¤ã‹ã‚‰ãªã„ã¨ã $COMMAND_NOT_FOUND_HANDLER 変数ã®å€¤ã‚’ 実行ã™ã‚‹ã‚ˆã†ã« - --autocd オプション = 対話シェル㧠"return" 組込ã¿ãŒé–¢æ•°å¤–ã§ä½¿ã‚ã‚ŒãŸæ™‚ã€çµ‚了ステータス 1 ã‚’è¿”ã™ã‚ˆã†ã« = ã‚³ãƒžãƒ³ãƒ‰ã®æ¤œç´¢ãƒ»å®Ÿè¡Œã‚’修正 * $PROMPT_COMMAND ãŒè¨­å®šã•れã¦ã„ã‚‹ã¨ãã€åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ãŒã‚る㨠"exit" を二回やã£ã¦ã‚‚シェルを終了ã§ããªã‹ã£ãŸ * $PROMPT_COMMAND ãŒè¨­å®šã•れã¦ã„る㨠"notifyle" ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæ­£ã—ã 動作ã—ã¦ã„ãªã‹ã£ãŸ * 行編集㧠redo ãŒã†ã¾ãå‹•ã‹ãªããªã£ã¦ã„㟠* 行編集ã§ãƒˆãƒ©ãƒƒãƒ—処ç†ã®ã‚ã¨ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ãŒå†æç”»ã•れã¦ã„ãªã‹ã£ãŸ * 行編集㧠vi-edit-and-accept コマンドã«ã¤ã„ã¦ã„ãã¤ã‹ã®ãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.12 + Emacs 風行編集 + "bindkey" 組込㿠+ $PROMPT_COMMAND ã¯é…列ã§ã‚‚よã„よã†ã« + 作業ディレクトリ変更後㫠$YASH_AFTER_CD を実行ã™ã‚‹ã‚ˆã†ã« = "fg", "bg" 組込ã¿ã¯å¸¸ã« SIGCONT を対象ジョブã«é€ä¿¡ã™ã‚‹ã‚ˆã†ã« = "fg", "bg", "disown", "wait" 組込ã¿ã®å¾Œã§ "exit" ã—よã†ã¨ã—ãŸã¨ã ã‚‚åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–ã«é–¢ã™ã‚‹è­¦å‘Šã‚’出ã™ã‚ˆã†ã« * vi 風行編集ã§ã€30 回目㮠yank ã®å¾Œèª¤ã£ãŸãƒ†ã‚­ã‚¹ãƒˆãŒ put ã•れã¦ã„㟠* vi 風行編集ã§ã€ã‚«ãƒ¼ã‚½ãƒ«ãŒè¡Œé ­ã«ã‚る㨠"s" コマンドãŒä½¿ãˆãªã‹ã£ãŸ ---------------------------------------------------------------------- Yash 2.11 + "--histspace", "--le-noconvmeta" オプション追加 + $HISTRMDUP 変数ã«å¯¾å¿œ + $YASH_LE_TIMEOUT 変数ã«å¯¾å¿œ + kill 組込ã¿ã® -l オプションã§ã‚·ã‚°ãƒŠãƒ«åをオペランドã¨ã—㦠渡ã›ã‚‹ã‚ˆã†ã« = "--le-convmeta" オプションã¯ã‚ªãƒ³ã‚ªãƒ•型オプション㫠= ログインシェルã§ã¯ "$-" 特殊パラメータ㫠"l" フラグをå«ã‚るよã†ã« * 空㮠case æ–‡ "case i in (*) esac" ã¯å¸¸ã«çµ‚了ステータス 0 を返㙠よã†ã« * "-f" オプション有効時ã€ã‚¯ã‚©ãƒ¼ãƒˆã•れãŸå˜èªžã«ä½™è¨ˆãªãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ ãŒãã£ã¤ã„ã¦ã„㟠* vi 風行編集㮠v コマンドã§ä¸æ­£ãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ã—ã¦ã„ãŸã®ã‚’修正 ---------------------------------------------------------------------- Yash 2.10 + 行編集ã«ãŠã‘るコマンド履歴検索 = 内容ã®ãªã„行ã¯å±¥æ­´ã«å…¥ã‚Œãªã„よã†ã« = vi 風行編集ã§ã€"cw" 㨠"cW" ãŒå®Ÿéš›ã® vi ã¨åŒæ§˜ã«æŒ¯ã‚‹èˆžã†ã‚ˆã†ã« * 行編集ãªã—ã§ configure ã—ãŸã¨ã "notifyle" オプションを設定ã—よㆠã¨ã™ã‚‹ã¨ã‚»ã‚°ãƒ•ã‚©ãŒç™ºç”Ÿã—ã¦ã„㟠* 行編集ã§ã€ç·¨é›†ã—ãŸå±¥æ­´ã‚’アンドゥã—ãŸã¨ãカーソルä½ç½®ãŒ æ­£ã—ããªã‹ã£ãŸ * 行編集中ã®ä¸æ­£ãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ã®ã„ãã¤ã‹ã®ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.9 + 対話モードã«ãŠã‘る行編集機能 x 行編集ã®å®Ÿè£…ãŒã¾ã é€”中 + åŒã˜å±¥æ­´ãƒ•ァイルを使用ã™ã‚‹è¤‡æ•°ã®ã‚·ã‚§ãƒ«ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹åŒå£«ã§ 履歴を共有ã™ã‚‹ã‚ˆã†ã« - "history" 組込ã¿ã‚’廃止 = éž ASCII ãªã‚¢ãƒ«ãƒ•ァベットも変数åã«ä½¿ãˆã‚‹ã‚ˆã†ã« = 入れå­ã®ãƒ‘ラメータ展開ã¯å¿…ãšãƒ–レースã§ããらãªã„ã¨ã„ã‘ãªã„よã†ã« = "help" 組込ã¿ã§ã€æŒ‡å®šã—ãŸã‚³ãƒžãƒ³ãƒ‰ãŒè¦‹ã¤ã‹ã‚‰ãªã‘れ㰠エラーを出ã™ã‚ˆã†ã« * 算術展開ã«ãŠã‘ã‚‹å°æ•°æ¼”ç®—ãŒæ­£ã—ããªã„ã“ã¨ãŒã‚ã£ãŸ * 算術展開ã§ä¸‹ç·šã§å§‹ã¾ã‚‹è­˜åˆ¥å­ãŒã‚¨ãƒ©ãƒ¼ã«ãªã£ã¦ã„㟠* "${#" ã§å§‹ã¾ã‚‹ãƒ‘ラメータ展開ã®è§£æžã‚’修正 (例: "${#=x}") * "pwd" 組込ã¿ã®ãƒ˜ãƒ«ãƒ—メッセージを修正 ---------------------------------------------------------------------- Yash 2.8 + 変化é‡ã‚’指定ã§ãるブレース展開: {a..b..c} + "command" 組込ã¿ã§ -B, -b オプション㌠-v, -V オプションã¨åŒæ™‚㫠使ãˆã‚‹ã‚ˆã†ã«ãªã£ãŸ = POSIX.1-2008 ã«æº–æ‹  . "read" 組込ã¿ã¯å…¥åŠ›ã®æœ«å°¾ã®ç©ºç™½é¡žã‚’常ã«å‰Šé™¤ã™ã‚‹ã‚ˆã†ã« . ãƒãƒ«ãƒ€å±•é–‹ã®çµæžœã‚’å˜èªžåˆ†å‰²ãƒ»ãƒ‘スå展開ã—ãªã„よã†ã« . "pwd -P" ã§ $PWD 変数を更新ã—ãªã„よã†ã« . "cd -L foo/.." ã¯ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒª "foo" ãŒå­˜åœ¨ã—ãªã„ã¨ãエラー㫠. "command" 組込ã¿ã§ -p オプション㌠-v, -V オプションã¨åŒæ™‚㫠使ãˆã‚‹ã‚ˆã†ã«ãªã£ãŸ . POSIX 準拠モードã§ã¯ã€ã‚¸ãƒ§ãƒ–制御中ã§ã‚‚éžåŒæœŸã‚³ãƒžãƒ³ãƒ‰ã¯ã™ã¹ã¦ SIGINT 㨠SIGQUIT を無視ã™ã‚‹ã‚ˆã†ã« * fc 組込ã¿ã§ç·¨é›†ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹éš›ã€$? 変数㫠fc ã§èµ·å‹•ã—㟠エディタã®çµ‚了ステータスãŒä»£å…¥ã•れã¦ã—ã¾ã£ã¦ã„㟠* $IFS ã®ä¸­ã«ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã€ã‚³ãƒ³ãƒžã€ã¾ãŸã¯ãƒ–レースを入れã¦ã‚‚ æ­£ã—ãå˜èªžåˆ†å‰²ã§ããªã‹ã£ãŸ * パスå展開ã«ãŠã„ã¦ã€ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®æ¤œç´¢æ¨©é™ã ã‘ãŒå¿…è¦ãªæ™‚ã§ã‚‚〠読ã¿è¾¼ã¿æ¨©é™ãŒãªã‘れã°å±•é–‹ã«å¤±æ•—ã—ã¦ã„㟠* シェルãŒèµ·å‹•ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®ã‚·ã‚°ãƒŠãƒ«ãƒžã‚¹ã‚¯ã¯ã€ã‚·ã‚§ãƒ«ã®ãƒžã‚¹ã‚¯ã‚’ å—ã‘ç¶™ãよã†ã«ã—㟠(トラップã—ãŸã‚·ã‚°ãƒŠãƒ«ã®ãƒžã‚¹ã‚¯ã‚’除ã) * "autocd" オプション有効時 "command" 組込ã¿ã«ã‚³ãƒžãƒ³ãƒ‰ã¨ã—㦠ディレクトリåを与ãˆãŸã¨ãã®å‹•作を修正 ---------------------------------------------------------------------- Yash 2.7 + ${array[index]:=value} ã§é…列è¦ç´ ã¸ã®ä»£å…¥ãŒå¯èƒ½ã« + ヒアストリングã®ãŸã‚ã®æ–°ã—ã„ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ "<<<" + ãƒ‘ã‚¤ãƒ—ã‚’é–‹ãæ–°ã—ã„ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ¼”ç®—å­ ">>|" - ループパイプ機能廃止 = シェルã®èµ·å‹•時㫠$IFS 変数を常ã«ãƒ‡ãƒ•ォルト値ã§åˆæœŸåŒ–ã™ã‚‹ã‚ˆã†ã« * "echo" ãŠã‚ˆã³ "printf" 組込ã¿ã§ã‚¨ãƒ©ãƒ¼æ™‚ã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出ã™ã‚ˆã†ã« * ファイルåã®å…ˆé ­ã«ã‚るクォートã•れãŸãƒ”リオドãŒãƒ•ァイルå展開㧠正ã—ãマッãƒã—ã¦ã„ãªã‹ã£ãŸ ---------------------------------------------------------------------- Yash 2.6 + fc 組込ã¿ã« -q オプション追加 + 複åˆã‚³ãƒžãƒ³ãƒ‰ã®å†…容ã¯ç©ºã§ã‚‚よã„よã†ã« * "alias -p" ã§ãƒã‚¤ãƒ•ンをé©åˆ‡ã«ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—ã™ã‚‹ã‚ˆã†ã« * POSIX 準拠モード㮠for æ–‡ã§ã€è­˜åˆ¥å­ã®ç›´å¾Œã®ã‚»ãƒŸã‚³ãƒ­ãƒ³ã‚’エラー㫠ã™ã‚‹ã‚ˆã†ã« * 複åˆã‚³ãƒžãƒ³ãƒ‰ã®ç›´å¾Œã§ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚¨ã‚¤ãƒªã‚¢ã‚¹ãŒä½¿ãˆãªã‹ã£ãŸ * "-o notify" ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæœ‰åŠ¹ãªæ™‚ "fg" ãŠã‚ˆã³ "wait" 組込ã¿ãŒ 䏿­£ãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ã‚’引ãèµ·ã“ã—ã¦ã„㟠---------------------------------------------------------------------- Yash 2.5 = シェルãŒä½¿ç”¨ã—ã¦ã„ã‚‹ FD ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯ã‚¨ãƒ©ãƒ¼ã«ã™ã‚‹ã‚ˆã†ã« * ã„ãã¤ã‹ã®ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆæ§‹æ–‡ã‚¨ãƒ©ãƒ¼ã‚’見逃ã—ã¦ã„㟠* "sig.y" テストãŒé–“é•ã£ã¦ã„㟠* リダイレクト付ãã® "exec" コマンドãŒãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆä»˜ãã® { } 括弧㮠中ã«ã‚ã‚‹å ´åˆã€æ‹¬å¼§ã«å¯¾ã™ã‚‹ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆãŒæ®‹ã£ãŸã¾ã¾ã«ãªã£ã¦ã„㟠* for æ–‡ã®è­˜åˆ¥å­ã®ç›´å¾Œã®ã‚³ãƒ¡ãƒ³ãƒˆã®è§£æžã‚¨ãƒ©ãƒ¼ã‚’修正 ---------------------------------------------------------------------- Yash 2.4 = "jobs" 組込ã¿ã® -p オプションã«å¯¾å¿œã™ã‚‹é•·ã„オプションを --pid-only ã‹ã‚‰ --pgid-only ã«å¤‰æ›´ * SIGCHLD, SIGINT, SIGTERM, SIGQUIT, SIGTSTP, SIGTTOU ã®ãƒˆãƒ©ãƒƒãƒ—㌠誤ã£ã¦ç„¡è¦–ã•れるã“ã¨ãŒã‚ã£ãŸ * SIGINT, SIGTERM, SIGQUIT, SIGTSTP, SIGTTOU ã®ã‚·ã‚°ãƒŠãƒ«ãƒãƒ³ãƒ‰ãƒ©ãŒ 誤ã£ã¦è§£é™¤ã•れã¦ã„る瞬間ãŒã‚ã£ãŸ * "wait" 組込ã¿ãŒã‚·ã‚°ãƒŠãƒ«ã«å‰²ã‚Šè¾¼ã¾ã‚ŒãŸã¨ãã®çµ‚了ステータスを修正 * ファイルアクセス権é™ã®åˆ¤å®šã‚’修正 * "command -V xxx/yyy" ã§ "xxx/yyy" ãŒæ­£ã—ã„コマンドã§ãªã„ã¨ã エラーメッセージを出ã™ã‚ˆã†ã« ---------------------------------------------------------------------- Yash 2.3 = 対話的ã‹ã¤éž POSIX 準拠モードã§å‹•作時ã€LC_CTYPE ã®å¤‰æ›´ãŒç›´ã¡ã« 有効ã«ãªã‚‹ã‚ˆã†ã« * パラメータ展開ã§ç©ºæ–‡å­—列を正ã—ã展開ã§ãã¦ã„ãªã‹ã£ãŸ * 稀ã«ã‚·ã‚°ãƒŠãƒ«ãŒç„¡è¦–ã•れる競åˆçŠ¶æ…‹ã‚’ä¿®æ­£ * typeset/readonly/export 組込ã¿ã§ä»£å…¥ã‚’行ã†ã¨ã‚·ã‚§ãƒ«å†…部ã®ãƒ‡ãƒ¼ã‚¿ãŒ æ­£ã—ãæ›´æ–°ã•れã¦ã„ãªã‹ã£ãŸã€‚ã“れã«ã‚ˆã‚Šã€PATH を変更ã—ãŸå¾Œã‚‚å¤ã„ PATH を使ã„ç¶šã‘ã¦ã—ã¾ã†ãªã©ã®å•題ãŒã‚ã£ãŸã€‚ ---------------------------------------------------------------------- Yash 2.2 + "help", "pushd", "popd", "dirs" 組込㿠= ルートディレクトリã‹ã‚‰ç›¸å¯¾ãƒ‘ス㧠"cd" ã™ã‚‹ã¨ã設定ã•れる $PWD ã®å€¤ã‚’修正 * "." ã‚„ ".." ã‚’å«ã‚€ãƒ•ァイルåå±•é–‹ãŒæ­£ã—ã動作ã—ã¦ã„ãªã‹ã£ãŸ ---------------------------------------------------------------------- Yash 2.1 + é…列変数 + "array", "echo", "printf", "test" 組込㿠+ "read" 組込ã¿ã® -A オプション * "${FOO:-bar}" ã®ã‚ˆã†ãªãƒ‘ラメータ展開ã®ä¸­ã®ã‚³ãƒ­ãƒ³ãƒ•ラグ㌠パラメータã®å€¤ãŒç‰¹å®šã®æ–‡å­—ã§å§‹ã¾ã‚‹å ´åˆã«ç„¡è¦–ã•れã¦ã„㟠* コマンドã«å¯¾ã—ã¦ä»£å…¥ã™ã‚‹ã¨ã読ã¿å–り専用変数ã§ã‚‚代入ã§ã㦠ã—ã¾ã£ã¦ã„㟠* "unset" 組込ã¿ã«å¤‰æ•°åã¨ã—㦠"=" を渡ã™ã¨èª¤ã£ã¦ä½ç½®ãƒ‘ラメータを 削除ã—ã€å ´åˆã«ã‚ˆã£ã¦ã¯ä¸æ­£ãªãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ã‚’引ãèµ·ã“ã—ã¦ã„ãŸã€‚ * 空白ã®ã¿ã‹ã‚‰ãªã‚‹å¤‰æ•°ã®å€¤ã®ãƒ•ィールド分割ãŒèª¤ã£ã¦ã„㟠* ファイルアクセス権é™ã®ç¢ºèªã¯å®Ÿãƒ¦ãƒ¼ã‚¶ãƒ»ã‚°ãƒ«ãƒ¼ãƒ— ID ã§ã¯ãªã実効 ユーザ・グループ ID ã«åŸºã¥ã„ã¦è¡Œã†ã‚ˆã†ã« ---------------------------------------------------------------------- Yash 2.0 + "history" 組込㿠+ コマンドリダイレクト * POSIX 準拠モードã®éžå¯¾è©±ã‚·ã‚§ãƒ«ã¯ç‰¹æ®Šçµ„è¾¼ã¿ã®ç‰¹å®šã®ã‚¨ãƒ©ãƒ¼ã§çµ‚了 ã™ã‚‹ã‚ˆã†ã« * エイリアス置æ›ã®å‡¦ç†ã‚’改良 * ãã®ä»–ã®ãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.0 beta2 + コマンド履歴 + "type", "hash", "fc" 組込㿠= "command" 組込ã¿ã® -V オプションã§ã‚³ãƒžãƒ³ãƒ‰ãŒã¿ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆ メッセージを出ã™ã‚ˆã†ã« * $PATH ã«ä»£å…¥ã—ãªãŒã‚‰å¤–部コマンドを呼出ã™ã¨ä¸æ­£ãªãƒ¡ãƒ¢ãƒªã‚¢ã‚¯ã‚»ã‚¹ãŒ 発生ã—ã¦ã„ãŸã€‚ * 一é‡å¼•ç”¨ç¬¦ãŒæ­£ã—ãè§£æžã•れãªã„å ´åˆãŒã‚ã£ãŸã€‚ * ãã®ä»–ã®ãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.0 beta1 + "read", "getopts", "command" 組込㿠+ --autocd, --curasync オプション + メールãƒã‚§ãƒƒã‚¯æ©Ÿèƒ½ + プロンプトコマンド = "readonly", "export" 組込ã¿ã¯å¸¸ã«ã‚°ãƒ­ãƒ¼ãƒãƒ«ã« * 標準入力をãƒãƒƒãƒ•ァリングã—ãªã„よã†ã«ã—㟠* "typeset" 組込ã¿ã§ '=' 以外ã®å…¨ã¦ã®æ–‡å­—を変数åã¨ã—ã¦å—ã‘付ã‘ã‚‹ よã†ã«ã—㟠* 特殊パラメータ $? ãŒå¤‰æ•°ä»£å…¥å†…ã§è¡Œã‚れãŸã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã®çµ‚了 ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ã‚’åæ˜ ã™ã‚‹ã‚ˆã†ã« * ãã®ä»–様々ãªãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.0 beta0 + "eval", "exec", ".", "times", "umask", "typeset", "export", "readonly", "unset", "shift", "trap" 組込㿠+ "wait" 組込ã¿ã‚’中断ã§ãるよã†ã« + æ•°å¼å±•é–‹ + 対話モードã§ãƒ—ロセスãŒã‚·ã‚°ãƒŠãƒ«ã«ã‚ˆã£ã¦çµ‚了ã—ãŸã‚‰ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’ 表示ã™ã‚‹ã‚ˆã†ã« - 起動時㫠"/etc/profile" 㨠"~/.profile" ã¯èª­ã¿è¾¼ã¾ãªã„よã†ã« * エイリアス置æ›ã§ã®ãƒˆãƒ¼ã‚¯ãƒ³åŒºåˆ‡ã‚Šã®èªè­˜ã‚’修正 * 値ã®ãªã„代入ã§ã®ãƒˆãƒ¼ã‚¯ãƒ³åŒºåˆ‡ã‚Šã®èªè­˜ã‚’修正 * ãã®ä»–様々ãªãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.0 alpha2 + 起動時㫠/etc/profile ã‚„ ~/.yashrc を読ã¿è¾¼ã‚€ã‚ˆã†ã« + --noprofile, --norcfile, --rcfile オプション + "pwd", "set", "exit", "return", "break", "continue", "jobs", "fg", "bg", "wait", "disown", "alias", "unalias" 組込㿠* --nocaseglob ㌠-c ã¨ã—ã¦è§£é‡ˆã•れã¦ã„㟠* --nocaseglob ã§å¤§æ–‡å­—å°æ–‡å­—ã®èªè­˜ãŒä¸å分ã ã£ãŸ * ジョブ制御ãŒã‚ªãƒ•ãªã‚‰ã€å¯¾è©±ã‚·ã‚§ãƒ«ã§ã‚‚ジョブã®çŠ¶æ…‹å¤‰åŒ–ã‚’ プロンプトå‰ã«è¡¨ç¤ºã—ãªã„よã†ã«ã—㟠= --nounset 有効時ã€${i?xxx} ã¯ã‚¨ãƒ©ãƒ¼ã¨ã—㦠xxx ã‚’è¿”ã™ã‚ˆã†ã« = ヘルプã®è¡¨ç¤ºã‚’簡潔㫠---------------------------------------------------------------------- Yash 2.0 alpha1 + オプション追加: -x, -h, -a = POSIX 準拠モードã§ã¯ 'PS3' ã®ãƒ‡ãƒ•ォルト値を設定ã—ãªã„よã†ã« + 'configure' ã«æ–°ã—ã„ '--no-undefined' オプション追加 + ":", "true", "false", "cd" 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ * PATH ã®å€¤ãŒå¤‰æ›´ã•れるã¨ãコマンドåãƒãƒƒã‚·ãƒ¥ã‚’クリアã™ã‚‹ã‚ˆã†ã« * ナル文字ãŒå…¥åŠ›ã•ã‚ŒãŸæ™‚ã®ã‚¢ã‚µãƒ¼ã‚·ãƒ§ãƒ³ã‚¨ãƒ©ãƒ¼ * ãã®ä»–様々ãªãƒã‚°ä¿®æ­£ ---------------------------------------------------------------------- Yash 2.0 alpha0 (2.x ç‰ˆã®æœ€åˆã®ãƒªãƒªãƒ¼ã‚¹) x æ•°å¼å±•é–‹ãŒæœªå®Ÿè£… x 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ãŒå…¨ã未実装 yash-2.35/util.d0000644000175000017500000000011212154557026013662 0ustar magicantmagicantutil.o: util.c common.h config.h util.h exec.h xgetopt.h option.h plist.h yash-2.35/redir.c0000644000175000017500000005660312154557026014031 0ustar magicantmagicant/* Yash: yet another shell */ /* redir.c: manages file descriptors and provides functions for redirections */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "redir.h" #include #include #include #include #if HAVE_GETTEXT # include #endif #include #if YASH_ENABLE_SOCKET # include #endif #include #include #include #include #include #if YASH_ENABLE_SOCKET # include #endif #include #include #include "exec.h" #include "expand.h" #include "input.h" #include "option.h" #include "parser.h" #include "path.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "yash.h" /********** Utilities **********/ /* Closes the specified file descriptor surely. * If `close' returns EINTR, tries again. * If `close' returns EBADF, it is considered successful and silently ignored. * If `close' returns an error other than EINTR/EBADF, an error message is * printed. */ int xclose(int fd) { while (close(fd) < 0) { switch (errno) { case EINTR: continue; case EBADF: return 0; default: xerror(errno, Ngt("error in closing file descriptor %d"), fd); return -1; } } return 0; } /* Performs `dup2' surely. * If `dup2' returns EINTR, tries again. * If `dup2' returns an error other than EINTR, an error message is printed. * `xclose' is called before `dup2'. */ int xdup2(int oldfd, int newfd) { if (oldfd != newfd) xclose(newfd); while (dup2(oldfd, newfd) < 0) { switch (errno) { case EINTR: continue; default: xerror(errno, Ngt("cannot copy file descriptor %d to %d"), oldfd, newfd); return -1; } } return newfd; } /* Repeatedly calls `write' until all `data' is written. * Returns true iff successful. On error, false is returned with `errno' set. */ /* Note that this function returns a Boolean value, not `ssize_t'. */ bool write_all(int fd, const void *data, size_t size) { while (size > 0) { ssize_t s = write(fd, data, size); if (s < 0) return false; data = (const char *) data + s; size -= s; } return true; } /********** Shell FDs **********/ static void reset_shellfdmin(void); /* True iff the standard input is redirected */ static bool is_stdin_redirected = false; /* Set of file descriptors used by the shell. * These file descriptors cannot be used by the user. */ static fd_set shellfds; /* The minimum file descriptor that can be used for shell FD. */ static int shellfdmin; /* The maximum file descriptor in `shellfds'. * `shellfdmax' is -1 when `shellfds' is empty. */ static int shellfdmax = -1; #ifndef SHELLFDMINMAX #define SHELLFDMINMAX 100 /* maximum for `shellfdmin' */ #endif #if SHELLFDMINMAX < 10 #error SHELLFDMINMAX too little #endif /* File descriptor associated with the controlling terminal */ int ttyfd = -1; /* Initializes shell FDs. */ void init_shellfds(void) { #ifndef NDEBUG static bool initialized = false; assert(!initialized); initialized = true; #endif FD_ZERO(&shellfds); reset_shellfdmin(); assert(shellfdmax == -1); // shellfdmax = -1; } /* Recomputes `shellfdmin'. */ void reset_shellfdmin(void) { errno = 0; shellfdmin = sysconf(_SC_OPEN_MAX); if (shellfdmin < 0) { if (errno != 0) shellfdmin = 10; else shellfdmin = SHELLFDMINMAX; } else { if (shellfdmin > FD_SETSIZE) shellfdmin = FD_SETSIZE; shellfdmin /= 2; if (shellfdmin > SHELLFDMINMAX) shellfdmin = SHELLFDMINMAX; else if (shellfdmin < 10) shellfdmin = 10; } } /* Adds the specified file descriptor (>= `shellfdmin') to `shellfds'. */ void add_shellfd(int fd) { assert(fd >= shellfdmin); if (fd < FD_SETSIZE) FD_SET(fd, &shellfds); if (shellfdmax < fd) shellfdmax = fd; } /* Removes the specified file descriptor from `shellfds'. * Must be called BEFORE `xclose(fd)'. */ void remove_shellfd(int fd) { if (0 <= fd && fd < FD_SETSIZE) FD_CLR(fd, &shellfds); if (fd == shellfdmax) { do shellfdmax--; while (shellfdmax >= 0 && !FD_ISSET(shellfdmax, &shellfds)); } } /* The argument to `FD_CLR' must be a valid (open) file descriptor. This is why * `remove_shellfd' must be called before closing the file descriptor. */ /* Checks if the specified file descriptor is in `shellfds'. */ bool is_shellfd(int fd) { return fd >= FD_SETSIZE || (fd >= 0 && FD_ISSET(fd, &shellfds)); } /* Clears `shellfds'. * If `leavefds' is false, the file descriptors in `shellfds' are closed. */ void clear_shellfds(bool leavefds) { if (!leavefds) { for (int fd = 0; fd <= shellfdmax; fd++) if (FD_ISSET(fd, &shellfds)) xclose(fd); FD_ZERO(&shellfds); shellfdmax = -1; } ttyfd = -1; } /* Duplicates the specified file descriptor as a new shell FD. * The new FD is added to `shellfds'. * On error, `errno' is set and -1 is returned. */ int copy_as_shellfd(int fd) { int newfd; #ifdef F_DUPFD_CLOEXEC /* Even if the F_DUPFD_CLOEXEC flag is defined in the header, the * OS kernel may not support it. We fall back on the normal F_DUPFD-F_SETFD * sequence if the F_DUPFD_CLOEXEC flag is rejected. */ static bool dupfd_cloexec_ok = true; if (dupfd_cloexec_ok) { newfd = fcntl(fd, F_DUPFD_CLOEXEC, shellfdmin); if (newfd >= 0 || errno != EINVAL) goto finish; dupfd_cloexec_ok = false; } #endif newfd = fcntl(fd, F_DUPFD, shellfdmin); if (newfd >= 0) fcntl(newfd, F_SETFD, FD_CLOEXEC); #ifdef F_DUPFD_CLOEXEC finish: #endif if (newfd >= 0) add_shellfd(newfd); return newfd; } /* Moves the specified file descriptor (FD) to a shell FD. * The original FD is closed (whether successful or not). * If `fd' is negative, this function simply returns `fd' (without changing * `errno'). If `fd' is non-negative and the FD cannot be copied, `errno' is set * to indicate the error. */ int move_to_shellfd(int fd) { if (fd < 0) return fd; int newfd = copy_as_shellfd(fd); int saveerrno = errno; xclose(fd); errno = saveerrno; return newfd; } /* Opens `ttyfd'. * On failure, an error message is printed and `do_job_control' is set to false. */ void open_ttyfd(void) { if (ttyfd < 0) { ttyfd = move_to_shellfd(open("/dev/tty", O_RDWR)); if (ttyfd < 0) { xerror(errno, Ngt("cannot open file `%s'"), "/dev/tty"); xerror(0, Ngt("disabling job control")); do_job_control = false; } } } /********** Redirections **********/ /* info used to undo redirection */ struct savefd_T { struct savefd_T *next; int sf_origfd; /* original file descriptor */ int sf_copyfd; /* copied file descriptor */ bool sf_stdin_redirected; /* original `is_stdin_redirected' */ }; static char *expand_redir_filename(const struct wordunit_T *filename) __attribute__((malloc,warn_unused_result)); static void save_fd(int oldfd, savefd_T **save) __attribute__((nonnull)); static int open_file(const char *path, int oflag) __attribute__((nonnull)); #if YASH_ENABLE_SOCKET static int open_socket(const char *hostandport, int socktype) __attribute__((nonnull)); #endif static int parse_and_check_dup(char *num, redirtype_T type) __attribute__((nonnull)); static int parse_and_exec_pipe(int outputfd, char *num, savefd_T **save) __attribute__((nonnull)); static int open_heredocument(const struct wordunit_T *content); static int open_herestring(char *s, bool appendnewline) __attribute__((nonnull)); static int open_process_redirection(const embedcmd_T *command, redirtype_T type) __attribute__((nonnull)); /* Opens redirection. * If `save' is non-NULL, the original FD is saved and a pointer to the info is * assigned to `*save' (whether successful or not). * Returns true iff successful. */ bool open_redirections(const redir_T *r, savefd_T **save) { *save = NULL; while (r != NULL) { if (r->rd_fd < 0) { xerror(0, Ngt("redirection: invalid file descriptor")); return false; } else if (is_shellfd(r->rd_fd)) { xerror(0, Ngt("redirection: file descriptor %d is unavailable"), r->rd_fd); return false; } /* expand rd_filename */ char *INIT(filename); switch (r->rd_type) { case RT_INPUT: case RT_OUTPUT: case RT_CLOBBER: case RT_APPEND: case RT_INOUT: case RT_DUPIN: case RT_DUPOUT: case RT_PIPE: case RT_HERESTR: filename = expand_redir_filename(r->rd_filename); if (filename == NULL) return false; break; default: break; } /* save original FD */ save_fd(r->rd_fd, save); /* now, open redirection */ int fd; int flags; bool keepopen; switch (r->rd_type) { case RT_INPUT: flags = O_RDONLY; goto openwithflags; case RT_OUTPUT: if (!shopt_clobber && !is_irregular_file(filename)) { flags = O_WRONLY | O_CREAT | O_EXCL; } else { case RT_CLOBBER: flags = O_WRONLY | O_CREAT | O_TRUNC; } goto openwithflags; case RT_APPEND: flags = O_WRONLY | O_CREAT | O_APPEND; goto openwithflags; case RT_INOUT: flags = O_RDWR | O_CREAT; goto openwithflags; openwithflags: keepopen = false; fd = open_file(filename, flags); if (fd < 0) { xerror(errno, Ngt("redirection: cannot open file `%s'"), filename); free(filename); return false; } free(filename); break; case RT_DUPIN: case RT_DUPOUT: keepopen = true; fd = parse_and_check_dup(filename, r->rd_type); if (fd < -1) return false; break; case RT_PIPE: keepopen = false; fd = parse_and_exec_pipe(r->rd_fd, filename, save); if (fd < 0) return false; break; case RT_HERE: case RT_HERERT: keepopen = false; fd = open_heredocument(r->rd_herecontent); if (fd < 0) return false; break; case RT_HERESTR: keepopen = false; fd = open_herestring(filename, true); if (fd < 0) return false; break; case RT_PROCIN: case RT_PROCOUT: keepopen = false; fd = open_process_redirection(&r->rd_command, r->rd_type); if (fd < 0) return false; break; default: assert(false); } /* move the new FD to `r->rd_fd' */ if (fd != r->rd_fd) { if (fd >= 0) { if (xdup2(fd, r->rd_fd) < 0) return false; if (!keepopen) xclose(fd); } else { xclose(r->rd_fd); } } if (r->rd_fd == STDIN_FILENO) is_stdin_redirected = true; r = r->next; } return true; } /* Expands the filename for redirection. * Returns a newly malloced string or NULL. */ char *expand_redir_filename(const struct wordunit_T *filename) { if (is_interactive) { return expand_single_with_glob(filename, TT_SINGLE); } else { wchar_t *result = expand_single(filename, TT_SINGLE); if (result == NULL) return NULL; char *mbsresult = realloc_wcstombs(unescapefree(result)); if (mbsresult == NULL) xerror(EILSEQ, Ngt("redirection")); return mbsresult; } } /* Saves the specified file descriptor if `save' is non-NULL. */ void save_fd(int fd, savefd_T **save) { assert(fd >= 0); int copyfd = copy_as_shellfd(fd); if (copyfd < 0 && errno != EBADF) { xerror(errno, Ngt("cannot save file descriptor %d"), fd); return; } /* If file descriptor `fd' is not open, `copy_as_shellfd' returns -1 with * the EBADF errno value. */ savefd_T *s = xmalloc(sizeof *s); s->next = *save; s->sf_origfd = fd; s->sf_copyfd = copyfd; s->sf_stdin_redirected = is_stdin_redirected; *save = s; } /* Opens the redirected file. * `path' and `oflag' are the first and second arguments to the `open' function. * If socket redirection is enabled and `path' begins with "/dev/tcp/" or * "/dev/udp/", a socket is opened. * Returns a new file descriptor if successful. Otherwise, `errno' is set and * -1 is returned. */ int open_file(const char *path, int oflag) { int fd = open(path, oflag, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); #if YASH_ENABLE_SOCKET if (fd < 0) { const char *hostandport = matchstrprefix(path, "/dev/tcp/"); if (hostandport != NULL) fd = open_socket(hostandport, SOCK_STREAM); } if (fd < 0) { const char *hostandport = matchstrprefix(path, "/dev/udp/"); if (hostandport != NULL) fd = open_socket(hostandport, SOCK_DGRAM); } #endif /* YASH_ENABLE_SOCKET */ return fd; } #if YASH_ENABLE_SOCKET /* Opens a socket. * `hostandport' is the name and the port of the host to connect, concatenated * with a slash. `socktype' specifies the type of the socket, which should be * SOCK_STREAM for TCP or SOCK_DGRAM for UDP. * On failure, returns -1 with `errno' unchanged. */ int open_socket(const char *hostandport, int socktype) { struct addrinfo hints, *ai; int err, saveerrno; char *hostname, *port; int fd; saveerrno = errno; /* decompose `hostandport' into `hostname' and `port' */ { wchar_t *whostandport; const wchar_t *wport; whostandport = malloc_mbstowcs(hostandport); if (whostandport == NULL) { errno = saveerrno; return -1; } wport = wcschr(whostandport, L'/'); if (wport != NULL) { hostname = malloc_wcsntombs(whostandport, wport - whostandport); port = malloc_wcstombs(wport + 1); // XXX error ignored } else { hostname = xstrdup(hostandport); port = NULL; } free(whostandport); } set_interruptible_by_sigint(true); hints.ai_flags = 0; hints.ai_family = AF_UNSPEC; hints.ai_socktype = socktype; hints.ai_protocol = 0; hints.ai_addrlen = 0; hints.ai_addr = NULL; hints.ai_canonname = NULL; hints.ai_next = NULL; err = getaddrinfo(hostname, port, &hints, &ai); free(hostname); free(port); if (err != 0) { xerror(0, Ngt("socket redirection: " "cannot resolve the address of `%s': %s"), hostandport, gai_strerror(err)); set_interruptible_by_sigint(false); errno = saveerrno; return -1; } fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (fd >= 0 && connect(fd, ai->ai_addr, ai->ai_addrlen) < 0) { xclose(fd); fd = -1; } saveerrno = errno; freeaddrinfo(ai); set_interruptible_by_sigint(false); errno = saveerrno; return fd; } #endif /* YASH_ENABLE_SOCKET */ /* Parses the argument to an RT_DUPIN/RT_DUPOUT redirection. * `num' is the argument to parse, which is expected to be "-" or a non-negative * integer. `num' is freed in this function. * If `num' is a non-negative integer, the value is returned. * If `num' is "-", -1 is returned. * Otherwise, a negative value other than -1 is returned. * `type' must be either RT_DUPIN or RT_DUPOUT. */ int parse_and_check_dup(char *const num, redirtype_T type) { int fd; if (strcmp(num, "-") == 0) { fd = -1; goto end; } if (!xisxdigit(num[0])) errno = EINVAL; else if (xstrtoi(num, 10, &fd)) if (fd < 0) errno = ERANGE; if (errno != 0) { xerror(errno, Ngt("redirection: %s"), num); fd = -2; goto end; } if (is_shellfd(fd)) { xerror(0, Ngt("redirection: file descriptor %d is unavailable"), fd); fd = -2; goto end; } if (posixly_correct) { /* check the read/write permission */ int flags = fcntl(fd, F_GETFL); if (flags < 0) { xerror(errno, Ngt("redirection: %s"), num); fd = -2; } else if (type == RT_DUPIN) { switch (flags & O_ACCMODE) { case O_RDONLY: case O_RDWR: /* ok */ break; default: xerror(0, Ngt("redirection: " "file descriptor %d is not readable"), fd); fd = -2; break; } } else { assert(type == RT_DUPOUT); switch (flags & O_ACCMODE) { case O_WRONLY: case O_RDWR: /* ok */ break; default: xerror(0, Ngt("redirection: " "file descriptor %d is not writable"), fd); fd = -2; break; } } } end: free(num); return fd; } /* Parses the argument to an RT_PIPE redirection and opens a pipe. * `outputfd' is the file descriptor of the output side of the pipe. * `num' is the argument to parse, which is expected to be a non-negative * integer that is the file descriptor of the input side of the pipe. * `num' is freed in this function. * The input side FD is saved in this function. * If successful, the actual file descriptor of the output side of the pipe is * returned, which may differ from `outputfd'. Otherwise, -1 is returned. */ int parse_and_exec_pipe(int outputfd, char *num, savefd_T **save) { int fd, inputfd; int pipefd[2]; assert(outputfd >= 0); if (!xisxdigit(num[0])) { errno = EINVAL; } else { if (xstrtoi(num, 10, &inputfd) && inputfd < 0) errno = ERANGE; } if (errno != 0) { xerror(errno, Ngt("redirection: %s"), num); fd = -1; } else if (outputfd == inputfd) { xerror(0, Ngt("redirection: %d>>|%d: " "the input and output file descriptors are same"), outputfd, inputfd); fd = -1; } else if (is_shellfd(inputfd)) { xerror(0, Ngt("redirection: file descriptor %d is unavailable"), inputfd); fd = -1; } else { /* ok, save inputfd and open the pipe */ save_fd(inputfd, save); if (pipe(pipefd) < 0) goto error; /* move the output side from what is to be the input side. */ if (pipefd[PIPE_OUT] == inputfd) { int newfd = dup(pipefd[PIPE_OUT]); if (newfd < 0) goto error2; xclose(pipefd[PIPE_OUT]); pipefd[PIPE_OUT] = newfd; } /* move the input side to where it should be. */ if (pipefd[PIPE_IN] != inputfd) { if (xdup2(pipefd[PIPE_IN], inputfd) < 0) goto error2; xclose(pipefd[PIPE_IN]); // pipefd[PIPE_IN] = inputfd; } /* The output side is not moved in this function. */ fd = pipefd[PIPE_OUT]; } end: free(num); return fd; error2:; int saveerrno = errno; xclose(pipefd[PIPE_IN]); xclose(pipefd[PIPE_OUT]); errno = saveerrno; error: xerror(errno, Ngt("redirection: %d>>|%d"), outputfd, inputfd); fd = -1; goto end; } /* Opens a here-document whose contents is specified by the argument. * Returns a newly opened file descriptor if successful, or -1 on error. */ /* The contents of the here-document is passed either through a pipe or a * temporary file. */ int open_heredocument(const wordunit_T *contents) { wchar_t *wcontents = expand_string(contents, true); if (wcontents == NULL) return -1; char *mcontents = realloc_wcstombs(wcontents); if (mcontents == NULL) { xerror(EILSEQ, Ngt("cannot write the here-document contents " "to the temporary file")); return -1; } return open_herestring(mcontents, false); } /* Opens a here-string whose contents is specified by the argument. * If `appendnewline' is true, a newline is appended to the value of `s'. * Returns a newly opened file descriptor if successful, or -1 on error. * `s' is freed in this function. */ /* The contents of the here-document is passed either through a pipe or a * temporary file. */ int open_herestring(char *s, bool appendnewline) { int fd; /* if contents is empty */ if (s[0] == '\0' && !appendnewline) { fd = open("/dev/null", O_RDONLY); if (fd >= 0) { free(s); return fd; } } size_t len = strlen(s); if (appendnewline) s[len++] = '\n'; #ifdef PIPE_BUF /* use a pipe if the contents is short enough */ if (len <= PIPE_BUF) { int pipefd[2]; if (pipe(pipefd) >= 0) { /* It is guaranteed that all the contents is written to the pipe * at once, so we don't have to use `write_all' here. */ if (write(pipefd[PIPE_OUT], s, len) < 0) xerror(errno, Ngt("cannot write the here-document contents " "to the temporary file")); xclose(pipefd[PIPE_OUT]); free(s); return pipefd[PIPE_IN]; } } #endif /* defined(PIPE_BUF) */ char *tempfile; fd = create_temporary_file(&tempfile, 0); if (fd < 0) { xerror(errno, Ngt("cannot create a temporary file for the here-document")); free(s); return -1; } if (unlink(tempfile) < 0) xerror(errno, Ngt("failed to remove temporary file `%s'"), tempfile); free(tempfile); if (!write_all(fd, s, len)) xerror(errno, Ngt("cannot write the here-document contents " "to the temporary file")); free(s); if (lseek(fd, 0, SEEK_SET) != 0) xerror(errno, Ngt("cannot seek the temporary file for the here-document")); return fd; } /* Opens process redirection and returns the file descriptor. * `type' must be RT_PROCIN or RT_PROCOUT. * The return value is -1 if failed. */ int open_process_redirection(const embedcmd_T *command, redirtype_T type) { int pipefd[2]; pid_t cpid; assert(type == RT_PROCIN || type == RT_PROCOUT); if (pipe(pipefd) < 0) { xerror(errno, Ngt("redirection: cannot open a pipe " "for the command redirection")); return -1; } cpid = fork_and_reset(-1, false, 0); if (cpid < 0) { /* fork failure */ xclose(pipefd[PIPE_IN]); xclose(pipefd[PIPE_OUT]); return -1; } else if (cpid) { /* parent process */ if (type == RT_PROCIN) { xclose(pipefd[PIPE_OUT]); return pipefd[PIPE_IN]; } else { xclose(pipefd[PIPE_IN]); return pipefd[PIPE_OUT]; } } else { /* child process */ if (type == RT_PROCIN) { xclose(pipefd[PIPE_IN]); if (pipefd[PIPE_OUT] != STDOUT_FILENO) { if (xdup2(pipefd[PIPE_OUT], STDOUT_FILENO) < 0) exit(Exit_NOEXEC); xclose(pipefd[PIPE_OUT]); } } else { xclose(pipefd[PIPE_OUT]); if (pipefd[PIPE_IN] != STDIN_FILENO) { if (xdup2(pipefd[PIPE_IN], STDIN_FILENO) < 0) exit(Exit_NOEXEC); xclose(pipefd[PIPE_IN]); } } if (command->is_preparsed) exec_and_or_lists(command->value.preparsed, true); else exec_wcs(command->value.unparsed, gt("command redirection"), true); assert(false); } } /* Restores the saved file descriptor and frees `save'. */ void undo_redirections(savefd_T *save) { while (save != NULL) { if (save->sf_copyfd >= 0) { remove_shellfd(save->sf_copyfd); xdup2(save->sf_copyfd, save->sf_origfd); xclose(save->sf_copyfd); } else { xclose(save->sf_origfd); } is_stdin_redirected = save->sf_stdin_redirected; savefd_T *next = save->next; free(save); save = next; } } /* Frees the FD-saving info without restoring FD. * The copied FDs are closed. */ void clear_savefd(savefd_T *save) { while (save != NULL) { if (save->sf_copyfd >= 0) { remove_shellfd(save->sf_copyfd); xclose(save->sf_copyfd); } savefd_T *next = save->next; free(save); save = next; } } /* Redirects the standard input to "/dev/null" if job control is off and the * standard input is not yet redirected. * If `posixly_correct' is true, the condition is slightly different: * "if non-interactive" rather than "if job control is off". */ void maybe_redirect_stdin_to_devnull(void) { int fd; if ((posixly_correct ? is_interactive : do_job_control) || is_stdin_redirected) return; if (xclose(STDIN_FILENO) < 0) return; fd = open("/dev/null", O_RDONLY); if (fd < 0) { //xerror(errno, Ngt("cannot redirect the standard input to /dev/null")); } else { assert(fd == STDIN_FILENO); } is_stdin_redirected = true; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/history.d0000644000175000017500000000023012154557026014407 0ustar magicantmagicanthistory.o: history.c common.h config.h history.h xgetopt.h builtin.h \ exec.h job.h option.h path.h redir.h sig.h strbuf.h util.h variable.h \ yash.h yash-2.35/xgetopt.d0000644000175000017500000000010112154557026014375 0ustar magicantmagicantxgetopt.o: xgetopt.c common.h config.h xgetopt.h option.h util.h yash-2.35/yash.d0000644000175000017500000000027612154557026013664 0ustar magicantmagicantyash.o: yash.c common.h config.h yash.h xgetopt.h alias.h builtin.h \ configm.h exec.h expand.h history.h input.h job.h option.h parser.h \ path.h redir.h sig.h strbuf.h util.h variable.h yash-2.35/plist.d0000644000175000017500000000006212154557026014044 0ustar magicantmagicantplist.o: plist.c common.h config.h plist.h util.h yash-2.35/sig.c0000644000175000017500000011515212154557026013501 0ustar magicantmagicant/* Yash: yet another shell */ /* sig.c: signal handling */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "sig.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #if HAVE_GETTEXT # include #endif #include "builtin.h" #include "exec.h" #include "expand.h" #include "job.h" #include "option.h" #include "parser.h" #include "redir.h" #include "siglist.h" #include "signum.h" #include "strbuf.h" #include "util.h" #include "yash.h" #if YASH_ENABLE_LINEEDIT # include "xfnmatch.h" # include "lineedit/complete.h" # include "lineedit/lineedit.h" #endif /* About the shell's signal handling: * * Yash always catches SIGCHLD. * When job control is active, SIGTSTP is ignored. * If the shell is interactive, SIGTERM and SIGQUIT are ignored and SIGINT and * SIGWINCH are caught. * Trapped signals are also caught. * * SIGQUIT and SIGINT are ignored in an asynchronous list. * SIGTSTP is left ignored in command substitution in a job-control shell. * * The shell inherits the signal mask from its invoker and commands invoked by * the shell also inherit it. (POSIX.1-2008) * Signals with the handler installed are almost always blocked to avoid * unexpected interruption of system calls. They are unblocked when: * - the shell waits for input * - the shell waits for a child process to finish * - the shell handles traps. * Also, SIGINT is unblocked when: * - the shell tries to open a socket * - the shell performs pathname expansion. * * SIGTTOU is blocked in `put_foreground' and unblocked in `ensure_foreground'. * All signals are blocked to avoid race conditions when the shell forks. */ static int parse_signal_number(const wchar_t *number) __attribute__((pure)); static void set_special_handler(int signum, void (*handler)(int signum)); static void reset_special_handler( int signum, void (*handler)(int signum), bool leave); static void sig_handler(int signum); static void handle_sigchld(void); static void set_trap(int signum, const wchar_t *command); static bool is_ignored(int signum); #if YASH_ENABLE_LINEEDIT # ifdef SIGWINCH static inline void handle_sigwinch(void); # endif static void sig_new_candidate( const le_compopt_T *restrict compopt, int num, xwcsbuf_T *restrict name) __attribute__((nonnull)); #endif /********** Auxiliary Functions **********/ /* Checks if there exists a process with the specified process ID, which must * be positive. */ bool process_exists(pid_t pid) { assert(pid > 0); return kill(pid, 0) >= 0 || errno != ESRCH; /* send a dummy signal to check if the process exists. */ } /* Returns the name of the signal with the specified number. * The returned name doesn't have the "SIG"-prefix. * An empty string is returned for an unknown signal number. * The returned string is valid until the next call to this function. */ const wchar_t *get_signal_name(int signum) { if (signum == 0) return L"EXIT"; #if defined SIGRTMIN && defined SIGRTMAX int sigrtmin = SIGRTMIN, sigrtmax = SIGRTMAX; if (sigrtmin <= signum && signum <= sigrtmax) { static wchar_t *name = NULL; if (signum == sigrtmin) return L"RTMIN"; if (signum == sigrtmax) return L"RTMAX"; int range = sigrtmax - sigrtmin, diff = signum - sigrtmin; free(name); if (diff <= range / 2) name = malloc_wprintf(L"RTMIN+%d", diff); else name = malloc_wprintf(L"RTMAX-%d", sigrtmax - signum); return name; } #endif for (const signal_T *s = signals; s->no != 0; s++) if (s->no == signum) return s->name; return L""; } /* Returns the number of the signal whose name is `name'. * `name' may have the "SIG"-prefix. * If `name' is an integer that is a valid signal number, the number is * returned. * Returns 0 for "EXIT" and -1 for an unknown name. * `name' should be all in uppercase. */ int get_signal_number(const wchar_t *name) { if (iswdigit(name[0])) return parse_signal_number(name); if (wcscmp(name, L"EXIT") == 0) return 0; if (wcsncmp(name, L"SIG", 3) == 0) name += 3; for (const signal_T *s = signals; s->no != 0; s++) if (wcscmp(name, s->name) == 0) return s->no; #if defined SIGRTMIN && defined SIGRTMAX if (wcsncmp(name, L"RTMIN", 5) == 0) { int sigrtmin = SIGRTMIN; name += 5; if (name[0] == L'\0') { return sigrtmin; } else if (name[0] == L'+') { int num; if (xwcstoi(name, 10, &num)) { assert(num >= 0); if (SIGRTMAX - sigrtmin >= num) return sigrtmin + num; } } } else if (wcsncmp(name, L"RTMAX", 5) == 0) { int sigrtmax = SIGRTMAX; name += 5; if (name[0] == L'\0') { return sigrtmax; } else if (name[0] == L'-') { int num; if (xwcstoi(name, 10, &num)) { assert(num < 0); if (SIGRTMIN - sigrtmax <= num) return sigrtmax + num; } } } #endif return -1; } /* Parses the specified string as non-negative integer and returns the integer * if it is zero or a valid signal number. Returns -1 otherwise. */ int parse_signal_number(const wchar_t *number) { int signum; /* parse `number' */ if (!xwcstoi(number, 10, &signum) || signum < 0) return -1; /* check if `signum' is a valid signal */ if (signum == 0) return 0; #if defined SIGRTMIN && defined SIGRTMAX if (SIGRTMIN <= signum && signum <= SIGRTMAX) return signum; #endif for (const signal_T *s = signals; s->no != 0; s++) if (s->no == signum) return signum; return -1; } /* Returns the number of the signal whose name is `name'. * `name' may have the "SIG"-prefix. * If `name' is an integer that is a valid signal number, the number is * returned. * Returns 0 for "EXIT" and -1 for an unknown name. * The given string is converted into uppercase. */ int get_signal_number_toupper(wchar_t *name) { for (wchar_t *n = name; *n != L'\0'; n++) *n = towupper(*n); return get_signal_number(name); } /********** Signal Handler Management */ /* set to true when any trap other than "ignore" is set */ bool any_trap_set = false; /* flag to indicate a signal is caught. */ static volatile sig_atomic_t any_signal_received = false; /* the signal for which trap is currently executed */ static int handled_signal = -1; /* flags to indicate a signal is caught. */ static volatile sig_atomic_t signal_received[MAXSIGIDX]; /* commands to be executed when a signal is trapped (caught). */ static wchar_t *trap_command[MAXSIGIDX]; /* These arrays are indexed by `sigindex'. The index 0 is for the EXIT trap. */ /* `signal_received' and `trap_command' for real-time signals. */ #if defined SIGRTMIN && defined SIGRTMAX # if RTSIZE == 0 # error "RTSIZE == 0" # endif static volatile sig_atomic_t rtsignal_received[RTSIZE]; static wchar_t *rttrap_command[RTSIZE]; #endif /* The signal mask the shell inherited on invocation. * This mask is inherited by commands the shell invokes. * When a signal's trap is set, the signal is removed from this mask. */ static sigset_t original_sigmask; /* Set of signals whose handler was "ignore" when the shell was invoked but * currently is substituted with the shell's handler. * The handler of these signals must be reset to "ignore" before the shell * invokes another command so that the command inherits "ignore" as the handler. * A signal is added to this set also when its trap handler is set to "ignore". */ static sigset_t ignored_signals; /* Set of signals whose trap is set to other than "ignore". * These signals are almost always blocked. */ static sigset_t trapped_signals; /* Set of signals that are in `original_sigmask' but not in `trapped_signals' */ static sigset_t accept_sigmask; /* This flag is set to true as well as `signal_received[sigindex(SIGCHLD/INT)]' * when SIGCHLD/SIGINT is caught. * This flag is used for job control while `signal_received[...]' is for trap * handling. */ static volatile sig_atomic_t sigchld_received, sigint_received; #if YASH_ENABLE_LINEEDIT && defined(SIGWINCH) /* This flag is set to true as well as `signal_received[sigindex(SIGWINCH)]' * when SIGWINCH is caught. * This flag is used by line-editing. */ static volatile sig_atomic_t sigwinch_received; #endif /* true iff SIGCHLD is handled. */ static bool main_handler_set = false; /* true iff SIGTSTP is ignored. */ static bool job_handler_set = false; /* true iff SIGTERM, SIGINT, SIGQUIT and SIGWINCH are ignored/handled. */ static bool interactive_handlers_set = false; /* Initializes the signal module. */ void init_signal(void) { sigemptyset(&original_sigmask); sigemptyset(&ignored_signals); sigemptyset(&trapped_signals); sigprocmask(SIG_SETMASK, NULL, &original_sigmask); accept_sigmask = original_sigmask; } /* Installs signal handlers used by the shell according to the current settings. */ void set_signals(void) { sigset_t block = trapped_signals; if (!job_handler_set && doing_job_control_now) { job_handler_set = true; set_special_handler(SIGTSTP, SIG_IGN); } if (!interactive_handlers_set && is_interactive_now) { interactive_handlers_set = true; sigaddset(&block, SIGINT); set_special_handler(SIGINT, sig_handler); set_special_handler(SIGTERM, SIG_IGN); set_special_handler(SIGQUIT, SIG_IGN); #if YASH_ENABLE_LINEEDIT && defined(SIGWINCH) sigaddset(&block, SIGWINCH); set_special_handler(SIGWINCH, sig_handler); #endif } if (!main_handler_set) { main_handler_set = true; sigaddset(&block, SIGCHLD); set_special_handler(SIGCHLD, sig_handler); } sigprocmask(SIG_BLOCK, &block, NULL); } /* Restores the original signal handlers for the signals used by the shell. * If `leave' is true, the current process is assumed to be about to exec: * the handler may be left unchanged if the handler is supposed to be reset * during exec. The signal setting for SIGCHLD is restored. * If `leave' is false, the setting for SIGCHLD are not restored. */ void restore_signals(bool leave) { if (job_handler_set) { job_handler_set = false; reset_special_handler(SIGTSTP, SIG_IGN, leave); } if (interactive_handlers_set) { interactive_handlers_set = false; reset_special_handler(SIGINT, sig_handler, leave); reset_special_handler(SIGTERM, SIG_IGN, leave); reset_special_handler(SIGQUIT, SIG_IGN, leave); #if YASH_ENABLE_LINEEDIT && defined(SIGWINCH) reset_special_handler(SIGWINCH, sig_handler, leave); #endif } if (main_handler_set) { sigset_t ss = original_sigmask; if (leave) { main_handler_set = false; reset_special_handler(SIGCHLD, sig_handler, leave); } else { sigaddset(&ss, SIGCHLD); } sigprocmask(SIG_SETMASK, &ss, NULL); } } /* Re-sets the signal handler for SIGTSTP according to the current * `doing_job_control_now' and `job_handler_set'. */ void reset_job_signals(void) { if (doing_job_control_now && !job_handler_set) { job_handler_set = true; set_special_handler(SIGTSTP, SIG_IGN); } else if (!doing_job_control_now && job_handler_set) { job_handler_set = false; reset_special_handler(SIGTSTP, SIG_IGN, false); } } /* Sets the signal handler of signal `signum' to function `handler', which must * be either SIG_IGN or `sig_handler'. * If the old handler is SIG_IGN, `signum' is added to `ignored_signals'. * If `handler' is SIG_IGN and the trap for the signal is set, the signal * handler is not changed. */ /* Note that this function does not block or unblock the specified signal. */ void set_special_handler(int signum, void (*handler)(int signum)) { const wchar_t *trap = trap_command[sigindex(signum)]; if (trap != NULL && trap[0] != L'\0') return; /* The signal handler has already been set. */ struct sigaction action, oldaction; action.sa_flags = 0; action.sa_handler = handler; sigemptyset(&action.sa_mask); sigemptyset(&oldaction.sa_mask); if (sigaction(signum, &action, &oldaction) >= 0) if (oldaction.sa_handler == SIG_IGN) sigaddset(&ignored_signals, signum); } /* Resets the signal handler for signal `signum' to what external commands * should inherit from the shell. The handler that have been passed to * `set_special_handler' must be passed as `handler'. If `leave' is true, the * current process is assumed to be about to exec: the handler may be left * unchanged if the handler is supposed to be reset during exec. */ void reset_special_handler(int signum, void (*handler)(int signum), bool leave) { struct sigaction action; if (sigismember(&ignored_signals, signum)) action.sa_handler = SIG_IGN; else if (sigismember(&trapped_signals, signum)) return; else action.sa_handler = SIG_DFL; if (leave && handler != SIG_IGN) handler = SIG_DFL; if (handler != action.sa_handler) { action.sa_flags = 0; sigemptyset(&action.sa_mask); sigaction(signum, &action, NULL); } } /* Unblocks SIGINT so that system calls can be interrupted. * First, this function must be called with the argument of true and this * function unblocks SIGINT. Later, this function must be called with the * argument of false and SIGINT is re-blocked. * This function is effective only if the shell is interactive. */ void set_interruptible_by_sigint(bool onoff) { if (interactive_handlers_set) { sigset_t ss; sigemptyset(&ss); sigaddset(&ss, SIGINT); sigprocmask(onoff ? SIG_UNBLOCK : SIG_BLOCK, &ss, NULL); } } /* Sets the signal handler for SIGQUIT and SIGINT to SIG_IGN * to prevent an asynchronous job from being killed by these signals. */ void ignore_sigquit_and_sigint(void) { struct sigaction action; if (!interactive_handlers_set) { sigemptyset(&action.sa_mask); action.sa_flags = 0; action.sa_handler = SIG_IGN; sigaction(SIGQUIT, &action, NULL); sigaction(SIGINT, &action, NULL); } /* Don't set the handers if interactive because they are reset when `restore_signals' is called later. */ sigaddset(&ignored_signals, SIGQUIT); sigaddset(&ignored_signals, SIGINT); } /* Sets the action of SIGTSTP to ignoring the signal * to prevent a command substitution process from being stopped by SIGTSTP. * `doing_job_control_now' must be true. */ void ignore_sigtstp(void) { assert(doing_job_control_now); /* Don't set the hander now because it is reset when `restore_signals' is * called later. struct sigaction action; sigemptyset(&action.sa_mask); action.sa_flags = 0; action.sa_handler = SIG_IGN; sigaction(SIGTSTP, &action, NULL); */ sigaddset(&ignored_signals, SIGTSTP); } /* Sends SIGSTOP to the shell process (and the processes in the same process * group). * On error, an error message is printed to the standard error. */ void stop_myself(void) { if (kill(0, SIGSTOP) < 0) xerror(errno, Ngt("cannot send SIGSTOP signal")); } /* the general signal handler */ void sig_handler(int signum) { any_signal_received = true; #if defined SIGRTMIN && defined SIGRTMAX int sigrtmin = SIGRTMIN; if (sigrtmin <= signum && signum <= SIGRTMAX) { size_t index = signum - sigrtmin; if (index < RTSIZE) rtsignal_received[index] = true; } else #endif { signal_received[sigindex(signum)] = true; switch (signum) { case SIGCHLD: sigchld_received = true; break; case SIGINT: sigint_received = true; break; #if YASH_ENABLE_LINEEDIT && defined(SIGWINCH) case SIGWINCH: sigwinch_received = true; break; #endif } } } /* Accepts currently pending signals and calls `handle_sigchld' and * `handle_traps'. */ void handle_signals(void) { sigset_t ss = accept_sigmask, savess; sigdelset(&ss, SIGCHLD); if (interactive_handlers_set) sigdelset(&ss, SIGINT); sigemptyset(&savess); sigprocmask(SIG_SETMASK, &ss, &savess); sigprocmask(SIG_SETMASK, &savess, NULL); handle_sigchld(); handle_traps(); } /* Waits for SIGCHLD to be caught and call `handle_sigchld'. * If SIGCHLD is already caught, this function doesn't wait. * If `interruptible' is true, this function can be canceled by SIGINT. * If `return_on_trap' is true, this function returns immediately after a trap * is handled. Otherwise, traps are not handled. * Returns the signal number if interrupted or zero if successful. */ int wait_for_sigchld(bool interruptible, bool return_on_trap) { int result = 0; sigset_t ss = accept_sigmask; sigdelset(&ss, SIGCHLD); if (interruptible) sigdelset(&ss, SIGINT); for (;;) { if (return_on_trap && ((result = handle_traps()) != 0)) break; if (interruptible && sigint_received) break; if (sigchld_received) break; if (sigsuspend(&ss) < 0) { if (errno != EINTR) { xerror(errno, "sigsuspend"); break; } } } if (interruptible && sigint_received) result = SIGINT; handle_sigchld(); return result; } /* Waits for the specified file descriptor to be available for reading. * `handle_sigchld' and `handle_sigwinch' are called to handle SIGCHLD and * SIGWINCH that are caught while waiting. * If `trap' is true, traps are also handled while waiting and the * `sigint_received' flag is cleared when this function returns. * The maximum time length of wait is specified by `timeout' in milliseconds. * If `timeout' is negative, the wait time is unlimited. * If the wait is interrupted by a signal, this function will re-wait for the * specified timeout, which means that this function may wait for a time length * longer than the specified timeout. * This function returns true if the input is ready or false if an error * occurred or it timed out. */ bool wait_for_input(int fd, bool trap, int timeout) { sigset_t ss; struct timespec to; struct timespec *top; assert(fd >= 0); if (fd >= FD_SETSIZE) { xerror(0, Ngt("too many files are opened for yash to handle")); return false; } ss = accept_sigmask; sigdelset(&ss, SIGCHLD); if (interactive_handlers_set) { sigdelset(&ss, SIGINT); #if YASH_ENABLE_LINEEDIT && defined SIGWINCH sigdelset(&ss, SIGWINCH); #endif } if (timeout < 0) { top = NULL; } else { to.tv_sec = timeout / 1000; to.tv_nsec = timeout % 1000 * 1000000; top = &to; } for (;;) { handle_sigchld(); if (trap) handle_traps(); #if YASH_ENABLE_LINEEDIT && defined SIGWINCH handle_sigwinch(); #endif fd_set fdset; FD_ZERO(&fdset); FD_SET(fd, &fdset); if (pselect(fd + 1, &fdset, NULL, NULL, top, &ss) >= 0) { if (trap) sigint_received = false; return FD_ISSET(fd, &fdset); } else { if (errno != EINTR) { xerror(errno, "pselect"); return false; } } } } /* Handles SIGCHLD if caught. */ void handle_sigchld(void) { static bool print_status = false; if (sigchld_received) { sigchld_received = false; do_wait(); print_status = true; } if (print_status) { /* print job status if the notify option is set */ #if YASH_ENABLE_LINEEDIT if (le_state & LE_STATE_ACTIVE) { if (!(le_state & LE_STATE_COMPLETING)) { if (shopt_notify || shopt_notifyle) { le_suspend_readline(); print_status = false; print_job_status_all(); le_resume_readline(); } } } else #endif if (shopt_notify) { sigset_t ss, savess; sigemptyset(&ss); sigaddset(&ss, SIGTTOU); sigemptyset(&savess); sigprocmask(SIG_BLOCK, &ss, &savess); print_status = false; print_job_status_all(); sigprocmask(SIG_SETMASK, &savess, NULL); } } } /* Executes the trap handlers for trapped signals if any. * There must not be an active job when this function is called. * Returns the signal number if any handler was executed, otherwise zero. * Note that, if more than one signal is caught, only one of their numbers is * returned. */ int handle_traps(void) { /* Signal handler execution is not reentrant because the value of * `savelaststatus' would be lost. But the EXIT is the only exception: * The EXIT trap may be executed inside another trap. */ if (!any_trap_set || !any_signal_received || handled_signal >= 0) return 0; #if YASH_ENABLE_LINEEDIT /* Don't handle traps during command line completion. Otherwise, the command * line would be messed up! */ if (le_state & LE_STATE_COMPLETING) return 0; #endif int signum = 0; bool save_sigint_received = sigint_received; struct execstate_T *execstate = NULL; savelaststatus = laststatus; sigint_received = false; do { /* we reset this before executing signal handlers to avoid race */ any_signal_received = false; for (const signal_T *s = signals; s->no != 0; s++) { size_t i = sigindex(s->no); if (signal_received[i]) { signal_received[i] = false; wchar_t *command = trap_command[i]; if (command != NULL && command[0] != L'\0') { #if YASH_ENABLE_LINEEDIT le_suspend_readline(); #endif if (execstate == NULL) execstate = save_execstate(); signum = handled_signal = s->no; command = xwcsdup(command); exec_wcs(command, "trap", false); free(command); laststatus = savelaststatus; } } } #if defined SIGRTMIN && defined SIGRTMAX int sigrtmin = SIGRTMIN, range = SIGRTMAX - sigrtmin + 1; if (range > RTSIZE) range = RTSIZE; for (int i = 0; i < range; i++) { if (rtsignal_received[i]) { rtsignal_received[i] = false; wchar_t *command = rttrap_command[i]; if (command != NULL && command[0] != L'\0') { #if YASH_ENABLE_LINEEDIT le_suspend_readline(); #endif if (execstate == NULL) execstate = save_execstate(); signum = handled_signal = sigrtmin + i; command = xwcsdup(command); exec_wcs(command, "trap", false); free(command); laststatus = savelaststatus; } } } #endif /* defined SIGRTMAX && defined SIGRTMIN */ } while (any_signal_received); sigint_received |= save_sigint_received; savelaststatus = -1; handled_signal = -1; if (execstate != NULL) restore_execstate(execstate); #if YASH_ENABLE_LINEEDIT if (shopt_notifyle && (le_state & LE_STATE_SUSPENDED)) print_job_status_all(); le_resume_readline(); #endif return signum; } /* Executes the EXIT trap if any. * This function calls `reset_execstate' without saving `execstate'. */ void execute_exit_trap(void) { wchar_t *command = trap_command[sigindex(0)]; if (command != NULL) { #ifndef NDEBUG static bool exit_handled = false; assert(!exit_handled); exit_handled = true; #endif savelaststatus = laststatus; command = xwcsdup(command); reset_execstate(); exec_wcs(command, "EXIT trap", false); free(command); savelaststatus = -1; } } /* Sets trap for the signal `signum' to `command'. * If `command' is NULL, the trap is reset to the default. * If `command' is an empty string, the trap is set to SIG_IGN. * This function may call `get_signal_name'. * An error message is printed to the standard error on error. */ void set_trap(int signum, const wchar_t *command) { if (signum == SIGKILL || signum == SIGSTOP) { xerror(0, Ngt("SIG%ls cannot be trapped"), signum == SIGKILL ? L"KILL" : L"STOP"); return; } wchar_t **commandp; volatile sig_atomic_t *receivedp; #if defined SIGRTMIN && defined SIGRTMAX int sigrtmin = SIGRTMIN; if (sigrtmin <= signum && signum <= SIGRTMAX) { size_t index = signum - sigrtmin; if (index < RTSIZE) { commandp = &rttrap_command[index]; receivedp = &rtsignal_received[index]; } else { xerror(0, Ngt("real-time signal SIG%ls is not supported"), get_signal_name(signum)); return; } } else #endif { size_t index = sigindex(signum); commandp = &trap_command[index]; receivedp = &signal_received[index]; } if (!is_interactive && *commandp == NULL && is_ignored(signum)) { /* Signals that were ignored on entry to a non-interactive shell cannot * be trapped or reset. (POSIX) */ #if FIXED_SIGNAL_AS_ERROR xerror(0, Ngt("SIG%ls cannot be reset"), get_signal_name(signum)); #endif return; } free(*commandp); if (command != NULL) { if (command[0] != L'\0') any_trap_set = true; *commandp = xwcsdup(command); } else { *commandp = NULL; } *receivedp = false; if (signum == 0) return; struct sigaction action; if (command == NULL) action.sa_handler = SIG_DFL; else if (command[0] == L'\0') action.sa_handler = SIG_IGN; else action.sa_handler = sig_handler; if (action.sa_handler == SIG_IGN) { sigaddset(&ignored_signals, signum); } else { sigdelset(&ignored_signals, signum); } if (action.sa_handler == sig_handler) { sigdelset(&original_sigmask, signum); sigaddset(&trapped_signals, signum); sigdelset(&accept_sigmask, signum); } else { sigdelset(&trapped_signals, signum); } switch (signum) { case SIGCHLD: /* SIGCHLD's signal handler is always `sig_handler' */ return; case SIGINT: #if YASH_ENABLE_LINEEDIT && defined SIGWINCH case SIGWINCH: #endif /* SIGINT and SIGWINCH's signal handler is always `sig_handler' * when interactive */ if (interactive_handlers_set) return; break; case SIGTSTP: if (job_handler_set) goto default_ignore; break; case SIGTERM: case SIGQUIT: if (interactive_handlers_set) goto default_ignore; break; default_ignore: if (action.sa_handler == SIG_DFL) action.sa_handler = SIG_IGN; break; } if (action.sa_handler == sig_handler) sigprocmask(SIG_BLOCK, &trapped_signals, NULL); sigemptyset(&action.sa_mask); action.sa_flags = 0; if (sigaction(signum, &action, NULL) < 0) { int saveerrno = errno; xerror(saveerrno, "sigaction(SIG%ls)", get_signal_name(signum)); } } /* Checks if the specified signal is ignored. * Asserts the shell is not interactive. */ bool is_ignored(int signum) { assert(!is_interactive_now); if (signum == 0) return false; if (doing_job_control_now && signum == SIGTSTP) return sigismember(&ignored_signals, signum); struct sigaction action; sigemptyset(&action.sa_mask); return sigaction(signum, NULL, &action) >= 0 && action.sa_handler == SIG_IGN; } /* Clears the EXIT trap. */ void clear_exit_trap(void) { set_trap(0, NULL); } /* Clears all traps except that are set to SIG_IGN. */ void clear_traps(void) { if (!any_trap_set && !any_signal_received) return; { size_t index = sigindex(0); wchar_t *command = trap_command[index]; if (command != NULL && command[0] != L'\0') set_trap(0, NULL); signal_received[index] = false; } for (const signal_T *s = signals; s->no != 0; s++) { size_t index = sigindex(s->no); wchar_t *command = trap_command[index]; if (command != NULL && command[0] != L'\0') set_trap(s->no, NULL); signal_received[index] = false; } #if defined SIGRTMIN && defined SIGRTMAX for (int sigrtmin = SIGRTMIN, i = 0; i < RTSIZE; i++) { wchar_t *command = rttrap_command[i]; if (command != NULL && command[0] != L'\0') set_trap(sigrtmin + i, NULL); rtsignal_received[i] = false; } #endif any_trap_set = false, any_signal_received = false; } /* Tests the `sigint_received' flag. Returns true only if interactive. */ bool is_interrupted(void) { return is_interactive_now && sigint_received; } /* Sets `laststatus' to (SIGINT + TERMSIGOFFSET) if the shell has been * interrupted. */ void set_laststatus_if_interrupted(void) { if (is_interrupted()) laststatus = SIGINT + TERMSIGOFFSET; } /* Sets the `sigint_received' flag. */ void set_interrupted(void) { sigint_received = true; } /* Resets the `sigint_received' flag. */ /* This function should be called just after calling `handle_signals'. */ void reset_sigint(void) { sigint_received = false; } #if YASH_ENABLE_LINEEDIT #ifdef SIGWINCH /* If SIGWINCH has been caught and line-editing is currently active, cause * line-editing to redraw the display. */ void handle_sigwinch(void) { if (sigwinch_received) le_display_size_changed(); } #endif /* defined SIGWINCH */ /* Resets the `sigwinch_received' flag. */ void reset_sigwinch(void) { #ifdef SIGWINCH sigwinch_received = false; #endif } /* Generates completion candidates for signal names matching the pattern. */ /* The prototype of this function is declared in "lineedit/complete.h". */ void generate_signal_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_SIGNAL)) return; le_compdebug("adding signal name candidates"); if (!le_compile_cpatterns(compopt)) return; bool prefix = matchwcsprefix(compopt->src, L"SIG"); xwcsbuf_T buf; wb_init(&buf); for (const signal_T *s = signals; s->no != 0; s++) { if (prefix) wb_cat(&buf, L"SIG"); wb_cat(&buf, s->name); sig_new_candidate(compopt, s->no, &buf); } #if defined SIGRTMIN && defined SIGRTMAX int sigrtmin = SIGRTMIN, sigrtmax = SIGRTMAX; for (int s = sigrtmin; s <= sigrtmax; s++) { if (prefix) wb_cat(&buf, L"SIG"); wb_cat(&buf, L"RTMIN"); if (s != sigrtmin) wb_wprintf(&buf, L"+%d", s - sigrtmin); sig_new_candidate(compopt, s, &buf); if (prefix) wb_cat(&buf, L"SIG"); wb_cat(&buf, L"RTMAX"); if (s != sigrtmax) wb_wprintf(&buf, L"-%d", sigrtmax - s); sig_new_candidate(compopt, s, &buf); } #endif wb_destroy(&buf); } /* If the pattern in `compopt' matches the specified signal name, adds a new * completion candidate with the name and the description for the signal. */ void sig_new_candidate( const le_compopt_T *restrict compopt, int num, xwcsbuf_T *restrict name) { if (le_wmatch_comppatterns(compopt, name->contents)) { xwcsbuf_T desc; wb_init(&desc); #if HAVE_STRSIGNAL char *mbsdesc = strsignal(num); if (mbsdesc != NULL) wb_wprintf(&desc, L"%d: %s", num, mbsdesc); else #endif wb_wprintf(&desc, L"%d", num); le_new_candidate(CT_SIG, wb_towcs(name), wb_towcs(&desc), compopt); wb_init(name); } else { wb_clear(name); } } #endif /* YASH_ENABLE_LINEEDIT */ /********** Built-in **********/ static bool print_trap(const wchar_t *signame, const wchar_t *command) __attribute__((nonnull(1))); static bool print_signal(int signum, const wchar_t *name, bool verbose) __attribute__((nonnull)); static void signal_job(int signum, const wchar_t *jobname) __attribute__((nonnull)); /* Options for the "trap" built-in. */ const struct xgetopt_T trap_options[] = { { L'p', L"print", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "trap" built-in. */ int trap_builtin(int argc, void **argv) { bool print = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, trap_options, 0)) != NULL) { switch (opt->shortopt) { case L'p': print = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (xoptind == argc) { /* print all traps */ sigset_t printed; sigemptyset(&printed); if (!print_trap(L"EXIT", trap_command[sigindex(0)])) return Exit_FAILURE; for (const signal_T *s = signals; s->no != 0; s++) { if (!sigismember(&printed, s->no)) { sigaddset(&printed, s->no); if (!print_trap(s->name, trap_command[sigindex(s->no)])) return Exit_FAILURE; } } #if defined SIGRTMIN && defined SIGRTMAX int sigrtmin = SIGRTMIN, sigrtmax = SIGRTMAX; for (int i = 0; i < RTSIZE; i++) { if (sigrtmin + i > sigrtmax) break; if (!print_trap(get_signal_name(sigrtmin + i), rttrap_command[i])) return Exit_FAILURE; } #endif } else if (print) { /* print specified traps */ #if defined SIGRTMIN && defined SIGRTMAX int sigrtmin = SIGRTMIN, sigrtmax = SIGRTMAX; #endif do { wchar_t *name = ARGV(xoptind); int signum = get_signal_number_toupper(name); if (signum < 0) { xerror(0, Ngt("no such signal `%ls'"), name); continue; } #if defined SIGRTMIN && defined SIGRTMAX if (sigrtmin <= signum && signum <= sigrtmax) { int index = signum - sigrtmin; if (index < RTSIZE) if (!print_trap(name, rttrap_command[index])) return Exit_FAILURE; } else #endif { if (!print_trap(name, trap_command[sigindex(signum)])) return Exit_FAILURE; } } while (++xoptind < argc); } else { const wchar_t *command; /* check if the first operand is an integer */ wchar_t *end; errno = 0; if (iswdigit(ARGV(xoptind)[0]) && (wcstoul(ARGV(xoptind), &end, 10), *end == L'\0')) { command = NULL; } else { command = ARGV(xoptind++); if (xoptind == argc) return special_builtin_syntax_error( insufficient_operands_error(2)); if (wcscmp(command, L"-") == 0) command = NULL; } /* set traps */ do { wchar_t *name = ARGV(xoptind); int signum = get_signal_number_toupper(name); if (signum < 0) { xerror(0, Ngt("no such signal `%ls'"), name); continue; } set_trap(signum, command); } while (++xoptind < argc); } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Prints trap to the standard output in a format that can be used to restore * the current signal handler for the specified signal. * If the `command' is NULL, this function does nothing. * Otherwise, the `command' is properly single-quoted and printed. * Returns true iff successful (no error). On error, an error message is printed * to the standard error. */ bool print_trap(const wchar_t *signame, const wchar_t *command) { if (command == NULL) return true; wchar_t *q = quote_sq(command); bool ok = xprintf("trap -- %ls %ls\n", q, signame); free(q); return ok; } #if YASH_ENABLE_HELP const char trap_help[] = Ngt( "set or print signal handlers" ); const char trap_syntax[] = Ngt( "\ttrap [action signal...]\n" "\ttrap signal_number [signal...]\n" "\ttrap -p [signal...]\n" ); #endif /* The "kill" built-in, which accepts the following options: * -s sig: specifies the signal to send * -n num: specifies the signal to send by number * -l: prints signal info * -v: prints signal info verbosely */ int kill_builtin(int argc, void **argv) { int signum = SIGTERM; bool list = false, verbose = false; /* We don't use the xgetopt function to parse options because the kill * built-in has non-standard syntax. */ int optind; for (optind = 1; optind < argc; optind++) { wchar_t *arg = ARGV(optind); if (arg[0] != L'-' || arg[1] == L'\0') break; for (size_t i = 1; arg[i] != L'\0'; i++) { switch (arg[i]) { case L'n': case L's': /* we don't make any differences between -n and -s options */ if (list) return mutually_exclusive_option_error(arg[i], L'l'); arg = &arg[i + 1]; if (arg[0] == L'\0') { arg = ARGV(++optind); if (arg == NULL) { xerror(0, Ngt("the signal name is not specified")); return Exit_ERROR; } } parse_signal_name: if (posixly_correct && matchwcsprefix(arg, L"SIG")) { xerror(0, Ngt("%ls: the signal name must be specified " "without `SIG'"), arg); return Exit_ERROR; } signum = get_signal_number_toupper(arg); if (signum < 0 || (signum == 0 && !iswdigit(arg[0]))) { xerror(0, Ngt("no such signal `%ls'"), arg); return Exit_FAILURE; } optind++; if (optind < argc && wcscmp(ARGV(optind), L"--") == 0) optind++; goto main; case L'l': list = true; break; case L'v': list = verbose = true; break; case L'-': if (i == 1) { if (arg[2] == L'\0') { /* `arg' is "--" */ optind++; goto main; } #if YASH_ENABLE_HELP if (!posixly_correct && matchwcsprefix(L"--help", arg)) return print_builtin_help(ARGV(0)); #endif } /* falls thru! */ default: if (i == 1 && !list) { arg = &arg[i]; goto parse_signal_name; } else { xerror(0, Ngt("`%ls' is not a valid option"), arg); return Exit_ERROR; } } } } main: if (list) { if (optind == argc) { /* print info of all signals */ for (const signal_T *s = signals; s->no != 0; s++) if (!print_signal(s->no, s->name, verbose)) return Exit_FAILURE; #if defined SIGRTMIN && defined SIGRTMAX for (int i = SIGRTMIN, max = SIGRTMAX; i <= max; i++) if (!print_signal(i, get_signal_name(i), verbose)) return Exit_FAILURE; #endif } else { /* print info of the specified signals */ do { int signum; const wchar_t *signame; if (xwcstoi(ARGV(optind), 10, &signum) && signum >= 0) { if (signum >= TERMSIGOFFSET) signum -= TERMSIGOFFSET; else if (signum >= (TERMSIGOFFSET & 0xFF)) signum -= (TERMSIGOFFSET & 0xFF); } else { signum = get_signal_number_toupper(ARGV(optind)); } signame = get_signal_name(signum); if (signum <= 0 || signame[0] == L'\0') { xerror(0, Ngt("no such signal `%ls'"), ARGV(optind)); continue; } if (!print_signal(signum, signame, verbose)) return Exit_FAILURE; } while (++optind < argc); } } else { /* send signal */ if (optind == argc) return insufficient_operands_error(1); do { wchar_t *proc = ARGV(optind); if (proc[0] == L'%') { signal_job(signum, proc); } else { long pid; if (!xwcstol(proc, 10, &pid)) { xerror(0, Ngt("`%ls' is not a valid integer"), proc); continue; } // XXX this cast might not be safe if (kill((pid_t) pid, signum) < 0) { xerror(errno, "%ls", proc); continue; } } } while (++optind < argc); } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Prints info about the specified signal. * `signum' must be a valid signal number and `name' must be the name of the * signal. * Returns false iff an IO error occurred. */ bool print_signal(int signum, const wchar_t *name, bool verbose) { if (!verbose) { return xprintf("%ls\n", name); } else { #if HAVE_STRSIGNAL const char *sigdesc = strsignal(signum); if (sigdesc != NULL) return xprintf("%d\t%-10ls %s\n", signum, name, sigdesc); else #endif return xprintf("%d\t%-10ls\n", signum, name); } } /* Sends the specified signal to the specified job. * Returns true iff successful. On error, an error message is printed to the * standard error. */ void signal_job(int signum, const wchar_t *jobspec) { pid_t jobpgid = get_job_pgid(jobspec); if (jobpgid <= 0) return; if (kill(-jobpgid, signum) < 0) xerror(errno, "%ls", jobspec); } #if YASH_ENABLE_HELP const char kill_help[] = Ngt( "send a signal to processes" ); const char kill_syntax[] = Ngt( "\tkill [-signal|-s signal|-n number] process...\n" "\tkill -l [-v] [number...]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/strbuf.d0000644000175000017500000000006512154557026014221 0ustar magicantmagicantstrbuf.o: strbuf.c common.h config.h strbuf.h util.h yash-2.35/common.h0000644000175000017500000000300312154557026014203 0ustar magicantmagicant/* Yash: yet another shell */ /* common.h: defines symbols common to all sources. */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* This file should be included at the very first in every source file. */ #ifndef YASH_COMMON_H #define YASH_COMMON_H #include "config.h" #ifndef __GNUC__ # define __attribute__(ignore) #endif #ifdef __CYGWIN__ # undef __STRICT_ANSI__ # define FD_SETSIZE 256 #endif #if HAVE_GETTEXT # define gt(MSGID) ((const char *) gettext(MSGID)) # define Ngt(MSGID) MSGID #else # define gt(MSGID) MSGID # define Ngt(MSGID) MSGID #endif #if HAVE_NGETTEXT # define ngt(MSGS,MSGP,N) ((const char *) ngettext(MSGS, MSGP, N)) #else # define ngt(MSGS,MSGP,N) gt((N) == 1 ? (MSGS) : (MSGP)) #endif #ifdef NDEBUG # define INIT(x) x #else # define INIT(x) x = x #endif #define ARGV(i) ((wchar_t *) argv[i]) #endif /* YASH_COMMON_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/makedeps.yash0000644000175000017500000000334312154557026015230 0ustar magicantmagicant# This script updates *.d files. # (C) 2007-2010 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . if [ -z "${YASH_VERSION-}" ] then printf '%s: This script must be executed by yash.\n' "$0" >&2 exit 126 fi check () { if ! [ -f "$1.d" ] || ! [ -s "$1.d" ] || [ "$1.c" -nt "$1.d" ] then return 1 fi for dep in $(sed -e '1s/^.*://' -e 's/\\$//' "$1.d") do if ! [ -f "$dep" ] then printf '%s: "%s" depends on non-existent file "%s".\n' \ "$0" "$1.d" "$dep" >&2 exit 1 fi if [ "$dep" -nt "$1.d" ] then return 1 fi done return 0 } for file do case $file in (*.c) if ! [ -f "$file" ] then printf '%s: "%s" is not a regular file.\n' "$0" "$file" >&2 exit 1 fi file=${file%.c} if ! check "$file" then printf 'gcc -std=c99 -MM "%s.c" >|"%s.d"\n' "$file" "$file" if ! gcc -std=c99 -MM "${file}.c" >|"${file}.d" then exitstatus=$? printf '%s: cannot update "%s".\n' "$0" "${file}.d" >&2 exit "$exitstatus" fi fi ;; (*) printf '%s: "%s" is not a C source file.\n' "$0" "$file" >&2 exit 1 ;; esac done # vim: set ft=sh ts=8 sts=4 sw=4 noet tw=80: yash-2.35/exec.c0000644000175000017500000020143212154557026013640 0ustar magicantmagicant/* Yash: yet another shell */ /* exec.c: command execution */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "exec.h" #include #include #include #if HAVE_GETTEXT # include #endif #include #include #if HAVE_PATHS_H # include #endif #include #include #include #include #include #include #include #include #include #if YASH_ENABLE_ALIAS # include "alias.h" #endif #include "builtin.h" #include "expand.h" #if YASH_ENABLE_HISTORY # include "history.h" #endif #include "input.h" #include "job.h" #include "option.h" #include "parser.h" #include "path.h" #include "plist.h" #include "redir.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" #include "xfnmatch.h" #include "yash.h" #if YASH_ENABLE_LINEEDIT # include "lineedit/complete.h" # include "lineedit/lineedit.h" #endif /* type of command execution */ typedef enum { E_NORMAL, /* normal execution */ E_ASYNC, /* asynchronous execution */ E_SELF, /* execution in the shell's own process */ } exec_T; /* info about file descriptors of pipes */ typedef struct pipeinfo_T { int pi_fromprevfd; /* reading end of the pipe from the previous process */ int pi_tonextfds[2]; /* both ends of the pipe to the next process */ /* -1 is assigned to unused members. */ } pipeinfo_T; #define PIPEINFO_INIT { -1, { -1, -1 }, } /* values used to specify the behavior of command search. */ typedef enum srchcmdtype_T { SCT_EXTERNAL = 1 << 0, /* search for an external command */ SCT_BUILTIN = 1 << 1, /* search for a built-in */ SCT_FUNCTION = 1 << 2, /* search for a function */ SCT_ALL = 1 << 3, /* search all */ SCT_STDPATH = 1 << 4, /* search the standard PATH */ SCT_CHECK = 1 << 5, /* check command existence */ } srchcmdtype_T; typedef enum cmdtype_T { CT_NONE, CT_EXTERNALPROGRAM, CT_SPECIALBUILTIN, CT_SEMISPECIALBUILTIN, CT_REGULARBUILTIN, CT_FUNCTION, } cmdtype_T; /* info about a simple command to execute */ typedef struct commandinfo_T { cmdtype_T type; /* type of command */ union { const char *path; /* command path (for external program) */ main_T *builtin; /* body of built-in */ command_T *function; /* body of function */ } value; } commandinfo_T; #define ci_path value.path #define ci_builtin value.builtin #define ci_function value.function typedef enum exception_T { E_NONE, E_CONTINUE, E_RETURN, E_BREAK_ITERATION, E_CONTINUE_ITERATION, } exception_T; /* state of currently executed loop */ typedef struct execstate_T { unsigned loopnest; /* level of nested loops */ unsigned breakloopnest; /* target of break/continue */ exception_T exception; /* exceptional jump to be done */ bool noreturn; /* true when the "return" built-in is not allowed */ bool iterating; /* true when iterative execution is ongoing */ } execstate_T; static void exec_pipelines(const pipeline_T *p, bool finally_exit); static void exec_pipelines_async(const pipeline_T *p) __attribute__((nonnull)); static void exec_if(const command_T *c, bool finally_exit) __attribute__((nonnull)); static inline bool exec_condition(const and_or_T *c); static void exec_for(const command_T *c, bool finally_exit) __attribute__((nonnull)); static void exec_while(const command_T *c, bool finally_exit) __attribute__((nonnull)); static void exec_case(const command_T *c, bool finally_exit) __attribute__((nonnull)); static void exec_funcdef(const command_T *c, bool finally_exit) __attribute__((nonnull)); static void exec_commands(command_T *c, exec_T type); static inline bool should_exit(const command_T *c) __attribute__((nonnull)); static inline void next_pipe(pipeinfo_T *pi, bool next) __attribute__((nonnull)); static pid_t exec_process( command_T *restrict c, exec_T type, pipeinfo_T *restrict pi, pid_t pgid) __attribute__((nonnull)); static inline void connect_pipes(pipeinfo_T *pi) __attribute__((nonnull)); static void search_command( const char *restrict name, const wchar_t *restrict wname, commandinfo_T *restrict ci, enum srchcmdtype_T type) __attribute__((nonnull)); static inline bool is_special_builtin(const char *cmdname) __attribute__((nonnull,pure)); static inline bool assignment_is_temporary(enum cmdtype_T type) __attribute__((const)); static bool command_not_found_handler(void *const *argv) __attribute__((nonnull)); static void exec_nonsimple_command(command_T *c, bool finally_exit) __attribute__((nonnull)); static void exec_simple_command(const commandinfo_T *ci, int argc, char *argv0, void **argv, bool finally_exit) __attribute__((nonnull)); static void exec_external_program( const char *path, int argc, char *argv0, void **argv, char **envs) __attribute__((nonnull)); static void print_xtrace(void *const *argv); static void exec_fall_back_on_sh( int argc, char *const *argv, char *const *env, const char *path) __attribute__((nonnull(2,3,4))); static void exec_function_body( command_T *body, void *const *args, bool finally_exit, bool complete) __attribute__((nonnull)); static inline int xexecve( const char *path, char *const *argv, char *const *envp) __attribute__((nonnull(1))); static int exec_iteration(void *const *commands, const char *codename) __attribute__((nonnull)); /* exit status of the last command */ int laststatus = Exit_SUCCESS; /* exit status of the command preceding the currently executed trap action */ int savelaststatus = -1; // -1 if not in a trap handler /* exit status of the last command substitution */ static int lastcmdsubstatus; /* the process ID of the last asynchronous list */ pid_t lastasyncpid; /* This flag is set to true while the shell is executing the condition of an if- * statement, an and-or list, etc. to suppress the effect of the "errexit" * option. */ static bool suppresserrexit = false; /* state of currently executed loop */ static execstate_T execstate; /* Note that `execstate' is not reset when a subshell forks. */ /* This flag is set when a special built-in is executed as such. */ bool special_builtin_executed; /* This flag is set while the "exec" built-in is executed. */ static bool exec_builtin_executed = false; /* True while executing auxiliary commands such as $PROMPT_COMMAND and * $COMMAND_NOT_FOUND_HANDLER. */ bool is_executing_auxiliary = false; /* the last assignment. */ static const assign_T *last_assign; /* a buffer for xtrace. */ static xwcsbuf_T xtrace_buffer = { .contents = NULL }; /* Resets `execstate' to the initial state. */ void reset_execstate(void) { execstate = (struct execstate_T) { .loopnest = 0, .breakloopnest = UINT_MAX, .exception = E_NONE, .noreturn = false, .iterating = false, }; } /* Saves the current `execstate' and returns it. * `execstate' is re-initialized. */ struct execstate_T *save_execstate(void) { struct execstate_T *save = xmalloc(sizeof execstate); *save = execstate; reset_execstate(); return save; } /* Restores `execstate' to `save' and frees `save'. */ void restore_execstate(struct execstate_T *save) { execstate = *save; free(save); } /* Disables the "return" built-in in the current `execstate'. */ void disable_return(void) { execstate.noreturn = true; } /* If we're returning, clear the flag. */ void cancel_return(void) { if (execstate.exception == E_RETURN) execstate.exception = E_NONE; } /* Returns true iff we're breaking/continuing/returning now. */ bool need_break(void) { return execstate.breakloopnest < execstate.loopnest || execstate.exception != E_NONE || is_interrupted(); } /* Executes the and-or lists. * If `finally_exit' is true, the shell exits after execution. */ void exec_and_or_lists(const and_or_T *a, bool finally_exit) { while (a != NULL && !need_break()) { if (!a->ao_async) exec_pipelines(a->ao_pipelines, finally_exit && !a->next); else exec_pipelines_async(a->ao_pipelines); a = a->next; } if (finally_exit) exit_shell(); } /* Executes the pipelines. */ void exec_pipelines(const pipeline_T *p, bool finally_exit) { for (bool first = true; p != NULL && !need_break(); p = p->next, first = false) { if (!first && p->pl_cond == (laststatus != Exit_SUCCESS)) continue; bool savesee = suppresserrexit; suppresserrexit |= p->pl_neg || p->next != NULL; bool self = finally_exit && !doing_job_control_now && !p->next && !p->pl_neg && !any_trap_set; exec_commands(p->pl_commands, self ? E_SELF : E_NORMAL); if (p->pl_neg) { if (laststatus == Exit_SUCCESS) laststatus = Exit_FAILURE; else laststatus = Exit_SUCCESS; } suppresserrexit = savesee; } if (finally_exit) exit_shell(); } /* Executes the pipelines asynchronously. */ void exec_pipelines_async(const pipeline_T *p) { if (p->next == NULL && !p->pl_neg) { exec_commands(p->pl_commands, E_ASYNC); return; } pid_t cpid = fork_and_reset(0, false, t_quitint); if (cpid > 0) { /* parent process: add a new job */ job_T *job = xmalloc(sizeof *job + sizeof *job->j_procs); process_T *ps = job->j_procs; ps->pr_pid = cpid; ps->pr_status = JS_RUNNING; ps->pr_statuscode = 0; ps->pr_name = pipelines_to_wcs(p); job->j_pgid = doing_job_control_now ? cpid : 0; job->j_status = JS_RUNNING; job->j_statuschanged = true; job->j_legacy = false; job->j_nonotify = false; job->j_pcount = 1; set_active_job(job); add_job(shopt_curasync); laststatus = Exit_SUCCESS; lastasyncpid = cpid; } else if (cpid == 0) { /* child process: execute the commands and then exit */ maybe_redirect_stdin_to_devnull(); exec_pipelines(p, true); assert(false); } else { /* fork failure */ laststatus = Exit_NOEXEC; } } /* Executes the if command */ void exec_if(const command_T *c, bool finally_exit) { assert(c->c_type == CT_IF); for (const ifcommand_T *cmds = c->c_ifcmds; cmds != NULL; cmds = cmds->next) { if (need_break()) goto done; if (exec_condition(cmds->ic_condition)) { exec_and_or_lists(cmds->ic_commands, finally_exit); assert(!finally_exit); return; } } laststatus = Exit_SUCCESS; done: if (finally_exit) exit_shell(); } /* Executes the condition of an if/while/until command. */ bool exec_condition(const and_or_T *c) { if (c == NULL) return true; bool savesee = suppresserrexit; suppresserrexit = true; exec_and_or_lists(c, false); suppresserrexit = savesee; return laststatus == Exit_SUCCESS; } /* Executes the for command. */ void exec_for(const command_T *c, bool finally_exit) { assert(c->c_type == CT_FOR); execstate.loopnest++; execstate.breakloopnest = UINT_MAX; int count; void **words; if (c->c_forwords != NULL) { /* expand the words between "in" and "do" of the for command. */ if (!expand_line(c->c_forwords, &count, &words)) { laststatus = Exit_EXPERROR; goto finish; } } else { /* no "in" keyword in the for command: use the positional parameters */ struct get_variable_T v = get_variable(L"@"); assert(v.type == GV_ARRAY && v.values != NULL); save_get_variable_values(&v); count = (int) v.count; words = v.values; } #define CHECK_LOOP \ if (execstate.breakloopnest < execstate.loopnest) { \ goto done; \ } else if (execstate.exception == E_CONTINUE) { \ execstate.exception = E_NONE; \ continue; \ } else if (execstate.exception != E_NONE) { \ goto done; \ } else if (is_interrupted()) { \ goto done; \ } else (void) 0 int i; for (i = 0; i < count; i++) { if (!set_variable(c->c_forname, words[i], posixly_correct ? SCOPE_GLOBAL : SCOPE_LOCAL, false)) goto done; exec_and_or_lists(c->c_forcmds, finally_exit && i + 1 == count); if (c->c_forcmds == NULL) handle_signals(); CHECK_LOOP; } done: while (++i < count) /* free unused words */ free(words[i]); free(words); if (count == 0 && c->c_forcmds != NULL) laststatus = Exit_SUCCESS; finish: execstate.loopnest--; if (finally_exit) exit_shell(); } /* Executes the while/until command. */ /* The exit status of a while/until command is that of `c_whlcmds' executed * last. If `c_whlcmds' is not executed at all, the status is 0 regardless of * `c_whlcond'. */ void exec_while(const command_T *c, bool finally_exit) { assert(c->c_type == CT_WHILE); execstate.loopnest++; execstate.breakloopnest = UINT_MAX; int status = Exit_SUCCESS; for (;;) { bool cond = exec_condition(c->c_whlcond); if (c->c_whlcond == NULL) handle_signals(); CHECK_LOOP; if (cond != c->c_whltype) break; if (c->c_whlcmds != NULL) { exec_and_or_lists(c->c_whlcmds, false); status = laststatus; } if (c->c_whlcmds == NULL) handle_signals(); CHECK_LOOP; } laststatus = status; done: execstate.loopnest--; if (finally_exit) exit_shell(); } #undef CHECK_LOOP /* Executes the case command. */ void exec_case(const command_T *c, bool finally_exit) { assert(c->c_type == CT_CASE); wchar_t *word = expand_single(c->c_casword, TT_SINGLE); if (word == NULL) goto fail; word = unescapefree(word); for (const caseitem_T *ci = c->c_casitems; ci != NULL; ci = ci->next) { for (void **pats = ci->ci_patterns; *pats != NULL; pats++) { wchar_t *pattern = expand_single(*pats, TT_SINGLE); if (pattern == NULL) goto fail; xfnmatch_T *xfnm = xfnm_compile( pattern, XFNM_HEADONLY | XFNM_TAILONLY); free(pattern); if (xfnm == NULL) continue; bool match = (xfnm_wmatch(xfnm, word).start != (size_t) -1); xfnm_free(xfnm); if (match) { if (ci->ci_commands != NULL) { exec_and_or_lists(ci->ci_commands, finally_exit); goto done; } else { goto success; } } } } success: laststatus = Exit_SUCCESS; done: free(word); if (finally_exit) exit_shell(); return; fail: laststatus = Exit_EXPERROR; goto done; } /* Executes the function definition. */ void exec_funcdef(const command_T *c, bool finally_exit) { assert(c->c_type == CT_FUNCDEF); wchar_t *funcname = expand_single(c->c_funcname, TT_SINGLE); if (funcname != NULL) { funcname = unescapefree(funcname); if (define_function(funcname, c->c_funcbody)) laststatus = Exit_SUCCESS; else laststatus = Exit_ASSGNERR; free(funcname); } else { laststatus = Exit_EXPERROR; } if (finally_exit) exit_shell(); } /* Executes the commands in a pipeline. */ void exec_commands(command_T *c, exec_T type) { size_t count; pid_t pgid; command_T *cc; job_T *job; process_T *ps, *pp; pipeinfo_T pinfo = PIPEINFO_INIT; /* increment the reference count of `c' to prevent `c' from being freed * during execution. */ c = comsdup(c); /* count the number of the commands */ count = 0; for (cc = c; cc != NULL; cc = cc->next) count++; assert(count > 0); job = xmallocs(sizeof *job, count, sizeof *job->j_procs); ps = job->j_procs; /* execute the commands */ pgid = 0, cc = c, pp = ps; do { pid_t pid; next_pipe(&pinfo, cc->next != NULL); pid = exec_process(cc, (type == E_SELF && cc->next != NULL) ? E_NORMAL : type, &pinfo, pgid); pp->pr_pid = pid; if (pid != 0) { pp->pr_status = JS_RUNNING; pp->pr_statuscode = 0; } else { pp->pr_status = JS_DONE; pp->pr_statuscode = laststatus; } pp->pr_name = NULL; /* name is given later */ if (pgid == 0) pgid = pid; cc = cc->next, pp++; } while (cc != NULL); assert(type != E_SELF); /* `exec_process' doesn't return for E_SELF */ assert(pinfo.pi_tonextfds[PIPE_IN] < 0); assert(pinfo.pi_tonextfds[PIPE_OUT] < 0); if (pinfo.pi_fromprevfd >= 0) xclose(pinfo.pi_fromprevfd); /* close leftover pipe */ if (pgid == 0) { /* nothing more to do if we didn't fork */ free(job); } else { job->j_pgid = doing_job_control_now ? pgid : 0; job->j_status = JS_RUNNING; job->j_statuschanged = true; job->j_legacy = false; job->j_nonotify = false; job->j_pcount = count; set_active_job(job); if (type == E_NORMAL) { wait_for_job(ACTIVE_JOBNO, doing_job_control_now, false, false); if (doing_job_control_now) put_foreground(shell_pgid); laststatus = calc_status_of_job(job); } else { assert(type == E_ASYNC); laststatus = Exit_SUCCESS; lastasyncpid = ps[count - 1].pr_pid; } if (job->j_status != JS_DONE) { for (cc = c, pp = ps; cc != NULL; cc = cc->next, pp++) pp->pr_name = command_to_wcs(cc, false); add_job(type == E_NORMAL || shopt_curasync); } else { notify_signaled_job(ACTIVE_JOBNO); remove_job(ACTIVE_JOBNO); } } handle_signals(); if (shopt_errexit && should_exit(c)) exit_shell_with_status(laststatus); comsfree(c); } /* Returns true if the shell should exit because of the `errexit' option. */ bool should_exit(const command_T *c) { if (suppresserrexit) return false; if (laststatus == Exit_SUCCESS) return false; /* If this is a multi-command pipeline, the commands are executed in * subshells. Otherwise, we need to check the type of the command. */ if (c->next == NULL) { switch (c->c_type) { case CT_SIMPLE: case CT_SUBSHELL: case CT_FUNCDEF: break; case CT_GROUP: case CT_IF: case CT_FOR: case CT_WHILE: case CT_CASE: return false; } } #if YASH_ENABLE_LINEEDIT if (le_state & LE_STATE_COMPLETING) return false; #endif return true; } /* Updates the contents of the `pipeinfo_T' to proceed to the next process * execution. `pi->pi_fromprevfd' and `pi->pi_tonextfds[PIPE_OUT]' are closed, * `pi->pi_tonextfds[PIPE_IN]' is moved to `pi->pi_fromprevfd', and, * if `next' is true, a new pipe is opened in `pi->pi_tonextfds'; otherwise, * `pi->pi_tonextfds' is assigned -1. * Returns true iff successful. */ void next_pipe(pipeinfo_T *pi, bool next) { if (pi->pi_fromprevfd >= 0) xclose(pi->pi_fromprevfd); if (pi->pi_tonextfds[PIPE_OUT] >= 0) xclose(pi->pi_tonextfds[PIPE_OUT]); pi->pi_fromprevfd = pi->pi_tonextfds[PIPE_IN]; if (next) { if (pipe(pi->pi_tonextfds) < 0) goto fail; /* The pipe's FDs must not be 0 or 1, or they may be overridden by each * other when we move the pipe to the standard input/output later. So, * if they are 0 or 1, we move them to bigger numbers. */ int origin = pi->pi_tonextfds[PIPE_IN]; int origout = pi->pi_tonextfds[PIPE_OUT]; if (origin < 2 || origout < 2) { if (origin < 2) pi->pi_tonextfds[PIPE_IN] = dup(origin); if (origout < 2) pi->pi_tonextfds[PIPE_OUT] = dup(origout); if (origin < 2) xclose(origin); if (origout < 2) xclose(origout); if (pi->pi_tonextfds[PIPE_IN] < 0) { xclose(pi->pi_tonextfds[PIPE_OUT]); goto fail; } if (pi->pi_tonextfds[PIPE_OUT] < 0) { xclose(pi->pi_tonextfds[PIPE_IN]); goto fail; } } } else { pi->pi_tonextfds[PIPE_IN] = pi->pi_tonextfds[PIPE_OUT] = -1; } return; fail: pi->pi_tonextfds[PIPE_IN] = pi->pi_tonextfds[PIPE_OUT] = -1; xerror(errno, Ngt("cannot open a pipe")); } /* Executes the command. * If job control is active, the child process's process group ID is set to * `pgid'. If `pgid' is 0, the child process's process ID is used as the process * group ID. * If the child process forked successfully, its process ID is returned. * If the command was executed without forking, `laststatus' is set to the exit * status of the command and 0 is returned. * if `type' is E_SELF, this function never returns. */ pid_t exec_process( command_T *restrict c, exec_T type, pipeinfo_T *restrict pi, pid_t pgid) { bool early_fork; /* do early fork? */ bool finally_exit; /* never return? */ int argc; void **argv = NULL; char *argv0 = NULL; pid_t cpid = 0; current_lineno = c->c_lineno; /* fork first if `type' is E_ASYNC, the command type is subshell, * or there is a pipe. */ early_fork = (type != E_SELF) && (type == E_ASYNC || c->c_type == CT_SUBSHELL || pi->pi_fromprevfd >= 0 || pi->pi_tonextfds[PIPE_OUT] >= 0); finally_exit = (type == E_SELF); if (early_fork) { sigtype_T sigtype = (type == E_ASYNC) ? t_quitint : 0; cpid = fork_and_reset(pgid, type == E_NORMAL, sigtype); if (cpid != 0) goto done; finally_exit = true; } if (c->c_type == CT_SIMPLE) { if (!expand_line(c->c_words, &argc, &argv)) { laststatus = Exit_EXPERROR; goto done; } if (is_interrupted()) { plfree(argv, free); goto done; } if (argc == 0) { argv0 = NULL; } else { argv0 = malloc_wcstombs(argv[0]); if (argv0 == NULL) argv0 = xstrdup(""); } } /* `argc' and `argv' are used only for `CT_SIMPLE'. */ lastcmdsubstatus = Exit_SUCCESS; /* connect pipes and close leftovers */ connect_pipes(pi); /* open redirections */ savefd_T *savefd; if (!open_redirections(c->c_redirs, &savefd)) { /* On redirection error, the command is not executed. */ laststatus = Exit_REDIRERR; if (posixly_correct && !is_interactive_now && c->c_type == CT_SIMPLE && argc > 0 && is_special_builtin(argv0)) finally_exit = true; goto done2; } if (type == E_ASYNC && pi->pi_fromprevfd < 0) maybe_redirect_stdin_to_devnull(); if (c->c_type != CT_SIMPLE) { exec_nonsimple_command(c, finally_exit && savefd == NULL); goto done1; } last_assign = c->c_assigns; if (argc == 0) { /* if there is no command word, just perform assignments */ if (do_assignments(c->c_assigns, false, shopt_allexport)) laststatus = lastcmdsubstatus; else laststatus = Exit_ASSGNERR; print_xtrace(NULL); goto done2; } commandinfo_T cmdinfo; bool temp; /* check if the command is a special built-in or a function and determine * whether we have to open a temporary environment. */ search_command(argv0, argv[0], &cmdinfo, SCT_BUILTIN | SCT_FUNCTION); special_builtin_executed = (cmdinfo.type == CT_SPECIALBUILTIN); temp = c->c_assigns != NULL && assignment_is_temporary(cmdinfo.type); if (temp) open_new_environment(true); /* perform the assignments */ if (!do_assignments(c->c_assigns, temp, true)) { /* On assignment error, the command is not executed. */ print_xtrace(NULL); laststatus = Exit_ASSGNERR; if (posixly_correct && !is_interactive_now && cmdinfo.type == CT_SPECIALBUILTIN) finally_exit = true; goto done3; } print_xtrace(argv); /* find command path */ if (cmdinfo.type == CT_NONE) { search_command(argv0, argv[0], &cmdinfo, SCT_EXTERNAL | SCT_BUILTIN | SCT_CHECK); if (cmdinfo.type == CT_NONE) { if (!posixly_correct && command_not_found_handler(argv)) goto done3; if (wcschr(argv[0], L'/') != NULL) { cmdinfo.type = CT_EXTERNALPROGRAM; cmdinfo.ci_path = argv0; } } } /* create a child process to execute the external command */ if (cmdinfo.type == CT_EXTERNALPROGRAM && !finally_exit) { cpid = fork_and_reset(pgid, type == E_NORMAL, t_leave); if (cpid != 0) goto done3; finally_exit = true; } /* execute! */ bool finally_exit2; switch (cmdinfo.type) { case CT_EXTERNALPROGRAM: finally_exit2 = true; break; case CT_FUNCTION: finally_exit2 = (finally_exit && /* !temp && */ savefd == NULL); break; default: finally_exit2 = false; break; } exec_simple_command(&cmdinfo, argc, argv0, argv, finally_exit2); /* Redirections are not undone after a successful "exec" command: * remove the saved data of file descriptors. */ if (exec_builtin_executed && laststatus == Exit_SUCCESS) { clear_savefd(savefd); savefd = NULL; } exec_builtin_executed = false; done3: if (temp) close_current_environment(); done2: if (c->c_type == CT_SIMPLE) plfree(argv, free), free(argv0); done1: undo_redirections(savefd); done: if (cpid < 0) { laststatus = Exit_NOEXEC; cpid = 0; } if (finally_exit) exit_shell(); return cpid; } /* Connects the pipe(s) and closes the pipes left. */ void connect_pipes(pipeinfo_T *pi) { if (pi->pi_fromprevfd >= 0) { xdup2(pi->pi_fromprevfd, STDIN_FILENO); xclose(pi->pi_fromprevfd); } if (pi->pi_tonextfds[PIPE_OUT] >= 0) { xdup2(pi->pi_tonextfds[PIPE_OUT], STDOUT_FILENO); xclose(pi->pi_tonextfds[PIPE_OUT]); } if (pi->pi_tonextfds[PIPE_IN] >= 0) xclose(pi->pi_tonextfds[PIPE_IN]); } /* Forks a subshell and does some settings. * If job control is active, the child process's process group ID is set to * `pgid'. If `pgid' is 0, the child process's process ID is used as the process * group ID.. * If `pgid' is negative or job control is inactive, the process group ID is not * changed. * If job control is active and `fg' is true, the child process becomes a * foreground process. * `sigtype' specifies the settings of signals in the child. * `sigtype' is a bitwise OR of the followings: * t_quitint: SIGQUIT & SIGINT are ignored if the parent's job control is off * t_tstp: SIGTSTP is ignored if the parent is job-controlling * t_leave: Don't clear traps and shell FDs. Restore the signal mask for * SIGCHLD. Don't reset `execstate'. This option must be used iff the * shell is going to `exec' to an external program. * Returns the return value of `fork'. */ pid_t fork_and_reset(pid_t pgid, bool fg, sigtype_T sigtype) { sigset_t savemask; if (sigtype & (t_quitint | t_tstp)) { /* block all signals to prevent the race condition */ sigset_t all; sigfillset(&all); sigemptyset(&savemask); sigprocmask(SIG_BLOCK, &all, &savemask); } pid_t cpid = fork(); if (cpid != 0) { if (cpid < 0) { /* fork failure */ xerror(errno, Ngt("cannot make a child process")); } else { /* parent process */ if (doing_job_control_now && pgid >= 0) setpgid(cpid, pgid); } if (sigtype & (t_quitint | t_tstp)) sigprocmask(SIG_SETMASK, &savemask, NULL); } else { /* child process */ bool save_doing_job_control_now = doing_job_control_now; if (save_doing_job_control_now && pgid >= 0) { setpgid(0, pgid); if (pgid == 0) pgid = getpgrp(); shell_pgid = pgid; if (fg) put_foreground(pgid); } if (sigtype & t_quitint) if (posixly_correct || !save_doing_job_control_now) ignore_sigquit_and_sigint(); if (sigtype & t_tstp) if (save_doing_job_control_now) ignore_sigtstp(); if (sigtype & t_leave) { clear_exit_trap(); } else { clear_traps(); neglect_all_jobs(); #if YASH_ENABLE_HISTORY close_history_file(); #endif reset_execstate(); } restore_signals(sigtype & t_leave); /* signal mask is restored here */ clear_shellfds(sigtype & t_leave); is_interactive_now = false; } return cpid; } /* Searches for a command. * The result is assigned to `*ci'. * `name' and `wname' must contain the same string value. * If the SCT_ALL flag is not set: * * a function whose name contains a slash cannot be found * * a regular built-in cannot be found in the POSIXly correct mode if the * SCT_EXTERNAL flag is not set either. * If the SCT_EXTERNAL flag is set, the SCT_CHECK flag is not set, and `name' * contains a slash, the external command of the given `name' is always found. */ void search_command( const char *restrict name, const wchar_t *restrict wname, commandinfo_T *restrict ci, enum srchcmdtype_T type) { bool slash = wcschr(wname, L'/') != NULL; const builtin_T *bi; if (!slash && (type & SCT_BUILTIN)) bi = get_builtin(name); else bi = NULL; if (bi != NULL && bi->type == BI_SPECIAL) { ci->type = CT_SPECIALBUILTIN; ci->ci_builtin = bi->body; return; } if ((type & SCT_FUNCTION) && (!slash || (type & SCT_ALL))) { command_T *funcbody = get_function(wname); if (funcbody != NULL) { ci->type = CT_FUNCTION; ci->ci_function = funcbody; return; } } if (bi != NULL) { if (bi->type == BI_SEMISPECIAL) { ci->type = CT_SEMISPECIALBUILTIN; ci->ci_builtin = bi->body; return; } else if (!posixly_correct) { goto regular_builtin; } } if (slash) { if (type & SCT_EXTERNAL) { if (!(type & SCT_CHECK) || is_executable_regular(name)) { ci->type = CT_EXTERNALPROGRAM; ci->ci_path = name; return; } } } else { if ((type & SCT_EXTERNAL) || (bi != NULL && (type & SCT_ALL))) { const char *cmdpath; if (type & SCT_STDPATH) cmdpath = get_command_path_default(name); else cmdpath = get_command_path(name, false); if (cmdpath != NULL) { if (bi != NULL) { regular_builtin: assert(bi->type == BI_REGULAR); ci->type = CT_REGULARBUILTIN; ci->ci_builtin = bi->body; } else { ci->type = CT_EXTERNALPROGRAM; ci->ci_path = cmdpath; } return; } } } /* command not found... */ ci->type = CT_NONE; ci->ci_path = NULL; return; } /* Returns true iff the specified command is a special built-in. */ bool is_special_builtin(const char *cmdname) { const builtin_T *bi = get_builtin(cmdname); return bi != NULL && bi->type == BI_SPECIAL; } /* Determines whether the assignments should be temporary according to `type'.*/ bool assignment_is_temporary(enum cmdtype_T type) { switch (type) { case CT_SPECIALBUILTIN: case CT_FUNCTION: return false; case CT_NONE: case CT_SEMISPECIALBUILTIN: case CT_REGULARBUILTIN: case CT_EXTERNALPROGRAM: return true; } assert(false); } /* Executes $COMMAND_NOT_FOUND_HANDLER if any. * `argv' is set to the positional parameters of the environment in which the * handler is executed. * Returns true iff the hander was executed and $HANDLED was set non-empty. */ bool command_not_found_handler(void *const *argv) { static bool handling = false; if (handling) return false; /* don't allow reentrance */ handling = true; bool handled; int result; open_new_environment(false); set_positional_parameters(argv); set_variable(L VAR_HANDLED, xwcsdup(L""), SCOPE_LOCAL, false); result = exec_variable_as_auxiliary_(VAR_COMMAND_NOT_FOUND_HANDLER); if (result >= 0) { const wchar_t *handledv = getvar(L VAR_HANDLED); handled = (handledv != NULL && handledv[0] != L'\0'); } else { handled = false; } close_current_environment(); handling = false; if (handled) { laststatus = result; return true; } else { return false; } } /* Executes the specified command whose type is not `CT_SIMPLE'. * The redirections for the command is not performed in this function. * For CT_SUBSHELL, this function must be called in an already-forked subshell. */ void exec_nonsimple_command(command_T *c, bool finally_exit) { switch (c->c_type) { case CT_SIMPLE: assert(false); case CT_SUBSHELL: case CT_GROUP: exec_and_or_lists(c->c_subcmds, finally_exit); break; case CT_IF: exec_if(c, finally_exit); break; case CT_FOR: exec_for(c, finally_exit); break; case CT_WHILE: exec_while(c, finally_exit); break; case CT_CASE: exec_case(c, finally_exit); break; case CT_FUNCDEF: exec_funcdef(c, finally_exit); break; } } /* Executes the simple command. */ /* `argv0' is the multibyte version of `argv[0]' */ void exec_simple_command( const commandinfo_T *ci, int argc, char *argv0, void **argv, bool finally_exit) { assert(plcount(argv) == (size_t) argc); switch (ci->type) { case CT_NONE: xerror(0, Ngt("no such command `%s'"), argv0); laststatus = Exit_NOTFOUND; break; case CT_EXTERNALPROGRAM: assert(finally_exit); exec_external_program(ci->ci_path, argc, argv0, argv, environ); break; case CT_SPECIALBUILTIN: case CT_SEMISPECIALBUILTIN: case CT_REGULARBUILTIN: yash_error_message_count = 0; const wchar_t *savecbn = current_builtin_name; current_builtin_name = argv[0]; laststatus = ci->ci_builtin(argc, argv); current_builtin_name = savecbn; break; case CT_FUNCTION: exec_function_body(ci->ci_function, &argv[1], finally_exit, false); break; } if (finally_exit) exit_shell(); } /* Executes the external program. * path: path to the program to be executed * argc: number of strings in `argv' * argv0: multibyte version of `argv[0]' * argv: pointer to an array of pointers to wide strings that are passed to * the program */ void exec_external_program( const char *path, int argc, char *argv0, void **argv, char **envs) { char *mbsargv[argc + 1]; mbsargv[0] = argv0; for (int i = 1; i < argc; i++) { mbsargv[i] = malloc_wcstombs(argv[i]); if (mbsargv[i] == NULL) mbsargv[i] = xstrdup(""); } mbsargv[argc] = NULL; restore_signals(true); xexecve(path, mbsargv, envs); int saveerrno = errno; if (saveerrno != ENOEXEC) { if (saveerrno == EACCES && is_directory(path)) saveerrno = EISDIR; xerror(saveerrno, strcmp(mbsargv[0], path) == 0 ? Ngt("cannot execute command `%s'") : Ngt("cannot execute command `%s' (%s)"), argv0, path); } else if (saveerrno != ENOENT) { exec_fall_back_on_sh(argc, mbsargv, envs, path); } laststatus = (saveerrno == ENOENT) ? Exit_NOTFOUND : Exit_NOEXEC; set_signals(); for (int i = 1; i < argc; i++) free(mbsargv[i]); } /* Returns a pointer to the xtrace buffer. * The buffer is initialized if not. */ xwcsbuf_T *get_xtrace_buffer(void) { if (xtrace_buffer.contents == NULL) wb_init(&xtrace_buffer); return &xtrace_buffer; } /* Prints a trace if the "xtrace" option is on. */ void print_xtrace(void *const *argv) { bool tracevars = xtrace_buffer.contents != NULL && xtrace_buffer.length > 0; if (shopt_xtrace && (!is_executing_auxiliary || shopt_traceall) && (tracevars || argv != NULL) #if YASH_ENABLE_LINEEDIT && !(le_state & LE_STATE_ACTIVE) #endif ) { bool first = true; struct promptset_T prompt = get_prompt(4); print_prompt(prompt.main); print_prompt(prompt.styler); if (tracevars) { fprintf(stderr, "%ls", xtrace_buffer.contents + 1); first = false; } if (argv != NULL) { for (void *const *a = argv; *a != NULL; a++) { if (!first) fputc(' ', stderr); fprintf(stderr, "%ls", (wchar_t *) *a); first = false; } } fputc('\n', stderr); print_prompt(PROMPT_RESET); free_prompt(prompt); } if (xtrace_buffer.contents != NULL) { wb_destroy(&xtrace_buffer); xtrace_buffer.contents = NULL; } } /* Executes the specified command as a shell script by `exec'ing a shell. * `path' is the full path to the script file. * Returns iff failed to `exec'. */ void exec_fall_back_on_sh( int argc, char *const *argv, char *const *envp, const char *path) { assert(argv[argc] == NULL); char *args[argc + 3]; size_t index = 0; args[index++] = "sh"; args[index++] = (char *) "-"; if (strcmp(path, "--") == 0) args[index++] = "./--"; else args[index++] = (char *) path; for (int i = 1; i < argc; i++) args[index++] = argv[i]; args[index] = NULL; #if HAVE_PROC_SELF_EXE xexecve("/proc/self/exe", args, envp); #elif HAVE_PROC_CURPROC_FILE xexecve("/proc/curproc/file", args, envp); #elif HAVE_PROC_OBJECT_AOUT char *objpath = malloc_printf( "/proc/%jd/object/a.out", (intmax_t) getpid()); xexecve(objpath, args, envp); free(objpath); #elif HAVE_PATHS_H && defined _PATH_BSHELL xexecve(_PATH_BSHELL, args, envp); #endif const char *shpath = get_command_path("sh", false); if (shpath != NULL) xexecve(shpath, args, envp); else errno = ENOENT; xerror(errno, Ngt("cannot invoke a new shell to execute script `%s'"), argv[0]); } /* Executes the specified command as a function. * `args' are the arguments to the function, which are wide strings cast to * (void *). * If `complete' is true, `set_completion_variables' will be called after a new * variable environment was opened before the function body is executed. */ void exec_function_body( command_T *body, void *const *args, bool finally_exit, bool complete) { bool save_noreturn = execstate.noreturn; execstate.noreturn = false; open_new_environment(false); set_positional_parameters(args); #if YASH_ENABLE_LINEEDIT if (complete) set_completion_variables(); #else (void) complete; #endif exec_commands(body, finally_exit ? E_SELF : E_NORMAL); if (execstate.exception == E_RETURN) execstate.exception = E_NONE; close_current_environment(); execstate.noreturn = save_noreturn; } /* Calls `execve' until it doesn't return EINTR. */ int xexecve(const char *path, char *const *argv, char *const *envp) { do execve(path, argv, envp); while (errno == EINTR); return -1; } /* Executes the command substitution and returns the string to substitute with. * This function blocks until the command finishes. * The return value is a newly-malloced string without a trailing newline. * NULL is returned on error. */ wchar_t *exec_command_substitution(const embedcmd_T *cmdsub) { int pipefd[2]; pid_t cpid; if (cmdsub->is_preparsed ? cmdsub->value.preparsed == NULL : cmdsub->value.unparsed[0] == L'\0') /* empty command */ return xwcsdup(L""); /* open a pipe to receive output from the command */ if (pipe(pipefd) < 0) { xerror(errno, Ngt("cannot open a pipe for the command substitution")); return NULL; } /* If the child is stopped by SIGTSTP, it can never be resumed and * the shell will be stuck. So we specify the `t_tstp' flag to prevent the * child from being stopped by SIGTSTP. */ cpid = fork_and_reset(-1, false, t_tstp); if (cpid < 0) { /* fork failure */ xclose(pipefd[PIPE_IN]); xclose(pipefd[PIPE_OUT]); lastcmdsubstatus = Exit_NOEXEC; return NULL; } else if (cpid > 0) { /* parent process */ FILE *f; xclose(pipefd[PIPE_OUT]); f = fdopen(pipefd[PIPE_IN], "r"); if (f == NULL) { xerror(errno, Ngt("cannot open a pipe for the command substitution")); xclose(pipefd[PIPE_IN]); lastcmdsubstatus = Exit_NOEXEC; return NULL; } /* read output from the command */ xwcsbuf_T buf; wint_t c; wb_init(&buf); while ((c = fgetwc(f)) != WEOF) wb_wccat(&buf, c); fclose(f); /* wait for the child to finish */ int savelaststatus = laststatus; wait_for_child(cpid, 0, false); lastcmdsubstatus = laststatus; laststatus = savelaststatus; /* trim trailing newlines and return */ size_t len = buf.length; while (len > 0 && buf.contents[len - 1] == L'\n') len--; return wb_towcs(wb_truncate(&buf, len)); } else { /* child process */ xclose(pipefd[PIPE_IN]); if (pipefd[PIPE_OUT] != STDOUT_FILENO) { /* connect the pipe */ if (xdup2(pipefd[PIPE_OUT], STDOUT_FILENO) < 0) exit(Exit_NOEXEC); xclose(pipefd[PIPE_OUT]); } if (cmdsub->is_preparsed) exec_and_or_lists(cmdsub->value.preparsed, true); else exec_wcs(cmdsub->value.unparsed, gt("command substitution"), true); assert(false); } } /* Executes commands in the given array of wide strings (iterative execution). * The strings are parsed and executed one by one. * If the iteration is interrupted by the "break -i" command, the remaining * elements are not executed. * `codename' is passed to `exec_wcs' as the command name. * Returns the exit status of the executed command (or zero if none executed). * When this function returns, `laststatus' is restored to the original value.*/ int exec_iteration(void *const *commands, const char *codename) { int savelaststatus = laststatus, commandstatus = Exit_SUCCESS; bool saveiterating = execstate.iterating; execstate.iterating = true; for (void *const *command = commands; *command != NULL; command++) { exec_wcs(*command, codename, false); commandstatus = laststatus; laststatus = savelaststatus; switch (execstate.exception) { case E_BREAK_ITERATION: execstate.exception = E_NONE; /* falls thru! */ default: goto done; case E_CONTINUE_ITERATION: execstate.exception = E_NONE; /* falls thru! */ case E_NONE: break; } if (execstate.breakloopnest < execstate.loopnest || is_interrupted()) goto done; } done: execstate.iterating = saveiterating; return commandstatus; } /* Executes the value of the specified variable. * The variable value is parsed as commands. * If the `varname' names an array, every element of the array is executed (but * if the iteration is interrupted by the "break -i" command, the remaining * elements are not executed). * `codename' is passed to `exec_wcs' as the command name. * Returns the exit status of the executed command (or zero if none executed, or * -1 if the variable is unset). * When this function returns, `laststatus' is restored to the original value.*/ int exec_variable_as_commands(const wchar_t *varname, const char *codename) { struct get_variable_T gv = get_variable(varname); switch (gv.type) { case GV_NOTFOUND: return -1; case GV_SCALAR: case GV_ARRAY: break; case GV_ARRAY_CONCAT: /* should execute the concatenated value, but is not supported now*/ return -1; } /* copy the array values in case they are unset during execution */ save_get_variable_values(&gv); int result = exec_iteration(gv.values, codename); plfree(gv.values, free); return result; } /* Calls `exec_variable_as_commands' with `is_executing_auxiliary' set to true. */ int exec_variable_as_auxiliary(const wchar_t *varname, const char *codename) { bool save_executing_auxiliary = is_executing_auxiliary; is_executing_auxiliary = true; int result = exec_variable_as_commands(varname, codename); is_executing_auxiliary = save_executing_auxiliary; return result; } #if YASH_ENABLE_LINEEDIT /* Autoloads the specified file to load a completion function definition. * String `cmdname', which may be NULL, is used as the only positional parameter * during script execution. * Returns true iff a file was autoloaded. */ bool autoload_completion_function_file( const wchar_t *filename, const wchar_t *cmdname) { char *mbsfilename = malloc_wcstombs(filename); if (mbsfilename == NULL) return false; char *path = which(mbsfilename, get_path_array(PA_LOADPATH), is_readable_regular); if (path == NULL) { le_compdebug("file \"%s\" was not found in $YASH_LOADPATH", mbsfilename); free(mbsfilename); return false; } int fd = move_to_shellfd(open(path, O_RDONLY)); if (fd < 0) { le_compdebug("cannot open file \"%s\"", path); free(path); return false; } struct execstate_T *saveexecstate = save_execstate(); int savelaststatus = laststatus; bool saveposix = posixly_correct; posixly_correct = false; open_new_environment(false); set_positional_parameters((void *[]) { (void *) cmdname, NULL }); le_compdebug("executing file \"%s\" (autoload)", path); exec_input(fd, mbsfilename, 0); le_compdebug("finished executing file \"%s\"", path); close_current_environment(); posixly_correct = saveposix; laststatus = savelaststatus; restore_execstate(saveexecstate); remove_shellfd(fd); xclose(fd); free(path); free(mbsfilename); return true; } /* Calls the function whose name is `funcname' as a completion function. * Returns false if no such function has been defined. */ bool call_completion_function(const wchar_t *funcname) { command_T *func = get_function(funcname); if (func == NULL) { le_compdebug("completion function \"%ls\" is not defined", funcname); return false; } struct execstate_T *saveexecstate = save_execstate(); int savelaststatus = laststatus; bool saveposix = posixly_correct; posixly_correct = false; le_compdebug("executing completion function \"%ls\"", funcname); exec_function_body(func, (void *[]) { NULL }, false, true); le_compdebug("finished executing completion function \"%ls\"", funcname); le_compdebug(" with the exit status of %d", laststatus); posixly_correct = saveposix; laststatus = savelaststatus; restore_execstate(saveexecstate); return true; } #endif /* YASH_ENABLE_LINEEDIT */ /********** Built-ins **********/ static int exec_builtin_2(int argc, void **argv, const wchar_t *as, bool clear) __attribute__((nonnull(2))); static int command_builtin_execute( int argc, void **argv, enum srchcmdtype_T type) __attribute__((nonnull)); static bool print_command_info(const wchar_t *commandname, enum srchcmdtype_T type, bool alias, bool keyword, bool humanfriendly) __attribute__((nonnull)); static void print_command_absolute_path( const char *name, const char *path, bool humanfriendly) __attribute__((nonnull)); /* Options for the "break", "continue" and "eval" built-ins. */ const struct xgetopt_T iter_options[] = { { L'i', L"iteration", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* Options for the "return" built-in. */ const struct xgetopt_T return_options[] = { { L'n', L"no-return", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "return" built-in, which accepts the following option: * -n: don't return from a function. */ int return_builtin(int argc, void **argv) { bool noreturn = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, return_options, 0)) != NULL) { switch (opt->shortopt) { case L'n': noreturn = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (!validate_operand_count(argc - xoptind, 0, 1)) return special_builtin_syntax_error(Exit_ERROR); int status; const wchar_t *statusstr = ARGV(xoptind); if (statusstr != NULL) { if (!xwcstoi(statusstr, 10, &status) || status < 0) { xerror(0, Ngt("`%ls' is not a valid integer"), statusstr); status = Exit_ERROR; special_builtin_syntax_error(status); /* return anyway */ } } else { status = (savelaststatus >= 0) ? savelaststatus : laststatus; } if (!noreturn) { if (execstate.noreturn && is_interactive_now) { xerror(0, Ngt("cannot be used in the interactive mode")); return Exit_FAILURE; } execstate.exception = E_RETURN; } return status; } #if YASH_ENABLE_HELP const char return_help[] = Ngt( "return from a function or script" ); const char return_syntax[] = Ngt( "\treturn [-n] [exit_status]\n" ); #endif /* The "break"/"continue" built-in, which accepts the following option: * -i: iterative execution */ int break_builtin(int argc, void **argv) { bool iter = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, iter_options, 0)) != NULL) { switch (opt->shortopt) { case L'i': iter = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (!validate_operand_count(argc - xoptind, 0, iter ? 0 : 1)) return special_builtin_syntax_error(Exit_ERROR); if (iter) { /* break/continue iteration */ if (!execstate.iterating) { xerror(0, Ngt("not in an iteration")); return Exit_ERROR; } if (wcscmp(ARGV(0), L"break") == 0) { execstate.exception = E_BREAK_ITERATION; } else { assert(wcscmp(ARGV(0), L"continue") == 0); execstate.exception = E_CONTINUE_ITERATION; } return laststatus; } else { unsigned count; const wchar_t *countstr = ARGV(xoptind); if (countstr == NULL) { count = 1; } else { unsigned long countl; if (!xwcstoul(countstr, 0, &countl)) { xerror(0, Ngt("`%ls' is not a valid integer"), countstr); return special_builtin_syntax_error(Exit_ERROR); } else if (countl == 0) { xerror(0, Ngt("%u is not a positive integer"), 0u); return special_builtin_syntax_error(Exit_ERROR); } else if (countl > UINT_MAX) { count = UINT_MAX; } else { count = (unsigned) countl; } } assert(count > 0); if (execstate.loopnest == 0) { xerror(0, Ngt("not in a loop")); return special_builtin_syntax_error(Exit_ERROR); } if (count > execstate.loopnest) count = execstate.loopnest; if (wcscmp(ARGV(0), L"break") == 0) { execstate.breakloopnest = execstate.loopnest - count; } else { assert(wcscmp(ARGV(0), L"continue") == 0); execstate.breakloopnest = execstate.loopnest - count + 1; execstate.exception = E_CONTINUE; } return Exit_SUCCESS; } } #if YASH_ENABLE_HELP const char break_help[] = Ngt( "exit a loop" ); const char break_syntax[] = Ngt( "\tbreak [count]\n" "\tbreak -i\n" ); const char continue_help[] = Ngt( "continue a loop" ); const char continue_syntax[] = Ngt( "\tcontinue [count]\n" "\tcontinue -i\n" ); #endif /* The "eval" built-in, which accepts the following option: * -i: iterative execution */ int eval_builtin(int argc __attribute__((unused)), void **argv) { bool iter = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, iter_options, XGETOPT_POSIX)) != NULL) { switch (opt->shortopt) { case L'i': iter = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (iter) { return exec_iteration(&argv[xoptind], "eval"); } else { wchar_t *args = joinwcsarray(&argv[xoptind], L" "); exec_wcs(args, "eval", false); free(args); return laststatus; } } #if YASH_ENABLE_HELP const char eval_help[] = Ngt( "evaluate arguments as a command" ); const char eval_syntax[] = Ngt( "\teval [-i] [argument...]\n" ); #endif /* Options for the "." built-in. */ const struct xgetopt_T dot_options[] = { { L'A', L"no-alias", OPTARG_NONE, false, NULL, }, { L'L', L"autoload", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "." built-in, which accepts the following option: * -A: disable aliases * -L: autoload */ int dot_builtin(int argc, void **argv) { bool enable_alias = true, autoload = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, dot_options, XGETOPT_POSIX)) != NULL) { switch (opt->shortopt) { case L'A': enable_alias = false; break; case L'L': autoload = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } const wchar_t *filename = ARGV(xoptind++); if (filename == NULL) return special_builtin_syntax_error(insufficient_operands_error(1)); bool has_args = xoptind < argc; if (has_args && posixly_correct) return special_builtin_syntax_error(too_many_operands_error(1)); char *mbsfilename = malloc_wcstombs(filename); if (mbsfilename == NULL) { xerror(EILSEQ, Ngt("unexpected error")); return Exit_ERROR; } char *path; if (autoload) { path = which(mbsfilename, get_path_array(PA_LOADPATH), is_readable_regular); if (path == NULL) { xerror(0, Ngt("file `%s' was not found in $YASH_LOADPATH"), mbsfilename); goto error; } } else if (wcschr(filename, L'/') == NULL) { path = which(mbsfilename, get_path_array(PA_PATH), is_readable_regular); if (path == NULL) { if (!posixly_correct) { path = mbsfilename; } else { xerror(0, Ngt("file `%s' was not found in $PATH"), mbsfilename); goto error; } } } else { path = mbsfilename; } if (has_args) { open_new_environment(false); set_positional_parameters(&argv[xoptind]); } int fd = move_to_shellfd(open(path, O_RDONLY)); if (path != mbsfilename) free(path); if (fd < 0) { xerror(errno, Ngt("cannot open file `%s'"), mbsfilename); goto error; } exec_input(fd, mbsfilename, enable_alias ? XIO_SUBST_ALIAS : 0); remove_shellfd(fd); xclose(fd); free(mbsfilename); if (has_args) { close_current_environment(); } return laststatus; error: free(mbsfilename); if (!is_interactive_now) exit_shell_with_status(Exit_FAILURE); return Exit_FAILURE; } #if YASH_ENABLE_HELP const char dot_help[] = Ngt( "read a file and execute commands" ); const char dot_syntax[] = Ngt( "\t. [-AL] file [argument...]\n" ); #endif /* Options for the "exec" built-in. */ const struct xgetopt_T exec_options[] = { { L'a', L"as", OPTARG_REQUIRED, false, NULL, }, { L'c', L"clear", OPTARG_NONE, false, NULL, }, { L'f', L"force", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "exec" built-in, which accepts the following options: * -a name: give as argv[0] to the command * -c: don't pass environment variables to the command * -f: suppress error when we have stopped jobs */ int exec_builtin(int argc, void **argv) { const wchar_t *as = NULL; bool clear = false, force = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, exec_options, XGETOPT_POSIX)) != NULL) { switch (opt->shortopt) { case L'a': as = xoptarg; break; case L'c': clear = true; break; case L'f': force = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } exec_builtin_executed = true; if (xoptind == argc) return Exit_SUCCESS; if (!posixly_correct && is_interactive_now && !force) { size_t sjc = stopped_job_count(); if (sjc > 0) { fprintf(stderr, ngt("You have a stopped job!", "You have %zu stopped jobs!", sjc), sjc); fprintf(stderr, gt(" Use the -f option to exec anyway.\n")); return Exit_FAILURE; } } return exec_builtin_2(argc - xoptind, &argv[xoptind], as, clear); } /* The main part of the "exec" built-in. * argc, argv: the operands (not arguments) of the "exec" built-in. * as: value of the -a option or NULL * clear: true iff the -c option is specified */ int exec_builtin_2(int argc, void **argv, const wchar_t *as, bool clear) { int err; const wchar_t *saveargv0 = ARGV(0); char *mbssaveargv0 = malloc_wcstombs(saveargv0); if (mbssaveargv0 == NULL) { xerror(EILSEQ, Ngt("unexpected error")); err = Exit_NOEXEC; goto error1; } char *mbsargv0; if (as != NULL) { mbsargv0 = malloc_wcstombs(as); if (mbsargv0 == NULL) { xerror(EILSEQ, Ngt("unexpected error")); err = Exit_NOEXEC; goto error2; } argv[0] = (void *) as; } else { mbsargv0 = mbssaveargv0; } const char *commandpath; if (wcschr(saveargv0, L'/') != NULL) { commandpath = mbssaveargv0; } else { commandpath = get_command_path(mbssaveargv0, false); if (commandpath == NULL) { xerror(0, Ngt("no such command `%s'"), mbssaveargv0); err = Exit_NOTFOUND; goto error3; } } char **envs; if (clear) { /* use the environment that contains only the variables assigned by the * assignment for this `exec' built-in. */ plist_T list; pl_init(&list); for (const assign_T *assign = last_assign; assign != NULL; assign = assign->next) { char *value = get_exported_value(assign->a_name); if (value != NULL) { pl_add(&list, malloc_printf("%ls=%s", assign->a_name, value)); free(value); } } envs = (char **) pl_toary(&list); } else { envs = environ; } exec_external_program(commandpath, argc, mbsargv0, argv, envs); err = Exit_NOEXEC; if (clear) plfree((void **) envs, free); error3: if (as != NULL) { free(mbsargv0); argv[0] = (void *) saveargv0; } error2: free(mbssaveargv0); error1: if (posixly_correct || !is_interactive_now) exit(err); return err; } #if YASH_ENABLE_HELP const char exec_help[] = Ngt( "replace the shell process with an external command" ); const char exec_syntax[] = Ngt( "\texec [-cf] [-a name] [command [argument...]]\n" ); #endif /* Options for the "command" built-in. */ const struct xgetopt_T command_options[] = { { L'a', L"alias", OPTARG_NONE, false, NULL, }, { L'b', L"builtin-command", OPTARG_NONE, false, NULL, }, { L'e', L"external-command", OPTARG_NONE, false, NULL, }, { L'f', L"function", OPTARG_NONE, false, NULL, }, { L'k', L"keyword", OPTARG_NONE, false, NULL, }, { L'p', L"standard-path", OPTARG_NONE, true, NULL, }, { L'v', L"identify", OPTARG_NONE, true, NULL, }, { L'V', L"verbose-identify", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "command"/"type" built-in, which accepts the following options: * -a: search aliases * -b: search built-ins * -e: search external commands * -f: search functions * -k: search keywords * -p: use the default path to find the command * -v: print info about the command * -V: print info about the command in a human-friendly format */ int command_builtin(int argc, void **argv) { bool argv0istype = wcscmp(ARGV(0), L"type") == 0; bool printinfo = argv0istype, humanfriendly = argv0istype; enum srchcmdtype_T type = 0; bool aliases = false, keywords = false, defpath = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, command_options, XGETOPT_POSIX)) != NULL) { switch (opt->shortopt) { case L'a': aliases = true; break; case L'b': type |= SCT_BUILTIN; break; case L'e': type |= SCT_EXTERNAL; break; case L'f': type |= SCT_FUNCTION; break; case L'k': keywords = true; break; case L'p': defpath = true; break; case L'v': printinfo = true; humanfriendly = false; break; case L'V': printinfo = true; humanfriendly = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (!printinfo) { if (aliases || keywords) { xerror(0, Ngt("the -a or -k option must be used with the -v option")); return Exit_ERROR; } if (xoptind == argc) { if (posixly_correct) return insufficient_operands_error(1); else return Exit_SUCCESS; } if (type == 0) type = SCT_EXTERNAL | SCT_BUILTIN; else type |= SCT_ALL; if (defpath) type |= SCT_STDPATH; return command_builtin_execute( argc - xoptind, &argv[xoptind], type); } else { if (posixly_correct && !validate_operand_count(argc - xoptind, 1, argv0istype ? SIZE_MAX : 1)) return Exit_ERROR; if (type == 0 && !aliases && !keywords) { type = SCT_EXTERNAL | SCT_BUILTIN | SCT_FUNCTION; aliases = keywords = true; } else { type |= SCT_ALL; } if (defpath) type |= SCT_STDPATH; type |= SCT_CHECK; bool ok = true; clearerr(stdout); for (int i = xoptind; i < argc; i++) { ok &= print_command_info( ARGV(i), type, aliases, keywords, humanfriendly); if (ferror(stdout)) break; } return ok && yash_error_message_count == 0 ? Exit_SUCCESS : Exit_FAILURE; } } /* Executes the specified simple command. * `argc' must be positive. * Returns the exit status of the command. */ int command_builtin_execute(int argc, void **argv, enum srchcmdtype_T type) { char *argv0 = malloc_wcstombs(argv[0]); commandinfo_T ci; bool finally_exit = false; if (argv0 == NULL) { xerror(EILSEQ, NULL); return Exit_NOTFOUND; } search_command(argv0, argv[0], &ci, type); if (ci.type == CT_EXTERNALPROGRAM) { pid_t cpid = fork_and_reset(0, true, t_leave); if (cpid < 0) { free(argv0); return Exit_NOEXEC; } else if (cpid > 0) { wchar_t **namep = wait_for_child( cpid, doing_job_control_now ? cpid : 0, doing_job_control_now); if (namep != NULL) *namep = joinwcsarray(argv, L" "); free(argv0); return laststatus; } finally_exit = true; } exec_simple_command(&ci, argc, argv0, argv, finally_exit); free(argv0); return laststatus; } /* Prints info about the specified command. * If the command is not found, returns false. */ bool print_command_info( const wchar_t *commandname, enum srchcmdtype_T type, bool aliases, bool keywords, bool humanfriendly) { const char *msgfmt; char *name = NULL; if (keywords && is_keyword(commandname)) { msgfmt = humanfriendly ? gt("%ls: a shell keyword\n") : "%ls\n"; xprintf(msgfmt, commandname); return true; } #if YASH_ENABLE_ALIAS if (aliases) { if (print_alias_if_defined(commandname, humanfriendly)) { return true; } else { if (ferror(stdout)) return false; } } #else (void) aliases; #endif name = malloc_wcstombs(commandname); if (name == NULL) return false; commandinfo_T ci; search_command(name, commandname, &ci, type); switch (ci.type) { case CT_NONE: if (humanfriendly) xerror(0, Ngt("no such command `%s'"), name); break; case CT_EXTERNALPROGRAM: print_command_absolute_path(name, ci.ci_path, humanfriendly); break; case CT_SPECIALBUILTIN: msgfmt = humanfriendly ? gt("%s: a special built-in\n") : "%s\n"; xprintf(msgfmt, name); break; case CT_SEMISPECIALBUILTIN: msgfmt = humanfriendly ? gt("%s: a semi-special built-in\n") : "%s\n"; xprintf(msgfmt, name); break; case CT_REGULARBUILTIN:; const char *cmdpath; if (type & SCT_STDPATH) cmdpath = get_command_path_default(name); else cmdpath = get_command_path(name, false); if (humanfriendly) { msgfmt = (cmdpath == NULL) ? Ngt("%s: a regular built-in (not found in $PATH)\n") : Ngt("%s: a regular built-in at %s\n"); xprintf(gt(msgfmt), name, cmdpath); } else { xprintf("%s\n", (cmdpath == NULL) ? name : cmdpath); } break; case CT_FUNCTION: msgfmt = humanfriendly ? gt("%s: a function\n") : "%s\n"; xprintf(msgfmt, name); break; } free(name); return ci.type != CT_NONE; } /* Prints the absolute path of the specified command. */ void print_command_absolute_path( const char *name, const char *path, bool humanfriendly) { if (path[0] == '/') { /* the path is already absolute */ if (humanfriendly) xprintf(gt("%s: an external command at %s\n"), name, path); else xprintf("%s\n", path); return; } const wchar_t *wpwd = getvar(L VAR_PWD); char *pwd = NULL; if (wpwd != NULL) { pwd = malloc_wcstombs(wpwd); if (pwd != NULL && !is_same_file(pwd, ".")) { free(pwd); pwd = NULL; } } if (pwd == NULL) { pwd = xgetcwd(); if (pwd == NULL) pwd = xstrdup("."); /* last resort */ } if (humanfriendly) xprintf(gt("%s: an external command at %s/%s\n"), name, pwd, path); else xprintf("%s/%s\n", pwd, path); free(pwd); } #if YASH_ENABLE_HELP const char command_help[] = Ngt( "execute or identify a command" ); const char command_syntax[] = Ngt( "\tcommand [-befp] command [argument...]\n" "\tcommand -v|-V [-abefkp] command...\n" ); const char type_help[] = Ngt( "identify a command" ); const char type_syntax[] = Ngt( "\ttype command...\n" ); #endif /* The "times" built-in. */ int times_builtin(int argc __attribute__((unused)), void **argv) { const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, 0)) != NULL) { switch (opt->shortopt) { #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (xoptind < argc) return special_builtin_syntax_error(too_many_operands_error(0)); double clock; struct tms tms; intmax_t sum, ssm, cum, csm; double sus, sss, cus, css; #define format_time(time, min, sec) \ do { \ double tsec = (time) / clock; \ double m = trunc(tsec / 60.0); \ (min) = (intmax_t) m; \ (sec) = tsec - m * 60.0; \ } while (0) clock = sysconf(_SC_CLK_TCK); if (times(&tms) == (clock_t) -1) { xerror(errno, Ngt("cannot get the time data")); return Exit_FAILURE; } format_time(tms.tms_utime, sum, sus); format_time(tms.tms_stime, ssm, sss); format_time(tms.tms_cutime, cum, cus); format_time(tms.tms_cstime, csm, css); #undef format_time xprintf("%jdm%fs %jdm%fs\n%jdm%fs %jdm%fs\n", sum, sus, ssm, sss, cum, cus, csm, css); return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } #if YASH_ENABLE_HELP const char times_help[] = Ngt( "print CPU time usage" ); const char times_syntax[] = Ngt( "\ttimes\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/0000755000175000017500000000000012154557026014343 5ustar magicantmagicantyash-2.35/lineedit/compparse.c0000644000175000017500000010301212154557026016475 0ustar magicantmagicant/* Yash: yet another shell */ /* compparse.c: simple parser for command line completion */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "compparse.h" #include #include #include #include #include #if YASH_ENABLE_ALIAS # include "../alias.h" #endif #include "../expand.h" #include "../option.h" #include "../parser.h" #include "../plist.h" #include "../strbuf.h" #include "../util.h" #include "../variable.h" #include "../xfnmatch.h" #include "complete.h" #include "editing.h" #include "lineedit.h" /* This structure contains data used in parsing */ typedef struct cparseinfo_T { xwcsbuf_T buf; size_t bufindex; #if YASH_ENABLE_ALIAS struct aliaslist_T *aliaslist; #endif le_context_T *ctxt; } cparseinfo_T; /* The `buf' buffer contains the first `le_main_index' characters of the edit * buffer. During parsing, alias substitution may be performed on this buffer. * The `bufindex' index indicates the point the parser is currently parsing. * The `ctxt' member points to the structure in which the final result is saved. */ /* This structure contains data used during parsing */ static cparseinfo_T *pi; #define BUF (pi->buf.contents) #define LEN (pi->buf.length) #define INDEX (pi->bufindex) static void empty_pwords(void); static void set_pwords(plist_T *pwords) __attribute__((nonnull)); static bool cparse_commands(void); static void skip_blanks(void); static void skip_blanks_and_newlines(void); #if YASH_ENABLE_ALIAS static bool csubstitute_alias(substaliasflags_T flags); #else # define csubstitute_alias(flags) false #endif static bool cparse_command(void); static bool has_token(const wchar_t *token) __attribute__((nonnull,pure)); static bool cparse_simple_command(void); static bool cparse_redirections(void); static bool ctryparse_assignment(void); static bool ctryparse_redirect(void); static bool cparse_for_command(void); static bool cparse_case_command(void); static bool cparse_function_definition(void); static wchar_t *cparse_and_expand_word( tildetype_T tilde, le_contexttype_T ctxttype) __attribute__((malloc,warn_unused_result)); static wordunit_T *cparse_word( bool testfunc(wchar_t c), tildetype_T tilde, le_contexttype_T ctxttype) __attribute__((nonnull,malloc,warn_unused_result)); static bool ctryparse_tilde(void); static wordunit_T *cparse_special_word_unit(le_contexttype_T ctxttype) __attribute__((malloc,warn_unused_result)); static wordunit_T *cparse_paramexp_raw(le_contexttype_T ctxttype) __attribute__((malloc,warn_unused_result)); static wordunit_T *cparse_paramexp_in_brace(le_contexttype_T ctxttype) __attribute__((malloc,warn_unused_result)); static wordunit_T *cparse_arith(void) __attribute__((malloc,warn_unused_result)); static wordunit_T *cparse_cmdsubst_in_paren(void) __attribute__((malloc,warn_unused_result)); static wordunit_T *cparse_cmdsubst_in_backquote(void) __attribute__((malloc,warn_unused_result)); static bool is_slash_or_closing_brace(wchar_t c) __attribute__((const)); static bool is_closing_brace(wchar_t c) __attribute__((const)); static bool is_closing_bracket(wchar_t c) __attribute__((const)); static bool is_arith_delimiter(wchar_t c) __attribute__((pure)); static bool remove_braceexpand(wchar_t *s) __attribute__((nonnull)); static bool remove_braceexpand_inner(xwcsbuf_T *buf, size_t *index) __attribute__((nonnull)); /* Parses the contents of the edit buffer (`le_main_buffer') from the beginning * up to the current cursor position (`le_main_index') and determines the * current completion context. * The results are returned as a newly malloced `le_context_T' data. */ le_context_T *le_get_context(void) { assert(wcslen(le_main_buffer.contents) == le_main_buffer.length); le_context_T *ctxt = xmalloc(sizeof *ctxt); cparseinfo_T parseinfo; wb_init(&parseinfo.buf); wb_ncat_force(&parseinfo.buf, le_main_buffer.contents, le_main_index); parseinfo.bufindex = 0; #if YASH_ENABLE_ALIAS parseinfo.aliaslist = NULL; #endif parseinfo.ctxt = ctxt; pi = &parseinfo; while (!cparse_commands()) parseinfo.bufindex++; #ifndef NDEBUG pi = NULL; #endif wb_destroy(&parseinfo.buf); #if YASH_ENABLE_ALIAS destroy_aliaslist(parseinfo.aliaslist); #endif if (shopt_braceexpand) if (remove_braceexpand(ctxt->pattern)) ctxt->type |= CTXT_EBRACED; ctxt->src = unescape(ctxt->pattern); if (is_pathname_matching_pattern(ctxt->pattern)) { ctxt->substsrc = true; } else { ctxt->substsrc = false; xwcsbuf_T buf; wb_initwith(&buf, ctxt->pattern); wb_wccat(&buf, L'*'); ctxt->pattern = wb_towcs(&buf); } ctxt->origindex = le_main_index; return ctxt; } /* If `pi->ctxt->pwords' is NULL, assigns a new empty list to it. */ void empty_pwords(void) { if (pi->ctxt->pwords == NULL) { pi->ctxt->pwordc = 0; pi->ctxt->pwords = xmalloc(1 * sizeof *pi->ctxt->pwords); pi->ctxt->pwords[0] = NULL; } } /* Sets `pi->ctxt->pwords' to the contents of `pwords'. */ void set_pwords(plist_T *pwords) { if (pi->ctxt->pwords == NULL) { pi->ctxt->pwordc = pwords->length; pi->ctxt->pwords = pl_toary(pwords); } else { plfree(pl_toary(pwords), free); } } /* Following parser functions return true iff parsing is finished and the result * is saved in the context structure `pi->ctxt'. * The result is saved in the following variables of the context structure: * quote, type, pwordc, pwords, pattern, srcindex. */ /* Parses commands from the current position until a right parenthesis (")") is * found or the whole line is parsed. */ bool cparse_commands(void) { for (;;) { skip_blanks(); switch (BUF[INDEX]) { case L'\n': case L';': case L'&': case L'|': INDEX++; continue; case L')': return false; } if (cparse_command()) return true; } } /* Skips blank characters. */ void skip_blanks(void) { while (iswblank(BUF[INDEX])) INDEX++; } /* Skips blank characters and newlines. */ void skip_blanks_and_newlines(void) { while (BUF[INDEX] == L'\n' || iswblank(BUF[INDEX])) INDEX++; } #if YASH_ENABLE_ALIAS /* Performs alias substitution at the current position. * See the description of `substitute_alias' for the usage of `flags'. * Returns true iff any alias is substituted. * If the word at the current INDEX is at the end of BUF, the word is not * substituted because it is the word being completed. */ bool csubstitute_alias(substaliasflags_T flags) { size_t len = 0; while (is_alias_name_char(BUF[INDEX + len])) len++; if (len == 0 || INDEX + len == LEN) return false; return substitute_alias(&pi->buf, INDEX, &pi->aliaslist, flags); } #endif /* Parses a command from the current position. */ bool cparse_command(void) { if (BUF[INDEX] == L'(') { INDEX++; if (cparse_commands()) return true; assert(BUF[INDEX] == L')'); INDEX++; return cparse_redirections(); } else if (has_token(L"{") || has_token(L"!")) { INDEX++; return false; } else if (has_token(L"if") || has_token(L"do")) { INDEX += 2; return false; } else if (has_token(L"then") || has_token(L"else") || has_token(L"elif")) { INDEX += 4; return false; } else if (has_token(L"while") || has_token(L"until")) { INDEX += 5; return false; } else if (has_token(L"}")) { INDEX++; return cparse_redirections(); } else if (has_token(L"fi")) { INDEX += 2; return cparse_redirections(); } else if (has_token(L"done") || has_token(L"esac")) { INDEX += 4; return cparse_redirections(); } else if (has_token(L"for")) { return cparse_for_command(); } else if (has_token(L"case")) { return cparse_case_command(); } else if (!posixly_correct && has_token(L"function")) { return cparse_function_definition(); } else { return cparse_simple_command(); } } /* Returns true iff the specified word is at the current position (and it is not * at the end of the buffer). */ bool has_token(const wchar_t *token) { const wchar_t *c = matchwcsprefix(BUF + INDEX, token); return c != NULL && *c != L'\0' && is_token_delimiter_char(*c); } /* Parses a simple command. */ bool cparse_simple_command(void) { cparse_simple_command: if (csubstitute_alias(AF_NONGLOBAL | AF_NORECUR)) return false; size_t saveindex; skip_blanks(); saveindex = INDEX; if (ctryparse_redirect()) return true; if (saveindex != INDEX) { skip_blanks(); goto cparse_simple_command; } if (ctryparse_assignment()) return true; if (saveindex != INDEX) { skip_blanks(); goto cparse_simple_command; } plist_T pwords; pl_init(&pwords); for (;;) { switch (BUF[INDEX]) { case L'\n': case L';': case L'&': case L'|': case L'(': case L')': plfree(pl_toary(&pwords), free); return false; } wordunit_T *w = cparse_word(is_token_delimiter_char, TT_SINGLE, pwords.length == 0 ? CTXT_COMMAND : CTXT_ARGUMENT); if (w == NULL) { set_pwords(&pwords); return true; } else { expand_multiple(w, &pwords); wordfree(w); } skip_blanks(); if (csubstitute_alias(0)) skip_blanks(); if (ctryparse_redirect()) { plfree(pl_toary(&pwords), free); return true; } skip_blanks(); } } /* Parses redirections as many as possible. * Global aliases are substituted if necessary. */ bool cparse_redirections(void) { size_t saveindex; do { skip_blanks(); saveindex = INDEX; if (ctryparse_redirect()) return true; } while (saveindex != INDEX || csubstitute_alias(0)); return false; } /* Parses an assignment if any. * `skip_blanks' should be called before this function is called. */ bool ctryparse_assignment(void) { size_t index = INDEX; if (BUF[index] == L'=' || iswdigit(BUF[index])) return false; while (is_name_char(BUF[index])) index++; if (BUF[index] != L'=') return false; INDEX = index + 1; if (BUF[INDEX] != L'(') { /* scalar variable */ wchar_t *value = cparse_and_expand_word(TT_MULTI, CTXT_ASSIGN); if (value == NULL) { empty_pwords(); return true; } else { free(value); return false; } } else { /* parse array contents */ plist_T pwords; pl_init(&pwords); INDEX++; for (;;) { skip_blanks(); if (csubstitute_alias(0)) skip_blanks(); if (BUF[INDEX] != L'\0' && is_token_delimiter_char(BUF[INDEX])) { if (BUF[INDEX] == L')') INDEX++; plfree(pl_toary(&pwords), free); return false; } wordunit_T *w = cparse_word( is_token_delimiter_char, TT_SINGLE, CTXT_ASSIGN); if (w == NULL) { set_pwords(&pwords); return true; } else { expand_multiple(w, &pwords); wordfree(w); } } } } /* Parses a redirection if any. * `skip_blanks' should be called before this function is called. */ bool ctryparse_redirect(void) { size_t index = INDEX; le_contexttype_T type; bool result; wchar_t *value; while (iswdigit(BUF[index])) index++; switch (BUF[index]) { case L'<': switch (BUF[index + 1]) { case L'<': type = CTXT_REDIR; switch (BUF[index + 2]) { case L'<': /* here-string */ case L'-': /* here-document */ INDEX = index + 3; break; default: /* here-document */ INDEX = index + 2; break; } break; case L'>': INDEX = index + 2; type = CTXT_REDIR; break; case L'&': INDEX = index + 2; type = CTXT_REDIR_FD; break; case L'(': INDEX = index + 2; goto parse_inner; default: INDEX = index + 1; type = CTXT_REDIR; break; } break; case L'>': switch (BUF[index + 1]) { case L'>': case L'|': INDEX = index + 2; type = CTXT_REDIR; break; case L'(': INDEX = index + 2; goto parse_inner; case L'&': INDEX = index + 2; type = CTXT_REDIR_FD; break; default: INDEX = index + 1; type = CTXT_REDIR; break; } break; default: /* not a redirection */ return false; } skip_blanks(); value = cparse_and_expand_word(TT_SINGLE, type); if (value == NULL) { empty_pwords(); return true; } else { free(value); return false; } parse_inner: result = cparse_commands(); if (!result) { assert(BUF[INDEX] == L')'); INDEX++; } return result; } /* Parses a for command. * There must be the "for" keyword at the current position. */ bool cparse_for_command(void) { assert(wcsncmp(&BUF[INDEX], L"for", 3) == 0); INDEX += 3; skip_blanks(); if (csubstitute_alias(0)) skip_blanks(); /* parse variable name */ wordunit_T *w = cparse_word(is_token_delimiter_char, TT_NONE, CTXT_VAR); if (w == NULL) { empty_pwords(); return true; } wordfree(w); skip_blanks_and_newlines(); /* parse "in" ... */ bool in = has_token(L"in"); if (in) { plist_T pwords; pl_init(&pwords); INDEX += 2; for (;;) { skip_blanks(); if (csubstitute_alias(0)) skip_blanks(); if (BUF[INDEX] == L';' || BUF[INDEX] == L'\n') { plfree(pl_toary(&pwords), free); INDEX++; break; } if (BUF[INDEX] != L'\0' && is_token_delimiter_char(BUF[INDEX])) { plfree(pl_toary(&pwords), free); return false; } w = cparse_word(is_token_delimiter_char, TT_SINGLE, CTXT_NORMAL); if (w == NULL) { set_pwords(&pwords); return true; } else { expand_multiple(w, &pwords); wordfree(w); } } skip_blanks_and_newlines(); } /* parse "do" ... */ if (has_token(L"do")) { INDEX += 2; return false; } /* found no "in" or "do", so the next word should be one of them */ w = cparse_word(is_token_delimiter_char, TT_NONE, in ? CTXT_FOR_DO : CTXT_FOR_IN); if (w == NULL) { empty_pwords(); return true; } wordfree(w); /* syntax error */ return false; } /* Parses a case command. * There must be the "case" keyword at the current position. */ bool cparse_case_command(void) { assert(wcsncmp(&BUF[INDEX], L"case", 4) == 0); INDEX += 4; skip_blanks(); if (csubstitute_alias(0)) skip_blanks(); /* parse matched word */ wordunit_T *w = cparse_word(is_token_delimiter_char, TT_SINGLE, CTXT_NORMAL); if (w == NULL) { empty_pwords(); return true; } wordfree(w); skip_blanks_and_newlines(); /* parse "in" */ if (has_token(L"in")) { INDEX += 2; return false; } /* there is no "in", so the next word should be "in". */ w = cparse_word(is_token_delimiter_char, TT_NONE, CTXT_CASE_IN); if (w == NULL) { empty_pwords(); return true; } wordfree(w); /* syntax error */ return false; } /* Parses a function definition command. * There must be the "function" keyword at the current position. */ bool cparse_function_definition(void) { assert(wcsncmp(&BUF[INDEX], L"function", 8) == 0); INDEX += 8; skip_blanks(); /* parse the function name */ wordunit_T *w = cparse_word(is_token_delimiter_char, TT_NONE, CTXT_FUNCTION); if (w == NULL) { empty_pwords(); return true; } wordfree(w); return false; } /* Parses the word at the current position. * `skip_blanks' should be called before this function is called. * The `ctxttype' parameter is the context type of the word parsed. * If the word was completely parsed, the word is expanded until quote removal * and returned as a newly-malloced string. * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. However, `pi->ctxt->pwords' is NULL * when the preceding words need to be determined by the caller. In this case, * the caller must update the `pwordc' and `pwords' member. */ wchar_t *cparse_and_expand_word(tildetype_T tilde, le_contexttype_T ctxttype) { wordunit_T *w = cparse_word(is_token_delimiter_char, tilde, ctxttype); if (w == NULL) { return NULL; } else { wchar_t *s = expand_single(w, tilde); wordfree(w); assert(s != NULL); return s; } } /* Parses the word at the current position. * `skip_blanks' should be called before this function is called. * `testfunc' is a function that determines if a character is a word delimiter. * The `ctxttype' parameter is the context type of the word parsed. * If the word was completely parsed, the word is returned. * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. However, `pi->ctxt->pwords' is NULL * when the preceding words need to be determined by the caller. In this case, * the caller must update the `pwordc' and `pwords' member. */ wordunit_T *cparse_word( bool testfunc(wchar_t c), tildetype_T tilde, le_contexttype_T ctxttype) { cparse_word: if (tilde != TT_NONE) if (ctryparse_tilde()) return NULL; wordunit_T *first = NULL, **lastp = &first; bool indq = false; /* in double quotes? */ size_t startindex = INDEX; size_t srcindex = le_main_index - (LEN - INDEX); #define MAKE_WORDUNIT_STRING \ do { \ wordunit_T *w = xmalloc(sizeof *w); \ w->next = NULL; \ w->wu_type = WT_STRING; \ w->wu_string = xwcsndup(&BUF[startindex], INDEX - startindex); \ *lastp = w, lastp = &w->next; \ } while (0) while (indq || !testfunc(BUF[INDEX])) { wordunit_T *wu; switch (BUF[INDEX]) { case L'\0': goto done; case L'\\': if (BUF[INDEX + 1] != L'\0') { INDEX += 2; continue; } break; case L'$': MAKE_WORDUNIT_STRING; wu = cparse_special_word_unit( (ctxttype & CTXT_MASK) | (indq ? CTXT_QUOTED : 0)); if (wu == NULL) { if (pi->ctxt->pwords == NULL && (pi->ctxt->type & CTXT_VBRACED)) { xwcsbuf_T buf; wchar_t *prefix = expand_single(first, tilde); assert(prefix != NULL); pi->ctxt->pattern = wb_towcs(wb_catfree( wb_initwith(&buf, prefix), pi->ctxt->pattern)); pi->ctxt->srcindex = srcindex; } wordfree(first); return NULL; } *lastp = wu, lastp = &wu->next; startindex = INDEX; continue; case L'`': wu = cparse_cmdsubst_in_backquote(); if (wu == NULL) { wordfree(first); return NULL; } *lastp = wu, lastp = &wu->next; startindex = INDEX; continue; case L'\'': if (!indq) { const wchar_t *end = wcschr(&BUF[INDEX + 1], L'\''); if (end == NULL) goto end_single_quote; INDEX = end - BUF; } break; case L'"': indq = !indq; break; case L':': if (!indq && tilde == TT_MULTI) { INDEX++; wordfree(first); goto cparse_word; } break; } INDEX++; } done: MAKE_WORDUNIT_STRING; if (BUF[INDEX] != L'\0') { assert(first != NULL); return first; } else { pi->ctxt->quote = indq ? QUOTE_DOUBLE : QUOTE_NORMAL; goto finish; } /* if the word ends without a closing quote, add one */ end_single_quote:; wordunit_T *w = xmalloc(sizeof *w); w->next = NULL; w->wu_type = WT_STRING; w->wu_string = malloc_wprintf(L"%ls'", &BUF[startindex]); *lastp = w, lastp = &w->next; pi->ctxt->quote = QUOTE_SINGLE; finish: pi->ctxt->type = ctxttype; pi->ctxt->pwordc = 0; pi->ctxt->pwords = NULL; pi->ctxt->pattern = expand_single(first, tilde); pi->ctxt->srcindex = srcindex; wordfree(first); return NULL; } /* Parses a tilde expansion at the current position if any. * If there is a tilde expansion to complete, this function returns true after * setting the members of `pi->ctxt'. (However, `pi->ctxt->pwords' is NULL * when the preceding words need to be determined by the caller. In this case, * the caller must update the `pwordc' and `pwords' member.) * Otherwise, this function simply returns false. */ bool ctryparse_tilde(void) { if (BUF[INDEX] != L'~') return false; size_t index = INDEX; do { index++; switch (BUF[index]) { case L'\n': case L';': case L'&': case L'|': case L'<': case L'>': case L'(': case L')': case L'$': case L'`': case L'/': case L':': case L'\\': case L'\'': case L'"': case L'?': case L'*': case L'[': return false; } } while (BUF[index] != L'\0'); pi->ctxt->quote = QUOTE_NONE; pi->ctxt->type = CTXT_TILDE; pi->ctxt->pwordc = 0; pi->ctxt->pwords = NULL; pi->ctxt->pattern = xwcsdup(&BUF[INDEX + 1]); pi->ctxt->srcindex = le_main_index - (LEN - (INDEX + 1)); return true; } /* Parses a parameter expansion or command substitution that starts with '$'. * The `ctxttype' parameter is the context type of the word containing this * expansion. * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. However, `pi->ctxt->pwords' is NULL * when the preceding words need to be determined by the caller. In this case, * the caller must update the `pwordc' and `pwords' member. */ wordunit_T *cparse_special_word_unit(le_contexttype_T ctxttype) { assert(BUF[INDEX] == L'$'); switch (BUF[INDEX + 1]) { case L'{': INDEX++; return cparse_paramexp_in_brace(ctxttype); case L'(': if (BUF[INDEX + 2] == L'(') return cparse_arith(); else return cparse_cmdsubst_in_paren(); default: return cparse_paramexp_raw(ctxttype); } } /* Parses a parameter that is not enclosed by { }. * The `ctxttype' parameter is the context type of the word containing this * parameter expansion. Only the CTXT_QUOTED flag in `ctxttype' affect the * result. * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. However, `pi->ctxt->pwords' is NULL * when the preceding words need to be determined by the caller. In this case, * the caller must update the `pwordc' and `pwords' member. */ wordunit_T *cparse_paramexp_raw(le_contexttype_T ctxttype) { assert(BUF[INDEX] == L'$'); size_t namelen; switch (BUF[INDEX + 1]) { case L'@': case L'*': case L'#': case L'?': case L'-': case L'$': case L'!': namelen = 1; break; default: if (iswdigit(BUF[INDEX + 1])) { namelen = 1; } else { namelen = 0; while (is_portable_name_char(BUF[INDEX + 1 + namelen])) namelen++; if (BUF[INDEX + 1 + namelen] == L'\0') { /* complete variable name */ pi->ctxt->quote = QUOTE_NONE; pi->ctxt->type = CTXT_VAR | (ctxttype & CTXT_QUOTED); pi->ctxt->pwordc = 0; pi->ctxt->pwords = malloc(1 * sizeof *pi->ctxt->pwords); pi->ctxt->pwords[0] = NULL; pi->ctxt->pattern = xwcsndup(&BUF[INDEX + 1], namelen); pi->ctxt->srcindex = le_main_index - namelen; return NULL; } } break; } wordunit_T *wu = xmalloc(sizeof *wu); wu->next = NULL; if (namelen == 0) { wu->wu_type = WT_STRING; wu->wu_string = xwcsdup(L"$"); } else { wu->wu_type = WT_PARAM; wu->wu_param = xmalloc(sizeof *wu->wu_param); wu->wu_param->pe_type = PT_MINUS; wu->wu_param->pe_name = xwcsndup(&BUF[INDEX + 1], namelen); wu->wu_param->pe_start = wu->wu_param->pe_end = wu->wu_param->pe_match = wu->wu_param->pe_subst = NULL; } INDEX += namelen + 1; return wu; } /* Parses a parameter expansion enclosed by { }. * The `ctxttype' parameter is the context type of the word containing this * parameter expansion. * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. However, `pi->ctxt->pwords' is NULL * when the preceding words need to be determined by the caller. In this case, * the caller must update the `pwordc' and `pwords' member. */ wordunit_T *cparse_paramexp_in_brace(le_contexttype_T ctxttype) { paramexp_T *pe = xmalloc(sizeof *pe); pe->pe_type = 0; pe->pe_name = NULL; pe->pe_start = pe->pe_end = pe->pe_match = pe->pe_subst = NULL; const size_t origindex = INDEX; assert(BUF[INDEX] == L'{'); INDEX++; /* parse PT_NUMBER */ if (BUF[INDEX] == L'#') { switch (BUF[INDEX + 1]) { case L'}': case L'+': case L'=': case L':': case L'/': case L'%': break; case L'-': case L'?': case L'#': if (BUF[INDEX + 2] != L'}') break; /* falls thru! */ case L'\0': default: pe->pe_type |= PT_NUMBER; INDEX++; break; } } /* parse nested expansion */ if (BUF[INDEX] == L'{') { pe->pe_type |= PT_NEST; pe->pe_nest = cparse_paramexp_in_brace(ctxttype & CTXT_MASK); if (pe->pe_nest == NULL) goto return_null; } else if (BUF[INDEX] == L'`' || (BUF[INDEX] == L'$' && (BUF[INDEX + 1] == L'{' || BUF[INDEX + 1] == L'('))) { pe->pe_type |= PT_NEST; pe->pe_nest = cparse_special_word_unit(ctxttype & CTXT_MASK); if (pe->pe_nest == NULL) goto return_null; } else { /* no nesting: parse parameter name */ size_t namelen; switch (BUF[INDEX]) { case L'@': case L'*': case L'#': case L'?': case L'-': case L'$': case L'!': namelen = 1; break; default: namelen = 0; while (is_name_char(BUF[INDEX + namelen])) namelen++; break; } if (BUF[INDEX + namelen] == L'\0') { pi->ctxt->quote = QUOTE_NORMAL; pi->ctxt->type = CTXT_VAR | CTXT_VBRACED | (ctxttype & CTXT_QUOTED); pi->ctxt->pwordc = 0; pi->ctxt->pwords = malloc(1 * sizeof *pi->ctxt->pwords); pi->ctxt->pwords[0] = NULL; pi->ctxt->pattern = xwcsndup(&BUF[INDEX], namelen); pi->ctxt->srcindex = le_main_index - namelen; goto return_null; } pe->pe_name = xwcsndup(&BUF[INDEX], namelen); INDEX += namelen; } /* parse index */ if (BUF[INDEX] == L'[') { INDEX++; wordunit_T *w = cparse_word(is_closing_bracket, TT_NONE, CTXT_ARITH); if (w == NULL) goto return_null; wordfree(w); /* don't assign the result to `pe->pe_start/end' since it may cause an * arithmetic expansion error. */ if (BUF[INDEX] == L']') INDEX++; } /* parse PT_COLON */ if (BUF[INDEX] == L':') { pe->pe_type |= PT_COLON; INDEX++; } /* parse '-', '+', '#', etc. */ switch (BUF[INDEX]) { case L'+': pe->pe_type |= PT_PLUS; goto parse_subst; case L'-': case L'=': case L'?': pe->pe_type |= PT_MINUS; goto parse_subst; case L'#': pe->pe_type |= PT_MATCH | PT_MATCHHEAD; goto parse_match; case L'%': pe->pe_type |= PT_MATCH | PT_MATCHTAIL; goto parse_match; case L'/': pe->pe_type |= PT_SUBST | PT_MATCHLONGEST; goto parse_match; case L'}': pe->pe_type |= PT_NONE; goto check_closing_paren; default: goto syntax_error; } parse_match: if (pe->pe_type & PT_COLON) { if ((pe->pe_type & PT_MASK) == PT_SUBST) pe->pe_type |= PT_MATCHHEAD | PT_MATCHTAIL; else goto syntax_error; INDEX++; } else if (BUF[INDEX] == BUF[INDEX + 1]) { if ((pe->pe_type & PT_MASK) == PT_MATCH) pe->pe_type |= PT_MATCHLONGEST; else pe->pe_type |= PT_SUBSTALL; INDEX += 2; } else if (BUF[INDEX] == L'/') { switch (BUF[INDEX + 1]) { case L'#': pe->pe_type |= PT_MATCHHEAD; INDEX += 2; break; case L'%': pe->pe_type |= PT_MATCHTAIL; INDEX += 2; break; default: INDEX += 1; break; } } else { INDEX++; } if ((pe->pe_type & PT_MASK) == PT_MATCH) { pe->pe_match = cparse_word( is_closing_brace, TT_NONE, ctxttype | CTXT_VBRACED); if (pe->pe_match == NULL) goto return_null; goto check_closing_paren; } else { pe->pe_match = cparse_word( is_slash_or_closing_brace, TT_NONE, ctxttype | CTXT_VBRACED); if (pe->pe_match == NULL) goto return_null; if (BUF[INDEX] != L'/') goto check_closing_paren; } parse_subst: INDEX++; pe->pe_subst = cparse_word( is_closing_brace, TT_NONE, ctxttype | CTXT_VBRACED); if (pe->pe_subst == NULL) goto return_null; check_closing_paren: if (BUF[INDEX] == L'}') INDEX++; switch (pe->pe_type & PT_MASK) { case PT_MINUS: case PT_PLUS: break; case PT_ASSIGN: case PT_ERROR: assert(false); default: if (pe->pe_type & PT_NEST) break; /* make the variable expansion nested with the PT_MINUS flag * to avoid a possible "nounset" error. */ paramexp_T *pe2 = xmalloc(sizeof *pe2); pe2->pe_type = PT_MINUS; pe2->pe_name = pe->pe_name; pe2->pe_start = pe2->pe_end = pe2->pe_match = pe2->pe_subst = NULL; wordunit_T *nest = xmalloc(sizeof *nest); nest->next = NULL; nest->wu_type = WT_PARAM; nest->wu_param = pe2; pe->pe_type |= PT_NEST; pe->pe_nest = nest; break; } wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_PARAM; result->wu_param = pe; return result; syntax_error: paramfree(pe); result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_STRING; result->wu_string = escapefree( xwcsndup(&BUF[origindex], INDEX - origindex), NULL); return result; return_null: paramfree(pe); return NULL; } /* Parses an arithmetic expansion. * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. */ wordunit_T *cparse_arith(void) { size_t startindex = INDEX; assert(BUF[INDEX ] == L'$'); assert(BUF[INDEX + 1] == L'('); unsigned nestparen = 0; INDEX += 2; for (;;) { if (BUF[INDEX] != L'\0' && is_arith_delimiter(BUF[INDEX])) { switch (BUF[INDEX++]) { case L'(': nestparen++; break; case L')': if (nestparen == 0) goto return_content; nestparen--; break; } } else { wordunit_T *w = cparse_word(is_arith_delimiter, TT_NONE, CTXT_ARITH); if (w == NULL) { empty_pwords(); return NULL; } wordfree(w); } } return_content:; wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_STRING; result->wu_string = xwcsndup(&BUF[startindex], INDEX - startindex); return result; } /* Parses a command substitution enclosed by "$( )". * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. */ wordunit_T *cparse_cmdsubst_in_paren(void) { size_t startindex = INDEX; assert(BUF[INDEX ] == L'$'); assert(BUF[INDEX + 1] == L'('); INDEX += 2; if (cparse_commands()) { return NULL; } else { assert(BUF[INDEX] == L')'); INDEX++; wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_STRING; result->wu_string = xwcsndup(&BUF[startindex], INDEX - startindex); return result; } } /* Parses a command substitution enclosed by backquotes. * If the parser reached the end of the input string, the return value is NULL * and the result is saved in `pi->ctxt'. */ wordunit_T *cparse_cmdsubst_in_backquote(void) { size_t startindex = INDEX; size_t endindex; assert(BUF[INDEX] == L'`'); INDEX++; endindex = INDEX; for (;;) { switch (BUF[endindex++]) { case L'\0': goto parse_inside; case L'`': goto return_content; case L'\\': if (BUF[endindex] != L'\0') endindex++; break; } } parse_inside: while (!cparse_commands()) INDEX++; return NULL; return_content: INDEX = endindex; wordunit_T *result = xmalloc(sizeof *result); result->next = NULL; result->wu_type = WT_STRING; result->wu_string = escapefree(xwcsndup(&BUF[startindex], endindex - startindex), NULL); return result; } bool is_slash_or_closing_brace(wchar_t c) { return c == L'/' || c == L'}' || c == L'\0'; } bool is_closing_brace(wchar_t c) { return c == L'}' || c == L'\0'; } bool is_closing_bracket(wchar_t c) { return c == L']' || c == L'\0'; } bool is_arith_delimiter(wchar_t c) { switch (c) { case L'\0': return true; case L'$': case L'`': case L'"': case L'\'': case L'\\': case L'_': return false; default: return !iswalnum(c); } } /* Remove brace expansion in the specified string and returns the last result of * expansion. * For example, remove_braceexpand("a{1,2{b,c}2{d,e") = "a2c2e". * The string is modified in place. * Returns true iff expansion is unclosed. */ bool remove_braceexpand(wchar_t *s) { bool unclosed = false; xwcsbuf_T buf; wb_init(&buf); wb_cat(&buf, s); for (size_t i = 0; i < buf.length; ) { switch (buf.contents[i]) { case L'{': unclosed = remove_braceexpand_inner(&buf, &i); break; case L'\\': i += 2; break; default: i++; break; } } assert(buf.length <= wcslen(s)); wmemcpy(s, buf.contents, buf.length + 1); wb_destroy(&buf); return unclosed; } bool remove_braceexpand_inner(xwcsbuf_T *buf, size_t *index) { bool foundcomma = false; size_t i = *index; size_t leftbraceindex = i; assert(buf->contents[leftbraceindex] == L'{'); i++; while (i < buf->length) { switch (buf->contents[i]) { case L'{': remove_braceexpand_inner(buf, &i); break; case L',': foundcomma = true; wb_remove(buf, leftbraceindex, i - leftbraceindex + 1); i = leftbraceindex; break; case L'}': if (foundcomma) /* remove right brace */ wb_remove(buf, i, 1); else i++; *index = i; return false; case L'\\': i += 2; break; default: i++; break; } } if (!foundcomma) /* remove left brace */ wb_remove(buf, leftbraceindex, 1); *index = buf->length; return true; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/editing.c0000644000175000017500000031744312154557026016146 0ustar magicantmagicant/* Yash: yet another shell */ /* editing.c: main editing module */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "editing.h" #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include #include #include #include #if YASH_ENABLE_ALIAS # include "../alias.h" #endif #include "../exec.h" #include "../expand.h" #include "../history.h" #include "../job.h" #include "../option.h" #include "../path.h" #include "../plist.h" #include "../redir.h" #include "../strbuf.h" #include "../util.h" #include "../xfnmatch.h" #include "../yash.h" #include "complete.h" #include "display.h" #include "keymap.h" #include "lineedit.h" #include "terminfo.h" /* The type of pairs of a command and an argument. */ struct le_command_T { le_command_func_T *func; wchar_t arg; }; /* The main buffer where the command line is edited. */ xwcsbuf_T le_main_buffer; /* The position of the cursor on the command line. * 0 <= le_main_index <= le_main_buffer.length */ size_t le_main_index; /* The history entry that is being edited in the main buffer now. * When we're editing no history entry, `main_history_entry' is `Histlist'. */ static const histlink_T *main_history_entry; /* The original value of `main_history_entry', converted into a wide string. */ static wchar_t *main_history_value; /* The direction of currently performed command history search. */ enum le_search_direction_T le_search_direction; /* The type of currently performed command history search. */ enum le_search_type_T le_search_type; /* Supplementary buffer used in command history search. * When search is not being performed, `le_search_buffer.contents' is NULL. */ xwcsbuf_T le_search_buffer; /* The search result for the current value of `le_search_buffer'. * If there is no match, `le_search_result' is `Histlist'. */ const histlink_T *le_search_result; /* The search string and the direction of the last search. */ static struct { enum le_search_direction_T direction; enum le_search_type_T type; wchar_t *value; } last_search; /* The last executed command and the currently executing command. */ static struct le_command_T last_command, current_command; /* The type of motion expecting commands. */ enum motion_expect_command_T { MEC_UPPERCASE = 1 << 0, /* convert the text to upper case */ MEC_LOWERCASE = 1 << 1, /* convert the text to lower case */ MEC_SWITCHCASE = MEC_UPPERCASE | MEC_LOWERCASE, /* switch case of text */ MEC_CASEMASK = MEC_SWITCHCASE, MEC_TOSTART = 1 << 2, /* move cursor to the beginning of the region */ MEC_TOEND = 1 << 3, /* move cursor to the end of the region */ MEC_MOVE = MEC_TOSTART | MEC_TOEND, /* move cursor to motion end */ MEC_CURSORMASK = MEC_MOVE, /* If none of MEC_TOSTART, MEC_TOEND, and MEC_MOVE is specified, the cursor * is not moved unless MEC_DELETE is specified. */ MEC_COPY = 1 << 4, /* copy the text to the kill ring */ MEC_DELETE = 1 << 5, /* delete the text */ MEC_INSERT = 1 << 6, /* go to insert mode */ MEC_KILL = MEC_COPY | MEC_DELETE, MEC_CHANGE = MEC_DELETE | MEC_INSERT, MEC_COPYCHANGE = MEC_KILL | MEC_INSERT, }; /* The state in which a command is executed. */ struct state_T { struct { /* When count is not specified, `sign' and `abs' are 0. * Otherwise, `sign' is 1 or -1. * When the negative sign is specified but digits are not, `abs' is 0.*/ int sign; unsigned abs; int multiplier; } count; enum motion_expect_command_T pending_command_motion; le_command_func_T *pending_command_char; }; #define COUNT_ABS_MAX 999999999 /* The current state. */ static struct state_T state; /* The last executed editing command and the then state. * Valid iff `.command.func' is non-null. */ static struct { struct le_command_T command; struct state_T state; } last_edit_command; /* The last executed find/till command. */ /* `last_find_command' is valid iff `.func' is non-null. */ static struct le_command_T last_find_command; /* The editing mode before the mode is changed to LE_MODE_CHAR_EXPECT/SEARCH. * When the char-expecting/search command finishes, the mode is restored to * this mode. */ static le_mode_id_T savemode; /* When starting the overwrite mode, the then `le_main_buffer' contents and * length are saved in this structure. The values are kept so that the original * contents can be restored when the user hits backspace. When the user leaves * the overwrite mode, `contents' is freed and set to NULL. */ static struct { wchar_t *contents; size_t length; } overwrite_save_buffer; /* History of the edit line between editing commands. */ static plist_T undo_history; /* Index of the current state in the history. * If the current state is the newest, the index is `undo_history.length'. */ static size_t undo_index; /* The history entry that is saved in the undo history. */ static const histlink_T *undo_history_entry; /* The index that is to be the value of the `index' member of the next undo * history entry. */ static size_t undo_save_index; /* Structure of history entries */ struct undo_history { size_t index; /* index of the cursor */ wchar_t contents[]; /* contents of the edit line */ }; #define KILL_RING_SIZE 32 /* must be power of 2 */ /* The kill ring */ static wchar_t *kill_ring[KILL_RING_SIZE]; /* The index of the element to which next killed string is assigned. */ static size_t next_kill_index = 0; /* The index of the last put element. */ static size_t last_put_elem = 0; /* < KILL_RING_SIZE */ /* The position and length of the last put string. */ static size_t last_put_range_start, last_put_range_length; /* Set to true if the next completion command should restart completion from * scratch. */ static bool reset_completion; /* The next value of `reset_completion'. */ static bool next_reset_completion; static void reset_state(void); static void reset_count(void); static int get_count(int default_value) __attribute__((pure)); static void save_current_edit_command(void); static void save_current_find_command(void); static void save_undo_history(void); static void maybe_save_undo_history(void); static void exec_motion_command(size_t new_index, bool inclusive); static void set_motion_expect_command(enum motion_expect_command_T cmd); static void exec_motion_expect_command( enum motion_expect_command_T cmd, le_command_func_T motion); static void exec_motion_expect_command_line(enum motion_expect_command_T cmd); static void exec_motion_expect_command_all(void); static void add_to_kill_ring(const wchar_t *s, size_t n) __attribute__((nonnull)); static void set_char_expect_command(le_command_func_T cmd) __attribute__((nonnull)); static void set_overwriting(bool overwriting); static inline bool is_overwriting(void) __attribute__((pure)); static void restore_overwritten_buffer_contents( size_t start_index, size_t end_index); static void set_search_mode(le_mode_id_T mode, enum le_search_direction_T dir); static void to_upper_case(wchar_t *s, size_t n) __attribute__((nonnull)); static void to_lower_case(wchar_t *s, size_t n) __attribute__((nonnull)); static void switch_case(wchar_t *s, size_t n) __attribute__((nonnull)); static void set_mode(le_mode_id_T newmode, bool overwrite); static void redraw_all(bool clear); static bool alert_if_first(void); static bool alert_if_last(void); static void move_cursor_forward_char(int offset); static void move_cursor_backward_char(int offset); static void move_cursor_forward_bigword(int count); static void move_cursor_backward_bigword(int count); static size_t next_bigword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static size_t next_end_of_bigword_index( const wchar_t *s, size_t i, bool progress) __attribute__((nonnull)); static size_t previous_bigword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static void move_cursor_forward_semiword(int count); static void move_cursor_backward_semiword(int count); static size_t next_semiword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static size_t next_end_of_semiword_index( const wchar_t *s, size_t i, bool progress) __attribute__((nonnull)); static size_t previous_semiword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static void move_cursor_forward_viword(int count); static inline bool need_cw_treatment(void) __attribute__((pure)); static void move_cursor_backward_viword(int count); static size_t next_viword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static size_t next_end_of_viword_index( const wchar_t *s, size_t i, bool progress) __attribute__((nonnull)); static size_t previous_viword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static void move_cursor_forward_emacsword(int count); static void move_cursor_backward_emacsword(int count); static size_t next_emacsword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static size_t previous_emacsword_index(const wchar_t *s, size_t i) __attribute__((nonnull)); static void find_char(wchar_t c); static void find_char_rev(wchar_t c); static void till_char(wchar_t c); static void till_char_rev(wchar_t c); static void exec_find(wchar_t c, int count, bool till); static size_t find_nth_occurence(wchar_t c, int n); static void put_killed_string(bool after_cursor, bool cursor_on_last_char); static void insert_killed_string( bool after_cursor, bool cursor_on_last_char, size_t index); static void cancel_undo(int offset); static void check_reset_completion(void); static void vi_replace_char(wchar_t c); static void vi_exec_alias(wchar_t c); struct xwcsrange { const wchar_t *start, *end; }; static struct xwcsrange get_next_bigword(const wchar_t *s) __attribute__((nonnull)); static struct xwcsrange get_prev_bigword( const wchar_t *beginning, const wchar_t *s) __attribute__((nonnull)); static void replace_horizontal_space(bool deleteafter, const wchar_t *s) __attribute__((nonnull)); static void go_to_history_absolute( const histlink_T *l, enum le_search_type_T curpos) __attribute__((nonnull)); static void go_to_history_relative(int offset, enum le_search_type_T curpos); static void go_to_history(const histlink_T *l, enum le_search_type_T curpos) __attribute__((nonnull)); static bool need_update_last_search_value(void) __attribute__((pure)); static void update_search(void); static void perform_search(const wchar_t *pattern, enum le_search_direction_T dir, enum le_search_type_T type) __attribute__((nonnull)); static void search_again(enum le_search_direction_T dir); static void beginning_search(enum le_search_direction_T dir); static inline bool beginning_search_check_go_to_history(const wchar_t *prefix) __attribute__((nonnull,pure)); #define ALERT_AND_RETURN_IF_PENDING \ do if (state.pending_command_motion != MEC_MOVE) \ { cmd_alert(L'\0'); return; } \ while (0) /* Initializes the editing module before starting editing. */ void le_editing_init(void) { wb_init(&le_main_buffer); le_main_index = 0; main_history_entry = Histlist; main_history_value = xwcsdup(L""); switch (shopt_lineedit) { case SHOPT_VI: le_set_mode(LE_MODE_VI_INSERT); break; case SHOPT_EMACS: le_set_mode(LE_MODE_EMACS); break; default: assert(false); } last_command.func = 0; last_command.arg = L'\0'; start_using_history(); pl_init(&undo_history); undo_index = 0; undo_save_index = le_main_index; undo_history_entry = Histlist; save_undo_history(); reset_completion = true; reset_state(); set_overwriting(false); } /* Finalizes the editing module when editing is finished. * Returns the content of the main buffer, which must be freed by the caller. */ wchar_t *le_editing_finalize(void) { assert(le_search_buffer.contents == NULL); plfree(pl_toary(&undo_history), free); le_complete_cleanup(); end_using_history(); free(main_history_value); wb_wccat(&le_main_buffer, L'\n'); return wb_towcs(&le_main_buffer); } /* Invokes the specified command. */ void le_invoke_command(le_command_func_T *cmd, wchar_t arg) { current_command.func = cmd; current_command.arg = arg; next_reset_completion = true; cmd(arg); last_command = current_command; reset_completion |= next_reset_completion; if (LE_CURRENT_MODE == LE_MODE_VI_COMMAND) if (le_main_index > 0 && le_main_index == le_main_buffer.length) le_main_index--; } /* Resets `state'. */ void reset_state(void) { reset_count(); state.pending_command_motion = MEC_MOVE; state.pending_command_char = 0; } /* Resets `state.count'. */ void reset_count(void) { state.count.sign = 0; state.count.abs = 0; state.count.multiplier = 1; } /* Returns the count value. * If the count is not set, returns the `default_value'. */ int get_count(int default_value) { long long result; if (state.count.sign == 0) result = (long long) default_value * state.count.multiplier; else if (state.count.sign < 0 && state.count.abs == 0) result = (long long) -state.count.multiplier; else result = (long long) state.count.abs * state.count.sign * state.count.multiplier; if (result < -COUNT_ABS_MAX) result = -COUNT_ABS_MAX; else if (result > COUNT_ABS_MAX) result = COUNT_ABS_MAX; return result; } /* Saves the currently executing command and the current state in * `last_edit_command' if we are not redoing and the mode is not "vi insert". */ void save_current_edit_command(void) { if (current_command.func != cmd_redo && LE_CURRENT_MODE != LE_MODE_VI_INSERT) { last_edit_command.command = current_command; last_edit_command.state = state; } } /* Saves the currently executing command and the current state in * `last_find_command' if we are not redoing/refinding. */ void save_current_find_command(void) { if (current_command.func != cmd_refind_char && current_command.func != cmd_refind_char_rev && current_command.func != cmd_redo) last_find_command = current_command; } /* Saves the current contents of the edit line to the undo history. * History entries at the current `undo_index' and newer are removed before * saving the current. If `undo_history_entry' is different from * `main_history_entry', all undo history entries are removed. */ void save_undo_history(void) { for (size_t i = undo_index; i < undo_history.length; i++) free(undo_history.contents[i]); pl_remove(&undo_history, undo_index, SIZE_MAX); struct undo_history *e = xmallocs(sizeof *e, le_main_buffer.length + 1, sizeof *e->contents); e->index = le_main_index; wcscpy(e->contents, le_main_buffer.contents); pl_add(&undo_history, e); assert(undo_index == undo_history.length - 1); undo_history_entry = main_history_entry; } /* Calls `save_undo_history' if the current contents of the edit line is not * saved. */ void maybe_save_undo_history(void) { assert(undo_index <= undo_history.length); size_t save_undo_save_index = undo_save_index; undo_save_index = le_main_index; if (undo_history_entry == main_history_entry) { if (undo_index < undo_history.length) { struct undo_history *h = undo_history.contents[undo_index]; if (wcscmp(le_main_buffer.contents, h->contents) == 0) { /* The contents of the main buffer is the same as saved in the * history. Just save the index. */ h->index = le_main_index; return; } undo_index++; } } else { if (wcscmp(le_main_buffer.contents, main_history_value) == 0) return; /* The contents of the buffer has been changed from the value of the * history entry, but it's not yet saved in the undo history. We first * save the original history value and then save the current buffer * contents. */ struct undo_history *h; pl_clear(&undo_history, free); h = xmallocs(sizeof *h, wcslen(main_history_value) + 1, sizeof *h->contents); assert(save_undo_save_index <= wcslen(main_history_value)); h->index = save_undo_save_index; wcscpy(h->contents, main_history_value); pl_add(&undo_history, h); undo_index = 1; } save_undo_history(); } /* Applies the currently pending editing command to the range between the * current cursor index and the specified index. If no editing command is * pending, simply moves the cursor to the specified index. */ /* This function is used for all cursor-moving commands, even when not in the * vi mode. */ void exec_motion_command(size_t new_index, bool inclusive) { assert(le_main_index <= le_main_buffer.length); assert(new_index <= le_main_buffer.length); size_t old_index = le_main_index; size_t start_index, end_index; if (old_index <= new_index) start_index = old_index, end_index = new_index; else start_index = new_index, end_index = old_index; if (inclusive && end_index < le_main_buffer.length) end_index++; enum motion_expect_command_T mec = state.pending_command_motion; /* don't save undo history when repeating backspace */ bool repeated_backspace = (mec & MEC_DELETE) && (new_index + 1 == old_index) && current_command.func == cmd_backward_delete_char && last_command.func == cmd_backward_delete_char; if (!repeated_backspace) maybe_save_undo_history(); if (mec & MEC_COPY) { add_to_kill_ring(&le_main_buffer.contents[start_index], end_index - start_index); } switch (mec & MEC_CASEMASK) { case MEC_UPPERCASE: to_upper_case(&le_main_buffer.contents[start_index], end_index - start_index); break; case MEC_LOWERCASE: to_lower_case(&le_main_buffer.contents[start_index], end_index - start_index); break; case MEC_SWITCHCASE: switch_case(&le_main_buffer.contents[start_index], end_index - start_index); break; } switch (mec & MEC_CURSORMASK) { case MEC_TOSTART: le_main_index = start_index; break; case MEC_TOEND: le_main_index = end_index; break; case MEC_MOVE: le_main_index = new_index; break; } if (mec & MEC_DELETE) { save_current_edit_command(); if (!is_overwriting() || old_index <= new_index) wb_remove(&le_main_buffer, start_index, end_index - start_index); else restore_overwritten_buffer_contents(start_index, end_index); le_main_index = start_index; } if (mec & MEC_INSERT) { le_set_mode(LE_MODE_VI_INSERT); set_overwriting(false); } reset_state(); } /* Sets the specified motion expecting command as pending. * If the command is already pending, the command is executed on the whole * line. */ void set_motion_expect_command(enum motion_expect_command_T cmd) { if (state.pending_command_motion == MEC_MOVE) { state.count.multiplier = get_count(1); state.count.sign = 0; state.count.abs = 0; state.pending_command_motion = cmd; } else { if (state.pending_command_motion == cmd) exec_motion_expect_command_all(); else cmd_alert(L'\0'); } } /* Executes the specified motion expecting command with the specified motion * command. */ void exec_motion_expect_command( enum motion_expect_command_T cmd, le_command_func_T motion) { if (current_command.func != cmd_redo) ALERT_AND_RETURN_IF_PENDING; state.pending_command_motion = cmd; motion(L'\0'); } /* Executes the specified motion expecting command from the beginning to the end * of the line. */ void exec_motion_expect_command_line(enum motion_expect_command_T cmd) { if (current_command.func != cmd_redo) ALERT_AND_RETURN_IF_PENDING; state.pending_command_motion = cmd; exec_motion_expect_command_all(); } /* Executes the currently pending motion expecting command from the beginning to * the end of the line. */ void exec_motion_expect_command_all(void) { size_t save_index = le_main_index; enum motion_expect_command_T save_pending = state.pending_command_motion; le_main_index = 0; cmd_end_of_line(L'\0'); if (!(save_pending & (MEC_DELETE | MEC_CURSORMASK))) le_main_index = save_index; } /* Adds the specified string to the kill ring. * The maximum number of characters that are added is specified by `n'. */ void add_to_kill_ring(const wchar_t *s, size_t n) { if (n > 0 && s[0] != L'\0') { free(kill_ring[next_kill_index]); kill_ring[next_kill_index] = xwcsndup(s, n); next_kill_index = (next_kill_index + 1) % KILL_RING_SIZE; } } /* Sets the editing mode to "char expect" and the pending command to `cmd'. * The current editing mode is saved in `savemode'. */ void set_char_expect_command(le_command_func_T cmd) { savemode = LE_CURRENT_MODE; le_set_mode(LE_MODE_CHAR_EXPECT); state.pending_command_char = cmd; } /* Enables or disables the overwrite mode. */ void set_overwriting(bool overwrite) { free(overwrite_save_buffer.contents); if (overwrite) { overwrite_save_buffer.contents = xwcsdup(le_main_buffer.contents); overwrite_save_buffer.length = le_main_buffer.length; } else { overwrite_save_buffer.contents = NULL; } } /* Returns true iff the overwrite mode is active. */ bool is_overwriting(void) { return overwrite_save_buffer.contents != NULL; } /* Restores the main buffer contents that were overwritten in the current * overwrite mode. The caller must adjust `le_main_index' because this function * may remove some characters from `le_main_buffer'. */ void restore_overwritten_buffer_contents(size_t start_index, size_t end_index) { size_t mid_index; if (overwrite_save_buffer.length < start_index) mid_index = start_index; else if (overwrite_save_buffer.length > end_index) mid_index = end_index; else mid_index = overwrite_save_buffer.length; /* Restore contents from `start_index' to `mid_index' */ wmemcpy(&le_main_buffer.contents[start_index], &overwrite_save_buffer.contents[start_index], mid_index - start_index); /* Contents from `mid_index' to `end_index' were actually not overwritten * but appended, so they should be removed. */ wb_remove(&le_main_buffer, mid_index, end_index - mid_index); } /* Starts command history search by setting the editing mode to `mode' with * the specified direction `dir'. `mode' must be either LE_MODE_VI_SEARCH or * LE_MODE_EMACS_SEARCH. * The current editing mode is saved in `savemode'. */ void set_search_mode(le_mode_id_T mode, enum le_search_direction_T dir) { le_complete_cleanup(); savemode = LE_CURRENT_MODE; le_set_mode(mode); le_search_direction = dir; switch (mode) { case LE_MODE_VI_SEARCH: le_search_type = SEARCH_VI; break; case LE_MODE_EMACS_SEARCH: le_search_type = SEARCH_EMACS; break; default: assert(false); } wb_init(&le_search_buffer); update_search(); } /* Converts the first `n' characters of string `s' to upper case. * The string must be at least `n' characters long. */ void to_upper_case(wchar_t *s, size_t n) { for (size_t i = 0; i < n; i++) s[i] = towupper(s[i]); } /* Converts the first `n' characters of string `s' to lower case. * The string must be at least `n' characters long. */ void to_lower_case(wchar_t *s, size_t n) { for (size_t i = 0; i < n; i++) s[i] = towlower(s[i]); } /* Switches case of the first `n' characters of string `s'. * The string must be at least `n' characters long. */ void switch_case(wchar_t *s, size_t n) { for (size_t i = 0; i < n; i++) { wchar_t c = s[i]; s[i] = iswlower(c) ? towupper(c) : towlower(c); } } /********** Basic Commands **********/ /* Does nothing. */ void cmd_noop(wchar_t c __attribute__((unused))) { next_reset_completion = false; reset_state(); } /* Alerts. */ void cmd_alert(wchar_t c __attribute__((unused))) { lebuf_print_alert(true); reset_state(); } /* Inserts the character argument into the buffer. * If the count is set, inserts `count' times. * If `is_overwriting()' is true, overwrites the character instead of inserting. */ void cmd_self_insert(wchar_t c) { ALERT_AND_RETURN_IF_PENDING; if (c == L'\0') { cmd_alert(L'\0'); return; } int count = get_count(1); while (--count >= 0) if (is_overwriting() && le_main_index < le_main_buffer.length) le_main_buffer.contents[le_main_index++] = c; else wb_ninsert_force(&le_main_buffer, le_main_index++, &c, 1); reset_state(); } /* Inserts the tab character. */ void cmd_insert_tab(wchar_t c __attribute__((unused))) { cmd_self_insert(L'\t'); } /* Sets the `le_next_verbatim' flag. * The next character will be input to the main buffer even if it's a special * character. */ void cmd_expect_verbatim(wchar_t c __attribute__((unused))) { le_next_verbatim = true; } /* Adds the specified digit to the accumulating argument. */ /* If `c' is not a digit or a hyphen, does nothing. */ void cmd_digit_argument(wchar_t c) { if (L'0' <= c && c <= L'9') { if (state.count.abs > COUNT_ABS_MAX / 10) { cmd_alert(L'\0'); // argument too large return; } if (state.count.sign == 0) state.count.sign = 1; state.count.abs = state.count.abs * 10 + (unsigned) (c - L'0'); } else if (c == L'-') { if (state.count.sign == 0) state.count.sign = -1; else state.count.sign = -state.count.sign; } next_reset_completion = false; } /* If the count is not set, moves the cursor to the beginning of the line. * Otherwise, adds the given digit to the count. */ void cmd_bol_or_digit(wchar_t c) { if (state.count.sign == 0) cmd_beginning_of_line(c); else cmd_digit_argument(c); } /* Accepts the current line. * `le_editstate' is set to LE_EDITSTATE_DONE to induce line-editing to * terminate. * If history search is currently active, the search result is accepted. If the * search was failing, the line is not accepted. */ void cmd_accept_line(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; if (le_search_buffer.contents == NULL) { le_editstate = LE_EDITSTATE_DONE; reset_state(); } else { if (le_search_result != Histlist) le_editstate = LE_EDITSTATE_DONE; cmd_srch_accept_search(L'\0'); } } /* Aborts the current line. * `le_editstate' is set to LE_EDITSTATE_INTERRUPTED to induce line-editing to * terminate. */ void cmd_abort_line(wchar_t c __attribute__((unused))) { cmd_srch_abort_search(L'\0'); le_editstate = LE_EDITSTATE_INTERRUPTED; reset_state(); } /* Sets `le_editstate' to LE_EDITSTATE_ERROR. * The `le_readline' function will return INPUT_EOF. */ void cmd_eof(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; cmd_srch_abort_search(L'\0'); le_editstate = LE_EDITSTATE_ERROR; reset_state(); } /* If the edit line is empty, sets `le_editstate' to LE_EDITSTATE_ERROR (return * EOF). Otherwise, alerts. */ void cmd_eof_if_empty(wchar_t c __attribute__((unused))) { if (le_main_buffer.length == 0) cmd_eof(L'\0'); else cmd_alert(L'\0'); } /* If the edit line is empty, sets `le_editstate' to LE_EDITSTATE_ERROR (return * EOF). Otherwise, deletes the character under the cursor. */ void cmd_eof_or_delete(wchar_t c __attribute__((unused))) { if (le_main_buffer.length == 0) cmd_eof(L'\0'); else cmd_delete_char(L'\0'); } /* Inserts a hash sign ('#') at the beginning of the line and accepts the line. * If any count is set and the line already begins with a hash sign, the hash * sign is removed rather than added. The line is accepted anyway. */ void cmd_accept_with_hash(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; if (state.count.sign == 0 || le_main_buffer.contents[0] != L'#') wb_insert(&le_main_buffer, 0, L"#"); else wb_remove(&le_main_buffer, 0, 1); le_main_index = 0; cmd_accept_line(L'\0'); } /* Changes the editing mode to "vi insert". */ void cmd_setmode_viinsert(wchar_t c __attribute__((unused))) { set_mode(LE_MODE_VI_INSERT, false); } /* Changes the editing mode to "vi command". */ void cmd_setmode_vicommand(wchar_t c __attribute__((unused))) { set_mode(LE_MODE_VI_COMMAND, false); } /* Changes the editing mode to "emacs". */ void cmd_setmode_emacs(wchar_t c __attribute__((unused))) { set_mode(LE_MODE_EMACS, false); } /* Changes the editing mode to the specified one. */ void set_mode(le_mode_id_T newmode, bool overwrite) { ALERT_AND_RETURN_IF_PENDING; maybe_save_undo_history(); if (LE_CURRENT_MODE == LE_MODE_VI_INSERT && newmode == LE_MODE_VI_COMMAND) if (le_main_index > 0) le_main_index--; le_set_mode(newmode); set_overwriting(overwrite); reset_state(); } /* Executes the currently pending char-expecting command. */ void cmd_expect_char(wchar_t c) { if (!state.pending_command_char) { cmd_alert(L'\0'); return; } current_command.func = state.pending_command_char; current_command.arg = c; state.pending_command_char(c); } /* Cancels the currently pending char-expecting command. */ void cmd_abort_expect_char(wchar_t c __attribute__((unused))) { if (!state.pending_command_char) { cmd_alert(L'\0'); return; } le_set_mode(savemode); reset_state(); } /* Redraws everything. */ void cmd_redraw_all(wchar_t c __attribute__((unused))) { redraw_all(false); } /* Clears the screen and redraws everything at the top of the screen. */ void cmd_clear_and_redraw_all(wchar_t c __attribute__((unused))) { redraw_all(true); } void redraw_all(bool clear) { next_reset_completion = false; le_display_clear(clear); le_restore_terminal(); le_setupterm(false); le_set_terminal(); } /********** Motion Commands **********/ /* Invokes `cmd_alert' and returns true if the cursor is on the first character. */ bool alert_if_first(void) { if (le_main_index > 0) return false; cmd_alert(L'\0'); return true; } /* Invokes `cmd_alert' and returns true if the cursor is on the last character. */ bool alert_if_last(void) { if (LE_CURRENT_MODE == LE_MODE_VI_COMMAND) { if (state.pending_command_motion != MEC_MOVE) return false; if (le_main_buffer.length > 0 && le_main_index < le_main_buffer.length - 1) return false; } else { if (le_main_index < le_main_buffer.length) return false; } cmd_alert(L'\0'); return true; } /* Moves forward one character (or `count' characters if the count is set). */ /* exclusive motion command */ void cmd_forward_char(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_forward_char(count); else move_cursor_backward_char(-count); } /* Moves backward one character (or `count' characters if the count is set). */ /* exclusive motion command */ void cmd_backward_char(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_backward_char(count); else move_cursor_forward_char(-count); } /* Moves the cursor forward by `offset'. The `offset' must not be negative. */ void move_cursor_forward_char(int offset) { assert(offset >= 0); if (alert_if_last()) return; #if COUNT_ABS_MAX > SIZE_MAX if (offset > SIZE_MAX) offset = SIZE_MAX; #endif size_t new_index; if (le_main_buffer.length - le_main_index < (size_t) offset) new_index = le_main_buffer.length; else new_index = le_main_index + offset; exec_motion_command(new_index, false); } /* Moves the cursor backward by `offset'. The `offset' must not be negative. */ void move_cursor_backward_char(int offset) { assert(offset >= 0); if (alert_if_first()) return; size_t new_index; #if COUNT_ABS_MAX > SIZE_MAX if ((int) le_main_index <= offset) #else if (le_main_index <= (size_t) offset) #endif new_index = 0; else new_index = le_main_index - offset; exec_motion_command(new_index, false); } /* Moves forward one bigword (or `count' bigwords if the count is set). */ /* exclusive motion command */ void cmd_forward_bigword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_forward_bigword(count); else move_cursor_backward_bigword(-count); } /* Moves the cursor to the end of the current bigword (or the next bigword if * already at the end). If the count is set, moves to the end of `count'th * bigword. */ /* inclusive motion command */ void cmd_end_of_bigword(wchar_t c __attribute__((unused))) { if (alert_if_last()) return; int count = get_count(1); size_t new_index = le_main_index; while (--count >= 0 && new_index < le_main_buffer.length) new_index = next_end_of_bigword_index( le_main_buffer.contents, new_index, true); exec_motion_command(new_index, true); } /* Moves backward one bigword (or `count' bigwords if the count is set). */ /* exclusive motion command */ void cmd_backward_bigword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_backward_bigword(count); else move_cursor_forward_bigword(-count); } /* Moves the cursor forward `count' bigwords. * If `count' is negative, the cursor is not moved. */ void move_cursor_forward_bigword(int count) { if (alert_if_last()) return; size_t new_index = le_main_index; if (!need_cw_treatment()) { while (count-- > 0 && new_index < le_main_buffer.length) new_index = next_bigword_index(le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } else { while (count > 1 && new_index < le_main_buffer.length) { new_index = next_bigword_index(le_main_buffer.contents, new_index); count--; } if (count > 0 && new_index < le_main_buffer.length) { new_index = next_end_of_bigword_index( le_main_buffer.contents, new_index, false); } exec_motion_command(new_index, true); } } /* Moves the cursor backward `count' bigwords. * If `count' is negative, the cursor is not moved. */ void move_cursor_backward_bigword(int count) { if (alert_if_first()) return; size_t new_index = le_main_index; while (count-- > 0 && new_index > 0) new_index = previous_bigword_index(le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } /* Returns the index of the next bigword in string `s', counted from index `i'. * The return value is greater than `i' unless `s[i]' is a null character. */ /* A bigword is a sequence of non-blank characters. */ size_t next_bigword_index(const wchar_t *s, size_t i) { while (s[i] != L'\0' && !iswblank(s[i])) i++; while (s[i] != L'\0' && iswblank(s[i])) i++; return i; } /* Returns the index of the end of the current bigword in string `s', counted * from index `i'. If `i' is at the end of the bigword and `progress' is true, * the end of the next bigword is returned. * The return value is greater than `i' unless `s[i]' is a null character. */ size_t next_end_of_bigword_index(const wchar_t *s, size_t i, bool progress) { const size_t init = i; start: if (s[i] == L'\0') return i; while (s[i] != L'\0' && iswblank(s[i])) i++; while (s[i] != L'\0' && !iswblank(s[i])) i++; i--; if (i > init || !progress) { return i; } else { i++; goto start; } } /* Returns the index of the previous bigword in string `s', counted from index * `i'. The return value is less than `i' unless `i' is zero. */ size_t previous_bigword_index(const wchar_t *s, size_t i) { const size_t init = i; start: while (i > 0 && iswblank(s[i])) i--; while (i > 0 && !iswblank(s[i])) i--; if (i == 0) return i; i++; if (i < init) { return i; } else { i--; goto start; } } /* Moves forward one semiword (or `count' semiwords if the count is set). */ /* exclusive motion command */ void cmd_forward_semiword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_forward_semiword(count); else move_cursor_backward_semiword(-count); } /* Moves the cursor to the end of the current semiword (or the next semiword if * already at the end). If the count is set, moves to the end of the `count'th * semiword. */ /* inclusive motion command */ void cmd_end_of_semiword(wchar_t c __attribute__((unused))) { if (alert_if_last()) return; int count = get_count(1); size_t new_index = le_main_index; while (--count >= 0 && new_index < le_main_buffer.length) new_index = next_end_of_semiword_index( le_main_buffer.contents, new_index, true); exec_motion_command(new_index, true); } /* Moves backward one semiword (or `count' semiwords if the count is set). */ /* exclusive motion command */ void cmd_backward_semiword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_backward_semiword(count); else move_cursor_forward_semiword(-count); } /* Moves the cursor forward `count' semiwords. * If `count' is negative, the cursor is not moved. */ void move_cursor_forward_semiword(int count) { if (alert_if_last()) return; size_t new_index = le_main_index; if (!need_cw_treatment()) { while (count-- > 0 && new_index < le_main_buffer.length) new_index = next_semiword_index(le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } else { while (count > 1 && new_index < le_main_buffer.length) { new_index = next_semiword_index(le_main_buffer.contents, new_index); count--; } if (count > 0 && new_index < le_main_buffer.length) { new_index = next_end_of_semiword_index( le_main_buffer.contents, new_index, false); } exec_motion_command(new_index, true); } } /* Moves the cursor backward `count' semiwords. * If `count' is negative, the cursor is not moved. */ void move_cursor_backward_semiword(int count) { if (alert_if_first()) return; size_t new_index = le_main_index; while (count-- > 0 && new_index > 0) new_index = previous_semiword_index(le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } /* Returns the index of the next semiword in string `s', counted from index `i'. * The return value is greater than `i' unless `s[i]' is a null character. */ /* A "semiword" is a sequence of characters that are not or . */ size_t next_semiword_index(const wchar_t *s, size_t i) { while (s[i] != L'\0' && !iswblank(s[i]) && !iswpunct(s[i])) i++; while (s[i] != L'\0' && (iswblank(s[i]) || iswpunct(s[i]))) i++; return i; } /* Returns the index of the end of the current semiword in string `s', counted * from index `i'. If `i' is at the end of the semiword and `progress' is true, * the end of the next semiword is returned. * The return value is greater than `i' unless `s[i]' is a null character. */ size_t next_end_of_semiword_index(const wchar_t *s, size_t i, bool progress) { const size_t init = i; start: if (s[i] == L'\0') return i; while (s[i] != L'\0' && (iswblank(s[i]) || iswpunct(s[i]))) i++; while (s[i] != L'\0' && !iswblank(s[i]) && !iswpunct(s[i])) i++; i--; if (i > init || !progress) { return i; } else { i++; goto start; } } /* Returns the index of the previous semiword in string `s', counted from index * `i'. The return value is less than `i' unless `i' is zero. */ size_t previous_semiword_index(const wchar_t *s, size_t i) { const size_t init = i; start: while (i > 0 && (iswblank(s[i]) || iswpunct(s[i]))) i--; while (i > 0 && !iswblank(s[i]) && !iswpunct(s[i])) i--; if (i == 0) return i; i++; if (i < init) { return i; } else { i--; goto start; } } /* Moves forward one viword (or `count' viwords if the count is set). */ /* exclusive motion command */ void cmd_forward_viword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_forward_viword(count); else move_cursor_backward_viword(-count); } /* Moves the cursor to the end of the current viword (or the next viword if * already at the end). If the count is set, moves to the end of the `count'th * viword. */ /* inclusive motion command */ void cmd_end_of_viword(wchar_t c __attribute__((unused))) { if (alert_if_last()) return; int count = get_count(1); size_t new_index = le_main_index; while (--count >= 0 && new_index < le_main_buffer.length) new_index = next_end_of_viword_index( le_main_buffer.contents, new_index, true); exec_motion_command(new_index, true); } /* Moves backward one viword (or `count' viwords if the count is set). */ /* exclusive motion command */ void cmd_backward_viword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_backward_viword(count); else move_cursor_forward_viword(-count); } /* Moves the cursor forward `count' viwords. * If `count' is negative, the cursor is not moved. */ void move_cursor_forward_viword(int count) { if (alert_if_last()) return; size_t new_index = le_main_index; if (!need_cw_treatment()) { while (count-- > 0 && new_index < le_main_buffer.length) new_index = next_viword_index(le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } else { while (count > 1 && new_index < le_main_buffer.length) { new_index = next_viword_index(le_main_buffer.contents, new_index); count--; } if (count > 0 && new_index < le_main_buffer.length) { new_index = next_end_of_viword_index( le_main_buffer.contents, new_index, false); } exec_motion_command(new_index, true); } } /* Checks if we need a special treatment for the "cw" and "cW" commands. */ bool need_cw_treatment(void) { return (state.pending_command_motion & MEC_INSERT) && !iswblank(le_main_buffer.contents[le_main_index]); } /* Moves the cursor backward `count' viwords. * If `count' is negative, the cursor is not moved. */ void move_cursor_backward_viword(int count) { if (alert_if_first()) return; size_t new_index = le_main_index; while (count-- > 0 && new_index > 0) new_index = previous_viword_index(le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } /* Returns the index of the next viword in string `s', counted from index `i'. * The return value is greater than `i' unless `s[i]' is a null character. */ /* A viword is a sequence either of alphanumeric characters and underscores or * of other non-blank characters. */ size_t next_viword_index(const wchar_t *s, size_t i) { if (s[i] == L'_' || iswalnum(s[i])) { do i++; while (s[i] == L'_' || iswalnum(s[i])); if (!iswblank(s[i])) return i; } else { while (!iswblank(s[i])) { if (s[i] == L'\0') return i; i++; if (s[i] == L'_' || iswalnum(s[i])) return i; } } do i++; while (iswblank(s[i])); return i; } /* Returns the index of the end of the current viword in string `s', counted * from index `i'. * If `progress' is true: * If `i' is at the end of the viword, the end of the next viword is returned. * The return value is greater than `i' unless `s[i]' is a null character. * If `progress' is false: * If `i' is at the end of the viword, `i' is returned. */ size_t next_end_of_viword_index(const wchar_t *s, size_t i, bool progress) { const size_t init = i; start: while (iswblank(s[i])) i++; if (s[i] == L'\0') return i; if (s[i] == L'_' || iswalnum(s[i])) { do i++; while (s[i] == L'_' || iswalnum(s[i])); } else { do i++; while (s[i] != L'\0' && s[i] != L'_' && !iswblank(s[i]) && !iswalnum(s[i])); } i--; if (i > init || !progress) { return i; } else { i++; goto start; } } /* Returns the index of the previous viword in string `s', counted form index * `i'. The return value is less than `i' unless `i' is zero. */ size_t previous_viword_index(const wchar_t *s, size_t i) { const size_t init = i; start: while (i > 0 && iswblank(s[i])) i--; if (s[i] == L'_' || iswalnum(s[i])) { do { if (i == 0) return 0; i--; } while (s[i] == L'_' || iswalnum(s[i])); } else { do { if (i == 0) return 0; i--; } while (s[i] != L'_' && !iswblank(s[i]) && !iswalnum(s[i])); } i++; if (i < init) { return i; } else { i--; goto start; } } /* Moves to the next emacsword (or the `count'th emacsword if the count is set). */ /* exclusive motion command */ void cmd_forward_emacsword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_forward_emacsword(count); else move_cursor_backward_emacsword(-count); } /* Moves backward one emacsword (or `count' emacswords if the count is set). */ /* exclusive motion command */ void cmd_backward_emacsword(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count >= 0) move_cursor_backward_emacsword(count); else move_cursor_forward_emacsword(-count); } /* Moves the cursor to the `count'th emacsword. * If `count' is negative, the cursor is not moved. */ void move_cursor_forward_emacsword(int count) { size_t new_index = le_main_index; while (count-- > 0 && new_index < le_main_buffer.length) new_index = next_emacsword_index(le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } /* Moves the cursor backward `count'th emacsword. * If `count' is negative, the cursor is not moved. */ void move_cursor_backward_emacsword(int count) { size_t new_index = le_main_index; while (count-- > 0 && new_index > 0) new_index = previous_emacsword_index( le_main_buffer.contents, new_index); exec_motion_command(new_index, false); } /* Returns the index of the next emacsword in string `s', counted from index * `i'. The return value is greater than `i' unless `s[i]' is a null character. */ /* An emacsword is a sequence of non-alphanumeric characters. */ size_t next_emacsword_index(const wchar_t *s, size_t i) { while (s[i] != L'\0' && !iswalnum(s[i])) i++; while (s[i] != L'\0' && iswalnum(s[i])) i++; return i; } /* Returns the index of the previous emacsword in string `s', counted from * index `i'. The return value is less than `i' unless `i' is zero. */ /* An emacsword is a sequence of alphanumeric characters. */ size_t previous_emacsword_index(const wchar_t *s, size_t i) { const size_t init = i; start: while (i > 0 && !iswalnum(s[i])) i--; while (i > 0 && iswalnum(s[i])) i--; if (i == 0) return i; i++; if (i < init) { return i; } else { i--; goto start; } } /* Moves the cursor to the beginning of the line. */ /* exclusive motion command */ void cmd_beginning_of_line(wchar_t c __attribute__((unused))) { exec_motion_command(0, false); } /* Moves the cursor to the end of the line. */ /* inclusive motion command */ void cmd_end_of_line(wchar_t c __attribute__((unused))) { exec_motion_command(le_main_buffer.length, true); } /* Moves the cursor to the `count'th character in the edit line. * If the count is not set, moves to the beginning of the line. If the count is * negative, moves to the `le_main_buffer.length + count'th character. */ /* exclusive motion command */ void cmd_go_to_column(wchar_t c __attribute__((unused))) { int index = get_count(0); if (index >= 0) { if (index > 0) index--; #if COUNT_ABS_MAX > SIZE_MAX if (index > (int) le_main_buffer.length) #else if ((size_t) index > le_main_buffer.length) #endif index = le_main_buffer.length; } else { #if COUNT_ABS_MAX > SIZE_MAX if (-index > (int) le_main_buffer.length) #else if ((size_t) -index > le_main_buffer.length) #endif index = 0; else index = (int) le_main_buffer.length + index; } exec_motion_command((size_t) index, false); } /* Moves the cursor to the first non-blank character. */ /* exclusive motion command */ void cmd_first_nonblank(wchar_t c __attribute__((unused))) { size_t i = 0; while (c = le_main_buffer.contents[i], c != L'\0' && iswblank(c)) i++; exec_motion_command(i, false); } /* Sets the editing mode to "char expect" and the pending command to * `find_char'. */ void cmd_find_char(wchar_t c __attribute__((unused))) { maybe_save_undo_history(); set_char_expect_command(find_char); } /* Moves the cursor to the `count'th occurrence of `c' after the current * position. */ /* inclusive motion command */ void find_char(wchar_t c) { exec_find(c, get_count(1), false); } /* Sets the editing mode to "char expect" and the pending command to * `find_char_rev'. */ void cmd_find_char_rev(wchar_t c __attribute__((unused))) { maybe_save_undo_history(); set_char_expect_command(find_char_rev); } /* Moves the cursor to the `count'th occurrence of `c' before the current * position. */ /* exclusive motion command */ void find_char_rev(wchar_t c) { exec_find(c, -get_count(1), false); } /* Sets the editing mode to "char expect" and the pending command to * `till_char'. */ void cmd_till_char(wchar_t c __attribute__((unused))) { maybe_save_undo_history(); set_char_expect_command(till_char); } /* Moves the cursor to the character just before `count'th occurrence of `c' * after the current position. */ /* inclusive motion command */ void till_char(wchar_t c) { exec_find(c, get_count(1), true); } /* Sets the editing mode to "char expect" and the pending command to * `till_char_rev'. */ void cmd_till_char_rev(wchar_t c __attribute__((unused))) { maybe_save_undo_history(); set_char_expect_command(till_char_rev); } /* Moves the cursor to the character just after `count'th occurrence of `c' * before the current position. */ /* exclusive motion command */ void till_char_rev(wchar_t c) { exec_find(c, -get_count(1), true); } /* Executes the find/till command. */ void exec_find(wchar_t c, int count, bool till) { le_set_mode(savemode); save_current_find_command(); size_t new_index = find_nth_occurence(c, count); if (new_index == SIZE_MAX) goto error; if (till) { if (new_index >= le_main_index) { if (new_index == 0) goto error; new_index--; } else { if (new_index == le_main_buffer.length) goto error; new_index++; } } exec_motion_command(new_index, new_index >= le_main_index); return; error: cmd_alert(L'\0'); return; } /* Finds the position of the `n'th occurrence of `c' in the edit line from the * current position. Returns `SIZE_MAX' on failure (no such occurrence). */ size_t find_nth_occurence(wchar_t c, int n) { size_t i = le_main_index; if (n == 0) { return i; } else if (c == L'\0') { return SIZE_MAX; /* no such occurrence */ } else if (n >= 0) { while (n > 0 && i < le_main_buffer.length) { i++; if (le_main_buffer.contents[i] == c) n--; } } else { while (n < 0 && i > 0) { i--; if (le_main_buffer.contents[i] == c) n++; } } if (n != 0) return SIZE_MAX; /* no such occurrence */ else return i; } /* Redoes the last find/till command. */ void cmd_refind_char(wchar_t c __attribute__((unused))) { if (!last_find_command.func) { cmd_alert(L'\0'); return; } last_find_command.func(last_find_command.arg); } /* Redoes the last find/till command in the reverse direction. */ void cmd_refind_char_rev(wchar_t c __attribute__((unused))) { if (!last_find_command.func) { cmd_alert(L'\0'); return; } if (state.count.sign == 0) state.count.sign = -1, state.count.abs = 1; else if (state.count.sign >= 0) state.count.sign = -1; else state.count.sign = 1; last_find_command.func(last_find_command.arg); } /********** Editing Commands **********/ /* Removes the character under the cursor. * If the count is set, `count' characters are killed. */ void cmd_delete_char(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_forward_char); } /* Removes the bigword after the cursor. * If the count is set, `count' bigwords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_delete_bigword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_forward_bigword); } /* Removes the semiword after the cursor. * If the count is set, `count' semiwords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_delete_semiword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_forward_semiword); } /* Removes the viword after the cursor. * If the count is set, `count' viwords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_delete_viword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_forward_viword); } /* Removes the emacsword after the cursor. * If the count is set, `count' emacswords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_delete_emacsword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_forward_emacsword); } /* Removes the character behind the cursor. * If the count is set, `count' characters are killed. */ void cmd_backward_delete_char(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_backward_char); } /* Removes the bigword behind the cursor. * If the count is set, `count' bigwords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_delete_bigword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_backward_bigword); } /* Removes the semiword behind the cursor. * If the count is set, `count' semiwords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_delete_semiword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_backward_semiword); } /* Removes the viword behind the cursor. * If the count is set, `count' viwords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_delete_viword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_backward_viword); } /* Removes the emacsword behind the cursor. * If the count is set, `count' emacswords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_delete_emacsword(wchar_t c __attribute__((unused))) { enum motion_expect_command_T cmd; cmd = (state.count.sign == 0) ? MEC_DELETE : MEC_KILL; exec_motion_expect_command(cmd, cmd_backward_emacsword); } /* Removes all characters in the edit line. */ void cmd_delete_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command_line(MEC_DELETE); } /* Removes all characters after the cursor. */ void cmd_forward_delete_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_DELETE, cmd_end_of_line); } /* Removes all characters behind the cursor. */ void cmd_backward_delete_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_DELETE, cmd_beginning_of_line); } /* Kills the character under the cursor. * If the count is set, `count' characters are killed. */ void cmd_kill_char(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_forward_char); } /* Kills the bigword after the cursor. * If the count is set, `count' bigwords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_kill_bigword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_forward_bigword); } /* Kills the semiword after the cursor. * If the count is set, `count' semiwords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_kill_semiword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_forward_semiword); } /* Kills the viword after the cursor. * If the count is set, `count' viwords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_kill_viword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_forward_viword); } /* Kills the emacsword after the cursor. * If the count is set, `count' emacswords are killed. * If the cursor is at the end of the line, the terminal is alerted. */ void cmd_kill_emacsword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_forward_emacsword); } /* Kills the character behind the cursor. * If the count is set, `count' characters are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_kill_char(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_backward_char); } /* Kills the bigword behind the cursor. * If the count is set, `count' bigwords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_kill_bigword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_backward_bigword); } /* Kills the semiword behind the cursor. * If the count is set, `count' semiwords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_kill_semiword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_backward_semiword); } /* Kills the viword behind the cursor. * If the count is set, `count' viwords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_kill_viword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_backward_viword); } /* Kills the emacsword behind the cursor. * If the count is set, `count' emacswords are killed. * If the cursor is at the beginning of the line, the terminal is alerted. */ void cmd_backward_kill_emacsword(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_backward_emacsword); } /* Kills all characters in the edit line. */ void cmd_kill_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command_line(MEC_KILL); } /* Kills all characters after the cursor. */ void cmd_forward_kill_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_end_of_line); } /* Kills all characters before the cursor. */ void cmd_backward_kill_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_beginning_of_line); } /* Inserts the last-killed string before the cursor. * If the count is set, inserts `count' times. * The cursor is left on the last character inserted. */ void cmd_put_before(wchar_t c __attribute__((unused))) { put_killed_string(false, true); } /* Inserts the last-killed string after the cursor. * If the count is set, inserts `count' times. * The cursor is left on the last character inserted. */ void cmd_put(wchar_t c __attribute__((unused))) { put_killed_string(true, true); } /* Inserts the last-killed string before the cursor. * If the count is set, inserts `count' times. * The cursor is left after the inserted string. */ void cmd_put_left(wchar_t c __attribute__((unused))) { put_killed_string(false, false); } /* Inserts the last-killed text at the current cursor position (`count' times). * If `after_cursor' is true, the text is inserted after the current cursor * position. Otherwise, before the current position. * If `cursor_on_last_char' is true, the cursor is left on the last character * inserted. Otherwise, the cursor is left after the inserted text. */ void put_killed_string(bool after_cursor, bool cursor_on_last_char) { ALERT_AND_RETURN_IF_PENDING; save_current_edit_command(); maybe_save_undo_history(); size_t index = (next_kill_index - 1) % KILL_RING_SIZE; if (kill_ring[index] == NULL) { cmd_alert(L'\0'); return; } insert_killed_string(after_cursor, cursor_on_last_char, index); } /* Inserts the killed text at the current cursor position (`count' times). * If `after_cursor' is true, the text is inserted after the current cursor * position. Otherwise, before the current position. * If `cursor_on_last_char' is true, the cursor is left on the last character * inserted. Otherwise, the cursor is left after the inserted text. * `index' specifies the text in the kill ring to be inserted. If the text * does not exist at the specified index in the kill ring, this function does * nothing. */ void insert_killed_string( bool after_cursor, bool cursor_on_last_char, size_t index) { const wchar_t *s = kill_ring[index]; if (s == NULL) return; last_put_elem = index; if (after_cursor && le_main_index < le_main_buffer.length) le_main_index++; size_t offset = le_main_buffer.length - le_main_index; for (int count = get_count(1); --count >= 0; ) wb_insert(&le_main_buffer, le_main_index, s); assert(le_main_buffer.length >= offset + 1); last_put_range_start = le_main_index; le_main_index = le_main_buffer.length - offset; last_put_range_length = le_main_index - last_put_range_start; if (cursor_on_last_char) le_main_index--; reset_state(); } /* Replaces the string just inserted by `cmd_put_left' with the previously * killed string. */ void cmd_put_pop(wchar_t c __attribute__((unused))) { static bool last_success = false; ALERT_AND_RETURN_IF_PENDING; if ((last_command.func != cmd_put_left && last_command.func != cmd_put && last_command.func != cmd_put_before && (last_command.func != cmd_put_pop || !last_success)) || kill_ring[last_put_elem] == NULL) { last_success = false; cmd_alert(L'\0'); return; } last_success = true; save_current_edit_command(); maybe_save_undo_history(); size_t index = last_put_elem; do index = (index - 1) % KILL_RING_SIZE; while (kill_ring[index] == NULL); /* Remove the just inserted text. */ assert(last_put_range_start <= le_main_buffer.length); wb_remove(&le_main_buffer, last_put_range_start, last_put_range_length); le_main_index = last_put_range_start; insert_killed_string(false, false, index); } /* Undoes the last editing command. */ void cmd_undo(wchar_t c __attribute__((unused))) { cancel_undo(-get_count(1)); } /* Undoes all changes to the edit line. */ void cmd_undo_all(wchar_t c __attribute__((unused))) { cancel_undo(-COUNT_ABS_MAX); } /* Cancels the last undo. */ void cmd_cancel_undo(wchar_t c __attribute__((unused))) { cancel_undo(get_count(1)); } /* Cancels all previous undo. */ void cmd_cancel_undo_all(wchar_t c __attribute__((unused))) { cancel_undo(COUNT_ABS_MAX); } /* Performs "undo"/"cancel undo". * `undo_index' is increased by `offset' and the contents of the history entry * of the new index is set to the edit line. * `offset' must be between `-COUNT_ABS_MAX' and `COUNT_ABS_MAX'. */ void cancel_undo(int offset) { maybe_save_undo_history(); if (undo_history_entry != main_history_entry) goto error; if (offset < 0) { if (undo_index == 0) goto error; #if COUNT_ABS_MAX > SIZE_MAX if (-offset > (int) undo_index) #else if ((size_t) -offset > undo_index) #endif undo_index = 0; else undo_index += offset; } else { if (undo_index + 1 >= undo_history.length) goto error; #if COUNT_ABS_MAX > SIZE_MAX if (offset >= (int) (undo_history.length - undo_index)) #else if ((size_t) offset >= undo_history.length - undo_index) #endif undo_index = undo_history.length - 1; else undo_index += offset; } const struct undo_history *entry = undo_history.contents[undo_index]; wb_replace(&le_main_buffer, 0, SIZE_MAX, entry->contents, SIZE_MAX); assert(entry->index <= le_main_buffer.length); le_main_index = entry->index; reset_state(); return; error: cmd_alert(L'\0'); return; } /* Redoes the last editing command. */ /* XXX: currently vi's "i" command cannot be redone. */ void cmd_redo(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; if (!last_edit_command.command.func) { cmd_alert(L'\0'); return; } if (state.count.sign != 0) last_edit_command.state.count = state.count; state = last_edit_command.state; last_edit_command.command.func(last_edit_command.command.arg); } /********** Completion Commands **********/ /* Performs command line completion. */ void cmd_complete(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete(lecr_normal); reset_state(); } /* Selects the next completion candidate. * If the count is set, selects the `count'th next candidate. */ void cmd_complete_next_candidate(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete_select_candidate(get_count(1)); reset_state(); } /* Selects the previous completion candidate. * If the count is set, selects the `count'th previous candidate. */ void cmd_complete_prev_candidate(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete_select_candidate(-get_count(1)); reset_state(); } /* Selects the first candidate in the next column. * If the count is set, selects that of the `count'th next column. */ void cmd_complete_next_column(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete_select_column(get_count(1)); reset_state(); } /* Selects the first candidate in the previous column. * If the count is set, selects that of the `count'th previous column. */ void cmd_complete_prev_column(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete_select_column(-get_count(1)); reset_state(); } /* Selects the first candidate in the next page. * If the count is set, selects that of the `count'th next page. */ void cmd_complete_next_page(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete_select_page(get_count(1)); reset_state(); } /* Selects the first candidate in the previous page. * If the count is set, selects that of the `count'th previous page. */ void cmd_complete_prev_page(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete_select_page(-get_count(1)); reset_state(); } /* Performs command line completion and * * if the count is not set, list all the candidates without changing the * main buffer. * * if the count is set, complete the `count'th candidate. */ void cmd_complete_list(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; maybe_save_undo_history(); le_complete_cleanup(); /* leave `next_reset_completion' to be true because the results of this * command cannot be used by succeeding completion commands. */ // next_reset_completion = false; le_complete_fix_candidate(get_count(0)); reset_state(); } /* Performs command line completion and replaces the current word with all of * the generated candidates. */ void cmd_complete_all(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete(lecr_substitute_all_candidates); reset_state(); } /* Performs command line completion and replaces the current word with the * longest common prefix of the candidates. */ void cmd_complete_max(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); le_complete(lecr_longest_common_prefix); reset_state(); } /* Clears the current candidates. */ void cmd_clear_candidates(wchar_t c __attribute__((unused))) { le_complete_cleanup(); } void check_reset_completion(void) { if (reset_completion) { maybe_save_undo_history(); le_complete_cleanup(); reset_completion = false; } next_reset_completion = false; } /********** Vi-Mode Specific Commands **********/ /* Sets the editing mode to "vi expect" and the pending command to * `vi_replace_char'. */ void cmd_vi_replace_char(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; set_char_expect_command(vi_replace_char); } /* Replaces the character under the cursor with `c'. * If the count is set, the `count' characters are replaced. */ void vi_replace_char(wchar_t c) { save_current_edit_command(); le_set_mode(savemode); if (c != L'\0') { int count = get_count(1); if (count > 0 && le_main_index < le_main_buffer.length) { do { le_main_buffer.contents[le_main_index] = c; count--, le_main_index++; } while (count > 0 && le_main_index < le_main_buffer.length); le_main_index--; } reset_state(); } else { cmd_alert(L'\0'); } } /* Moves the cursor to the beginning of the line and sets the editing mode to * "vi insert". */ void cmd_vi_insert_beginning(wchar_t c __attribute__((unused))) { exec_motion_expect_command_line(MEC_INSERT | MEC_TOSTART); } /* Moves the cursor forward one character and sets the editing mode to "vi * insert". */ void cmd_vi_append(wchar_t c __attribute__((unused))) { reset_count(); exec_motion_expect_command(MEC_INSERT | MEC_MOVE, cmd_forward_char); } /* Moves the cursor to the end of the line and sets the editing mode to "vi * insert".*/ void cmd_vi_append_to_eol(wchar_t c __attribute__((unused))) { exec_motion_expect_command_line(MEC_INSERT | MEC_TOEND); } /* Sets the editing mode to "vi insert" and starts the overwrite mode. */ void cmd_vi_replace(wchar_t c __attribute__((unused))) { set_mode(LE_MODE_VI_INSERT, true); } /* Sets the pending command to MEC_SWITCHCASE. * The count multiplier is set to the current count. * If the pending command is already set to MEC_SWITCHCASE, the whole line is * switch-cased. */ void cmd_vi_switch_case(wchar_t c __attribute__((unused))) { set_motion_expect_command(MEC_SWITCHCASE | MEC_TOSTART); } /* Switches the case of the character under the cursor and advances the cursor. * If the count is set, `count' characters are changed. */ void cmd_vi_switch_case_char(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_SWITCHCASE | MEC_TOEND, cmd_forward_char); } /* Sets the pending command to MEC_COPY. * The count multiplier is set to the current count. * If the pending command is already set to MEC_COPY, the whole line is copied * to the kill ring. */ void cmd_vi_yank(wchar_t c __attribute__((unused))) { set_motion_expect_command(MEC_COPY); } /* Copies the content of the edit line from the current position to the end. */ void cmd_vi_yank_to_eol(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_COPY, cmd_end_of_line); } /* Sets the pending command to MEC_KILL. * The count multiplier is set to the current count. * If the pending command is already set to MEC_KILL, the whole line is moved * to the kill ring. */ void cmd_vi_delete(wchar_t c __attribute__((unused))) { set_motion_expect_command(MEC_KILL); } /* Deletes the content of the edit line from the current position to the end and * put it in the kill ring. */ /* cmd_vi_delete_to_eol is the same as cmd_forward_kill_line. void cmd_vi_delete_to_eol(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_KILL, cmd_end_of_line); } */ /* Sets the pending command to MEC_CHANGE. * The count multiplier is set to the current count. * If the pending command is already set to MEC_CHANGE, the whole line is * deleted and the editing mode is set to "vi insert". */ void cmd_vi_change(wchar_t c __attribute__((unused))) { set_motion_expect_command(MEC_CHANGE); } /* Deletes the content of the edit line from the current position to the end and * sets the editing mode to "vi insert". */ void cmd_vi_change_to_eol(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_CHANGE, cmd_end_of_line); } /* Deletes all the content of the edit line and sets the editing mode to "vi * insert". */ void cmd_vi_change_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command_line(MEC_CHANGE); } /* Sets the pending command to `MEC_COPYCHANGE'. * The count multiplier is set to the current count. * If the pending command is already set to `MEC_COPYCHANGE', the whole line is * moved to the kill ring and the editing mode is set to "vi insert". */ void cmd_vi_yank_and_change(wchar_t c __attribute__((unused))) { set_motion_expect_command(MEC_COPYCHANGE); } /* Deletes the content of the edit line from the current position to the end, * put it in the kill ring, and sets the editing mode to "vi insert". */ void cmd_vi_yank_and_change_to_eol(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_COPYCHANGE, cmd_end_of_line); } /* Deletes all the content of the edit line, put it in the kill ring, and sets * the editing mode to "vi insert". */ void cmd_vi_yank_and_change_line(wchar_t c __attribute__((unused))) { exec_motion_expect_command_line(MEC_COPYCHANGE); } /* Kills the character under the cursor and sets the editing mode to * "vi insert". If the count is set, `count' characters are killed. */ void cmd_vi_substitute(wchar_t c __attribute__((unused))) { exec_motion_expect_command(MEC_COPYCHANGE, cmd_forward_char); } /* Appends a space followed by the last bigword from the newest history entry. * If the count is specified, the `count'th word is appended. * The mode is changed to vi-insert. */ void cmd_vi_append_last_bigword(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; save_current_edit_command(); maybe_save_undo_history(); wchar_t *lastcmd = NULL; int count = get_count(-1); if (count == 0 || histlist.count == 0) goto fail; struct xwcsrange range; lastcmd = malloc_mbstowcs(ashistentry(histlist.Newest)->value); if (lastcmd == NULL) goto fail; if (count >= 0) { /* find the count'th word */ range.start = range.end = lastcmd; do { struct xwcsrange r = get_next_bigword(range.end); if (r.start == r.end) break; range = r; } while (--count > 0 && *range.end != L'\0'); } else { /* find the count'th last word */ range.start = range.end = lastcmd + wcslen(lastcmd); do { struct xwcsrange r = get_prev_bigword(lastcmd, range.start); if (r.start == r.end) break; range = r; } while (++count < 0 && lastcmd < range.start); } assert(range.start <= range.end); if (range.start == range.end) goto fail; if (le_main_index < le_main_buffer.length) le_main_index++; size_t len = range.end - range.start; wb_ninsert_force(&le_main_buffer, le_main_index, L" ", 1); le_main_index += 1; wb_ninsert_force(&le_main_buffer, le_main_index, range.start, len); le_main_index += len; free(lastcmd); cmd_setmode_viinsert(L'\0'); return; fail: free(lastcmd); cmd_alert(L'\0'); return; } struct xwcsrange get_next_bigword(const wchar_t *s) { struct xwcsrange result; while (iswblank(*s)) s++; result.start = s; while (*s != L'\0' && !iswblank(*s)) s++; result.end = s; return result; /* result.start == result.end if no bigword found */ } struct xwcsrange get_prev_bigword(const wchar_t *beginning, const wchar_t *s) { struct xwcsrange result; assert(beginning <= s); do { if (beginning == s) { result.start = result.end = s; return result; } } while (iswblank(*--s)); result.end = &s[1]; do { if (beginning == s) { result.start = s; return result; } } while (!iswblank(*--s)); result.start = &s[1]; return result; /* result.start == result.end if no bigword found */ } /* Sets the editing mode to "vi expect" and the pending command to * `vi_exec_alias'. */ void cmd_vi_exec_alias(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; set_char_expect_command(vi_exec_alias); } /* Appends the value of the alias `_c' to the pre-buffer so that the alias value * is interpreted as commands, where `c' in the alias name is the argument of * this command. */ void vi_exec_alias(wchar_t c) { le_set_mode(savemode); state.pending_command_char = 0; #if YASH_ENABLE_ALIAS wchar_t aliasname[3] = { L'_', c, L'\0', }; const wchar_t *aliasvalue = get_alias_value(aliasname); if (aliasvalue != NULL) { char *mbaliasvalue = malloc_wcstombs(aliasvalue); if (mbaliasvalue != NULL) { le_append_to_prebuffer(mbaliasvalue); return; } } #else (void) c; #endif cmd_alert(L'\0'); } /* Invokes an external command to edit the current line and accepts the result. * If the count is set, goes to the `count'th history entry and edit it. * If the editor returns a non-zero status, the line is not accepted. */ /* cf. history.c:fc_edit_and_exec_entries */ void cmd_vi_edit_and_accept(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; char *tempfile; int fd; FILE *f; pid_t cpid; int savelaststatus; if (state.count.sign != 0) { int num = get_count(0); if (num < 0) goto error0; const histlink_T *l = get_history_entry((unsigned) num); if (l == Histlist) goto error0; go_to_history(l, SEARCH_VI); } le_complete_cleanup(); le_suspend_readline(); fd = create_temporary_file(&tempfile, S_IRUSR | S_IWUSR); if (fd < 0) { xerror(errno, Ngt("cannot create a temporary file to edit history")); goto error1; } f = fdopen(fd, "w"); if (f == NULL) { xerror(errno, Ngt("cannot open temporary file `%s'"), tempfile); xclose(fd); goto error2; } savelaststatus = laststatus; cpid = fork_and_reset(0, true, 0); if (cpid < 0) { // fork failed xerror(0, Ngt("cannot invoke the editor to edit history")); fclose(f); if (unlink(tempfile) < 0) xerror(errno, Ngt("failed to remove temporary file `%s'"), tempfile); error2: free(tempfile); error1: le_resume_readline(); error0: cmd_alert(L'\0'); } else if (cpid > 0) { // parent process fclose(f); wchar_t **namep = wait_for_child(cpid, doing_job_control_now ? cpid : 0, doing_job_control_now); if (namep) *namep = malloc_wprintf(L"vi %s", tempfile); if (laststatus != Exit_SUCCESS) goto end; f = fopen(tempfile, "r"); if (f == NULL) { cmd_alert(L'\0'); } else { wint_t c; wb_clear(&le_main_buffer); while ((c = fgetwc(f)) != WEOF) wb_wccat(&le_main_buffer, (wchar_t) c); fclose(f); /* remove trailing newline */ while (le_main_buffer.length > 0 && le_main_buffer.contents[le_main_buffer.length - 1] == L'\n') wb_remove(&le_main_buffer, le_main_buffer.length - 1, 1); le_main_index = le_main_buffer.length; le_editstate = LE_EDITSTATE_DONE; end: reset_state(); } laststatus = savelaststatus; unlink(tempfile); free(tempfile); if (shopt_notify || shopt_notifyle) print_job_status_all(); le_resume_readline(); } else { // child process fwprintf(f, L"%ls\n", le_main_buffer.contents); fclose(f); wchar_t *command = malloc_wprintf(L"vi %s", tempfile); free(tempfile); exec_wcs(command, gt("lineedit"), true); #ifndef NDEBUG free(command); #endif assert(false); } } /* Performs command line completion and * * if the count is not set, list all the candidates without changing the * main buffer. * * if the count is set, complete the `count'th candidate and set the mode * to vi-insert. */ void cmd_vi_complete_list(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; maybe_save_undo_history(); le_complete_cleanup(); /* leave `next_reset_completion' to be true because the results of this * command cannot be used by succeeding completion commands. */ // next_reset_completion = false; size_t oldindex = le_main_index; if (le_main_index < le_main_buffer.length) le_main_index++; if (le_complete_fix_candidate(get_count(0))) { cmd_setmode_viinsert(L'\0'); } else { le_main_index = oldindex; reset_state(); } } /* Performs command line completion and replaces the current word with all of * the generated candidates. * The mode is changed to vi-insert. */ void cmd_vi_complete_all(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); if (le_main_index < le_main_buffer.length) le_main_index++; le_complete(lecr_substitute_all_candidates); cmd_setmode_viinsert(L'\0'); } /* Performs command line completion and replaces the current word with the * longest common prefix of the candidates. * The mode is changed to vi-insert. */ void cmd_vi_complete_max(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; check_reset_completion(); if (le_main_index < le_main_buffer.length) le_main_index++; le_complete(lecr_longest_common_prefix); cmd_setmode_viinsert(L'\0'); } /* Starts vi-like command history search in the forward direction. */ void cmd_vi_search_forward(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; set_search_mode(LE_MODE_VI_SEARCH, FORWARD); } /* Starts vi-like command history search in the backward direction. */ void cmd_vi_search_backward(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; set_search_mode(LE_MODE_VI_SEARCH, BACKWARD); } /********** Emacs-Mode Specific Commands **********/ /* Moves the character before the cursor to the right by `count' characters. */ void cmd_emacs_transpose_chars(wchar_t c __attribute__((unused))) { //ALERT_AND_RETURN_IF_PENDING; if (state.pending_command_motion != MEC_MOVE || le_main_index == 0) goto error; maybe_save_undo_history(); if (state.count.sign == 0 && le_main_index == le_main_buffer.length && le_main_index >= 2) le_main_index--; int count = get_count(1); size_t index; if (count >= 0) { #if COUNT_ABS_MAX > SIZE_MAX if (count <= (int) (le_main_buffer.length - le_main_index)) #else if ((size_t) count <= le_main_buffer.length - le_main_index) #endif index = le_main_index + (size_t) count; else { le_main_index = le_main_buffer.length; goto error; } } else { #if COUNT_ABS_MAX > SIZE_MAX if (-count < (int) le_main_index) #else if ((size_t) -count < le_main_index) #endif index = le_main_index + (size_t) count; else { le_main_index = 0; goto error; } } size_t old_index = le_main_index; assert(le_main_index > 0 && count > 0); assert(0 < index && index <= le_main_buffer.length); c = le_main_buffer.contents[old_index - 1]; wb_remove(&le_main_buffer, old_index - 1, 1); wb_ninsert(&le_main_buffer, index - 1, &c, 1); le_main_index = index; if (index > old_index) index = old_index; reset_state(); return; error: cmd_alert(L'\0'); } /* Interchanges the word before the cursor and the `count' words after the * cursor. */ void cmd_emacs_transpose_words(wchar_t c __attribute__((unused))) { if (state.pending_command_motion != MEC_MOVE || le_main_index == 0) goto error; maybe_save_undo_history(); int count = get_count(1); size_t w1start, w1end, w2start, w2end, new_index; xwcsbuf_T buf; if (count == 0) goto end; w1start = previous_emacsword_index(le_main_buffer.contents, le_main_index); w1end = next_emacsword_index(le_main_buffer.contents, w1start); if (count >= 0) { w2end = next_emacsword_index(le_main_buffer.contents, w1end); w2start = previous_emacsword_index(le_main_buffer.contents, w2end); while (--count > 0) { if (w2end == le_main_buffer.length) goto error; w2end = next_emacsword_index(le_main_buffer.contents, w2end); } new_index = w2end; } else { w2start = w1start, w2end = w1end; w1start = previous_emacsword_index(le_main_buffer.contents, w2start); w1end = next_emacsword_index(le_main_buffer.contents, w1start); while (++count < 0) { if (w1start == 0) goto error; w1start = previous_emacsword_index( le_main_buffer.contents, w1start); } new_index = w1start + (w2end - w2start); } if (w1end >= w2start) goto error; wb_init(&buf); wb_ncat_force(&buf, &le_main_buffer.contents[w2start], w2end - w2start); wb_ncat_force(&buf, &le_main_buffer.contents[w1end], w2start - w1end); wb_ncat_force(&buf, &le_main_buffer.contents[w1start], w1end - w1start); assert(buf.length == w2end - w1start); wb_replace_force(&le_main_buffer, w1start, buf.length, buf.contents, buf.length); wb_destroy(&buf); le_main_index = new_index; end: reset_state(); return; error: cmd_alert(L'\0'); } /* Converts the word after the cursor to lower case. * If the count is set, `count' words are converted. * The cursor is left after the last converted word. */ void cmd_emacs_downcase_word(wchar_t c __attribute__((unused))) { exec_motion_expect_command( MEC_LOWERCASE | MEC_TOEND, cmd_forward_emacsword); } /* Converts `count' words after the cursor to upper case. * If the count is set, `count' words are converted. * The cursor is left after the last converted word. */ void cmd_emacs_upcase_word(wchar_t c __attribute__((unused))) { exec_motion_expect_command( MEC_UPPERCASE | MEC_TOEND, cmd_forward_emacsword); } /* Capitalizes the word after the cursor. * If the count is set, `count' words are capitalized. * The cursor is left after the last capitalized word. */ void cmd_emacs_capitalize_word(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; maybe_save_undo_history(); int count = get_count(1); if (count > 0) { wchar_t *s = &le_main_buffer.contents[le_main_index]; do { while (*s != L'\0' && !iswalnum(*s)) s++; *s = towupper(*s); s++; while (*s != L'\0' && iswalnum(*s)) s++; } while (*s != L'\0' && --count > 0); le_main_index = s - le_main_buffer.contents; } else if (count < 0) { size_t index = le_main_index; do { index = previous_emacsword_index(le_main_buffer.contents, index); le_main_buffer.contents[index] = towupper(le_main_buffer.contents[index]); } while (index > 0 && ++count < 0); } reset_state(); } /* Deletes blank characters around the cursor. * If the count is set, only blanks before the cursor are deleted. */ void cmd_emacs_delete_horizontal_space(wchar_t c __attribute__((unused))) { replace_horizontal_space(state.count.sign == 0, L""); } /* Replaces blank characters around the cursor with a space. * The cursor is left after the space. * A space is inserted even if there are no blanks around the cursor. * If the count is specified, blanks are replaced with `count' spaces. */ void cmd_emacs_just_one_space(wchar_t c __attribute__((unused))) { int count = get_count(1); if (count < 0) count = 0; else if (count > 1000) count = 1000; wchar_t s[count + 1]; wmemset(s, L' ', count); s[count] = L'\0'; replace_horizontal_space(true, s); } /* Replaces blank characters around the cursor with the specified string. * If `deleteafter' is true, blanks after the cursor are replaced as well as * blanks before the cursor. If `deleteafter' is false, only blanks before the * cursor are replaced. * The cursor is left after the replacement. */ void replace_horizontal_space(bool deleteafter, const wchar_t *s) { ALERT_AND_RETURN_IF_PENDING; maybe_save_undo_history(); size_t start_index = le_main_index; while (start_index > 0 && iswblank(le_main_buffer.contents[start_index - 1])) start_index--; size_t end_index = le_main_index; if (deleteafter) while (end_index < le_main_buffer.length && iswblank(le_main_buffer.contents[end_index])) end_index++; size_t slen = wcslen(s); wb_replace_force(&le_main_buffer, start_index, end_index - start_index, s, slen); le_main_index = start_index + slen; reset_state(); } /* Starts emacs-like command history search in the forward direction. */ void cmd_emacs_search_forward(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; set_search_mode(LE_MODE_EMACS_SEARCH, FORWARD); } /* Starts emacs-like command history search in the backward direction. */ void cmd_emacs_search_backward(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; set_search_mode(LE_MODE_EMACS_SEARCH, BACKWARD); } /********** History-Related Commands **********/ /* Goes to the oldest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor position is not changed. */ void cmd_oldest_history(wchar_t c __attribute__((unused))) { go_to_history_absolute(histlist.Oldest, SEARCH_PREFIX); } /* Goes to the newest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor position is not changed. */ void cmd_newest_history(wchar_t c __attribute__((unused))) { go_to_history_absolute(histlist.Newest, SEARCH_PREFIX); } /* Goes to the newest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor position is not changed. */ void cmd_return_history(wchar_t c __attribute__((unused))) { go_to_history_absolute(Histlist, SEARCH_PREFIX); } /* Goes to the oldest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor is put at the beginning of line. */ void cmd_oldest_history_bol(wchar_t c __attribute__((unused))) { go_to_history_absolute(histlist.Oldest, SEARCH_VI); } /* Goes to the newest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor is put at the beginning of line. */ void cmd_newest_history_bol(wchar_t c __attribute__((unused))) { go_to_history_absolute(histlist.Newest, SEARCH_VI); } /* Goes to the newest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor is put at the beginning of line. */ void cmd_return_history_bol(wchar_t c __attribute__((unused))) { go_to_history_absolute(Histlist, SEARCH_VI); } /* Goes to the oldest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor is put at the end of line. */ void cmd_oldest_history_eol(wchar_t c __attribute__((unused))) { go_to_history_absolute(histlist.Oldest, SEARCH_EMACS); } /* Goes to the newest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor is put at the end of line. */ void cmd_newest_history_eol(wchar_t c __attribute__((unused))) { go_to_history_absolute(histlist.Newest, SEARCH_EMACS); } /* Goes to the newest history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * The cursor is put at the end of line. */ void cmd_return_history_eol(wchar_t c __attribute__((unused))) { go_to_history_absolute(Histlist, SEARCH_EMACS); } /* Goes to the specified history entry. * If the count is specified, goes to the history entry whose number is count. * If the specified entry is not found, the terminal is alerted. * See `go_to_history' for the meaning of `curpos'. */ void go_to_history_absolute(const histlink_T *l, enum le_search_type_T curpos) { ALERT_AND_RETURN_IF_PENDING; if (state.count.sign == 0) { if (histlist.count == 0) goto alert; } else { int num = get_count(0); if (num <= 0) goto alert; l = get_history_entry((unsigned) num); if (l == Histlist) goto alert; } go_to_history(l, curpos); reset_state(); return; alert: cmd_alert(L'\0'); return; } /* Goes to the `count'th next history entry. * The cursor position is not changed. */ void cmd_next_history(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; go_to_history_relative(get_count(1), SEARCH_PREFIX); } /* Goes to the `count'th previous history entry. * The cursor position is not changed. */ void cmd_prev_history(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; go_to_history_relative(-get_count(1), SEARCH_PREFIX); } /* Goes to the `count'th next history entry. * The cursor is put at the beginning of line. */ void cmd_next_history_bol(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; go_to_history_relative(get_count(1), SEARCH_VI); } /* Goes to the `count'th previous history entry. * The cursor is put at the beginning of line. */ void cmd_prev_history_bol(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; go_to_history_relative(-get_count(1), SEARCH_VI); } /* Goes to the `count'th next history entry. * The cursor is put at the end of line. */ void cmd_next_history_eol(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; go_to_history_relative(get_count(1), SEARCH_EMACS); } /* Goes to the `count'th previous history entry. * The cursor is put at the end of line. */ void cmd_prev_history_eol(wchar_t c __attribute__((unused))) { ALERT_AND_RETURN_IF_PENDING; go_to_history_relative(-get_count(1), SEARCH_EMACS); } /* Goes to the `offset'th next history entry. * See `go_to_history' for the meaning of `curpos'. */ void go_to_history_relative(int offset, enum le_search_type_T curpos) { const histlink_T *l = main_history_entry; if (offset > 0) { do { if (l == Histlist) goto alert; l = l->next; } while (--offset > 0); } else if (offset < 0) { do { l = l->prev; if (l == Histlist) goto alert; } while (++offset < 0); } go_to_history(l, curpos); reset_state(); return; alert: cmd_alert(L'\0'); return; } /* Sets the value of the specified history entry to the main buffer. * The value of `curpos' specifies where the cursor is left: * SEARCH_PREFIX: the current position (unless it exceeds the buffer length) * SEARCH_VI: the beginning of the buffer * SEARCH_EMACS: the end of the buffer */ void go_to_history(const histlink_T *l, enum le_search_type_T curpos) { maybe_save_undo_history(); free(main_history_value); wb_clear(&le_main_buffer); if (l == undo_history_entry && undo_index < undo_history.length) { struct undo_history *h = undo_history.contents[undo_index]; wb_cat(&le_main_buffer, h->contents); assert(h->index <= le_main_buffer.length); le_main_index = h->index; } else { if (l != Histlist) wb_mbscat(&le_main_buffer, ashistentry(l)->value); switch (curpos) { case SEARCH_PREFIX: if (le_main_index > le_main_buffer.length) le_main_index = le_main_buffer.length; break; case SEARCH_VI: le_main_index = 0; break; case SEARCH_EMACS: le_main_index = le_main_buffer.length; break; } } main_history_entry = l; main_history_value = xwcsdup(le_main_buffer.contents); undo_save_index = le_main_index; } /***** History Search Commands *****/ /* Appends the argument character to the search buffer. */ void cmd_srch_self_insert(wchar_t c) { if (le_search_buffer.contents == NULL || c == L'\0') { cmd_alert(L'\0'); return; } wb_wccat(&le_search_buffer, c); update_search(); } /* Removes the last character from the search buffer. * If there are no characters in the buffer, calls `cmd_srch_abort_search' (for * vi-like search) or `cmd_alert' (for emacs-like search). */ void cmd_srch_backward_delete_char(wchar_t c __attribute__((unused))) { if (le_search_buffer.contents == NULL) { cmd_alert(L'\0'); return; } if (le_search_buffer.length == 0) { switch (le_search_type) { case SEARCH_VI: cmd_srch_abort_search(L'\0'); return; case SEARCH_EMACS: cmd_alert(L'\0'); return; case SEARCH_PREFIX: assert(false); } } wb_remove(&le_search_buffer, le_search_buffer.length - 1, 1); update_search(); } /* Removes all characters from the search buffer. */ void cmd_srch_backward_delete_line(wchar_t c __attribute__((unused))) { if (le_search_buffer.contents == NULL) { cmd_alert(L'\0'); return; } wb_clear(&le_search_buffer); update_search(); } /* Settles the current search result and continues the search with the current * pattern in the forward direction. This is like `cmd_search_again_forward' * but this command can be used during the search. */ void cmd_srch_continue_forward(wchar_t c __attribute__((unused))) { if (le_search_buffer.contents == NULL) { cmd_alert(L'\0'); return; } le_search_direction = FORWARD; if (le_search_result != Histlist) go_to_history(le_search_result, le_search_type); update_search(); } /* Settles the current search result and continues the search with the current * pattern in the backward direction. This is like `cmd_search_again_backward' * but this command can be used during the search. */ void cmd_srch_continue_backward(wchar_t c __attribute__((unused))) { if (le_search_buffer.contents == NULL) { cmd_alert(L'\0'); return; } le_search_direction = BACKWARD; if (le_search_result != Histlist) go_to_history(le_search_result, le_search_type); update_search(); } /* Finishes the history search and accepts the current result candidate. * If no search is being performed, does nothing. */ void cmd_srch_accept_search(wchar_t c __attribute__((unused))) { if (le_search_buffer.contents == NULL) return; last_search.direction = le_search_direction; last_search.type = le_search_type; if (need_update_last_search_value()) { free(last_search.value); last_search.value = wb_towcs(&le_search_buffer); } else { wb_destroy(&le_search_buffer); } le_search_buffer.contents = NULL; le_set_mode(savemode); if (le_search_result == Histlist) { cmd_alert(L'\0'); } else { go_to_history(le_search_result, le_search_type); } reset_state(); } /* Checks if we should update `last_search.value' to the current value of * `le_search_buffer'. */ bool need_update_last_search_value(void) { switch (le_search_type) { case SEARCH_PREFIX: break; case SEARCH_VI: if (le_search_buffer.contents[0] == L'\0') return false; if (le_search_buffer.contents[0] == L'^' && le_search_buffer.contents[1] == L'\0') return false; return true; case SEARCH_EMACS: return le_search_buffer.contents[0] != L'\0'; } assert(false); } /* Aborts the history search. * If no search is being performed, does nothing. */ void cmd_srch_abort_search(wchar_t c __attribute__((unused))) { if (le_search_buffer.contents == NULL) return; wb_destroy(&le_search_buffer); le_search_buffer.contents = NULL; le_set_mode(savemode); reset_state(); } /* Re-calculates the search result candidate. */ void update_search(void) { const wchar_t *pattern = le_search_buffer.contents; if (pattern[0] == L'\0') { switch (le_search_type) { case SEARCH_PREFIX: break; case SEARCH_VI: pattern = last_search.value; if (pattern == NULL) { le_search_result = Histlist; goto done; } break; case SEARCH_EMACS: le_search_result = Histlist; goto done; } } perform_search(pattern, le_search_direction, le_search_type); done: reset_state(); } /* Performs history search with the given parameters and updates the result * candidate. */ void perform_search(const wchar_t *pattern, enum le_search_direction_T dir, enum le_search_type_T type) { const histlink_T *l = main_history_entry; xfnmatch_T *xfnm; if (dir == FORWARD && l == Histlist) goto done; switch (type) { case SEARCH_PREFIX: { wchar_t *p = escape(pattern, NULL); xfnm = xfnm_compile(p, XFNM_HEADONLY); free(p); break; } case SEARCH_VI: { xfnmflags_T flags = 0; if (pattern[0] == L'^') { flags |= XFNM_HEADONLY; pattern++; if (pattern[0] == L'\0') { l = Histlist; goto done; } } xfnm = xfnm_compile(pattern, flags); break; } case SEARCH_EMACS: { wchar_t *p = escape(pattern, NULL); xfnm = xfnm_compile(p, 0); free(p); break; } default: assert(false); } if (xfnm == NULL) { l = Histlist; goto done; } for (;;) { switch (dir) { case FORWARD: l = l->next; break; case BACKWARD: l = l->prev; break; } if (l == Histlist) break; if (xfnm_match(xfnm, ashistentry(l)->value) == 0) break; } xfnm_free(xfnm); done: le_search_result = l; } /* Redoes the last search. */ void cmd_search_again(wchar_t c __attribute__((unused))) { search_again(last_search.direction); } /* Redoes the last search in the reverse direction. */ void cmd_search_again_rev(wchar_t c __attribute__((unused))) { switch (last_search.direction) { case FORWARD: search_again(BACKWARD); break; case BACKWARD: search_again(FORWARD); break; } } /* Redoes the last search in the forward direction. */ void cmd_search_again_forward(wchar_t c __attribute__((unused))) { search_again(FORWARD); } /* Redoes the last search in the backward direction. */ void cmd_search_again_backward(wchar_t c __attribute__((unused))) { search_again(BACKWARD); } /* Performs command search for the last search pattern in the specified * direction. If the count is set, re-search `count' times. If the count is * negative, search in the opposite direction. */ void search_again(enum le_search_direction_T dir) { ALERT_AND_RETURN_IF_PENDING; if (last_search.value == NULL) { cmd_alert(L'\0'); return; } int count = get_count(1); if (count < 0) { count = -count; switch (dir) { case FORWARD: dir = BACKWARD; break; case BACKWARD: dir = FORWARD; break; } } while (--count >= 0) { perform_search(last_search.value, dir, last_search.type); if (le_search_result == Histlist) { cmd_alert(L'\0'); break; } else { go_to_history(le_search_result, last_search.type); } } reset_state(); } /* Searches the history in the forward direction for an entry that has a common * prefix with the current buffer contents. The "prefix" is the first * `le_main_index' characters of the buffer. */ void cmd_beginning_search_forward(wchar_t c __attribute__((unused))) { beginning_search(FORWARD); } /* Searches the history in the backward direction for an entry that has a common * prefix with the current buffer contents. The "prefix" is the first * `le_main_index' characters of the buffer. */ void cmd_beginning_search_backward(wchar_t c __attribute__((unused))) { beginning_search(BACKWARD); } /* Searches the history in the specified direction for an entry that has a * common prefix with the current buffer contents. The "prefix" is the first * `le_main_index' characters of the buffer. */ void beginning_search(enum le_search_direction_T dir) { ALERT_AND_RETURN_IF_PENDING; int count = get_count(1); if (count < 0) { count = -count; switch (dir) { case FORWARD: dir = BACKWARD; break; case BACKWARD: dir = FORWARD; break; } } wchar_t *prefix = xwcsndup(le_main_buffer.contents, le_main_index); while (--count >= 0) { perform_search(prefix, dir, SEARCH_PREFIX); if (le_search_result == Histlist) { if (dir == FORWARD && beginning_search_check_go_to_history(prefix)) go_to_history(le_search_result, SEARCH_PREFIX); else cmd_alert(L'\0'); break; } else { go_to_history(le_search_result, SEARCH_PREFIX); } } free(prefix); reset_state(); } bool beginning_search_check_go_to_history(const wchar_t *prefix) { if (le_search_result == undo_history_entry && undo_index < undo_history.length) { const struct undo_history *h = undo_history.contents[undo_index]; return matchwcsprefix(h->contents, prefix) != NULL; } else { return false; } } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/complete.c0000644000175000017500000013617712154557026016336 0ustar magicantmagicant/* Yash: yet another shell */ /* complete.c: command line completion */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "complete.h" #include #include #include #include #if HAVE_GETGRENT # include #endif #if HAVE_GETTEXT # include #endif #if HAVE_GETHOSTENT # include #endif #if HAVE_GETPWENT # include #endif #include #include #include #include #include #include #include #include #include #include "../builtin.h" #include "../exec.h" #include "../expand.h" #include "../hashtable.h" #include "../option.h" #include "../parser.h" #include "../path.h" #include "../plist.h" #include "../redir.h" #include "../sig.h" #include "../strbuf.h" #include "../util.h" #include "../variable.h" #include "../xfnmatch.h" #include "../yash.h" #include "compparse.h" #include "display.h" #include "editing.h" #include "lineedit.h" #include "terminfo.h" #if HAVE_WCSCASECMP # ifndef wcscasecmp extern int wcscasecmp(const wchar_t *s1, const wchar_t *s2) __attribute__((nonnull)); # endif #endif #if HAVE_GETPWENT # ifndef setpwent extern void setpwent(void); # endif # ifndef getpwent extern struct passwd *getpwent(void); # endif # ifndef endpwent extern void endpwent(void); # endif #endif #if HAVE_GETGRENT # if 0 /* avoid conflict on BSD */ extern void setgrent(void); # endif # ifndef getgrent extern struct group *getgrent(void); # endif # ifndef endgrent extern void endgrent(void); # endif #endif #if HAVE_GETHOSTENT # if 0 /* avoid conflict on SunOS */ extern void sethostent(int); # endif # ifndef gethostent extern struct hostent *gethostent(void); # endif # if 0 /* avoid conflict on SunOS */ extern void endhostent(void); # endif #endif static void select_candidate(void selector(int offset), int offset) __attribute__((nonnull)); static void select_candidate_by_offset(int offset); static void free_candidate(void *c) __attribute__((nonnull)); static void free_context(le_context_T *ctxt); static void sort_candidates(void); static int sort_candidates_cmp(const void *cp1, const void *cp2) __attribute__((nonnull)); static void print_context_info(const le_context_T *ctxt) __attribute__((nonnull)); static void print_compopt_info(const le_compopt_T *compopt) __attribute__((nonnull)); static void execute_completion_function(void); static void complete_command_default(void); static void simple_completion(le_candgentype_T type); static void generate_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); static bool le_match_patterns(const le_comppattern_T *ps, const char *s) __attribute__((nonnull(2))); static bool le_wmatch_patterns(const le_comppattern_T *ps, const wchar_t *s) __attribute__((nonnull(2))); static void generate_file_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); static void generate_external_command_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); static void generate_keyword_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); static void generate_logname_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); static void generate_group_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); static void generate_host_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); static void generate_candidates_from_words( le_candtype_T type, void *const *words, const wchar_t *description, const le_compopt_T *compopt) __attribute__((nonnull)); static void word_completion(size_t count, ...) __attribute__((nonnull)); static size_t get_common_prefix_length(void) __attribute__((pure)); static void update_main_buffer(bool subst, bool finish); static void insert_to_main_buffer(wchar_t c); static bool need_subst(void); static void substitute_source_word_all(void); static void quote(xwcsbuf_T *restrict buf, const wchar_t *restrict s, le_quote_T quotetype) __attribute__((nonnull)); /* The current completion context. */ static le_context_T *ctxt = NULL; /* A list that contains the current completion candidates. * The elements pointed to by `le_candidates.contains[*]' are of type * `le_candidate_T'. */ plist_T le_candidates = { .contents = NULL }; /* The index of the currently selected candidate in `le_candidates'. * When no candidate is selected, the index is `le_candidates.length'. */ size_t le_selected_candidate_index; /* The length of the longest common prefix of the current candidates. * The value is ((size_t) -1) when not computed. */ static size_t common_prefix_length; /* Performs command line completion. * Existing candidates are deleted, if any, and candidates are computed from * the current command line. * `lecr' is called after candidate generation. */ void le_complete(le_compresult_T lecr) { if (shopt_le_compdebug) { /* If the `le-compdebug' option is set, the command line is temporarily * cleared during completion. * Note that `shopt_le_compdebug' is referenced only here. During the * completion, we check the value of `le_state' to test if the option * is set. The value of `shopt_le_compdebug' might be changed by a * candidate generator code. */ le_display_finalize(); le_restore_terminal(); le_state = LE_STATE_SUSPENDED | LE_STATE_COMPLETING; le_compdebug("completion start"); } else { le_state |= LE_STATE_COMPLETING; le_allow_terminal_signal(true); } le_complete_cleanup(); pl_init(&le_candidates); common_prefix_length = (size_t) -1; ctxt = le_get_context(); if (le_state_is_compdebug) print_context_info(ctxt); execute_completion_function(); sort_candidates(); le_compdebug("total of %zu candidate(s)", le_candidates.length); /* display the results */ lecr(); if (le_state_is_compdebug) { le_compdebug("completion end"); le_setupterm(true); le_set_terminal(); } else { assert((le_state & (LE_STATE_ACTIVE | LE_STATE_COMPLETING)) == (LE_STATE_ACTIVE | LE_STATE_COMPLETING)); le_allow_terminal_signal(false); /* the terminal size may have been changed during completion, so we * re-check the terminal state here. */ le_display_clear(false); le_setupterm(true); } le_state = LE_STATE_ACTIVE; } /* An `le_compresult_T' function that does nothing. */ void lecr_nop(void) { } /* An `le_compresult_T' function for `cmd_complete'. */ void lecr_normal(void) { if (le_candidates.length == 0) { le_selected_candidate_index = 0; } else if (ctxt->substsrc || need_subst()) { le_selected_candidate_index = 0; substitute_source_word_all(); le_complete_cleanup(); } else if (le_candidates.length == 1) { le_selected_candidate_index = 0; update_main_buffer(false, true); le_complete_cleanup(); } else { le_selected_candidate_index = le_candidates.length; le_display_make_rawvalues(); update_main_buffer(false, false); } } /* An `le_compresult_T' function for `cmd_vi_complete_all'. */ void lecr_substitute_all_candidates(void) { le_selected_candidate_index = 0; if (le_candidates.length == 0) { lebuf_print_alert(true); } else { substitute_source_word_all(); } le_complete_cleanup(); } /* An `le_compresult_T' function for `cmd_vi_complete_max'. */ void lecr_longest_common_prefix(void) { le_selected_candidate_index = 0; if (le_candidates.length == 0) { lebuf_print_alert(true); } else { bool subst = ctxt->substsrc || need_subst(); if (le_candidates.length > 1) { le_selected_candidate_index = le_candidates.length; update_main_buffer(subst, false); } else { update_main_buffer(subst, true); } } le_complete_cleanup(); } /* Updates `le_selected_candidate_index' by calling `selector' with the argument * `offset'. The `selector' function must update `le_selected_candidate_index' * according to the given `offset'. * The main buffer contents is also updated so that it contains the value of the * new selected candidate. * If there are no candidates, `le_complete' is called to produce candidates. */ void select_candidate(void selector(int offset), int offset) { if (le_candidates.contents == NULL) { le_complete(lecr_normal); return; } else if (le_candidates.length == 0) { return; } selector(offset); update_main_buffer(false, false); } /* Increases `le_selected_candidate_index' by `offset', selecting the `offset'th * next candidate. If there are no candidates, simply calls `le_complete' to * produce candidates. */ void le_complete_select_candidate(int offset) { select_candidate(select_candidate_by_offset, offset); } void select_candidate_by_offset(int offset) { assert(le_selected_candidate_index <= le_candidates.length); if (offset >= 0) { offset %= le_candidates.length + 1; le_selected_candidate_index += offset; le_selected_candidate_index %= le_candidates.length + 1; } else { offset = -offset % (le_candidates.length + 1); if ((size_t) offset <= le_selected_candidate_index) le_selected_candidate_index -= offset; else le_selected_candidate_index += le_candidates.length - offset + 1; } assert(le_selected_candidate_index <= le_candidates.length); } /* Selects the first candidate of the `offset'th next column. * If there are no candidates, simply calls `le_complete' to produce candidates. */ void le_complete_select_column(int offset) { select_candidate(le_display_select_column, offset); } /* Selects the first candidate of the `offset'th next page. * If there are no candidates, simply calls `le_complete' to produce candidates. */ void le_complete_select_page(int offset) { select_candidate(le_display_select_page, offset); } /* If `index' is not positive, performs completion and lists candidates. * Otherwise, substitutes the source word with the `index'th candidate and * cleans up. * Returns true iff the source word was successfully substituted. */ bool le_complete_fix_candidate(int index) { if (le_candidates.contents == NULL) { le_complete(lecr_nop); le_selected_candidate_index = le_candidates.length; le_display_make_rawvalues(); } if (le_candidates.length == 0) { lebuf_print_alert(true); return false; } if (index <= 0) return false; unsigned uindex = (unsigned) index - 1; if (uindex >= le_candidates.length) { lebuf_print_alert(true); return false; } le_selected_candidate_index = uindex; bool subst = ctxt->substsrc; if (!subst) { const le_candidate_T *cand = le_candidates.contents[le_selected_candidate_index]; subst = (matchwcsprefix(cand->origvalue, ctxt->src) == NULL); } update_main_buffer(subst, true); le_complete_cleanup(); return true; } /* Clears the current candidates. */ void le_complete_cleanup(void) { le_display_complete_cleanup(); if (le_candidates.contents != NULL) { plfree(pl_toary(&le_candidates), free_candidate); le_candidates.contents = NULL; } free_context(ctxt); ctxt = NULL; } /* Frees a completion candidate. * The argument must point to a `le_candidate_T' value. */ void free_candidate(void *c) { le_candidate_T *cand = c; free(cand->origvalue); free(cand->rawvalue.raw); free(cand->desc); free(cand->rawdesc.raw); free(cand); } /* Frees the specified `le_context_T' data. */ void free_context(le_context_T *ctxt) { if (ctxt != NULL) { plfree(ctxt->pwords, free); free(ctxt->src); free(ctxt->pattern); free(ctxt); } } /* Sorts the candidates in the candidate list and removes duplicates. */ void sort_candidates(void) { qsort(le_candidates.contents, le_candidates.length, sizeof *le_candidates.contents, sort_candidates_cmp); if (le_candidates.length >= 2) { for (size_t i = le_candidates.length - 1; i > 0; i--) { le_candidate_T *cand1 = le_candidates.contents[i]; le_candidate_T *cand2 = le_candidates.contents[i - 1]; // XXX case-sensitive if (wcscoll(cand1->origvalue, cand2->origvalue) == 0) { free_candidate(cand1); pl_remove(&le_candidates, i, 1); } } } } int sort_candidates_cmp(const void *cp1, const void *cp2) { const le_candidate_T *cand1 = *(const le_candidate_T **) cp1; const le_candidate_T *cand2 = *(const le_candidate_T **) cp2; const wchar_t *v1 = cand1->origvalue; const wchar_t *v2 = cand2->origvalue; /* Candidates that start with hyphens are sorted in a special order so that * short options come before long options. Such candidates are sorted case- * insensitively. */ if (v1[0] == L'-' || v2[0] == L'-') { while (*v1 == L'-' && *v2 == L'-') v1++, v2++; if (*v1 == L'-') return 1; if (*v2 == L'-') return -1; #if HAVE_WCSCASECMP int cmp = wcscasecmp(v1, v2); if (cmp != 0) return cmp; #endif } return wcscoll(v1, v2); // XXX case-sensitive } /* Prints the formatted string to the standard error if the completion debugging * option is on. * The string is preceded by "[compdebug] " and followed by a newline. */ void le_compdebug(const char *format, ...) { if (!le_state_is_compdebug) return; fputs("[compdebug] ", stderr); va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); fputc('\n', stderr); } /* Prints information on the specified context if the `compdebug' option is * enabled. */ void print_context_info(const le_context_T *ctxt) { const char *INIT(s); switch (ctxt->quote) { case QUOTE_NONE: s = "none"; break; case QUOTE_NORMAL: s = "normal"; break; case QUOTE_SINGLE: s = "single"; break; case QUOTE_DOUBLE: s = "double"; break; } le_compdebug("quote type: %s", s); switch (ctxt->type & CTXT_MASK) { case CTXT_NORMAL: s = "normal"; break; case CTXT_COMMAND: s = "command"; break; case CTXT_ARGUMENT: s = "argument"; break; case CTXT_TILDE: s = "tilde"; break; case CTXT_VAR: s = "variable"; break; case CTXT_ARITH: s = "arithmetic"; break; case CTXT_ASSIGN: s = "assignment"; break; case CTXT_REDIR: s = "redirection"; break; case CTXT_REDIR_FD: s = "redirection (fd)"; break; case CTXT_FOR_IN: s = "\"in\" or \"do\""; break; case CTXT_FOR_DO: s = "\"do\""; break; case CTXT_CASE_IN: s = "\"in\""; break; case CTXT_FUNCTION: s = "function name"; break; } le_compdebug("context type: %s%s%s%s", s, ctxt->type & CTXT_EBRACED ? " (in brace expn)" : "", ctxt->type & CTXT_VBRACED ? " (in variable)" : "", ctxt->type & CTXT_QUOTED ? " (quoted)" : ""); for (int i = 0; i < ctxt->pwordc; i++) le_compdebug("preceding word %d: \"%ls\"", i + 1, (const wchar_t *) ctxt->pwords[i]); le_compdebug("target word: \"%ls\"", ctxt->src); le_compdebug(" as pattern: \"%ls\"", ctxt->pattern); } /* Prints information on the specified `compopt' if the `compdebug' option is * enabled. */ void print_compopt_info(const le_compopt_T *compopt) { if (!le_state_is_compdebug) return; const char *INIT(s); le_compdebug("target word without prefix: \"%ls\"", compopt->src); for (const le_comppattern_T *p = compopt->patterns; p != NULL; p = p->next){ switch (p->type) { case CPT_ACCEPT: s = "accept"; break; case CPT_REJECT: s = "reject"; break; } le_compdebug("pattern: \"%ls\" (%s)", p->pattern, s); } if (compopt->suffix != NULL) le_compdebug("suffix: \"%ls\"", compopt->suffix); if (!compopt->terminate) le_compdebug("completed word will not be terminated"); } /********** Completion Function Execution **********/ /* name of the file that is autoloaded in the first completion */ #define INIT_COMPFILE "completion/INIT" /* completion function names */ #define COMMAND_COMPFUNC "completion//command" #define ARGUMENT_COMPFUNC "completion//argument" /* Loads and executes completion function to generate candidates. */ void execute_completion_function(void) { static bool once = false; if (!once) { once = true; autoload_completion_function_file(L"" INIT_COMPFILE, NULL); } switch (ctxt->type & CTXT_MASK) { case CTXT_NORMAL: case CTXT_ASSIGN: case CTXT_REDIR: simple_completion(CGT_FILE); break; case CTXT_COMMAND: if (!call_completion_function(L"" COMMAND_COMPFUNC)) complete_command_default(); break; case CTXT_ARGUMENT: if (!call_completion_function(L"" ARGUMENT_COMPFUNC)) simple_completion(CGT_FILE); break; case CTXT_TILDE: simple_completion(CGT_LOGNAME | CGT_DIRSTACK); break; case CTXT_VAR: simple_completion(CGT_VARIABLE); break; case CTXT_ARITH: simple_completion(CGT_SCALAR); break; case CTXT_REDIR_FD: break; case CTXT_FOR_IN: word_completion(2, L"in", L"do"); break; case CTXT_FOR_DO: word_completion(1, L"do"); break; case CTXT_CASE_IN: word_completion(1, L"in"); break; case CTXT_FUNCTION: simple_completion(CGT_FUNCTION); break; } } /* Sets special local variables $WORDS and $TARGETWORD in the current variable * environment. Also sets the $IFS variable to the default value. */ void set_completion_variables(void) { set_array(L VAR_WORDS, ctxt->pwordc, pldup(ctxt->pwords, copyaswcs), SCOPE_LOCAL, false); set_variable(L VAR_TARGETWORD, xwcsdup(ctxt->src), SCOPE_LOCAL, false); set_variable(L VAR_IFS, xwcsdup(DEFAULT_IFS), SCOPE_LOCAL, false); } /* Performs command name completion in the default settings. */ void complete_command_default(void) { le_comppattern_T pattern1, pattern2; le_compopt_T compopt; pattern1.type = CPT_ACCEPT; pattern1.pattern = ctxt->pattern; pattern1.cpattern = NULL; pattern2.next = NULL; pattern2.type = CPT_REJECT; pattern2.pattern = L"*/*"; pattern2.cpattern = NULL; compopt.ctxt = ctxt; compopt.src = ctxt->src; compopt.patterns = &pattern1; pattern1.next = NULL; compopt.type = CGT_DIRECTORY; compopt.suffix = L"/"; compopt.terminate = false; print_compopt_info(&compopt); generate_file_candidates(&compopt); compopt.suffix = NULL; compopt.terminate = true; if (wcschr(ctxt->src, L'/') != NULL) { // pattern1.next = NULL; compopt.type = CGT_EXECUTABLE; } else { pattern1.next = &pattern2; compopt.type = CGT_COMMAND; if (ctxt->quote == QUOTE_NORMAL && wcschr(ctxt->pattern, L'\\') == NULL) compopt.type |= CGT_KEYWORD | CGT_NALIAS; } print_compopt_info(&compopt); generate_candidates(&compopt); } /********** Completion Candidate Generation **********/ /* Perform completion for the specified candidate type(s). */ void simple_completion(le_candgentype_T type) { le_comppattern_T pattern = { .type = CPT_ACCEPT, .pattern = ctxt->pattern, }; le_compopt_T compopt = { .ctxt = ctxt, .type = type, .src = ctxt->src, .patterns = &pattern, .suffix = NULL, .terminate = true, }; print_compopt_info(&compopt); generate_candidates(&compopt); } /* Calls all candidate generation functions. * `cpattern's in `compopt->patterns' are freed in this function but are NOT * set to NULL. */ void generate_candidates(const le_compopt_T *compopt) { generate_file_candidates(compopt); generate_builtin_candidates(compopt); generate_external_command_candidates(compopt); generate_function_candidates(compopt); generate_keyword_candidates(compopt); #if YASH_ENABLE_ALIAS generate_alias_candidates(compopt); #endif generate_variable_candidates(compopt); generate_job_candidates(compopt); generate_signal_candidates(compopt); generate_logname_candidates(compopt); generate_group_candidates(compopt); generate_host_candidates(compopt); generate_bindkey_candidates(compopt); generate_dirstack_candidates(compopt); for (const le_comppattern_T *p = compopt->patterns; p != NULL; p = p->next) xfnm_free(p->cpattern); } /* Adds the specified value as a completion candidate to the candidate list. * The ignored prefix in `ctxt->origsrc' is prepended to the candidate value. * A description for the candidate can be given as `desc', which may be NULL * when no description is provided. * Arguments `value' and `desc' must be freeable strings, which are used as the * candidate value and description, respectively. * This function must NOT be used for a CT_FILE candidate. * If `value' is NULL, this function does nothing (except freeing `desc'). */ void le_new_candidate(le_candtype_T type, wchar_t *value, wchar_t *desc, const le_compopt_T *compopt) { if (value == NULL) { free(desc); return; } if (desc != NULL && (desc[0] == L'\0' || wcscmp(value, desc) == 0)) { /* ignore useless description */ free(desc); desc = NULL; } le_candidate_T *cand = xmalloc(sizeof *cand); cand->type = type; cand->value = value; cand->rawvalue.raw = NULL; cand->rawvalue.width = 0; cand->desc = desc; cand->rawdesc.raw = NULL; cand->rawdesc.width = 0; le_add_candidate(cand, compopt); } /* Adds the specified candidate to the candidate list. * The le_candidate_T structure must have been properly initialized, except for * the `origvalue' and `terminate' members, which are initialized in this * function. * This function treats the prefix and suffix specified in the "complete" * built-in invocation. */ void le_add_candidate(le_candidate_T *cand, const le_compopt_T *compopt) { xwcsbuf_T buf; wb_initwith(&buf, cand->value); /* prepend prefix */ const wchar_t *origsrc = compopt->ctxt->src; size_t prefixlength = compopt->src - origsrc; if (prefixlength != 0) wb_ninsert_force(&buf, 0, origsrc, prefixlength); /* append suffix */ bool allowterminate = true; if ((cand->type == CT_FILE) && S_ISDIR(cand->appendage.filestat.mode) && !(compopt->type & CGT_DIRECTORY)) { wb_wccat(&buf, L'/'); allowterminate = false; } else if (compopt->suffix != NULL) { wb_cat(&buf, compopt->suffix); } cand->origvalue = wb_towcs(&buf); cand->value = &cand->origvalue[prefixlength]; cand->terminate = compopt->terminate && allowterminate; if (le_state_is_compdebug) { const char *typestr = NULL; switch (cand->type) { case CT_WORD: typestr = "word"; break; case CT_FILE: typestr = "file"; break; case CT_COMMAND: typestr = "command"; break; case CT_ALIAS: typestr = "alias"; break; case CT_OPTION: typestr = "option"; break; case CT_VAR: typestr = "variable"; break; case CT_JOB: typestr = "job"; break; case CT_SIG: typestr = "signal"; break; case CT_LOGNAME: typestr = "user name"; break; case CT_GRP: typestr = "group name"; break; case CT_HOSTNAME: typestr = "host name"; break; case CT_BINDKEY: typestr = "lineedit command"; break; } le_compdebug("new %s candidate \"%ls\"", typestr, cand->origvalue); if (cand->desc != NULL) le_compdebug(" (desc: %ls)", cand->desc); if (!cand->terminate) le_compdebug(" (no termination)"); } pl_add(&le_candidates, cand); } /* Compiles `pattern's in `compopt->patterns' into `cpattern's if not yet * compiled. Returns true iff successful. */ bool le_compile_cpatterns(const le_compopt_T *compopt) { for (le_comppattern_T *p = compopt->patterns; p != NULL; p = p->next) { if (p->cpattern != NULL) continue; p->cpattern = xfnm_compile(p->pattern, XFNM_HEADONLY | XFNM_TAILONLY); if (p->cpattern == NULL) { le_compdebug("failed to compile pattern \"%ls\"", p->pattern); return false; } } return true; } /* Perform pattern matching for multibyte string `s' using patterns `ps'. * The patterns must have been compiled. Returns true iff successful. */ bool le_match_patterns(const le_comppattern_T *ps, const char *s) { for (; ps != NULL; ps = ps->next){ bool match = (xfnm_match(ps->cpattern, s) == 0); switch (ps->type) { case CPT_ACCEPT: if (!match) return false; break; case CPT_REJECT: if (match) return false; break; } } return true; } /* Perform pattern matching for multibyte string `s' using patterns in * `compopt->patterns'. The patterns must have been compiled. * Returns true iff successful. */ bool le_match_comppatterns(const le_compopt_T *compopt, const char *s) { return le_match_patterns(compopt->patterns, s); } /* Perform pattern matching for wide string `s' using patterns `ps'. * The patterns must have been compiled. Returns true iff successful. */ bool le_wmatch_patterns(const le_comppattern_T *ps, const wchar_t *s) { for (; ps != NULL; ps = ps->next) { bool match = (xfnm_wmatch(ps->cpattern, s).start != (size_t) -1); switch (ps->type) { case CPT_ACCEPT: if (!match) return false; break; case CPT_REJECT: if (match) return false; break; } } return true; } /* Perform pattern matching for wide string `s' using patterns in * `compopt->patterns'. The patterns must have been compiled. * Returns true iff successful. */ bool le_wmatch_comppatterns(const le_compopt_T *compopt, const wchar_t *s) { return le_wmatch_patterns(compopt->patterns, s); } /* Generates file name candidates. * The CGT_FILE, CGT_DIRECTORY, and CGT_EXECUTABLE flags specify what candidate * to generate. The other flags are ignored. */ void generate_file_candidates(const le_compopt_T *compopt) { if (!(compopt->type & (CGT_FILE | CGT_DIRECTORY | CGT_EXECUTABLE))) return; le_compdebug("adding filename candidates"); if (!le_compile_cpatterns(compopt)) return; enum wglobflags_T flags = 0; // if (shopt_nocaseglob) flags |= WGLB_CASEFOLD; XXX case-sensitive if (shopt_dotglob) flags |= WGLB_PERIOD; if (shopt_extendedglob) flags |= WGLB_RECDIR; const le_comppattern_T *p = compopt->patterns; assert(p->type == CPT_ACCEPT); /* generate candidates by wglob */ plist_T list; wglob(p->pattern, flags, pl_init(&list)); p = p->next; /* check pathnames in `list' and add them to the candidate list */ for (size_t i = 0; i < list.length; i++) { wchar_t *name = list.contents[i]; if (p != NULL) { const wchar_t *basename = wcsrchr(name, L'/'); if (basename == NULL) basename = name; if (!le_wmatch_patterns(p, basename)) { free(name); continue; } } char *mbsname = malloc_wcstombs(name); struct stat st; if (mbsname != NULL && (stat(mbsname, &st) >= 0 || lstat(mbsname, &st) >= 0)) { bool executable = S_ISREG(st.st_mode) && is_executable(mbsname); if ((compopt->type & CGT_FILE) || ((compopt->type & CGT_DIRECTORY) && S_ISDIR(st.st_mode)) || ((compopt->type & CGT_EXECUTABLE) && executable)) { le_candidate_T *cand = xmalloc(sizeof *cand); cand->type = CT_FILE; cand->value = name; cand->rawvalue.raw = NULL; cand->rawvalue.width = 0; cand->desc = NULL; cand->rawdesc.raw = NULL; cand->rawdesc.width = 0; cand->appendage.filestat.is_executable = executable; cand->appendage.filestat.mode = st.st_mode; cand->appendage.filestat.nlink = st.st_nlink; cand->appendage.filestat.size = st.st_size; le_add_candidate(cand, compopt); name = NULL; } } free(name); free(mbsname); } pl_destroy(&list); } /* Generates candidates that are the names of external commands matching the * pattern. * If CGT_EXTCOMMAND is not in `type', this function does nothing. */ void generate_external_command_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_EXTCOMMAND)) return; le_compdebug("adding external command name candidates"); if (!le_compile_cpatterns(compopt)) return; char *const *paths = get_path_array(PA_PATH); xstrbuf_T path; if (paths == NULL) return; sb_init(&path); for (const char *dirpath; (dirpath = *paths) != NULL; paths++) { DIR *dir = opendir(dirpath); struct dirent *de; size_t dirpathlen; if (dir == NULL) continue; sb_cat(&path, dirpath); if (path.length > 0 && path.contents[path.length - 1] != '/') sb_ccat(&path, '/'); dirpathlen = path.length; while ((de = readdir(dir)) != NULL) { if (!le_match_comppatterns(compopt, de->d_name)) continue; sb_cat(&path, de->d_name); if (is_executable_regular(path.contents)) le_new_candidate(CT_COMMAND, malloc_mbstowcs(de->d_name), NULL, compopt); sb_truncate(&path, dirpathlen); } sb_clear(&path); closedir(dir); } sb_destroy(&path); } /* Generates candidates that are keywords matching the pattern. */ void generate_keyword_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_KEYWORD)) return; le_compdebug("adding keyword candidates"); if (!le_compile_cpatterns(compopt)) return; static const wchar_t *keywords[] = { L"case", L"do", L"done", L"elif", L"else", L"esac", L"fi", L"for", L"function", L"if", L"then", L"until", L"while", NULL, // XXX "select" is not currently supported }; for (const wchar_t **k = keywords; *k != NULL; k++) if (le_wmatch_comppatterns(compopt, *k)) le_new_candidate(CT_COMMAND, xwcsdup(*k), NULL, compopt); } /* Generates candidates to complete a user name matching the pattern. */ void generate_logname_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_LOGNAME)) return; le_compdebug("adding user name candidates"); #if HAVE_GETPWENT if (!le_compile_cpatterns(compopt)) return; struct passwd *pwd; setpwent(); while ((pwd = getpwent()) != NULL) if (le_match_comppatterns(compopt, pwd->pw_name)) le_new_candidate(CT_LOGNAME, malloc_mbstowcs(pwd->pw_name), # if HAVE_PW_GECOS (pwd->pw_gecos != NULL) ? malloc_mbstowcs(pwd->pw_gecos) : # endif NULL, compopt); endpwent(); #else le_compdebug(" getpwent not supported on this system"); #endif } /* Generates candidates to complete a group name matching the pattern. */ void generate_group_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_GROUP)) return; le_compdebug("adding group name candidates"); #if HAVE_GETGRENT if (!le_compile_cpatterns(compopt)) return; struct group *grp; setgrent(); while ((grp = getgrent()) != NULL) if (le_match_comppatterns(compopt, grp->gr_name)) le_new_candidate( CT_GRP, malloc_mbstowcs(grp->gr_name), NULL, compopt); endgrent(); #else le_compdebug(" getgrent not supported on this system"); #endif } /* Generates candidates to complete a host name matching the pattern. */ void generate_host_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_HOSTNAME)) return; le_compdebug("adding host name candidates"); #if HAVE_GETHOSTENT if (!le_compile_cpatterns(compopt)) return; struct hostent *host; sethostent(true); while ((host = gethostent()) != NULL) { if (le_match_comppatterns(compopt, host->h_name)) le_new_candidate( CT_HOSTNAME, malloc_mbstowcs(host->h_name), NULL, compopt); if (host->h_aliases != NULL) for (char *const *a = host->h_aliases; *a != NULL; a++) if (le_match_comppatterns(compopt, *a)) le_new_candidate( CT_HOSTNAME, malloc_mbstowcs(*a), NULL, compopt); } endhostent(); #else le_compdebug(" gethostent not supported on this system"); #endif } /* Generates candidates from words that match the pattern. */ void generate_candidates_from_words( le_candtype_T type, void *const *words, const wchar_t *description, const le_compopt_T *compopt) { if (words[0] == NULL) return; le_compdebug("adding specified words"); if (!le_compile_cpatterns(compopt)) return; const wchar_t *word; for (size_t i = 0; (word = words[i]) != NULL; i++) { if (le_wmatch_comppatterns(compopt, word)) le_new_candidate(type, xwcsdup(word), (description == NULL) ? NULL : xwcsdup(description), compopt); } } /* Generates candidates with the specified word values. * The words must be given as (const wchar_t *). * The first argument `count' is the number of the words. */ void word_completion(size_t count, ...) { va_list ap; le_comppattern_T pattern = { .type = CPT_ACCEPT, .pattern = ctxt->pattern, }; le_compopt_T compopt = { .ctxt = ctxt, .type = 0, .src = ctxt->src, .patterns = &pattern, .suffix = NULL, .terminate = true, }; print_compopt_info(&compopt); va_start(ap, count); for (size_t i = 0; i < count; i++) { const wchar_t *word = va_arg(ap, const wchar_t *); if (matchwcsprefix(word, compopt.src)) le_new_candidate(CT_WORD, xwcsdup(word), NULL, &compopt); } va_end(ap); } /********** Displaying Functions **********/ /* Calculates the length of the longest common prefix (leading substring) * for the current candidates. * The result includes the ignored prefix in the candidate values. * The result is saved in `common_prefix_length'. * There must be at least one candidate in `le_candidates'. */ size_t get_common_prefix_length(void) { assert(le_candidates.contents != NULL); assert(le_candidates.length > 0); if (common_prefix_length != (size_t) -1) return common_prefix_length; const le_candidate_T *cand = le_candidates.contents[0]; const wchar_t *value = cand->origvalue; size_t cpl = wcslen(value); for (size_t i = 1; i < le_candidates.length; i++) { cand = le_candidates.contents[i]; const wchar_t *value2 = cand->origvalue; for (size_t j = 0; j < cpl; j++) if (value[j] != value2[j]) // XXX comparison is case-sensitive cpl = j; } common_prefix_length = cpl; if (le_state_is_compdebug) { wchar_t value[common_prefix_length + 1]; wmemcpy(value, cand->origvalue, common_prefix_length); value[common_prefix_length] = L'\0'; le_compdebug("candidate common prefix: \"%ls\"", value); } return common_prefix_length; } /* Inserts the currently selected candidate into the main buffer. * The already inserted candidate is replaced if any. * When no candidate is selected, sets to the longest common prefix of the * candidates. There must be at least one candidate. * If `subst' is true, the whole source word is replaced with the candidate * value. Otherwise, the source word is appended (in which case the word must * have a valid common prefix). * If `finish' is true and if the completed candidate's `terminate' member is * true, the word is closed so that the next word can just be entered directly. * If either `subst' or `finish' is true, the completion state must be cleaned * up after this function. */ void update_main_buffer(bool subst, bool finish) { const le_candidate_T *cand; xwcsbuf_T buf; size_t srclen; size_t substindex; le_quote_T quotetype; wb_init(&buf); if (subst) { srclen = 0; substindex = ctxt->srcindex; quotetype = QUOTE_NORMAL; } else { srclen = wcslen(ctxt->src); substindex = ctxt->origindex; quotetype = ctxt->quote; } if (le_selected_candidate_index >= le_candidates.length) { size_t cpl = get_common_prefix_length(); assert(srclen <= cpl); cand = le_candidates.contents[0]; size_t valuelen = cpl - srclen; wchar_t value[valuelen + 1]; wcsncpy(value, cand->origvalue + srclen, valuelen); value[valuelen] = L'\0'; quote(&buf, value, quotetype); } else { cand = le_candidates.contents[le_selected_candidate_index]; assert(srclen <= wcslen(cand->origvalue)); if (cand->origvalue[0] == L'\0' && quotetype == QUOTE_NORMAL) wb_cat(&buf, L"\"\""); else quote(&buf, cand->origvalue + srclen, quotetype); } assert(le_main_index >= substindex); wb_replace_force(&le_main_buffer, substindex, le_main_index - substindex, buf.contents, buf.length); le_main_index = substindex + buf.length; wb_destroy(&buf); if (le_selected_candidate_index >= le_candidates.length) return; if (!cand->terminate) return; switch (quotetype) { case QUOTE_NONE: case QUOTE_NORMAL: break; case QUOTE_SINGLE: insert_to_main_buffer(L'\''); break; case QUOTE_DOUBLE: insert_to_main_buffer(L'"'); break; } if (!finish) return; if (ctxt->type & CTXT_VBRACED) { insert_to_main_buffer(L'}'); return; } else if (ctxt->type & CTXT_EBRACED) { insert_to_main_buffer(L','); return; } if (ctxt->type & CTXT_QUOTED) { insert_to_main_buffer(L'"'); } switch (ctxt->type & CTXT_MASK) { case CTXT_NORMAL: case CTXT_COMMAND: case CTXT_ARGUMENT: case CTXT_VAR: case CTXT_ARITH: case CTXT_ASSIGN: case CTXT_REDIR: case CTXT_REDIR_FD: case CTXT_FOR_IN: case CTXT_FOR_DO: case CTXT_CASE_IN: case CTXT_FUNCTION: insert_to_main_buffer(L' '); break; case CTXT_TILDE: insert_to_main_buffer(L'/'); break; } } /* Inserts the specified character to the main buffer (`le_main_buffer') at the * current index (`le_main_index'). The index is increased by 1. */ void insert_to_main_buffer(wchar_t c) { wb_ninsert_force(&le_main_buffer, le_main_index, &c, 1); le_main_index += 1; } /* Determines whether the source word should be substituted even if * `ctxt->substsrc' is false. */ /* Returns true if there is a candidate that does not begin with * `ctxt->origsrc'. */ bool need_subst(void) { for (size_t i = 0; i < le_candidates.length; i++) { const le_candidate_T *cand = le_candidates.contents[i]; if (matchwcsprefix(cand->origvalue, ctxt->src) == NULL) return true; } return false; } /* Substitutes the source word in the main buffer with all of the current * candidates. `ctxt' must be a valid context. */ void substitute_source_word_all(void) { le_compdebug("substituting source word with candidate(s)"); /* remove source word */ wb_remove(&le_main_buffer, ctxt->srcindex, le_main_index - ctxt->srcindex); le_main_index = ctxt->srcindex; /* insert candidates */ xwcsbuf_T buf; wb_init(&buf); for (size_t i = 0; i < le_candidates.length; i++) { const le_candidate_T* cand = le_candidates.contents[i]; quote(&buf, cand->origvalue, QUOTE_NORMAL); wb_wccat(&buf, L' '); } wb_ninsert_force(&le_main_buffer, le_main_index, buf.contents, buf.length); le_main_index += buf.length; wb_destroy(&buf); } /* Quotes characters in the specified string that are not treated literally * in quotation mode `quotetype'. * The result is appended to the specified buffer, which must have been * initialized by the caller. */ void quote(xwcsbuf_T *restrict buf, const wchar_t *restrict s, le_quote_T quotetype) { const wchar_t *quotechars = (ctxt->type == CTXT_COMMAND) ? L"=|&;<>()$`\\\"'*?[]#~{}" : L"|&;<>()$`\\\"'*?[]#~{}"; switch (quotetype) { case QUOTE_NONE: wb_cat(buf, s); return; case QUOTE_NORMAL: for (size_t i = 0; s[i] != L'\0'; i++) { if (s[i] == L'\n') { wb_ncat_force(buf, L"'\n'", 3); } else { if (wcschr(quotechars, s[i]) != NULL || iswspace(s[i])) wb_wccat(buf, L'\\'); wb_wccat(buf, s[i]); } } return; case QUOTE_SINGLE: for (size_t i = 0; s[i] != L'\0'; i++) { if (s[i] != L'\'') wb_wccat(buf, s[i]); else wb_ncat_force(buf, L"'\\''", 4); } return; case QUOTE_DOUBLE: for (size_t i = 0; s[i] != L'\0'; i++) { if (wcschr(CHARS_ESCAPABLE, s[i]) != NULL) wb_wccat(buf, L'\\'); wb_wccat(buf, s[i]); } return; } assert(false); } /********** Built-ins **********/ /* Options for the "complete" built-in. */ const struct xgetopt_T complete_options[] = { { L'A', L"accept", OPTARG_REQUIRED, true, NULL, }, { L'a', L"alias", OPTARG_NONE, true, NULL, }, { L'-', L"array-variable", OPTARG_NONE, true, NULL, }, { L'-', L"bindkey", OPTARG_NONE, true, NULL, }, { L'b', L"builtin-command", OPTARG_NONE, true, NULL, }, { L'c', L"command", OPTARG_NONE, true, NULL, }, { L'D', L"description", OPTARG_REQUIRED, true, NULL, }, { L'd', L"directory", OPTARG_NONE, true, NULL, }, { L'-', L"dirstack-index", OPTARG_NONE, true, NULL, }, { L'-', L"executable-file", OPTARG_NONE, true, NULL, }, { L'-', L"external-command", OPTARG_NONE, true, NULL, }, { L'f', L"file", OPTARG_NONE, true, NULL, }, { L'-', L"finished-job", OPTARG_NONE, true, NULL, }, { L'-', L"function", OPTARG_NONE, true, NULL, }, { L'-', L"global-alias", OPTARG_NONE, true, NULL, }, { L'g', L"group", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'h', L"hostname", OPTARG_NONE, true, NULL, }, { L'j', L"job", OPTARG_NONE, true, NULL, }, { L'k', L"keyword", OPTARG_NONE, true, NULL, }, { L'T', L"no-termination", OPTARG_NONE, true, NULL, }, { L'-', L"normal-alias", OPTARG_NONE, true, NULL, }, { L'O', L"option", OPTARG_NONE, true, NULL, }, { L'P', L"prefix", OPTARG_REQUIRED, true, NULL, }, { L'-', L"regular-builtin", OPTARG_NONE, true, NULL, }, { L'R', L"reject", OPTARG_REQUIRED, true, NULL, }, { L'-', L"running-job", OPTARG_NONE, true, NULL, }, { L'-', L"scalar-variable", OPTARG_NONE, true, NULL, }, { L'-', L"semi-special-builtin", OPTARG_NONE, true, NULL, }, { L'-', L"signal", OPTARG_NONE, true, NULL, }, { L'-', L"special-builtin", OPTARG_NONE, true, NULL, }, { L'-', L"stopped-job", OPTARG_NONE, true, NULL, }, { L'S', L"suffix", OPTARG_REQUIRED, true, NULL, }, { L'u', L"username", OPTARG_NONE, true, NULL, }, { L'v', L"variable", OPTARG_NONE, true, NULL, }, { L'\0', NULL, 0, false, NULL, }, }; /* The "complete" built-in. */ int complete_builtin(int argc __attribute__((unused)), void **argv) { const wchar_t *prefix = NULL, *suffix = NULL; const wchar_t *description = NULL; le_candgentype_T cgtype = 0; le_candtype_T candtype = CT_WORD; le_comppattern_T *patterns = NULL; bool terminate = true; #define NEWPATTERN(typ) \ do { \ le_comppattern_T *newpattern = xmalloc(sizeof *newpattern); \ *newpattern = (le_comppattern_T) { \ .next = patterns, .type = typ, .pattern = xoptarg, \ }; \ patterns = newpattern; \ } while (0) int exitstatus; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, complete_options, 0)) != NULL) { switch (opt->shortopt) { case L'A': NEWPATTERN(CPT_ACCEPT); break; case L'a': cgtype |= CGT_ALIAS; break; case L'b': cgtype |= CGT_BUILTIN; break; case L'c': cgtype |= CGT_COMMAND; break; case L'D': if (description != NULL) goto dupopterror; description = xoptarg; break; case L'd': cgtype |= CGT_DIRECTORY; break; case L'f': cgtype |= CGT_FILE; break; case L'g': cgtype |= CGT_GROUP; break; case L'h': cgtype |= CGT_HOSTNAME; break; case L'j': cgtype |= CGT_JOB; break; case L'k': cgtype |= CGT_KEYWORD; break; case L'O': candtype = CT_OPTION; break; case L'P': if (prefix != NULL) goto dupopterror; prefix = xoptarg; break; case L'R': NEWPATTERN(CPT_REJECT); break; case L'S': if (suffix != NULL) goto dupopterror; suffix = xoptarg; break; case L'T': terminate = false; break; case L'u': cgtype |= CGT_LOGNAME; break; case L'v': cgtype |= CGT_VARIABLE; break; case L'-': switch (opt->longopt[0]) { case L'a': cgtype |= CGT_ARRAY; break; case L'b': cgtype |= CGT_BINDKEY; break; case L'd': cgtype |= CGT_DIRSTACK; break; case L'e': assert(opt->longopt[1] == L'x'); switch (opt->longopt[2]) { case L'e': cgtype |= CGT_EXECUTABLE; break; case L't': cgtype |= CGT_EXTCOMMAND; break; default: assert(false); } break; case L'f': switch (opt->longopt[1]) { case L'i': cgtype |= CGT_DONE; break; case L'u': cgtype |= CGT_FUNCTION; break; default: assert(false); } break; case L'g': cgtype |= CGT_GALIAS; break; #if YASH_ENABLE_HELP case L'h': exitstatus = print_builtin_help(ARGV(0)); goto finish; #endif case L'n': cgtype |= CGT_NALIAS; break; case L'r': switch (opt->longopt[1]) { case L'e': cgtype |= CGT_RBUILTIN; break; case L'u': cgtype |= CGT_RUNNING; break; default: assert(false); } break; case L's': switch (opt->longopt[1]) { case L'c': cgtype |= CGT_SCALAR; break; case L'e': cgtype |= CGT_SSBUILTIN; break; case L'i': cgtype |= CGT_SIGNAL; break; case L'p': cgtype |= CGT_SBUILTIN; break; case L't': cgtype |= CGT_STOPPED; break; default: assert(false); } break; default: assert(false); } break; dupopterror: xerror(0, Ngt("more than one -%lc option is specified"), (wint_t) opt->shortopt); /* falls thru */ default: exitstatus = Exit_ERROR; goto finish; } } #undef NEWPATTERN if (ctxt == NULL) { xerror(0, Ngt("the complete built-in can be used " "during command line completion only")); exitstatus = Exit_ERROR; goto finish; } void *const *words = &argv[xoptind]; /* treat `prefix' */ const wchar_t *src = ctxt->src, *pattern = ctxt->pattern; if (prefix != NULL) { src = matchwcsprefix(src, prefix); if (src == NULL) { xerror(0, Ngt("the specified prefix `%ls' does not match " "the target word `%ls'"), prefix, ctxt->src); exitstatus = Exit_ERROR; goto finish; } while (*prefix != L'\0') { if (*pattern == L'\\') pattern++; assert(*pattern != L'\0'); pattern++; prefix++; } } le_comppattern_T comppatterns = { .next = patterns, .type = CPT_ACCEPT, .pattern = pattern, }; le_compopt_T compopt = { .ctxt = ctxt, .type = cgtype, .src = src, .patterns = &comppatterns, .suffix = suffix, .terminate = terminate, }; print_compopt_info(&compopt); size_t oldcount = le_candidates.length; generate_candidates_from_words(candtype, words, description, &compopt); generate_candidates(&compopt); size_t newcount = le_candidates.length; exitstatus = (oldcount != newcount) ? Exit_SUCCESS : Exit_FAILURE; finish: while (patterns != NULL) { le_comppattern_T *next = patterns->next; free(patterns); patterns = next; } return exitstatus; } #if YASH_ENABLE_HELP const char complete_help[] = Ngt( "generate completion candidates" ); const char complete_syntax[] = Ngt( "\tcomplete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \\\n" "\t [-abcdfghjkuv] [[-O] [-D description] words...]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/compparse.d0000644000175000017500000000041012154557026016474 0ustar magicantmagicantcompparse.o: compparse.c ../common.h ../config.h compparse.h ../alias.h \ ../xgetopt.h ../expand.h ../option.h ../parser.h ../input.h ../plist.h \ ../strbuf.h ../util.h ../variable.h ../xfnmatch.h complete.h \ ../xgetopt.h editing.h key.h lineedit.h ../input.h yash-2.35/lineedit/display.h0000644000175000017500000000410312154557026016157 0ustar magicantmagicant/* Yash: yet another shell */ /* display.h: display control */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_DISPLAY_H #define YASH_DISPLAY_H #include #include "../input.h" #include "../strbuf.h" #include "lineedit.h" typedef struct le_pos_T { int line, column; } le_pos_T; extern struct lebuf_T { xstrbuf_T buf; le_pos_T pos; int maxcolumn; } lebuf; extern void lebuf_init(le_pos_T p); extern int lebuf_putchar(int c); extern void lebuf_update_position(int width); extern void lebuf_putwchar_raw(wchar_t c); extern void lebuf_putwchar(wchar_t c, _Bool convert_cntrl); extern void lebuf_putws(const wchar_t *s, _Bool convert_cntrl) __attribute__((nonnull)); extern void lebuf_print_prompt(const wchar_t *s) __attribute__((nonnull)); extern _Bool lebuf_putwchar_trunc(wchar_t c); extern void lebuf_putws_trunc(const wchar_t *s) __attribute__((nonnull)); extern void le_display_init(struct promptset_T prompt); extern void le_display_finalize(void); extern void le_display_clear(_Bool clear); extern void le_display_flush(void); extern void le_display_update(_Bool cursor); extern void le_display_make_rawvalues(void); extern void le_display_complete_cleanup(void); extern void le_display_select_column(int offset); extern void le_display_select_page(int offset); extern _Bool le_try_print_prompt(const wchar_t *s) __attribute__((nonnull)); #endif /* YASH_DISPLAY_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/editing.h0000644000175000017500000001572412154557026016150 0ustar magicantmagicant/* Yash: yet another shell */ /* editing.h: main editing module */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_EDITING_H #define YASH_EDITING_H #include #include "../strbuf.h" #include "key.h" extern xwcsbuf_T le_main_buffer; extern size_t le_main_index; enum le_search_direction_T { FORWARD, BACKWARD, }; /* FORWARD: find the oldest candidate from the ones newer than the current * BACKWARD: find the newest candidate from the ones older than the current */ enum le_search_type_T { SEARCH_PREFIX, SEARCH_VI, SEARCH_EMACS, }; extern enum le_search_direction_T le_search_direction; extern enum le_search_type_T le_search_type; extern xwcsbuf_T le_search_buffer; extern const struct histlink_T *le_search_result; extern void le_editing_init(void); extern wchar_t *le_editing_finalize(void) __attribute__((malloc,warn_unused_result)); extern void le_invoke_command(le_command_func_T *cmd, wchar_t arg) __attribute__((nonnull)); /********** Commands **********/ // This header file is parsed by the Makefile script to create the "commands.in" // file. For every line that ends with "/*C*/", the first word that starts with // "cmd_" is interpreted as a command name. /* basic commands */ extern le_command_func_T cmd_noop, /*C*/ cmd_alert, /*C*/ cmd_self_insert, /*C*/ cmd_insert_tab, /*C*/ cmd_expect_verbatim, /*C*/ cmd_digit_argument, /*C*/ cmd_bol_or_digit, /*C*/ cmd_accept_line, /*C*/ cmd_abort_line, /*C*/ cmd_eof, /*C*/ cmd_eof_if_empty, /*C*/ cmd_eof_or_delete, /*C*/ cmd_accept_with_hash, /*C*/ cmd_setmode_viinsert, /*C*/ cmd_setmode_vicommand, /*C*/ cmd_setmode_emacs, /*C*/ cmd_expect_char, /*C*/ cmd_abort_expect_char, /*C*/ cmd_redraw_all, /*C*/ cmd_clear_and_redraw_all; /*C*/ /* motion commands */ extern le_command_func_T cmd_forward_char, /*C*/ cmd_backward_char, /*C*/ cmd_forward_bigword, /*C*/ cmd_end_of_bigword, /*C*/ cmd_backward_bigword, /*C*/ cmd_forward_semiword, /*C*/ cmd_end_of_semiword, /*C*/ cmd_backward_semiword, /*C*/ cmd_forward_viword, /*C*/ cmd_end_of_viword, /*C*/ cmd_backward_viword, /*C*/ cmd_forward_emacsword, /*C*/ cmd_backward_emacsword, /*C*/ cmd_beginning_of_line, /*C*/ cmd_end_of_line, /*C*/ cmd_go_to_column, /*C*/ cmd_first_nonblank, /*C*/ cmd_find_char, /*C*/ cmd_find_char_rev, /*C*/ cmd_till_char, /*C*/ cmd_till_char_rev, /*C*/ cmd_refind_char, /*C*/ cmd_refind_char_rev; /*C*/ /* editing commands */ extern le_command_func_T cmd_delete_char, /*C*/ cmd_delete_bigword, /*C*/ cmd_delete_semiword, /*C*/ cmd_delete_viword, /*C*/ cmd_delete_emacsword, /*C*/ cmd_backward_delete_char, /*C*/ cmd_backward_delete_bigword, /*C*/ cmd_backward_delete_semiword, /*C*/ cmd_backward_delete_viword, /*C*/ cmd_backward_delete_emacsword, /*C*/ cmd_delete_line, /*C*/ cmd_forward_delete_line, /*C*/ cmd_backward_delete_line, /*C*/ cmd_kill_char, /*C*/ cmd_kill_bigword, /*C*/ cmd_kill_semiword, /*C*/ cmd_kill_viword, /*C*/ cmd_kill_emacsword, /*C*/ cmd_backward_kill_char, /*C*/ cmd_backward_kill_bigword, /*C*/ cmd_backward_kill_semiword, /*C*/ cmd_backward_kill_viword, /*C*/ cmd_backward_kill_emacsword, /*C*/ cmd_kill_line, /*C*/ cmd_forward_kill_line, /*C*/ cmd_backward_kill_line, /*C*/ cmd_put_before, /*C*/ cmd_put, /*C*/ cmd_put_left, /*C*/ cmd_put_pop, /*C*/ cmd_undo, /*C*/ cmd_undo_all, /*C*/ cmd_cancel_undo, /*C*/ cmd_cancel_undo_all, /*C*/ cmd_redo; /*C*/ /* completion commands */ extern le_command_func_T cmd_complete, /*C*/ cmd_complete_next_candidate, /*C*/ cmd_complete_prev_candidate, /*C*/ cmd_complete_next_column, /*C*/ cmd_complete_prev_column, /*C*/ cmd_complete_next_page, /*C*/ cmd_complete_prev_page, /*C*/ cmd_complete_list, /*C*/ cmd_complete_all, /*C*/ cmd_complete_max, /*C*/ cmd_clear_candidates; /*C*/ /* vi-mode specific commands */ extern le_command_func_T cmd_vi_replace_char, /*C*/ cmd_vi_insert_beginning, /*C*/ cmd_vi_append, /*C*/ cmd_vi_append_to_eol, /*C*/ cmd_vi_replace, /*C*/ cmd_vi_switch_case, /*C*/ cmd_vi_switch_case_char, /*C*/ cmd_vi_yank, /*C*/ cmd_vi_yank_to_eol, /*C*/ cmd_vi_delete, /*C*/ #define cmd_vi_delete_to_eol cmd_forward_kill_line /*C*/ cmd_vi_change, /*C*/ cmd_vi_change_to_eol, /*C*/ cmd_vi_change_line, /*C*/ cmd_vi_yank_and_change, /*C*/ cmd_vi_yank_and_change_to_eol, /*C*/ cmd_vi_yank_and_change_line, /*C*/ cmd_vi_substitute, /*C*/ cmd_vi_append_last_bigword, /*C*/ cmd_vi_exec_alias, /*C*/ cmd_vi_edit_and_accept, /*C*/ cmd_vi_complete_list, /*C*/ cmd_vi_complete_all, /*C*/ cmd_vi_complete_max, /*C*/ cmd_vi_search_forward, /*C*/ cmd_vi_search_backward; /*C*/ /* emacs-mode specific commands */ extern le_command_func_T cmd_emacs_transpose_chars, /*C*/ cmd_emacs_transpose_words, /*C*/ cmd_emacs_upcase_word, /*C*/ cmd_emacs_downcase_word, /*C*/ cmd_emacs_capitalize_word, /*C*/ cmd_emacs_delete_horizontal_space, /*C*/ cmd_emacs_just_one_space, /*C*/ cmd_emacs_search_forward, /*C*/ cmd_emacs_search_backward; /*C*/ /* history-related commands */ extern le_command_func_T cmd_oldest_history, /*C*/ cmd_newest_history, /*C*/ cmd_return_history, /*C*/ cmd_oldest_history_bol, /*C*/ cmd_newest_history_bol, /*C*/ cmd_return_history_bol, /*C*/ cmd_oldest_history_eol, /*C*/ cmd_newest_history_eol, /*C*/ cmd_return_history_eol, /*C*/ cmd_next_history, /*C*/ cmd_prev_history, /*C*/ cmd_next_history_bol, /*C*/ cmd_prev_history_bol, /*C*/ cmd_next_history_eol, /*C*/ cmd_prev_history_eol, /*C*/ /* command history search */ cmd_srch_self_insert, /*C*/ cmd_srch_backward_delete_char, /*C*/ cmd_srch_backward_delete_line, /*C*/ cmd_srch_continue_forward, /*C*/ cmd_srch_continue_backward, /*C*/ cmd_srch_accept_search, /*C*/ cmd_srch_abort_search, /*C*/ cmd_search_again, /*C*/ cmd_search_again_rev, /*C*/ cmd_search_again_forward, /*C*/ cmd_search_again_backward, /*C*/ cmd_beginning_search_forward, /*C*/ cmd_beginning_search_backward; /*C*/ #endif /* YASH_EDITING_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/terminfo.d0000644000175000017500000000026312154557026016334 0ustar magicantmagicantterminfo.o: terminfo.c ../common.h ../config.h terminfo.h ../option.h \ ../xgetopt.h ../sig.h ../util.h ../variable.h display.h ../input.h \ ../strbuf.h lineedit.h key.h trie.h yash-2.35/lineedit/display.c0000644000175000017500000013067212154557026016165 0ustar magicantmagicant/* Yash: yet another shell */ /* display.c: display control */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "display.h" #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include #include #include #include "../history.h" #include "../job.h" #include "../option.h" #include "../plist.h" #include "../strbuf.h" #include "../util.h" #include "complete.h" #include "editing.h" #include "terminfo.h" /* Characters displayed on the screen by line-editing are divided into three * parts: the prompt, the edit line and the candidate area. * The prompt is immediately followed by the edit line (on the same line) but * the candidate area are always on separate lines. * The three parts are printed in this order, from upper to lower. * When history search is active, the edit line is replaced by the temporary * search result line and the search target line. * * We have to track the cursor position each time we print a character on the * screen, so that we can correctly reposition the cursor later. To do this, we * use a buffer (`lebuf') accompanied by a position data. The `lebuf_putwchar' * function appends a wide character to the buffer and updates the position data * accordingly. * * In most terminals, when as many characters are printed as the number of * the columns, the cursor temporarily sticks to the end of the line. The cursor * moves to the next line immediately before the next character is printed. So * we must take care not to move the cursor (by the "cub1" capability, etc.) * when the cursor is sticking, or we cannot track the cursor position * correctly. To deal with this problem, if we finish printing a text at the end * of a line, we print a dummy space character and erase it to ensure the cursor * is no longer sticking. */ #if HAVE_WCWIDTH # ifndef wcwidth extern int wcwidth(wchar_t c); # endif #else # undef wcwidth # define wcwidth(c) (iswprint(c) ? 1 : 0) #endif /********** The Print Buffer **********/ static void lebuf_init_with_max(le_pos_T p, int maxcolumn); static void lebuf_wprintf(bool convert_cntrl, const wchar_t *format, ...) __attribute__((nonnull(2))); static const wchar_t *print_color_seq(const wchar_t *s) __attribute__((nonnull)); static bool lebuf_putchar1_trunc(int c); /* The print buffer. */ struct lebuf_T lebuf; /* Initializes the print buffer with the specified position data. */ void lebuf_init(le_pos_T p) { lebuf_init_with_max(p, le_columns); } /* Initializes the print buffer with the specified position data. * The number of columns in a line is specified by `maxcolumn'. * If `maxcolumn' is negative, it is considered as infinite. */ void lebuf_init_with_max(le_pos_T p, int maxcolumn) { lebuf.pos = p; lebuf.maxcolumn = maxcolumn; sb_init(&lebuf.buf); } /* Appends the specified byte to the print buffer without updating the position * data. Returns the appended character `c'. */ /* The signature of this function is so defined as to match that of the * `putchar' function. */ int lebuf_putchar(int c) { sb_ccat(&lebuf.buf, TO_CHAR(c)); return c; } /* Updates the position data of the print buffer as if a character with the * specified width has been printed. * The specified width must not be less than zero. */ void lebuf_update_position(int width) { assert(width >= 0); int new_column = lebuf.pos.column + width; if (lebuf.maxcolumn < 0 || new_column < lebuf.maxcolumn || (le_ti_xenl && new_column == lebuf.maxcolumn)) lebuf.pos.column = new_column; else if (new_column == lebuf.maxcolumn) lebuf.pos.line++, lebuf.pos.column = 0; else lebuf.pos.line++, lebuf.pos.column = width; } /* Appends the specified wide character to the print buffer without updating the * position data. */ void lebuf_putwchar_raw(wchar_t c) { sb_printf(&lebuf.buf, "%lc", (wint_t) c); } /* Appends the specified wide character to the print buffer and updates the * position data accordingly. * If `convert_cntrl' is true, a non-printable character is converted to the * '^'-prefixed form or the bracketed form. */ void lebuf_putwchar(wchar_t c, bool convert_cntrl) { int width = wcwidth(c); if (width > 0) { /* printable character */ lebuf_update_position(width); lebuf_putwchar_raw(c); } else { /* non-printable character */ if (!convert_cntrl) { switch (c) { case L'\a': lebuf_print_alert(false); return; case L'\n': lebuf_print_nel(); return; case L'\r': lebuf_print_cr(); return; default: lebuf_putwchar_raw(c); return; } } else { if (c < L'\040') { lebuf_putwchar(L'^', false); lebuf_putwchar(c + L'\100', true); } else if (c == L'\177') { lebuf_putwchar(L'^', false); lebuf_putwchar(L'?', false); } else { lebuf_wprintf(false, L"<%jX>", (uintmax_t) c); } } } } /* Appends the specified string to the print buffer. */ void lebuf_putws(const wchar_t *s, bool convert_cntrl) { for (size_t i = 0; s[i] != L'\0'; i++) lebuf_putwchar(s[i], convert_cntrl); } /* Appends the formatted string to the print buffer. */ void lebuf_wprintf(bool convert_cntrl, const wchar_t *format, ...) { va_list args; wchar_t *s; va_start(args, format); s = malloc_vwprintf(format, args); va_end(args); lebuf_putws(s, convert_cntrl); free(s); } /* Prints the specified prompt string to the print buffer. * Escape sequences, which are defined in "../input.c", are handled in this * function. */ void lebuf_print_prompt(const wchar_t *s) { le_pos_T save_pos = lebuf.pos; while (*s != L'\0') { if (*s != L'\\') { lebuf_putwchar(*s, false); } else switch (*++s) { default: lebuf_putwchar(*s, false); break; case L'\0': lebuf_putwchar(L'\\', false); goto done; // case L'\\': lebuf_putwchar(L'\\', false); break; case L'a': lebuf_putwchar(L'\a', false); break; case L'e': lebuf_putwchar(L'\033', false); break; case L'n': lebuf_putwchar(L'\n', false); break; case L'r': lebuf_putwchar(L'\r', false); break; case L'$': lebuf_putwchar(geteuid() != 0 ? L'$' : L'#', false); break; case L'j': lebuf_wprintf(false, L"%zu", job_count()); break; case L'!': lebuf_wprintf(false, L"%u", next_history_number()); break; case L'[': save_pos = lebuf.pos; break; case L']': lebuf.pos = save_pos; break; case L'f': s = print_color_seq(s); continue; } s++; } done:; } /* Prints a sequence to change the terminal font. * When this function is called, `*s' must be L'f' after the backslash. * This function returns a pointer to the character just after the escape * sequence. */ const wchar_t *print_color_seq(const wchar_t *s) { assert(s[-1] == L'\\'); assert(s[ 0] == L'f'); #define SETFG(color) \ lebuf_print_setfg(LE_COLOR_##color + (s[1] == L't' ? 8 : 0)) #define SETBG(color) \ lebuf_print_setbg(LE_COLOR_##color + (s[1] == L't' ? 8 : 0)) for (;;) switch (*++s) { case L'k': SETFG(BLACK); break; case L'r': SETFG(RED); break; case L'g': SETFG(GREEN); break; case L'y': SETFG(YELLOW); break; case L'b': SETFG(BLUE); break; case L'm': SETFG(MAGENTA); break; case L'c': SETFG(CYAN); break; case L'w': SETFG(WHITE); break; case L'K': SETBG(BLACK); break; case L'R': SETBG(RED); break; case L'G': SETBG(GREEN); break; case L'Y': SETBG(YELLOW); break; case L'B': SETBG(BLUE); break; case L'M': SETBG(MAGENTA); break; case L'C': SETBG(CYAN); break; case L'W': SETBG(WHITE); break; case L'd': lebuf_print_op(); break; case L'D': lebuf_print_sgr0(); break; case L's': lebuf_print_smso(); break; case L'u': lebuf_print_smul(); break; case L'v': lebuf_print_rev(); break; case L'n': lebuf_print_blink(); break; case L'i': lebuf_print_dim(); break; case L'o': lebuf_print_bold(); break; case L'x': lebuf_print_invis(); break; default: if (!iswalnum(*s)) goto done; } done: if (*s == L'.') s++; return s; #undef SETFG #undef SETBG } /* Like `lebuf_putwchar', but prints only if there are enough column to the * right of the current position. * Returns false iff there is not enough column. * Returns true for a non-printable character. */ bool lebuf_putwchar_trunc(wchar_t c) { int width = wcwidth(c); if (width <= 0) return true; int new_column = lebuf.pos.column + width; if (0 <= lebuf.maxcolumn && lebuf.maxcolumn <= new_column) return false; lebuf.pos.column = new_column; lebuf_putwchar_raw(c); return true; } /* Like `lebuf_putws', but stops printing when the cursor reaches the end of * the line. Non-printable characters are ignored. */ void lebuf_putws_trunc(const wchar_t *s) { while (*s != L'\0' && lebuf_putwchar_trunc(*s)) s++; } /* Like `lebuf_putwchar_trunc', but prints a byte instead of a wide character. * The width of the character byte is assumed to be 1. */ bool lebuf_putchar1_trunc(int c) { if (0 < lebuf.maxcolumn && lebuf.maxcolumn <= lebuf.pos.column + 1) return false; lebuf.pos.column += 1; sb_ccat(&lebuf.buf, TO_CHAR(c)); return true; } /********** Displaying **********/ typedef struct candpage_T candpage_T; typedef struct candcol_T candcol_T; static void finish(void); static void clear_to_end_of_screen(void); static void clear_editline(void); static void maybe_print_promptsp(void); static void update_editline(void); static void check_cand_overwritten(void); static void update_styler(void); static void reset_style_before_moving(void); static void update_right_prompt(void); static void print_search(void); static void go_to(le_pos_T p); static void go_to_index(size_t index); static void go_to_after_editline(void); static void fillip_cursor(void); static void print_candidate_rawvalue(const le_candidate_T *cand) __attribute__((nonnull)); static void update_candidates(void); static void make_pages_and_columns(void); static bool arrange_candidates(size_t cand_per_col, int totalwidthlimit); static void divide_candidates_pages(size_t cand_per_col); static void free_candpage(void *candpage) __attribute__((nonnull)); static void free_candcol(void *candcol) __attribute__((nonnull)); static void print_candidates_all(void); static void update_highlighted_candidate(void); static void print_candidate(const le_candidate_T *cand, const candcol_T *col, bool highlight, bool printdesc) __attribute__((nonnull)); static void print_candidate_count(size_t pageindex); static void print_candidate_count_0(void); static size_t col_of_cand(size_t candindex); static int col_of_cand_cmp(const void *candindexp, const void *colp) __attribute__((nonnull)); static size_t page_of_col(size_t colindex); static int page_of_col_cmp(const void *colindexp, const void *pagep) __attribute__((nonnull)); static size_t select_list_item(size_t index, int offset, size_t listsize) __attribute__((const)); /* True when the prompt is displayed on the screen. */ /* The print buffer, `rprompt', and `sprompt' are valid iff `display_active' is * true. */ static bool display_active = false; /* The current cursor position. */ static le_pos_T current_position; /* The maximum number of lines that have been displayed. */ static int line_max; /* The set of strings printed as the prompt, right prompt, after prompt. * May contain escape sequences. */ static struct promptset_T prompt; /* The position of the first character of the edit line, just after the prompt. */ static le_pos_T editbasepos; /* The content of the edit line that is currently displayed on the screen. */ static wchar_t *current_editline = NULL; /* An array of cursor positions of each character in the edit line. * If the nth character of `current_editline' is positioned at line `l', column * `c', then cursor_positions[n] == l * le_columns + c. */ static int *cursor_positions = NULL; /* The line number of the last edit line (or the search buffer). */ static int last_edit_line; /* True when the terminal's current font setting is the one set by the styler * prompt. */ static bool styler_active; /* The line on which the right prompt is displayed. * The value is -1 when the right prompt is not displayed. */ static int rprompt_line; /* The value of the right prompt where escape sequences have been processed. */ static struct { char *value; size_t length; /* number of bytes in `value' */ int width; /* width of right prompt on screen */ } rprompt; /* The value of the styler prompt where escape sequences have been processed. */ static struct { char *value; size_t length; /* number of bytes in `value' */ } sprompt; /* The type of completion candidate pages. */ struct candpage_T { size_t colindex; /* index of the first column in this page */ size_t colcount; /* number of the columns in this page */ }; /* The type of completion candidate columns. */ struct candcol_T { size_t candindex; /* index of the first candidate in this column */ size_t candcount; /* number of the candidates in this column */ int valuewidth; /* max width of the candidate values */ int descwidth; /* max width of the candidate descriptions */ int width; /* total width of the whole column. */ }; /* A list of completion candidate pages. * The elements pointed to by `candpages.contents[*]' are of type `candpage_T'. */ static plist_T candpages = { .contents = NULL }; /* A list of completion candidate columns. * The elements pointed to by `candcols.contents[*]' are of type `candcol_T'. * `candcols' is active iff `candpages' is active. */ static plist_T candcols = { .contents = NULL }; /* The index of the candidate that is currently highlighted. * An invalid index indicates that no candidate is highlighted. */ static size_t candhighlight; #define NOHIGHLIGHT ((size_t) -1) /* The number of the first line on which the candidate area is displayed. * When the candidate area is inactive, this value is negative. */ /* When the candidate area is overwritten by the edit line or the right prompt, * this value is updated to the first line number of the remaining area. */ static int candbaseline; /* When the candidate area is overwritten by the edit line or the right prompt, * this flag is set. */ static bool candoverwritten; /* Initializes the display module. */ void le_display_init(struct promptset_T prompt_) { prompt = prompt_; } /* Updates the prompt and the edit line, clears the candidate area, and leave * the cursor at a blank line. * Must be called before `le_editing_finalize'. */ void le_display_finalize(void) { assert(le_search_buffer.contents == NULL); le_display_update(false); lebuf_print_sgr0(); go_to_after_editline(); finish(); } /* Clears prompt, edit line and candidate area on the screen. * If `clear' is true, also prints the "clear" capability. */ void le_display_clear(bool clear) { if (display_active) { lebuf_init(current_position); lebuf_print_sgr0(); if (clear) lebuf_print_clear(); else go_to((le_pos_T) { 0, 0 }); finish(); } } /* Deactivates the display. * Can be called only when `display_active' is true. * This function clears the completion candidates, flushes the `lebuf' buffer, * and frees data that are no longer in use. */ void finish(void) { assert(display_active); clear_to_end_of_screen(), candbaseline = -1; le_display_complete_cleanup(); free(current_editline), current_editline = NULL; free(cursor_positions), cursor_positions = NULL; free(rprompt.value); free(sprompt.value); le_display_flush(); display_active = false; } /* Flushes the contents of the print buffer to the standard error and destroys * the buffer. */ void le_display_flush(void) { current_position = lebuf.pos; fwrite(lebuf.buf.contents, 1, lebuf.buf.length, stderr); fflush(stderr); sb_destroy(&lebuf.buf); } /* Clears the screen area below the cursor. * The cursor must be at the beginning of a line. */ void clear_to_end_of_screen(void) { assert(lebuf.pos.column == 0); reset_style_before_moving(); if (lebuf_print_ed()) /* if the terminal has "ed" capability, just use it */ return; int saveline = lebuf.pos.line; for (;;) { lebuf_print_el(); if (lebuf.pos.line >= line_max) break; lebuf_print_nel(); } go_to((le_pos_T) { saveline, 0 }); } /* Clears (part of) the edit line on the screen from the current cursor * position to the end of the edit line. * The prompt and the candidate area are not cleared. * When this function is called, the cursor must be positioned within the edit * line. When this function returns, the cursor is moved back to that position. */ void clear_editline(void) { assert(lebuf.pos.line > editbasepos.line || (lebuf.pos.line == editbasepos.line && lebuf.pos.column >= editbasepos.column)); le_pos_T save_pos = lebuf.pos; reset_style_before_moving(); for (;;) { lebuf_print_el(); if (lebuf.pos.line >= last_edit_line) break; lebuf_print_nel(); } rprompt_line = -1; go_to(save_pos); } /* (Re)prints the display appropriately and, if `cursor' is true, moves the * cursor to the proper position. * The print buffer must not have been initialized. * The output is sent to the print buffer. The buffer needs to be flushed for * its contents to be actually displayed. */ void le_display_update(bool cursor) { if (display_active) { lebuf_init(current_position); } else { display_active = true; last_edit_line = line_max = 0; candhighlight = NOHIGHLIGHT, candbaseline = -1, candoverwritten = false; /* prepare the right prompt */ lebuf_init((le_pos_T) { 0, 0 }); lebuf_print_sgr0(); lebuf_print_prompt(prompt.right); if (lebuf.pos.line != 0) { /* right prompt must be one line */ sb_clear(&lebuf.buf); /* lebuf.pos.line = */ lebuf.pos.column = 0; } rprompt.value = lebuf.buf.contents; rprompt.length = lebuf.buf.length; rprompt.width = lebuf.pos.column; rprompt_line = -1; /* prepare the styler prompt */ lebuf_init((le_pos_T) { 0, 0 }); lebuf_print_sgr0(); lebuf_print_prompt(prompt.styler); if (lebuf.pos.line != 0 || lebuf.pos.column != 0) { /* styler prompt must have no width */ sb_clear(&lebuf.buf); /* lebuf.pos.line = lebuf.pos.column = 0; */ } sprompt.value = lebuf.buf.contents; sprompt.length = lebuf.buf.length; styler_active = false; /* print main prompt */ lebuf_init((le_pos_T) { 0, 0 }); maybe_print_promptsp(); lebuf_print_prompt(prompt.main); fillip_cursor(); editbasepos = lebuf.pos; } if (le_search_buffer.contents == NULL) { /* print edit line */ update_editline(); } else { /* print search line */ print_search(); return; } /* print right prompt */ update_right_prompt(); /* print completion candidates */ update_candidates(); /* set cursor position */ assert(le_main_index <= le_main_buffer.length); if (cursor) { go_to_index(le_main_index); update_styler(); } } /* Prints a dummy string that moves the cursor to the first column of the next * line if the cursor is not at the first column. * This function does nothing if the "le-promptsp" option is not set. */ void maybe_print_promptsp(void) { if (shopt_le_promptsp) { lebuf_print_smso(); lebuf_putchar('$'); lebuf_print_sgr0(); for (int count = le_columns - (le_ti_xenl ? 1 : 2); --count >= 0; ) lebuf_putchar(' '); lebuf_print_cr(); lebuf_print_ed(); } } /* Prints the content of the edit line. * The cursor may be anywhere when this function is called. * The cursor is left at an unspecified position when this function returns. */ void update_editline(void) { size_t index = 0; if (current_editline != NULL) { /* We only reprint what have been changed from the last update: * skip the unchanged part at the beginning of the line. */ assert(cursor_positions != NULL); while (current_editline[index] != L'\0' && current_editline[index] == le_main_buffer.contents[index]) index++; /* return if nothing has changed */ if (current_editline[index] == L'\0' && le_main_buffer.contents[index] == L'\0') return; go_to_index(index); if (current_editline[index] != L'\0') clear_editline(); } else { /* print the whole edit line */ go_to(editbasepos); clear_editline(); } update_styler(); current_editline = xreallocn(current_editline, le_main_buffer.length + 1, sizeof *current_editline); cursor_positions = xreallocn(cursor_positions, le_main_buffer.length + 1, sizeof *cursor_positions); for (;;) { wchar_t c = le_main_buffer.contents[index]; current_editline[index] = c; cursor_positions[index] = lebuf.pos.line * lebuf.maxcolumn + lebuf.pos.column; if (index == le_main_buffer.length) break; lebuf_putwchar(c, true); index++; } fillip_cursor(); last_edit_line = (lebuf.pos.line >= rprompt_line) ? lebuf.pos.line : rprompt_line; /* clear the right prompt if the edit line reaches it. */ if (rprompt_line == lebuf.pos.line && lebuf.pos.column > lebuf.maxcolumn - rprompt.width - 2) { lebuf_print_el(); rprompt_line = -1; } else if (rprompt_line < lebuf.pos.line) { rprompt_line = -1; } /* clear the remaining of the current line if we're overwriting the * candidate area. */ check_cand_overwritten(); } /* Sets the `candoverwritten' flag and clears to the end of line if the current * position is in the candidate area. */ void check_cand_overwritten(void) { if (0 <= candbaseline && candbaseline <= lebuf.pos.line) { lebuf_print_el(); candbaseline = lebuf.pos.line + 1; candoverwritten = true; } } /* If the styler prompt is inactive, prints it. */ void update_styler(void) { if (!styler_active) { sb_ncat_force(&lebuf.buf, sprompt.value, sprompt.length); styler_active = true; } } /* If the "msgr" capability is unavailable, prints the "sgr0" capability. */ /* Cursor-moving capabilities cannot be used in the standout mode unless the * "msgr" capability is available. We need to reset text style using the "sgr0" * capability before moving cursor. */ void reset_style_before_moving(void) { if (!le_ti_msgr) { lebuf_print_sgr0(); styler_active = false; } } /* Prints the right prompt if there is enough room in the edit line or if the * "le-alwaysrp" option is set. * The edit line must have been printed when this function is called. */ void update_right_prompt(void) { if (rprompt_line >= 0) return; if (rprompt.width == 0) return; if (lebuf.maxcolumn - rprompt.width - 2 < 0) return; int c = cursor_positions[le_main_buffer.length] % lebuf.maxcolumn; bool has_enough_room = (c <= lebuf.maxcolumn - rprompt.width - 2); if (!has_enough_room && !shopt_le_alwaysrp) return; go_to_index(le_main_buffer.length); if (!has_enough_room) { lebuf_print_nel(); check_cand_overwritten(); } lebuf_print_cuf(lebuf.maxcolumn - rprompt.width - lebuf.pos.column - 1); sb_ncat_force(&lebuf.buf, rprompt.value, rprompt.length); lebuf.pos.column += rprompt.width; last_edit_line = rprompt_line = lebuf.pos.line; styler_active = false; } /* Prints the current search result and the search line. * The cursor may be anywhere when this function is called. * Characters after the prompt are cleared in this function. * When this function returns, the cursor is left after the search line. */ void print_search(void) { assert(le_search_buffer.contents != NULL); free(current_editline), current_editline = NULL; free(cursor_positions), cursor_positions = NULL; go_to(editbasepos); clear_editline(); update_styler(); if (le_search_result != Histlist) lebuf_wprintf(true, L"%s", ashistentry(le_search_result)->value); reset_style_before_moving(); lebuf_print_nel(); clear_to_end_of_screen(), candbaseline = -1; update_styler(); switch (le_search_type) { const char *text; case SEARCH_PREFIX: assert(false); case SEARCH_VI: switch (le_search_direction) { case FORWARD: lebuf_putwchar(L'?', false); break; case BACKWARD: lebuf_putwchar(L'/', false); break; default: assert(false); } break; case SEARCH_EMACS: switch (le_search_direction) { case FORWARD: text = "Forward search: "; break; case BACKWARD: text = "Backward search: "; break; default: assert(false); } lebuf_wprintf(false, L"%s", gt(text)); break; } lebuf_putws(le_search_buffer.contents, true); fillip_cursor(); last_edit_line = lebuf.pos.line; } /* Moves the cursor to the specified position. * The target column must be less than `lebuf.maxcolumn'. */ void go_to(le_pos_T p) { if (line_max < lebuf.pos.line) line_max = lebuf.pos.line; assert(p.line <= line_max); assert(p.column < lebuf.maxcolumn); if (p.line == lebuf.pos.line) { if (lebuf.pos.column == p.column) return; reset_style_before_moving(); if (lebuf.pos.column < p.column) lebuf_print_cuf(p.column - lebuf.pos.column); else lebuf_print_cub(lebuf.pos.column - p.column); return; } reset_style_before_moving(); lebuf_print_cr(); if (lebuf.pos.line < p.line) lebuf_print_cud(p.line - lebuf.pos.line); else if (lebuf.pos.line > p.line) lebuf_print_cuu(lebuf.pos.line - p.line); if (p.column > 0) lebuf_print_cuf(p.column); } /* Moves the cursor to the character of the specified index in the main buffer. * This function relies on `cursor_positions', so `update_editline()' must have * been called beforehand. */ void go_to_index(size_t index) { int p = cursor_positions[index]; go_to((le_pos_T) { .line = p / lebuf.maxcolumn, .column = p % lebuf.maxcolumn }); } /* Moves the cursor to the beginning of the line below `last_edit_line'. * The edit line (and possibly the right prompt) must have been printed. */ void go_to_after_editline(void) { if (rprompt_line >= 0) { go_to((le_pos_T) { rprompt_line, lebuf.maxcolumn - 1 }); lebuf_print_nel(); } else { go_to_index(le_main_buffer.length); if (lebuf.pos.column != 0 || lebuf.pos.line == 0) lebuf_print_nel(); } } /* If the cursor is sticking to the end of line, moves it to the next line. */ void fillip_cursor(void) { if (0 <= lebuf.maxcolumn && lebuf.maxcolumn <= lebuf.pos.column) { lebuf_putwchar(L' ', false); lebuf_putwchar(L'\r', false); lebuf_print_el(); if (rprompt_line == lebuf.pos.line) rprompt_line = -1; } } /* Sets the `raw' and `width' members of candidates in `le_candidates'. * This function uses the print buffer to calculate the widths. */ void le_display_make_rawvalues(void) { assert(le_candidates.contents != NULL); for (size_t i = 0; i < le_candidates.length; i++) { le_candidate_T *cand = le_candidates.contents[i]; assert(cand->rawvalue.raw == NULL); lebuf_init_with_max((le_pos_T) { 0, 0 }, -1); print_candidate_rawvalue(cand); cand->rawvalue.raw = sb_tostr(&lebuf.buf); cand->rawvalue.width = lebuf.pos.column; assert(cand->rawdesc.raw == NULL); if (cand->desc != NULL) { lebuf_init_with_max((le_pos_T) { 0, 0 }, -1); lebuf_putws_trunc(cand->desc); cand->rawdesc.raw = sb_tostr(&lebuf.buf); cand->rawdesc.width = lebuf.pos.column; } } } /* Prints the "raw value" of the specified candidate to the print buffer. * The output is truncated when the cursor reaches the end of the line. */ void print_candidate_rawvalue(const le_candidate_T *cand) { const wchar_t *s = cand->value; if (cand->type == CT_FILE) { /* skip directory components for a file candidate */ for (;;) { const wchar_t *ss = wcschr(s, L'/'); if (ss == NULL || *++ss == L'\0') break; s = ss; } } else if (cand->type == CT_OPTION) { /* prepend a hyphen if none */ if (cand->value[0] != L'-') lebuf_putwchar_trunc(L'-'); } lebuf_putws_trunc(s); } /* Updates the candidate area. * The edit line (and the right prompt if any) must have been printed before * calling this function. * The cursor may be anywhere when this function is called. * The cursor is left at an unspecified position when this function returns. */ void update_candidates(void) { if (le_candidates.contents != NULL || candbaseline >= 0) { if (candoverwritten) le_display_complete_cleanup(); if (candpages.contents == NULL) { make_pages_and_columns(); print_candidates_all(); } else if (le_candidates.contents == NULL || candbaseline < 0 || candoverwritten) { print_candidates_all(); } else { update_highlighted_candidate(); } } } /* Arranges the current candidates in `le_candidates' to fit to the screen, * making pages and columns of candidates. * The edit line (and the right prompt if any) must have been printed before * calling this function. * The results are assigned to `candpages' and `candcols', which must not be * initialized when this function is called. * If there are too few lines or columns available to show the candidates on * the screen or if there are no candidates, this function does nothing. */ void make_pages_and_columns(void) { assert(candpages.contents == NULL); assert(candcols.contents == NULL); if (le_candidates.contents == NULL || le_candidates.length == 0) return; int maxrowi = le_lines - last_edit_line - 1; if (maxrowi < 2 || le_columns < 4) return; /* we need at least 2 lines & 4 columns */ pl_init(&candpages); pl_init(&candcols); #if INT_MAX > SIZE_MAX size_t maxrow = (maxrowi > SIZE_MAX) ? SIZE_MAX : (size_t) maxrowi; #else size_t maxrow = (size_t) maxrowi; #endif /* first check if the candidates fit into one page */ for (size_t cand_per_col = 1; cand_per_col <= maxrow; cand_per_col++) { if (arrange_candidates(cand_per_col, le_columns)) { candpage_T *page = xmalloc(sizeof *page); page->colindex = 0; page->colcount = candcols.length; pl_add(&candpages, page); return; } } /* divide the candidate list into pages */ divide_candidates_pages(maxrow - 1); } /* Tries to arrange the current candidates in `le_candidates' into columns that * have `cand_per_col' candidates each. * `cand_per_col' must be positive. * Candidate list `le_candidates' must not be empty. * If `totalwidthlimit' is non-negative and if the total width of the resulting * columns is >= `totalwidthlimit', then this function fails. * On success, the resulting columns are added to `candcols', which must have * been initialized as an empty list before calling this function, and true is * returned. On failure, `candcols' is not modified and false is returned. * This function never modifies `candpages'. */ bool arrange_candidates(size_t cand_per_col, int totalwidthlimit) { int totalwidth = 0; size_t candindex = 0; assert(cand_per_col > 0); assert(candcols.contents[0] == NULL); do { candcol_T *col = xmalloc(sizeof *col); col->candindex = candindex; if (le_candidates.length - candindex < cand_per_col) col->candcount = le_candidates.length - candindex; else col->candcount = cand_per_col; col->valuewidth = col->descwidth = col->width = 0; for (size_t nextcandindex = candindex + col->candcount; candindex < nextcandindex; candindex++) { le_candidate_T *cand = le_candidates.contents[candindex]; if (col->valuewidth < cand->rawvalue.width) col->valuewidth = cand->rawvalue.width; if (col->descwidth < cand->rawdesc.width) col->descwidth = cand->rawdesc.width; } col->valuewidth += 2; if (col->descwidth > 0) col->descwidth += 4; col->width = col->valuewidth + col->descwidth; totalwidth += col->width; pl_add(&candcols, col); if (totalwidthlimit >= 0 && totalwidth >= totalwidthlimit) { pl_clear(&candcols, free_candcol); return false; } } while (candindex < le_candidates.length); return true; } /* Divides the current candidates in `le_candidates' into columns that have * `cand_per_col' candidates each and divides the columns into pages that each * fit into the screen. * Candidate list `le_candidates' must not be empty. * The resulting columns and pages are added to `candcols' and `candpages', * which must have been initialized as empty lists before calling this function. */ void divide_candidates_pages(size_t cand_per_col) { /* divide candidates into columns */ bool ok = arrange_candidates(cand_per_col, -1); assert(ok); /* divide columns into pages */ size_t colindex = 0; assert(candpages.contents[0] == NULL); do { candpage_T *page = xmalloc(sizeof *page); int pagewidth; candcol_T *col; page->colindex = colindex; col = candcols.contents[colindex]; pagewidth = col->width; while ((col = candcols.contents[++colindex]) != NULL && pagewidth + col->width < le_columns) pagewidth += col->width; page->colcount = colindex - page->colindex; /* Each page contains at least one column: The page width may not * necessarily be less than the screen width. */ pl_add(&candpages, page); } while (colindex < candcols.length); /* col != NULL */ } /* Clears data used for displaying the candidate area. */ /* Must be called when the current candidates are updated. */ void le_display_complete_cleanup(void) { if (candpages.contents != NULL) { plfree(pl_toary(&candpages), free_candpage); candpages.contents = NULL; assert(candcols.contents != NULL); plfree(pl_toary(&candcols), free_candcol); candcols.contents = NULL; } candhighlight = NOHIGHLIGHT; } /* Frees a completion candidate page. * The argument must point to a `candpage_T' value. */ void free_candpage(void *candpage) { candpage_T *p = candpage; free(p); } /* Frees a completion candidate column. * The argument must point to a `candcol_T' value. */ void free_candcol(void *candcol) { candcol_T *c = candcol; free(c); } /* Prints the whole candidate area. * The edit line (and the right prompt, if any) must have been printed and * `make_pages_and_columns' must have been called before calling this function. * The cursor may be anywhere when this function is called. * The cursor is left at an unspecified position when this function returns. * If the candidate list is inactive, this function does nothing but clearing * the candidate area. If there are no candidates, an error message is printed. */ void print_candidates_all(void) { lebuf_print_sgr0(), styler_active = false; go_to_after_editline(); clear_to_end_of_screen(); assert(lebuf.pos.column == 0); candoverwritten = false; if (le_candidates.contents == NULL) return; if (le_candidates.length == 0) { candbaseline = lebuf.pos.line; print_candidate_count_0(); return; } if (candpages.contents == NULL) return; candbaseline = lebuf.pos.line; size_t pageindex = le_selected_candidate_index < le_candidates.length ? page_of_col(col_of_cand(le_selected_candidate_index)) : 0; const candpage_T *page = candpages.contents[pageindex]; const candcol_T *firstcol = candcols.contents[page->colindex]; for (size_t rowi = 0, rowcount = firstcol->candcount; ; ) { int scrcol = 0; for (size_t coli = 0; coli < page->colcount; coli++) { const candcol_T *col = candcols.contents[page->colindex + coli]; if (rowi >= col->candcount) break; while (lebuf.pos.column < scrcol) lebuf_putchar1_trunc(' '); size_t candindex = col->candindex + rowi; print_candidate(le_candidates.contents[candindex], col, le_selected_candidate_index == candindex, true); scrcol += col->width; } rowi++; if (rowi >= rowcount) break; lebuf_print_nel(); } if (candpages.length > 1) { /* print status line */ lebuf_print_nel(); print_candidate_count(pageindex); } candhighlight = le_selected_candidate_index; } /* Reprints the highlighted candidate. * The previously highlighted candidate is reprinted in the normal style and * the currently selected candidate is highlighted. * Before calling this function, the candidate area must have been printed by * `print_candidates_all'. * The cursor may be anywhere when this function is called and is left at an * unspecified position when this function returns. */ void update_highlighted_candidate(void) { assert(candbaseline >= 0); if (le_candidates.length == 0) return; if (candhighlight == le_selected_candidate_index) return; size_t oldpageindex, oldcolindex, newpageindex, newcolindex; if (candhighlight < le_candidates.length) { oldcolindex = col_of_cand(candhighlight); oldpageindex = page_of_col(oldcolindex); } else { oldcolindex = 0; oldpageindex = 0; } if (le_selected_candidate_index < le_candidates.length) { newcolindex = col_of_cand(le_selected_candidate_index); newpageindex = page_of_col(newcolindex); } else { newcolindex = 0; newpageindex = 0; } if (oldpageindex != newpageindex) { print_candidates_all(); return; } lebuf_print_sgr0(), styler_active = false; const candpage_T *page = candpages.contents[newpageindex]; const candcol_T *col; int column; size_t rowindex; /* de-highlight the previous selected candidate */ if (candhighlight < le_candidates.length) { column = 0; for (size_t i = page->colindex; i < oldcolindex; i++) { col = candcols.contents[i]; column += col->width; } col = candcols.contents[oldcolindex]; rowindex = candhighlight - col->candindex; go_to((le_pos_T) { .line = candbaseline + (int) rowindex, .column = column }); print_candidate( le_candidates.contents[candhighlight], col, false, false); } /* highlight the current selected candidate */ candhighlight = le_selected_candidate_index; if (candhighlight < le_candidates.length) { column = 0; for (size_t i = page->colindex; i < newcolindex; i++) { col = candcols.contents[i]; column += col->width; } col = candcols.contents[newcolindex]; rowindex = candhighlight - col->candindex; go_to((le_pos_T) { .line = candbaseline + (int) rowindex, .column = column }); print_candidate( le_candidates.contents[candhighlight], col, true, false); } /* print status line */ if (candpages.length > 1) { col = candcols.contents[page->colindex]; go_to((le_pos_T) { .line = candbaseline + col->candcount, .column = 0 }); lebuf_print_el(); print_candidate_count(newpageindex); } } /* Prints the specified candidate at the current cursor position. * The candidate is highlighted iff `highlight' is true. * Iff `printdesc' is true, the candidate's description is printed. * The cursor is left just after the printed candidate. */ void print_candidate(const le_candidate_T *cand, const candcol_T *col, bool highlight, bool printdesc) { int line = lebuf.pos.line; /* print value */ if (true /* cand->value != NULL */) { int base = lebuf.pos.column; if (highlight) lebuf_print_bold(); lebuf_putchar1_trunc(highlight ? '[' : ' '); if (lebuf.pos.column + cand->rawvalue.width < lebuf.maxcolumn) { lebuf.pos.column += cand->rawvalue.width; sb_cat(&lebuf.buf, cand->rawvalue.raw); } else { print_candidate_rawvalue(cand); } while (lebuf.pos.column + 2 < lebuf.maxcolumn && lebuf.pos.column - base < col->valuewidth - 1) lebuf_putchar1_trunc(' '); if (highlight) lebuf_print_sgr0(), lebuf_print_bold(); lebuf_putchar1_trunc(highlight ? ']' : ' '); if (highlight) lebuf_print_sgr0(); } /* print description */ if (printdesc && cand->desc != NULL) { lebuf_putchar1_trunc(' '); lebuf_putchar1_trunc('('); if (lebuf.pos.column + cand->rawdesc.width < lebuf.maxcolumn) { lebuf.pos.column += cand->rawdesc.width; sb_cat(&lebuf.buf, cand->rawdesc.raw); } else { lebuf_putws_trunc(cand->desc); } lebuf_putchar1_trunc(')'); } assert(lebuf.pos.line == line); } /* Prints the number of the currently selected candidate, the total number of * the candidates, the number of the current page, and the total number of the * pages at the current position. * The index of the page to which the selected candidate belong must be given * as `pageindex'. */ void print_candidate_count(size_t pageindex) { size_t sindex = (le_selected_candidate_index < le_candidates.length) ? le_selected_candidate_index + 1 : 0; char *s1 = malloc_printf(gt("Candidate %zu of %zu; Page %zu of %zu"), sindex, le_candidates.length, pageindex + 1, candpages.length); if (s1 != NULL) { wchar_t *s2 = realloc_mbstowcs(s1); if (s2 != NULL) { lebuf_putws_trunc(s2); free(s2); } } } /* Prints an error message that tells there are no candidates. */ void print_candidate_count_0(void) { wchar_t *s = malloc_mbstowcs(gt("No candidates")); if (s != NULL) { lebuf_putws_trunc(s); free(s); } } /* Returns the index of the column to which the candidate of index `candindex' * belongs. Column list `candcols' must not be empty. */ size_t col_of_cand(size_t candindex) { assert(candcols.length > 0); void **colp = bsearch(&candindex, candcols.contents, candcols.length, sizeof *candcols.contents, col_of_cand_cmp); assert(colp != NULL); return colp - candcols.contents; } int col_of_cand_cmp(const void *candindexp, const void *colp) { size_t candindex = *(const size_t *) candindexp; const candcol_T *col = *(void **) colp; if (candindex < col->candindex) return -1; else if (candindex < col->candindex + col->candcount) return 0; else return 1; } /* Returns the index of the page to which the column of index `colindex' * belongs. Page list `candpages' must not be empty. */ size_t page_of_col(size_t colindex) { assert(candpages.length > 0); void **pagep = bsearch(&colindex, candpages.contents, candpages.length, sizeof *candpages.contents, page_of_col_cmp); assert(pagep != NULL); return pagep - candpages.contents; } int page_of_col_cmp(const void *colindexp, const void *pagep) { size_t colindex = *(const size_t *) colindexp; const candpage_T *page = *(void **) pagep; if (colindex < page->colindex) return -1; else if (colindex < page->colindex + page->colcount) return 0; else return 1; } /* Sets `le_selected_candidate_index' to the index of the first candidate of * the `offset'th next column, counted from the column containing the currently * selected candidate. * If `candcols' is empty, `le_selected_candidate_index' is left unchanged. */ void le_display_select_column(int offset) { if (candcols.contents == NULL) return; size_t colindex = le_selected_candidate_index < le_candidates.length ? col_of_cand(le_selected_candidate_index) : 0; colindex = select_list_item(colindex, offset, candcols.length); const candcol_T *col = candcols.contents[colindex]; le_selected_candidate_index = col->candindex; } /* Sets `le_selected_candidate_index' to the index of the first candidate of * the `offset'th next page, counted from the page containing the currently * selected candidate. * If `candpages' is empty, `le_selected_candidate_index' is left unchanged. */ void le_display_select_page(int offset) { if (candpages.contents == NULL) return; size_t pageindex = le_selected_candidate_index < le_candidates.length ? page_of_col(col_of_cand(le_selected_candidate_index)) : 0; pageindex = select_list_item(pageindex, offset, candpages.length); const candpage_T *page = candpages.contents[pageindex]; const candcol_T *col = candcols.contents[page->colindex]; le_selected_candidate_index = col->candindex; } /* Computes `(index + offset) mod listsize'. */ size_t select_list_item(size_t index, int offset, size_t listsize) { if (offset >= 0) { offset %= listsize; index += offset; index %= listsize; } else { offset = -offset % listsize; if ((size_t) offset <= index) index -= offset; else index += listsize - offset; } assert(index < listsize); return index; } /********** Utility **********/ /* If the standard error is a terminal, prints the specified prompt to the * terminal and returns true. */ bool le_try_print_prompt(const wchar_t *s) { if (isatty(STDERR_FILENO) && le_setupterm(true)) { lebuf_init((le_pos_T) { 0, 0 }); lebuf_print_prompt(s); le_display_flush(); return true; } else { return false; } } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/complete.d0000644000175000017500000000054112154557026016320 0ustar magicantmagicantcomplete.o: complete.c ../common.h ../config.h complete.h ../plist.h \ ../xgetopt.h ../builtin.h ../exec.h ../xgetopt.h ../expand.h \ ../hashtable.h ../option.h ../parser.h ../input.h ../path.h ../redir.h \ ../sig.h ../strbuf.h ../util.h ../variable.h ../xfnmatch.h ../yash.h \ compparse.h display.h ../input.h lineedit.h editing.h key.h terminfo.h yash-2.35/lineedit/trie.h0000644000175000017500000000451012154557026015457 0ustar magicantmagicant/* Yash: yet another shell */ /* trie.h: trie library for lineedit */ /* (C) 2007-2009 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_TRIE_H #define YASH_TRIE_H #include #include "key.h" typedef union trievalue_T { const wchar_t *keyseq; le_command_func_T *cmdfunc; } trievalue_T; typedef struct trienode_T trie_T; typedef struct trieget_T { enum { TG_NOMATCH = 0, TG_EXACTMATCH = 1 << 0, TG_PREFIXMATCH = 1 << 1, TG_AMBIGUOUS = TG_EXACTMATCH | TG_PREFIXMATCH, } type; size_t matchlength; trievalue_T value; } trieget_T; extern trie_T *trie_create(void) __attribute__((malloc,warn_unused_result)); extern trie_T *trie_set(trie_T *t, const char *keystr, trievalue_T v) __attribute__((nonnull(1,2),malloc,warn_unused_result)); extern trie_T *trie_set_null(trie_T *t, trievalue_T v) __attribute__((nonnull(1),malloc,warn_unused_result)); extern trie_T *trie_setw(trie_T *t, const wchar_t *keywcs, trievalue_T v) __attribute__((nonnull(1,2),malloc,warn_unused_result)); extern trie_T *trie_remove(trie_T *t, const char *keystr) __attribute__((nonnull(1,2),malloc,warn_unused_result)); extern trie_T *trie_removew(trie_T *t, const wchar_t *keywcs) __attribute__((nonnull(1,2),malloc,warn_unused_result)); extern trieget_T trie_get(const trie_T *t, const char *keystr, size_t keylen) __attribute__((nonnull)); extern trieget_T trie_getw(const trie_T *t, const wchar_t *keywcs) __attribute__((nonnull)); extern int trie_foreachw(const trie_T *t, int (*func)(void *v, const wchar_t *key, le_command_func_T *cmd), void *v) __attribute__((nonnull(1,2))); extern void trie_destroy(trie_T *t); #endif /* YASH_TRIE_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/lineedit.d0000644000175000017500000000032312154557026016303 0ustar magicantmagicantlineedit.o: lineedit.c ../common.h ../config.h lineedit.h ../input.h \ ../option.h ../xgetopt.h ../sig.h ../strbuf.h ../util.h ../variable.h \ display.h editing.h key.h keymap.h ../xgetopt.h terminfo.h trie.h yash-2.35/lineedit/terminfo.h0000644000175000017500000000461012154557026016340 0ustar magicantmagicant/* Yash: yet another shell */ /* terminfo.h: interface to terminfo and termios */ /* (C) 2007-2010 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_TERMINFO_H #define YASH_TERMINFO_H extern _Bool le_need_term_update; extern int le_lines, le_columns, le_colors; extern int le_ti_xmc; extern _Bool le_ti_am, le_ti_xenl, le_ti_msgr; extern _Bool le_meta_bit8; extern struct trienode_T /* trie_T */ *le_keycodes; extern _Bool le_setupterm(_Bool bypass); enum le_color { LE_COLOR_BLACK = 0, LE_COLOR_RED = 1, LE_COLOR_GREEN = 2, LE_COLOR_YELLOW = 3, LE_COLOR_BLUE = 4, LE_COLOR_MAGENTA = 5, LE_COLOR_CYAN = 6, LE_COLOR_WHITE = 7, }; extern void lebuf_print_cr(void); extern void lebuf_print_nel(void); extern void lebuf_print_cub(long count); extern void lebuf_print_cuf(long count); extern void lebuf_print_cud(long count); extern void lebuf_print_cuu(long count); extern _Bool lebuf_print_el(void); extern _Bool lebuf_print_ed(void); extern _Bool lebuf_print_clear(void); extern _Bool lebuf_print_op(void); extern void lebuf_print_setfg(long color); extern void lebuf_print_setbg(long color); extern _Bool lebuf_print_sgr0(void); extern _Bool lebuf_print_smso(void); extern _Bool lebuf_print_smul(void); extern _Bool lebuf_print_rev(void); extern _Bool lebuf_print_blink(void); extern _Bool lebuf_print_dim(void); extern _Bool lebuf_print_bold(void); extern _Bool lebuf_print_invis(void); extern void lebuf_print_alert(_Bool direct_stderr); extern int le_eof_char, le_kill_char, le_interrupt_char, le_erase_char; extern _Bool le_set_terminal(void); extern _Bool le_save_terminal(void); extern _Bool le_restore_terminal(void); extern _Bool le_allow_terminal_signal(_Bool allow); #endif /* YASH_TERMINFO_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/complete.h0000644000175000017500000002414712154557026016334 0ustar magicantmagicant/* Yash: yet another shell */ /* complete.h: command line completion */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_COMPLETE_H #define YASH_COMPLETE_H #include #include #include "../plist.h" #include "../xgetopt.h" typedef enum le_candtype_T { CT_WORD, // normal word CT_FILE, // file name CT_COMMAND, // command name CT_ALIAS, // alias name CT_OPTION, // command option CT_VAR, // variable name CT_JOB, // job name CT_SIG, // signal name CT_LOGNAME, // user name CT_GRP, // group name CT_HOSTNAME, // host name CT_BINDKEY, // line-editing command name } le_candtype_T; typedef struct le_rawvalue_T { char *raw; // pre-printed version of candidate value/description int width; // screen width of `raw' } le_rawvalue_T; typedef struct le_candidate_T { le_candtype_T type; wchar_t *value; // candidate value without ignored prefix wchar_t *origvalue; // candidate value including ignored prefix le_rawvalue_T rawvalue; wchar_t *desc; // candidate description le_rawvalue_T rawdesc; _Bool terminate; // if completed word should be terminated union { struct { _Bool is_executable; mode_t mode; nlink_t nlink; off_t size; } filestat; // only used for CT_FILE } appendage; } le_candidate_T; typedef enum le_quote_T { QUOTE_NONE, // no quotation required QUOTE_NORMAL, // not in single/double quotation; backslashes can be used QUOTE_SINGLE, // in single quotation QUOTE_DOUBLE, // in double quotation } le_quote_T; typedef enum le_contexttype_T { CTXT_NORMAL, // normal word CTXT_COMMAND, // command word CTXT_ARGUMENT, // command argument word CTXT_TILDE, // tilde expansion CTXT_VAR, // variable name CTXT_ARITH, // arithmetic expansion CTXT_ASSIGN, // assignment CTXT_REDIR, // redirection target (that is a file name) CTXT_REDIR_FD, // redirection target (that is a file descriptor) CTXT_FOR_IN, // where keyword "in" or "do" is expected CTXT_FOR_DO, // where keyword "do" is expected CTXT_CASE_IN, // where keyword "in" is expected CTXT_FUNCTION, // where a function name is expected CTXT_MASK = ((1 << 4) - 1), CTXT_EBRACED = 1 << 4, // completion occurs in brace expansion CTXT_VBRACED = 1 << 5, // completion occurs in variable expansion CTXT_QUOTED = 1 << 6, // unquote after completion } le_contexttype_T; typedef struct le_context_T { le_quote_T quote; le_contexttype_T type; int pwordc; // number of `pwords' (non-negative) void **pwords; // words preceding the source word wchar_t *src; // source word wchar_t *pattern; // source word as a matching pattern size_t srcindex; // start index of source word size_t origindex; // original `le_main_index' _Bool substsrc; // substitute source word with candidates? } le_context_T; /* The `pwords' member is an array of pointers to wide strings containing the * expanded words preceding the source word. * The `src' member is the source word expanded by the four expansions, brace * expansion, word splitting, and quote removal. * The `pattern' member is like `src', but differs in that it may contain * backslash escapes and that it may have an additional asterisk at the end * to make it a pattern. * The `srcindex' member designates where the source word starts in the edit * line. The `origindex' member is the value of `le_main_index' before starting * completion. * The `substsrc' member designates whether the source word should be * substituted with obtained candidates. The value is true if and only if the * source word after word splitting is not a globbing pattern, in which case an * asterisk is appended to the source word to make it a pattern. */ /* If the source word is field-split into more than one word, the words but the * last are included in `pwords'. */ /* Examples: * For the command line of "foo --bar='x", the completion parser function * `le_get_context' returns: * `quote' = QUOTE_SINGLE * `type' = CTXT_NORMAL * `pwordc' = 1 * `pwords' = { L"foo" } * `src', = L"--bar=x" * `pattern', = L"--bar=\\x" * `srcindex' = 4 * `origindex' = 12 * `substsrc' = false */ typedef enum le_candgentype_T { CGT_FILE = 1 << 0, // file of any kind CGT_DIRECTORY = 1 << 1, // directory CGT_EXECUTABLE = 1 << 2, // executable file CGT_SBUILTIN = 1 << 3, // special builtin CGT_SSBUILTIN = 1 << 4, // semi-special builtin CGT_RBUILTIN = 1 << 5, // regular builtin CGT_BUILTIN = CGT_SBUILTIN | CGT_SSBUILTIN | CGT_RBUILTIN, CGT_EXTCOMMAND = 1 << 6, // external command CGT_FUNCTION = 1 << 7, // function CGT_COMMAND = CGT_BUILTIN | CGT_EXTCOMMAND | CGT_FUNCTION, CGT_KEYWORD = 1 << 8, // shell keyword CGT_NALIAS = 1 << 9, // non-global alias CGT_GALIAS = 1 << 10, // global alias CGT_ALIAS = CGT_NALIAS | CGT_GALIAS, CGT_SCALAR = 1 << 11, // scalar variable CGT_ARRAY = 1 << 12, // array variable CGT_VARIABLE = CGT_SCALAR | CGT_ARRAY, CGT_RUNNING = 1 << 13, // running job CGT_STOPPED = 1 << 14, // stopped job CGT_DONE = 1 << 15, // finished job CGT_JOB = CGT_RUNNING | CGT_STOPPED | CGT_DONE, CGT_SIGNAL = 1 << 16, // signal name CGT_LOGNAME = 1 << 17, // login user name CGT_GROUP = 1 << 18, // group name CGT_HOSTNAME = 1 << 19, // host name CGT_BINDKEY = 1 << 20, // line-editing command name CGT_DIRSTACK = 1 << 21, // directory stack entry } le_candgentype_T; typedef struct le_comppattern_T { struct le_comppattern_T *next; enum { CPT_ACCEPT, CPT_REJECT, } type; const wchar_t *pattern; // pattern (not including ignored prefix) struct xfnmatch_T *cpattern; // compiled pattern } le_comppattern_T; typedef struct le_compopt_T { const le_context_T *ctxt; // completion context le_candgentype_T type; // type of generated candidates const wchar_t *src; // `ctxt->src' + wcslen(ignored prefix) le_comppattern_T *patterns; // patterns to be matched to candidates const wchar_t *suffix; // string appended to candidate values _Bool terminate; // whether completed word should be terminated } le_compopt_T; /* The `patterns' member of the `le_compopt_T' structure must not be NULL and * the first element of the `le_comppattern_T' linked list must be of type * CPT_ACCEPT. */ typedef void le_compresult_T(void); extern plist_T le_candidates; extern size_t le_selected_candidate_index; extern void le_complete(le_compresult_T lecr); extern void lecr_nop(void); extern void lecr_normal(void); extern void lecr_substitute_all_candidates(void); extern void lecr_longest_common_prefix(void); extern void le_complete_select_candidate(int offset); extern void le_complete_select_column(int offset); extern void le_complete_select_page(int offset); extern _Bool le_complete_fix_candidate(int index); extern void le_complete_cleanup(void); extern void le_compdebug(const char *format, ...) __attribute__((nonnull,format(printf,1,2))); extern void set_completion_variables(void); extern void le_new_command_candidate(wchar_t *cmdname) __attribute__((nonnull)); extern void le_new_candidate(le_candtype_T type, wchar_t *restrict value, wchar_t *restrict desc, const le_compopt_T *compopt) __attribute__((nonnull(4))); extern void le_add_candidate(le_candidate_T *cand, const le_compopt_T *compopt) __attribute__((nonnull)); extern _Bool le_compile_cpatterns(const le_compopt_T *compopt) __attribute__((nonnull)); extern _Bool le_match_comppatterns(const le_compopt_T *compopt, const char *s) __attribute__((nonnull)); extern _Bool le_wmatch_comppatterns( const le_compopt_T *compopt, const wchar_t *s) __attribute__((nonnull)); extern int complete_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char complete_help[], complete_syntax[]; #endif extern const struct xgetopt_T complete_options[]; /* This function is defined in "../alias.c". */ extern void generate_alias_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); /* This function is defined in "../builtin.c". */ extern void generate_builtin_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); /* This function is defined in "../job.c". */ extern void generate_job_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); /* This function is defined in "../sig.c". */ extern void generate_signal_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); /* These functions are defined in "../variable.c". */ extern void generate_variable_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); extern void generate_function_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); extern void generate_dirstack_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); /* This function is defined in "keymap.c". */ extern void generate_bindkey_candidates(const le_compopt_T *compopt) __attribute__((nonnull)); #endif /* YASH_COMPLETE_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/trie.c0000644000175000017500000002607512154557026015464 0ustar magicantmagicant/* Yash: yet another shell */ /* trie.c: trie library for lineedit */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "trie.h" #include #include #include #include #include #include "../strbuf.h" #include "../util.h" typedef union triekey_T { char as_char; wchar_t as_wchar; } triekey_T; typedef struct trieentry_T { triekey_T key; struct trienode_T *child; } trieentry_T; typedef struct trienode_T { bool valuevalid; trievalue_T value; size_t count; struct trieentry_T entries[]; } trienode_T; #define RAISE_COUNT(count) ((count) | 3) static inline bool isempty(const trienode_T *node) __attribute__((nonnull,pure)); static trienode_T *ensure_size(trienode_T *node, size_t count) __attribute__((nonnull,malloc,warn_unused_result)); static inline ssize_t search(const trienode_T *node, char c) __attribute__((nonnull,pure)); static ssize_t binarysearch(const trieentry_T *e, size_t count, char key) __attribute__((nonnull,pure)); static inline ssize_t searchw(const trienode_T *node, wchar_t c) __attribute__((nonnull,pure)); static ssize_t binarysearchw(const trieentry_T *e, size_t count, wchar_t key) __attribute__((nonnull,pure)); static trienode_T *insert_entry(trienode_T *node, size_t index, triekey_T key) __attribute__((nonnull,malloc,warn_unused_result)); static trienode_T *shrink(trienode_T *node) __attribute__((nonnull,malloc,warn_unused_result)); static int foreachw(const trienode_T *t, int (*func)(void *v, const wchar_t *key, le_command_func_T *cmd), void *v, xwcsbuf_T *buf) __attribute__((nonnull(1,2,4))); /* Creates a new empty trie. */ trienode_T *trie_create(void) { trienode_T *result = xmallocs( sizeof *result, RAISE_COUNT(0), sizeof *result->entries); result->valuevalid = false; result->count = 0; return result; } /* Checks if the node is empty. */ /* An empty node can be freed. */ bool isempty(const trienode_T *node) { return node->count == 0 && !node->valuevalid; } /* Reallocates the node to ensure the node size enough for the specified entry * count. */ trienode_T *ensure_size(trienode_T *node, size_t count) { count = RAISE_COUNT(count); if (RAISE_COUNT(node->count) >= count) return node; else return xreallocs(node, sizeof *node, count, sizeof *node->entries); } /* Search the node for the entry of the specified byte character key. * If the entry is found, the index to it is returned. * If not found, `-index-1' is returned where `index' is the index that would be * returned if the entry was in the trie. */ ssize_t search(const trienode_T *node, char key) { return binarysearch(node->entries, node->count, key); } ssize_t binarysearch(const trieentry_T *e, size_t count, char key) { ssize_t offset = 0; while (count > 0) { size_t i = count / 2; char ekey = e[offset + i].key.as_char; if (key == ekey) return offset + i; else if (key < ekey) count = i; else offset += i + 1, count -= i + 1; } return -offset - 1; } /* Search the node for the entry of the specified wide character key. * If the entry is found, the index to it is returned. * If not found, `-index-1' is returned where `index' is the index that would be * returned if the entry was in the trie. */ ssize_t searchw(const trienode_T *node, wchar_t key) { return binarysearchw(node->entries, node->count, key); } ssize_t binarysearchw(const trieentry_T *e, size_t count, wchar_t key) { ssize_t offset = 0; while (count > 0) { size_t i = count / 2; wchar_t ekey = e[offset + i].key.as_wchar; if (key == ekey) return offset + i; else if (key < ekey) count = i; else offset += i + 1, count -= i + 1; } return -offset - 1; } /* Creates a new child at `index'. */ trienode_T *insert_entry(trienode_T *node, size_t index, triekey_T key) { assert(index <= node->count); node = ensure_size(node, node->count + 1); if (index < node->count) memmove(&node->entries[index + 1], &node->entries[index], sizeof *node->entries * (node->count - index)); node->entries[index].key = key; node->entries[index].child = trie_create(); node->count++; return node; } /* Adds a mapping from `keystr' to `v'. * The existing mapping for `keystr' is lost if any. */ trienode_T *trie_set(trienode_T *node, const char *keystr, trievalue_T v) { if (keystr[0] == '\0') { node->valuevalid = true; node->value = v; } else { ssize_t index = search(node, keystr[0]); if (index < 0) { index = -(index + 1); node = insert_entry(node, (size_t) index, (triekey_T) { .as_char = keystr[0] }); } node->entries[index].child = trie_set(node->entries[index].child, &keystr[1], v); } return node; } /* Adds a mapping from "\0" to `v'. * The existing mapping for `keystr' is lost if any. */ trienode_T *trie_set_null(trienode_T *node, trievalue_T v) { ssize_t index = search(node, '\0'); if (index < 0) { index = -(index + 1); node = insert_entry(node, (size_t) index, (triekey_T) { .as_char = '\0' }); } node->entries[index].child = trie_set(node->entries[index].child, "", v); return node; } /* Adds a mapping from `keywcs' to `v'. * The existing mapping for `keywcs' is lost if any. */ trienode_T *trie_setw(trienode_T *node, const wchar_t *keywcs, trievalue_T v) { if (keywcs[0] == L'\0') { node->valuevalid = true; node->value = v; } else { ssize_t index = searchw(node, keywcs[0]); if (index < 0) { index = -(index + 1); node = insert_entry(node, (size_t) index, (triekey_T) { .as_wchar = keywcs[0] }); } node->entries[index].child = trie_setw(node->entries[index].child, &keywcs[1], v); } return node; } /* Decreases the child count. The node may be reallocated in this function. */ trienode_T *shrink(trienode_T *node) { size_t oldcount, newcount; oldcount = RAISE_COUNT(node->count); node->count--; newcount = RAISE_COUNT(node->count); if (oldcount != newcount) node = xreallocs(node, sizeof *node, newcount, sizeof *node->entries); return node; } /* Removes the mapping for the specified byte string key. */ trienode_T *trie_remove(trienode_T *node, const char *keystr) { if (keystr[0] == '\0') { node->valuevalid = false; } else { ssize_t index = search(node, keystr[0]); if (index >= 0) { node->entries[index].child = trie_remove(node->entries[index].child, &keystr[1]); if (isempty(node->entries[index].child)) { free(node->entries[index].child); memmove(&node->entries[index], &node->entries[index + 1], sizeof *node->entries * (node->count - index - 1)); node = shrink(node); } } } return node; } /* Removes the mapping for the specified wide string key. */ trienode_T *trie_removew(trienode_T *node, const wchar_t *keywcs) { if (keywcs[0] == L'\0') { node->valuevalid = false; } else { ssize_t index = searchw(node, keywcs[0]); if (index >= 0) { node->entries[index].child = trie_removew(node->entries[index].child, &keywcs[1]); if (isempty(node->entries[index].child)) { free(node->entries[index].child); memmove(&node->entries[index], &node->entries[index + 1], sizeof *node->entries * (node->count - index - 1)); node = shrink(node); } } } return node; } /* Matches `keystr' with the entries of the trie. * This function does not treat '\0' as the end of a string. The length of * `keystr' is given by `keylen'. * `value' of the return value is valid only if the TG_EXACTMATCH flag is in * `type'. */ trieget_T trie_get(const trienode_T *t, const char *keystr, size_t keylen) { trieget_T result = { .type = TG_NOMATCH, .matchlength = 0, }; if (keylen == 0) { if (t->valuevalid) result.type |= TG_EXACTMATCH, result.value = t->value; if (t->count > 0) result.type |= TG_PREFIXMATCH; return result; } ssize_t index = search(t, keystr[0]); if (index < 0) { if (t->valuevalid) result.type |= TG_EXACTMATCH, result.value = t->value; return result; } result = trie_get(t->entries[index].child, &keystr[1], keylen - 1); if (result.type & TG_EXACTMATCH) { result.matchlength++; } else if (t->valuevalid) { result.type |= TG_EXACTMATCH; result.matchlength = 0; result.value = t->value; } return result; } /* Matches `keywcs' with the entries of the trie. * `value' of the return value is valid only if the TG_EXACTMATCH flag is in * `type'. */ trieget_T trie_getw(const trienode_T *t, const wchar_t *keywcs) { trieget_T result = { .type = TG_NOMATCH, .matchlength = 0, }; if (keywcs[0] == L'\0') { if (t->valuevalid) result.type |= TG_EXACTMATCH, result.value = t->value; if (t->count > 0) result.type |= TG_PREFIXMATCH; return result; } ssize_t index = searchw(t, keywcs[0]); if (index < 0) { if (t->valuevalid) result.type |= TG_EXACTMATCH, result.value = t->value; return result; } result = trie_getw(t->entries[index].child, &keywcs[1]); if (result.type & TG_EXACTMATCH) { result.matchlength++; } else if (t->valuevalid) { result.type |= TG_EXACTMATCH; result.matchlength = 0; result.value = t->value; } return result; } /* Calls function `func' for each entry in trie `t'. * Pointer `v' is passed to the function as the first argument. * Returns zero if `func' was called for all the entries. * When `func' returns non-zero, the iteration is aborted and `trie_foreachw' * returns the value returned by `func'. */ int trie_foreachw(const trienode_T *t, int (*func)(void *v, const wchar_t *key, le_command_func_T *cmd), void *v) { xwcsbuf_T buf; int result; wb_init(&buf); result = foreachw(t, func, v, &buf); wb_destroy(&buf); return result; } int foreachw(const trienode_T *t, int func(void *v, const wchar_t *key, le_command_func_T cmd), void *v, xwcsbuf_T *buf) { int result; if (t->valuevalid) { result = func(v, buf->contents, t->value.cmdfunc); if (result != 0) return result; } for (size_t i = 0; i < t->count; i++) { wb_wccat(buf, t->entries[i].key.as_wchar); result = foreachw(t->entries[i].child, func, v, buf); if (result != 0) return result; assert(buf->length > 0); wb_truncate(buf, buf->length - 1); } return 0; } /* Destroys the whole tree. * All the stored data are lost. */ void trie_destroy(trienode_T *node) { if (node != NULL) { for (size_t i = 0; i < node->count; i++) trie_destroy(node->entries[i].child); free(node); } } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/terminfo.c0000644000175000017500000006465412154557026016351 0ustar magicantmagicant/* Yash: yet another shell */ /* terminfo.c: interface to terminfo and termios */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "terminfo.h" #include #include #if HAVE_CURSES_H # include #elif HAVE_NCURSES_H # include #elif HAVE_NCURSES_NCURSES_H # include #elif HAVE_NCURSESW_NCURSES_H # include #endif #include #include #include #include #if HAVE_TIOCGWINSZ # include #endif #if HAVE_TERM_H # include #elif HAVE_NCURSES_TERM_H # include #elif HAVE_NCURSESW_TERM_H # include #endif #include #include #include "../option.h" #include "../sig.h" #include "../util.h" #include "../variable.h" #include "display.h" #include "key.h" #include "trie.h" /********** TERMINFO **********/ /* terminfo capabilities */ #define TI_am "am" #define TI_bel "bel" #define TI_blink "blink" #define TI_bold "bold" #define TI_clear "clear" #define TI_colors "colors" #define TI_cols "cols" #define TI_cr "cr" #define TI_cub "cub" #define TI_cub1 "cub1" #define TI_cud "cud" #define TI_cud1 "cud1" #define TI_cuf "cuf" #define TI_cuf1 "cuf1" #define TI_cuu "cuu" #define TI_cuu1 "cuu1" #define TI_dim "dim" #define TI_ed "ed" #define TI_el "el" #define TI_flash "flash" #define TI_invis "invis" #define TI_kBEG "kBEG" #define TI_kCAN "kCAN" #define TI_kCMD "kCMD" #define TI_kCPY "kCPY" #define TI_kCRT "kCRT" #define TI_kDC "kDC" #define TI_kDL "kDL" #define TI_kEND "kEND" #define TI_kEOL "kEOL" #define TI_kEXT "kEXT" #define TI_kFND "kFND" #define TI_kHLP "kHLP" #define TI_kHOM "kHOM" #define TI_kIC "kIC" #define TI_kLFT "kLFT" #define TI_kMOV "kMOV" #define TI_kMSG "kMSG" #define TI_kNXT "kNXT" #define TI_kOPT "kOPT" #define TI_kPRT "kPRT" #define TI_kPRV "kPRV" #define TI_kRDO "kRDO" #define TI_kRES "kRES" #define TI_kRIT "kRIT" #define TI_kRPL "kRPL" #define TI_kSAV "kSAV" #define TI_kSPD "kSPD" #define TI_kUND "kUND" #define TI_ka1 "ka1" #define TI_ka3 "ka3" #define TI_kb2 "kb2" #define TI_kbeg "kbeg" #define TI_kbs "kbs" #define TI_kc1 "kc1" #define TI_kc3 "kc3" #define TI_kcan "kcan" #define TI_kcbt "kcbt" #define TI_kclo "kclo" #define TI_kclr "kclr" #define TI_kcmd "kcmd" #define TI_kcpy "kcpy" #define TI_kcrt "kcrt" #define TI_kctab "kctab" #define TI_kcub1 "kcub1" #define TI_kcud1 "kcud1" #define TI_kcuf1 "kcuf1" #define TI_kcuu1 "kcuu1" #define TI_kdch1 "kdch1" #define TI_kdl1 "kdl1" #define TI_ked "ked" #define TI_kel "kel" #define TI_kend "kend" #define TI_kent "kent" #define TI_kext "kext" #define TI_kf0 "kf0" #define TI_kf1 "kf1" #define TI_kf2 "kf2" #define TI_kf3 "kf3" #define TI_kf4 "kf4" #define TI_kf5 "kf5" #define TI_kf6 "kf6" #define TI_kf7 "kf7" #define TI_kf8 "kf8" #define TI_kf9 "kf9" #define TI_kf10 "kf10" #define TI_kf11 "kf11" #define TI_kf12 "kf12" #define TI_kf13 "kf13" #define TI_kf14 "kf14" #define TI_kf15 "kf15" #define TI_kf16 "kf16" #define TI_kf17 "kf17" #define TI_kf18 "kf18" #define TI_kf19 "kf19" #define TI_kf20 "kf20" #define TI_kf21 "kf21" #define TI_kf22 "kf22" #define TI_kf23 "kf23" #define TI_kf24 "kf24" #define TI_kf25 "kf25" #define TI_kf26 "kf26" #define TI_kf27 "kf27" #define TI_kf28 "kf28" #define TI_kf29 "kf29" #define TI_kf30 "kf30" #define TI_kf31 "kf31" #define TI_kf32 "kf32" #define TI_kf33 "kf33" #define TI_kf34 "kf34" #define TI_kf35 "kf35" #define TI_kf36 "kf36" #define TI_kf37 "kf37" #define TI_kf38 "kf38" #define TI_kf39 "kf39" #define TI_kf40 "kf40" #define TI_kf41 "kf41" #define TI_kf42 "kf42" #define TI_kf43 "kf43" #define TI_kf44 "kf44" #define TI_kf45 "kf45" #define TI_kf46 "kf46" #define TI_kf47 "kf47" #define TI_kf48 "kf48" #define TI_kf49 "kf49" #define TI_kf50 "kf50" #define TI_kf51 "kf51" #define TI_kf52 "kf52" #define TI_kf53 "kf53" #define TI_kf54 "kf54" #define TI_kf55 "kf55" #define TI_kf56 "kf56" #define TI_kf57 "kf57" #define TI_kf58 "kf58" #define TI_kf59 "kf59" #define TI_kf60 "kf60" #define TI_kf61 "kf61" #define TI_kf62 "kf62" #define TI_kf63 "kf63" #define TI_kfnd "kfnd" #define TI_khlp "khlp" #define TI_khome "khome" #define TI_khts "khts" #define TI_kich1 "kich1" #define TI_kil1 "kil1" #define TI_kind "kind" #define TI_kll "kll" #define TI_km "km" #define TI_kmous "kmous" #define TI_kmov "kmov" #define TI_kmrk "kmrk" #define TI_kmsg "kmsg" #define TI_knp "knp" #define TI_knxt "knxt" #define TI_kopn "kopn" #define TI_kopt "kopt" #define TI_kpp "kpp" #define TI_kprt "kprt" #define TI_kprv "kprv" #define TI_krdo "krdo" #define TI_kref "kref" #define TI_kres "kres" #define TI_krfr "krfr" #define TI_kri "kri" #define TI_krmir "krmir" #define TI_krpl "krpl" #define TI_krst "krst" #define TI_ksav "ksav" #define TI_kslt "kslt" #define TI_kspd "kspd" #define TI_ktbc "ktbc" #define TI_kund "kund" #define TI_lines "lines" #define TI_msgr "msgr" #define TI_nel "nel" #define TI_op "op" #define TI_rev "rev" #define TI_rmkx "rmkx" #define TI_setab "setab" #define TI_setaf "setaf" #define TI_setb "setb" #define TI_setf "setf" #define TI_sgr0 "sgr0" #define TI_smkx "smkx" #define TI_smso "smso" #define TI_smul "smul" #define TI_xenl "xenl" #define TI_xmc "xmc" /* This flag is set to true when the terminfo database needs to be refreshed * because the $TERM variable has been changed. */ _Bool le_need_term_update = 1; /* Number of lines, columns and colors available in the current terminal. */ /* Initialized in `le_setupterm'. */ int le_lines, le_columns, le_colors; /* The value of the "xmc" capability. */ int le_ti_xmc; /* Whether the terminal has the "xenl" and "msgr" flags set. */ _Bool le_ti_xenl, le_ti_msgr; /* True if the meta key inputs character whose 8th bit is set. */ /* Used only if the `shopt_le_convmeta' option is "auto". */ _Bool le_meta_bit8; /* Strings sent by terminal when special key is pressed. * The values of entries are `keyseq'. */ trie_T *le_keycodes = NULL; /* True if the terminal is set to the keyboard-transmit mode. */ static _Bool transmit_mode = 0; static inline int is_strcap_valid(const char *s) __attribute__((const)); static void set_up_keycodes(void); static _Bool try_print_cap(const char *capname) __attribute__((nonnull)); static void move_cursor(char *capone, char *capmul, long count, int affcnt) __attribute__((nonnull)); static _Bool move_cursor_1(char *capone, long count) __attribute__((nonnull)); static _Bool move_cursor_mul(char *capmul, long count, int affcnt) __attribute__((nonnull)); static void print_color_code(long color, char *seta, char *set) __attribute__((nonnull)); static void print_smkx(void); static void print_rmkx(void); static int putchar_stderr(int c); /* Checks if the result of `tigetstr' is valid. */ int is_strcap_valid(const char *s) { return s != NULL && s != (const char *) -1; } /* Calls `setupterm' and checks if terminfo data is available. * If `bypass' is true and `le_need_term_update' is false, the terminfo data * are not refreshed and only the terminal size (`le_lines' and `le_columns') * is adjusted. * Returns true iff successful. */ _Bool le_setupterm(_Bool bypass) { static _Bool once = 0; int err; reset_sigwinch(); assert(once || le_need_term_update); #if HAVE_TIOCGWINSZ if (bypass && !le_need_term_update) { struct winsize ws; if (ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == 0 && ws.ws_row > 0 && ws.ws_col > 0) { if (getenv(VAR_LINES) == NULL) le_lines = ws.ws_row; if (getenv(VAR_COLUMNS) == NULL) le_columns = ws.ws_col; return 1; } } #else (void) bypass; #endif /* HAVE_TIOCGWINSZ */ if (once) del_curterm(cur_term); if (setupterm(NULL, STDERR_FILENO, &err) == ERR) return 0; once = 1; if (tigetflag(TI_am) <= 0) return 0; if (!is_strcap_valid(tigetstr(TI_cub1)) && !is_strcap_valid(tigetstr(TI_cub))) return 0; if (!is_strcap_valid(tigetstr(TI_cuf1)) && !is_strcap_valid(tigetstr(TI_cuf))) return 0; if (!is_strcap_valid(tigetstr(TI_cud1)) && !is_strcap_valid(tigetstr(TI_cud))) return 0; if (!is_strcap_valid(tigetstr(TI_cuu1)) && !is_strcap_valid(tigetstr(TI_cuu))) return 0; if (!is_strcap_valid(tigetstr(TI_el))) return 0; le_lines = tigetnum(TI_lines); le_columns = tigetnum(TI_cols); if (le_lines <= 0 || le_columns <= 0) return 0; le_colors = tigetnum(TI_colors); le_ti_xmc = tigetnum(TI_xmc); le_ti_xenl = tigetflag(TI_xenl) > 0; le_ti_msgr = tigetflag(TI_msgr) > 0; le_meta_bit8 = tigetflag(TI_km) > 0; set_up_keycodes(); le_need_term_update = 0; return 1; } /* Initializes `le_keycodes'. */ void set_up_keycodes(void) { trie_destroy(le_keycodes); static const struct charmap { char c; const wchar_t *keyseq; } charmap[] = { { '\01', Key_c_a, }, { '\02', Key_c_b, }, { '\03', Key_c_c, }, { '\04', Key_c_d, }, { '\05', Key_c_e, }, { '\06', Key_c_f, }, { '\07', Key_c_g, }, { '\10', Key_c_h, }, { '\11', Key_c_i, }, { '\12', Key_c_j, }, { '\13', Key_c_k, }, { '\14', Key_c_l, }, { '\15', Key_c_m, }, { '\16', Key_c_n, }, { '\17', Key_c_o, }, { '\20', Key_c_p, }, { '\21', Key_c_q, }, { '\22', Key_c_r, }, { '\23', Key_c_s, }, { '\24', Key_c_t, }, { '\25', Key_c_u, }, { '\26', Key_c_v, }, { '\27', Key_c_w, }, { '\30', Key_c_x, }, { '\31', Key_c_y, }, { '\32', Key_c_z, }, { '\33', Key_c_lb, }, { '\34', Key_c_bs, }, { '\35', Key_c_rb, }, { '\36', Key_c_hat, }, { '\37', Key_c_ul, }, { '\77', Key_c_del, }, }; static const struct keymap { char *capability; const wchar_t *keyseq; } keymap [] = { { TI_ka1, Key_a1, }, { TI_ka3, Key_a3, }, { TI_kb2, Key_b2, }, { TI_kbs, Key_backspace, }, { TI_kbeg, Key_beg, }, { TI_kcbt, Key_btab, }, { TI_kc1, Key_c1, }, { TI_kc3, Key_c3, }, { TI_kcan, Key_cancel, }, { TI_ktbc, Key_catab, }, { TI_kclr, Key_clear, }, { TI_kclo, Key_close, }, { TI_kcmd, Key_command, }, { TI_kcpy, Key_copy, }, { TI_kcrt, Key_create, }, { TI_kctab, Key_ctab, }, { TI_kdch1, Key_delete, }, { TI_kdl1, Key_dl, }, { TI_kcud1, Key_down, }, { TI_krmir, Key_eic, }, { TI_kend, Key_end, }, { TI_kent, Key_enter, }, { TI_kel, Key_eol, }, { TI_ked, Key_eos, }, { TI_kext, Key_exit, }, { TI_kf0, Key_f00, }, { TI_kf1, Key_f01, }, { TI_kf2, Key_f02, }, { TI_kf3, Key_f03, }, { TI_kf4, Key_f04, }, { TI_kf5, Key_f05, }, { TI_kf6, Key_f06, }, { TI_kf7, Key_f07, }, { TI_kf8, Key_f08, }, { TI_kf9, Key_f09, }, { TI_kf10, Key_f10, }, { TI_kf11, Key_f11, }, { TI_kf12, Key_f12, }, { TI_kf13, Key_f13, }, { TI_kf14, Key_f14, }, { TI_kf15, Key_f15, }, { TI_kf16, Key_f16, }, { TI_kf17, Key_f17, }, { TI_kf18, Key_f18, }, { TI_kf19, Key_f19, }, { TI_kf20, Key_f20, }, { TI_kf21, Key_f21, }, { TI_kf22, Key_f22, }, { TI_kf23, Key_f23, }, { TI_kf24, Key_f24, }, { TI_kf25, Key_f25, }, { TI_kf26, Key_f26, }, { TI_kf27, Key_f27, }, { TI_kf28, Key_f28, }, { TI_kf29, Key_f29, }, { TI_kf30, Key_f30, }, { TI_kf31, Key_f31, }, { TI_kf32, Key_f32, }, { TI_kf33, Key_f33, }, { TI_kf34, Key_f34, }, { TI_kf35, Key_f35, }, { TI_kf36, Key_f36, }, { TI_kf37, Key_f37, }, { TI_kf38, Key_f38, }, { TI_kf39, Key_f39, }, { TI_kf40, Key_f40, }, { TI_kf41, Key_f41, }, { TI_kf42, Key_f42, }, { TI_kf43, Key_f43, }, { TI_kf44, Key_f44, }, { TI_kf45, Key_f45, }, { TI_kf46, Key_f46, }, { TI_kf47, Key_f47, }, { TI_kf48, Key_f48, }, { TI_kf49, Key_f49, }, { TI_kf50, Key_f50, }, { TI_kf51, Key_f51, }, { TI_kf52, Key_f52, }, { TI_kf53, Key_f53, }, { TI_kf54, Key_f54, }, { TI_kf55, Key_f55, }, { TI_kf56, Key_f56, }, { TI_kf57, Key_f57, }, { TI_kf58, Key_f58, }, { TI_kf59, Key_f59, }, { TI_kf60, Key_f60, }, { TI_kf61, Key_f61, }, { TI_kf62, Key_f62, }, { TI_kf63, Key_f63, }, { TI_kfnd, Key_find, }, { TI_khlp, Key_help, }, { TI_khome, Key_home, }, { TI_kich1, Key_insert, }, { TI_kil1, Key_il, }, { TI_kcub1, Key_left, }, { TI_kll, Key_ll, }, { TI_kmrk, Key_mark, }, { TI_kmsg, Key_message, }, { TI_kmous, Key_mouse, }, { TI_kmov, Key_move, }, { TI_knxt, Key_next, }, { TI_knp, Key_pagedown, }, { TI_kopn, Key_open, }, { TI_kopt, Key_options, }, { TI_kpp, Key_pageup, }, { TI_kprv, Key_previous, }, { TI_kprt, Key_print, }, { TI_krdo, Key_redo, }, { TI_kref, Key_reference, }, { TI_krfr, Key_refresh, }, { TI_krpl, Key_replace, }, { TI_krst, Key_restart, }, { TI_kres, Key_resume, }, { TI_kcuf1, Key_right, }, { TI_ksav, Key_save, }, { TI_kslt, Key_select, }, { TI_kind, Key_sf, }, { TI_kri, Key_sr, }, { TI_khts, Key_stab, }, { TI_kspd, Key_suspend, }, { TI_kund, Key_undo, }, { TI_kcuu1, Key_up, }, { TI_kBEG, Key_s_beg, }, { TI_kCAN, Key_s_cancel, }, { TI_kCMD, Key_s_command, }, { TI_kCPY, Key_s_copy, }, { TI_kCRT, Key_s_create, }, { TI_kDC, Key_s_delete, }, { TI_kDL, Key_s_dl, }, { TI_kEND, Key_s_end, }, { TI_kEOL, Key_s_eol, }, { TI_kEXT, Key_s_exit, }, { TI_kFND, Key_s_find, }, { TI_kHLP, Key_s_help, }, { TI_kHOM, Key_s_home, }, { TI_kIC, Key_s_insert, }, { TI_kLFT, Key_s_left, }, { TI_kMSG, Key_s_message, }, { TI_kMOV, Key_s_move, }, { TI_kNXT, Key_s_next, }, { TI_kOPT, Key_s_options, }, { TI_kPRV, Key_s_prev, }, { TI_kPRT, Key_s_print, }, { TI_kRDO, Key_s_redo, }, { TI_kRPL, Key_s_replace, }, { TI_kRIT, Key_s_right, }, { TI_kRES, Key_s_resume, }, { TI_kSAV, Key_s_save, }, { TI_kSPD, Key_s_suspend, }, { TI_kUND, Key_s_undo, }, }; trie_T *t = trie_create(); t = trie_set_null(t, (trievalue_T) { .keyseq = Key_c_at }); for (size_t i = 0; i < sizeof charmap / sizeof *charmap; i++) { if (xiscntrl(charmap[i].c)) t = trie_set(t, (char []) { charmap[i].c, '\0', }, (trievalue_T) { .keyseq = charmap[i].keyseq }); } for (size_t i = 0; i < sizeof keymap / sizeof *keymap; i++) { const char *seq = tigetstr(keymap[i].capability); if (is_strcap_valid(seq)) t = trie_set(t, seq, (trievalue_T) { .keyseq = keymap[i].keyseq }); } le_keycodes = t; } /* Tries to print the specified capability string to the print buffer. * Returns 1 iff successful. */ _Bool try_print_cap(const char *capname) { char *v = tigetstr((char *) capname); if (is_strcap_valid(v) && v[0] != '\0') if (tputs(v, 1, lebuf_putchar) != ERR) return 1; return 0; } /* Prints the "cr" code to the print buffer. * (carriage return: move cursor to first char of line) */ void lebuf_print_cr(void) { #if 0 char *v = tigetstr(TI_cr); if (is_strcap_valid(v) && v[0] != '\0') tputs(v, 1, lebuf_putchar); else #endif lebuf_putchar('\r'); lebuf.pos.column = 0; } /* Prints the "nel" code to the print buffer. * (newline: move cursor to first char of next line) */ void lebuf_print_nel(void) { #if 0 char *v = tigetstr(TI_nel); if (is_strcap_valid(v) && v[0] != '\0') tputs(v, 1, lebuf_putchar); else #endif lebuf_putchar('\r'), lebuf_putchar('\n'); lebuf.pos.line++, lebuf.pos.column = 0; } /* Moves the cursor. * `capone' must be one of "cub1", "cuf1", "cud1", "cuu1". * `capmul' must be one of "cub", "cuf", "cud", "cuu". */ void move_cursor(char *capone, char *capmul, long count, int affcnt) { if (count > 0) { if (count == 1) { if (!move_cursor_1(capone, 1)) move_cursor_mul(capmul, 1, affcnt); } else { if (!move_cursor_mul(capmul, count, affcnt)) move_cursor_1(capone, count); } } } _Bool move_cursor_1(char *capone, long count) { char *v = tigetstr(capone); if (is_strcap_valid(v) && v[0] != '\0') { do tputs(v, 1, lebuf_putchar); while (--count > 0); return 1; } else { return 0; } } _Bool move_cursor_mul(char *capmul, long count, int affcnt) { char *v = tigetstr(capmul); if (is_strcap_valid(v)) { v = tparm(v, count, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L); if (v != NULL) { tputs(v, affcnt, lebuf_putchar); return 1; } } return 0; } /* Prints the "cub"/"cub1" code to the print buffer. * (move cursor backward by `count' columns) * `count' must be small enough not to go beyond the screen bounds. */ void lebuf_print_cub(long count) { move_cursor(TI_cub1, TI_cub, count, 1); lebuf.pos.column -= count; assert(lebuf.pos.column >= 0); } /* Prints the "cuf"/"cuf1" code to the print buffer. * (move cursor forward by `count' columns) * `count' must be small enough not to go beyond the screen bounds. */ void lebuf_print_cuf(long count) { move_cursor(TI_cuf1, TI_cuf, count, 1); lebuf.pos.column += count; assert(lebuf.pos.column < lebuf.maxcolumn); } /* Prints the "cud"/"cud1" code to the print buffer. * (move cursor down by `count' lines) * `count' must be small enough not to go beyond screen bounds. * The cursor must be on the first column. */ void lebuf_print_cud(long count) { assert(lebuf.pos.column == 0); move_cursor(TI_cud1, TI_cud, count, count + 1); lebuf.pos.line += count; } /* Prints the "cuu"/"cuu1" code to the print buffer. * (move cursor up by `count' lines) * `count' must be small enough not to go beyond screen bounds. * The cursor must be on the first column. */ void lebuf_print_cuu(long count) { assert(lebuf.pos.column == 0); move_cursor(TI_cuu1, TI_cuu, count, count + 1); lebuf.pos.line -= count; } /* Prints the "el" code to the print buffer. (clear to end of line) * Returns true iff successful. */ _Bool lebuf_print_el(void) { return try_print_cap(TI_el); } /* Prints the "ed" code to the print buffer if available. * (clear to end of screen) * Returns true iff successful. */ _Bool lebuf_print_ed(void) { return try_print_cap(TI_ed); } /* Prints the "clear" code if available. (clear whole screen) * Returns true iff successful. */ _Bool lebuf_print_clear(void) { if (try_print_cap(TI_clear)) { lebuf.pos.line = lebuf.pos.column = 0; return 1; } else { return 0; } } /* Prints the "op" code. (set color pairs to default) * Returns true iff successful. */ _Bool lebuf_print_op(void) { return try_print_cap(TI_op); } /* Prints the "setf"/"setaf" code. */ void lebuf_print_setfg(long color) { print_color_code(color, TI_setaf, TI_setf); } /* Prints the "setb"/"setab" code. */ void lebuf_print_setbg(long color) { print_color_code(color, TI_setab, TI_setb); } void print_color_code(long color, char *seta, char *set) { if (le_colors < 16) color &= 0x7L; if (le_colors <= color) return; char *v = tigetstr(seta); if (!is_strcap_valid(v) || v[0] == '\0') { v = tigetstr(set); color = ((color & 0x1L) << 2) | (color & 0x2L) | ((color & 0x4L) >> 2) | (color & ~0x7L); } if (is_strcap_valid(v)) { v = tparm(v, color, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L); if (v != NULL) tputs(v, 1, lebuf_putchar); } } /* Prints the "sgr0" code to the print buffer. * (reset the terminal font) * Returns true iff successful. */ _Bool lebuf_print_sgr0(void) { return try_print_cap(TI_sgr0); } /* Prints the "smso" code to the print buffer. (start standout mode) * Returns true iff successful. */ _Bool lebuf_print_smso(void) { if (try_print_cap(TI_smso)) { if (le_ti_xmc > 0) lebuf_update_position(le_ti_xmc); return 1; } else { return 0; } } /* Prints the "smul" code to the print buffer. (start underline mode) * Returns true iff successful. */ _Bool lebuf_print_smul(void) { return try_print_cap(TI_smul); } /* Prints the "rev" code to the print buffer. (start reverse mode) * Returns true iff successful. */ _Bool lebuf_print_rev(void) { return try_print_cap(TI_rev); } /* Prints the "blink" code to the print buffer. (start blink mode) * Returns true iff successful. */ _Bool lebuf_print_blink(void) { return try_print_cap(TI_blink); } /* Prints the "dim" code to the print buffer. (start dim mode) * Returns true iff successful. */ _Bool lebuf_print_dim(void) { return try_print_cap(TI_dim); } /* Prints the "bold" code to the print buffer. (start bold mode) * Returns true iff successful. */ _Bool lebuf_print_bold(void) { return try_print_cap(TI_bold); } /* Prints the "invis" code to the print buffer. (start invisible mode) * Returns true iff successful. */ _Bool lebuf_print_invis(void) { return try_print_cap(TI_invis); } /* Prints the "flash" or "bel" code to alert the user. * If `direct_stderr' is true, the output is sent to the standard error; * otherwise, to the print buffer. */ void lebuf_print_alert(_Bool direct_stderr) { int (*outfunc)(int) = direct_stderr ? putchar_stderr : lebuf_putchar; char *v = NULL; if (shopt_le_visiblebell) v = tigetstr(TI_flash); if (!is_strcap_valid(v) || v[0] == '\0') v = tigetstr(TI_bel); if (is_strcap_valid(v) && v[0] == '\0') tputs(v, 1, outfunc); else outfunc('\a'); } /* Prints the "smkx" code to the standard error and sets the `transmit_mode' * flag. */ void print_smkx(void) { char *v = tigetstr(TI_smkx); if (is_strcap_valid(v)) { tputs(v, 1, putchar_stderr); transmit_mode = 1; } } /* Prints the "rmkx" code to the standard error if the `transmit_mode' flag is * set. The flag is cleared in this function. */ void print_rmkx(void) { if (transmit_mode) { char *v = tigetstr(TI_rmkx); if (is_strcap_valid(v)) tputs(v, 1, putchar_stderr); transmit_mode = 0; } } /* Like `putchar', but prints to `stderr'. */ int putchar_stderr(int c) { return fputc(c, stderr); } /********** TERMIOS **********/ /* Special characters. */ int le_eof_char, le_kill_char, le_interrupt_char, le_erase_char; static struct termios original_terminal_state; static inline int normchar(cc_t c) __attribute__((const)); static void to_raw_mode(struct termios *term, _Bool isig) __attribute__((nonnull)); static inline int xtcgetattr(int fd, struct termios *term) __attribute__((nonnull)); static inline int xtcsetattr(int fd, int opt, const struct termios *term) __attribute__((nonnull)); /* Sets the terminal to the "raw" mode. * The current state is saved as `original_terminal_state'. * Returns true iff the terminal (the standard input) has been successfully * prepared. */ _Bool le_set_terminal(void) { struct termios term; /* First we call `tcdrain' to get a clean state and to ensure the shell is * in the foreground. */ tcdrain(STDIN_FILENO); /* get the original state */ if (!le_save_terminal()) return 0; term = original_terminal_state; le_eof_char = normchar(term.c_cc[VEOF]); le_kill_char = normchar(term.c_cc[VKILL]); le_interrupt_char = normchar(term.c_cc[VINTR]); le_erase_char = normchar(term.c_cc[VERASE]); /* set attributes */ to_raw_mode(&term, 0); if (xtcsetattr(STDIN_FILENO, TCSADRAIN, &term) != 0) goto fail; /* check if the attributes are properly set */ if (xtcgetattr(STDIN_FILENO, &term) != 0) goto fail; if ((term.c_iflag & (INLCR | ICRNL)) || (term.c_lflag & (ECHO | ICANON)) || (term.c_cc[VTIME] != 0) || (term.c_cc[VMIN] != 0)) goto fail; // XXX it should be configurable whether we print smkx or not. print_smkx(); return 1; fail: xtcsetattr(STDIN_FILENO, TCSADRAIN, &original_terminal_state); return 0; } int normchar(cc_t c) { if (c == _POSIX_VDISABLE) return -1; else return (unsigned char) c; } /* Saves the current terminal state in `original_terminal_state'. * This function flushes the standard error before saving the state. * Returns true iff the standard input is a terminal and the terminal state was * successfully saved. */ _Bool le_save_terminal(void) { fflush(stderr); return xtcgetattr(STDIN_FILENO, &original_terminal_state) >= 0; } /* Restores the terminal to the original state saved in * `original_terminal_state'. * This function flushes the standard error before restoring the state. * Returns true iff the standard input is a terminal and the terminal state was * successfully restored. */ _Bool le_restore_terminal(void) { print_rmkx(); fflush(stderr); return xtcsetattr(STDIN_FILENO, TCSADRAIN, &original_terminal_state) >= 0; } /* Sets the ISIG flag of the terminal, which specifies whether, when the user * enters the INTR/QUIT/SUSP character, a corresponding signal is sent to the * foreground process(es). * If `allow' is true, a signal is sent. If `allow' is false, a signal is not * sent. * This function can be used only when the terminal is set to the "raw" mode * using the `le_set_terminal' function. */ _Bool le_allow_terminal_signal(_Bool allow) { struct termios term = original_terminal_state; to_raw_mode(&term, allow); return xtcsetattr(STDIN_FILENO, TCSADRAIN, &term) == 0; } /* Modifies the specified termios structure into the "raw" mode values. * If `isig' is true, the ISIG flag is not cleared from `term->c_lflag'. */ void to_raw_mode(struct termios *term, _Bool isig) { term->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | INLCR | IGNCR | ICRNL | IXON); term->c_iflag |= IGNPAR; term->c_lflag &= ~(ECHO | ICANON | IEXTEN) & (isig ? ~0 : ~ISIG); term->c_cc[VTIME] = 0; term->c_cc[VMIN] = 0; } /* Calls `tcgetattr'. * If it returns EINTR, re-calls it. */ int xtcgetattr(int fd, struct termios *term) { int result; do result = tcgetattr(fd, term); while (result != 0 && errno == EINTR); return result; } /* Calls `tcsetattr'. * If it returns EINTR, re-calls it. */ int xtcsetattr(int fd, int opt, const struct termios *term) { int result; do result = tcsetattr(fd, opt, term); while (result != 0 && errno == EINTR); return result; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/key.h0000644000175000017500000002417012154557026015310 0ustar magicantmagicant/* Yash: yet another shell */ /* key.h: definition of key codes */ /* (C) 2007-2009 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_KEY_H #define YASH_KEY_H #include /* Strings representing special keys */ #define Key_a1 L"\\a1" // upper left of keypad #define Key_a3 L"\\a3" // upper right of keypad #define Key_b2 L"\\b2" // center of keypad #define Key_backspace L"\\B" // backspace #define Key_beg L"\\bg" // beg #define Key_btab L"\\bt" // back-tab #define Key_c1 L"\\c1" // lower left of keypad #define Key_c3 L"\\c3" // lower right of keypad #define Key_cancel L"\\cn" // cancel key #define Key_catab L"\\ca" // clear-all-tabs key #define Key_clear L"\\cs" // clear-screen or erase key #define Key_close L"\\cl" // close key #define Key_command L"\\co" // command (cmd) key #define Key_copy L"\\cp" // copy key #define Key_create L"\\cr" // create key #define Key_ctab L"\\ct" // clear-tab key #define Key_delete L"\\X" // delete (delete-character) key #define Key_dl L"\\dl" // delete-line key #define Key_down L"\\D" // down-arrow key #define Key_eic L"\\ei" // exit-insert-mode #define Key_end L"\\E" // end key #define Key_enter L"\\et" // enter/send key #define Key_eol L"\\el" // clear-to-end-of-line key #define Key_eos L"\\es" // clear-to-end-of-screen key #define Key_exit L"\\ex" // exit key #define Key_f00 L"\\F00" // function key F0 #define Key_f01 L"\\F01" // function key F1 #define Key_f02 L"\\F02" // function key F2 #define Key_f03 L"\\F03" // function key F3 #define Key_f04 L"\\F04" // function key F4 #define Key_f05 L"\\F05" // function key F5 #define Key_f06 L"\\F06" // function key F6 #define Key_f07 L"\\F07" // function key F7 #define Key_f08 L"\\F08" // function key F8 #define Key_f09 L"\\F09" // function key F9 #define Key_f10 L"\\F10" // function key F10 #define Key_f11 L"\\F11" // function key F11 #define Key_f12 L"\\F12" // function key F12 #define Key_f13 L"\\F13" // function key F13 #define Key_f14 L"\\F14" // function key F14 #define Key_f15 L"\\F15" // function key F15 #define Key_f16 L"\\F16" // function key F16 #define Key_f17 L"\\F17" // function key F17 #define Key_f18 L"\\F18" // function key F18 #define Key_f19 L"\\F19" // function key F19 #define Key_f20 L"\\F20" // function key F20 #define Key_f21 L"\\F21" // function key F21 #define Key_f22 L"\\F22" // function key F22 #define Key_f23 L"\\F23" // function key F23 #define Key_f24 L"\\F24" // function key F24 #define Key_f25 L"\\F25" // function key F25 #define Key_f26 L"\\F26" // function key F26 #define Key_f27 L"\\F27" // function key F27 #define Key_f28 L"\\F28" // function key F28 #define Key_f29 L"\\F29" // function key F29 #define Key_f30 L"\\F30" // function key F30 #define Key_f31 L"\\F31" // function key F31 #define Key_f32 L"\\F32" // function key F32 #define Key_f33 L"\\F33" // function key F33 #define Key_f34 L"\\F34" // function key F34 #define Key_f35 L"\\F35" // function key F35 #define Key_f36 L"\\F36" // function key F36 #define Key_f37 L"\\F37" // function key F37 #define Key_f38 L"\\F38" // function key F38 #define Key_f39 L"\\F39" // function key F39 #define Key_f40 L"\\F40" // function key F40 #define Key_f41 L"\\F41" // function key F41 #define Key_f42 L"\\F42" // function key F42 #define Key_f43 L"\\F43" // function key F43 #define Key_f44 L"\\F44" // function key F44 #define Key_f45 L"\\F45" // function key F45 #define Key_f46 L"\\F46" // function key F46 #define Key_f47 L"\\F47" // function key F47 #define Key_f48 L"\\F48" // function key F48 #define Key_f49 L"\\F49" // function key F49 #define Key_f50 L"\\F50" // function key F50 #define Key_f51 L"\\F51" // function key F51 #define Key_f52 L"\\F52" // function key F52 #define Key_f53 L"\\F53" // function key F53 #define Key_f54 L"\\F54" // function key F54 #define Key_f55 L"\\F55" // function key F55 #define Key_f56 L"\\F56" // function key F56 #define Key_f57 L"\\F57" // function key F57 #define Key_f58 L"\\F58" // function key F58 #define Key_f59 L"\\F59" // function key F59 #define Key_f60 L"\\F60" // function key F60 #define Key_f61 L"\\F61" // function key F61 #define Key_f62 L"\\F62" // function key F62 #define Key_f63 L"\\F63" // function key F63 #define Key_find L"\\fd" // find key #define Key_help L"\\hp" // help key #define Key_home L"\\H" // home key #define Key_insert L"\\I" // insert (insert-char/enter-insert-mode) #define Key_il L"\\il" // insert-line key #define Key_left L"\\L" // left-arrow key #define Key_ll L"\\ll" // home-down key #define Key_mark L"\\mk" // mark key #define Key_message L"\\me" // message key #define Key_mouse L"\\ms" // mouse event #define Key_move L"\\mv" // move key #define Key_next L"\\nx" // next-object key #define Key_pagedown L"\\N" // page-down (next-page) key #define Key_open L"\\on" // open key #define Key_options L"\\op" // options key #define Key_pageup L"\\P" // page-up (previous-page) key #define Key_previous L"\\pv" // previous-object key #define Key_print L"\\pr" // print/copy key #define Key_redo L"\\rd" // redo key #define Key_reference L"\\rf" // ref(erence) key #define Key_refresh L"\\rh" // refresh key #define Key_replace L"\\rp" // replace key #define Key_restart L"\\rs" // restart key #define Key_resume L"\\re" // resume key #define Key_right L"\\R" // right-arrow key #define Key_save L"\\sv" // save key #define Key_select L"\\sl" // select key #define Key_sf L"\\sf" // scroll-forward key #define Key_sr L"\\sr" // scroll-backward key #define Key_stab L"\\st" // set-tab key #define Key_suspend L"\\su" // suspend key #define Key_undo L"\\ud" // undo key #define Key_up L"\\U" // up-arrow key #define Key_s_beg L"\\Sbg" // shift+beginning #define Key_s_cancel L"\\Scn" // shift+cancel #define Key_s_command L"\\Sco" // shift+command #define Key_s_copy L"\\Scp" // shift+copy #define Key_s_create L"\\Scr" // shift+create #define Key_s_delete L"\\SX" // shift+delete #define Key_s_dl L"\\Sdl" // shift+delete-line #define Key_s_end L"\\SE" // shift+end #define Key_s_eol L"\\Sel" // shift+end-of-line #define Key_s_exit L"\\Sex" // shift+exit #define Key_s_find L"\\Sfd" // shift+find #define Key_s_help L"\\Shp" // shift+help #define Key_s_home L"\\SH" // shift+home #define Key_s_insert L"\\SI" // shift+insert #define Key_s_left L"\\SL" // shift+left #define Key_s_message L"\\Smg" // shift+message #define Key_s_move L"\\Smv" // shift+move #define Key_s_next L"\\Snx" // shift+next #define Key_s_options L"\\Sop" // shift+options #define Key_s_prev L"\\Spv" // shift+previous #define Key_s_print L"\\Spr" // shift+print #define Key_s_redo L"\\Srd" // shift+redo #define Key_s_replace L"\\Srp" // shift+replace #define Key_s_right L"\\SR" // shift+right #define Key_s_resume L"\\Sre" // shift+resume #define Key_s_save L"\\Ssv" // shift+save #define Key_s_suspend L"\\Ssu" // shift+suspend #define Key_s_undo L"\\Sud" // shift+undo #define Key_c_at L"\\^@" // ctrl+@ #define Key_c_a L"\\^A" // ctrl+A #define Key_c_b L"\\^B" // ctrl+B #define Key_c_c L"\\^C" // ctrl+C #define Key_c_d L"\\^D" // ctrl+D #define Key_c_e L"\\^E" // ctrl+E #define Key_c_f L"\\^F" // ctrl+F #define Key_c_g L"\\^G" // ctrl+G #define Key_c_h L"\\^H" // ctrl+H #define Key_c_i L"\\^I" // ctrl+I #define Key_c_j L"\\^J" // ctrl+J #define Key_c_k L"\\^K" // ctrl+K #define Key_c_l L"\\^L" // ctrl+L #define Key_c_m L"\\^M" // ctrl+M #define Key_c_n L"\\^N" // ctrl+N #define Key_c_o L"\\^O" // ctrl+O #define Key_c_p L"\\^P" // ctrl+P #define Key_c_q L"\\^Q" // ctrl+Q #define Key_c_r L"\\^R" // ctrl+R #define Key_c_s L"\\^S" // ctrl+S #define Key_c_t L"\\^T" // ctrl+T #define Key_c_u L"\\^U" // ctrl+U #define Key_c_v L"\\^V" // ctrl+V #define Key_c_w L"\\^W" // ctrl+W #define Key_c_x L"\\^X" // ctrl+X #define Key_c_y L"\\^Y" // ctrl+Y #define Key_c_z L"\\^Z" // ctrl+Z #define Key_c_lb L"\\^[" // ctrl+[ #define Key_c_bs L"\\^\\" // ctrl+\ // #define Key_c_rb L"\\^]" // ctrl+] #define Key_c_hat L"\\^^" // ctrl+^ #define Key_c_ul L"\\^_" // ctrl+_ #define Key_c_del L"\\^?" // delete #define Key_interrupt L"\\!" // INTR #define Key_eof L"\\#" // EOF #define Key_kill L"\\$" // KILL #define Key_erase L"\\?" // ERASE #define Key_tab Key_c_i #define Key_newline Key_c_j #define Key_cr Key_c_m #define Key_escape Key_c_lb #define Key_backslash L"\\\\" // must end with '\\' #define META_BIT 0x80 #define ESCAPE_CHAR '\33' /* The type of functions that implement commands. */ typedef void le_command_func_T(wchar_t wc); #endif /* YASH_KEY_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/lineedit.c0000644000175000017500000002675112154557026016317 0ustar magicantmagicant/* Yash: yet another shell */ /* lineedit.c: command line editing */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "lineedit.h" #include #include #include #include #include #include #include #include #include "../option.h" #include "../sig.h" #include "../strbuf.h" #include "../util.h" #include "../variable.h" #include "display.h" #include "editing.h" #include "key.h" #include "keymap.h" #include "terminfo.h" #include "trie.h" static void reader_init(void); static void reader_finalize(void); static void read_next(void); static int get_read_timeout(void) __attribute__((pure)); static char pop_prebuffer(void); static inline bool has_meta_bit(char c) __attribute__((pure)); static inline trieget_T make_trieget(const wchar_t *keyseq) __attribute__((nonnull,const)); static void append_to_second_buffer(wchar_t wc); /* The state of line-editing. */ enum le_state_T le_state; /* The state of editing. */ enum le_editstate_T le_editstate; /* Do line-editing using the specified prompts. * The prompts may contain backslash escapes specified in "input.c". * The result is returned as a newly malloced wide string, including the * trailing newline. It is assigned to `*resultp' iff the return value is * INPUT_OK. Returns INPUT_ERROR iff failed to set up the terminal. */ inputresult_T le_readline(struct promptset_T prompt, wchar_t **resultp) { assert(is_interactive_now); assert(le_state == LE_STATE_INACTIVE); if (!isatty(STDIN_FILENO) || !isatty(STDERR_FILENO) || !le_setupterm(true) || !le_set_terminal()) return INPUT_ERROR; le_state = LE_STATE_ACTIVE; le_keymap_init(); le_editing_init(); le_display_init(prompt); reader_init(); le_editstate = LE_EDITSTATE_EDITING; do read_next(); while (le_editstate == LE_EDITSTATE_EDITING); wchar_t *resultline; reader_finalize(); le_display_finalize(); resultline = le_editing_finalize(); le_restore_terminal(); le_state = LE_STATE_INACTIVE; switch (le_editstate) { case LE_EDITSTATE_DONE: *resultp = resultline; return INPUT_OK; case LE_EDITSTATE_ERROR: free(resultline); return INPUT_EOF; case LE_EDITSTATE_INTERRUPTED: free(resultline); return INPUT_INTERRUPTED; case LE_EDITSTATE_EDITING: assert(false); } assert(false); } /* Clears the edit line and restores the terminal state. * Does nothing if line-editing is not active. */ void le_suspend_readline(void) { if (le_state == LE_STATE_ACTIVE) { le_state = LE_STATE_SUSPENDED; le_display_clear(false); le_restore_terminal(); } } /* Resumes line-editing suspended by `le_suspend_readline'. * Does nothing if the line-editing is not suspended. */ void le_resume_readline(void) { if (le_state == LE_STATE_SUSPENDED) { le_state = LE_STATE_ACTIVE; le_setupterm(true); le_set_terminal(); le_display_update(true); le_display_flush(); } } /* Re-retrieves the terminfo and reprints everything. */ /* When the display size is changed, this function is called. */ void le_display_size_changed(void) { if (le_state == LE_STATE_ACTIVE) { le_display_clear(false); le_setupterm(true); le_display_update(true); le_display_flush(); } } /********** Input Reading **********/ /* Temporary buffer that contains bytes that are treated as input. */ static xstrbuf_T reader_prebuffer; /* Temporary buffer that contains input bytes. */ static xstrbuf_T reader_first_buffer; /* Conversion state used in reading input. */ static mbstate_t reader_state; /* Temporary buffer that contains input converted into wide characters. */ static xwcsbuf_T reader_second_buffer; /* If true, next input will be inserted directly to the main buffer. */ bool le_next_verbatim; /* Initializes the state of the reader. */ void reader_init(void) { sb_init(&reader_first_buffer); memset(&reader_state, 0, sizeof reader_state); wb_init(&reader_second_buffer); le_next_verbatim = false; } /* Frees memory used by the reader. */ void reader_finalize(void) { sb_destroy(&reader_first_buffer); wb_destroy(&reader_second_buffer); } /* Reads the next byte from the standard input and take all the corresponding * actions. * May return without doing anything if a signal was caught, if the shell was * interrupted, etc. * The caller must check `le_state' after this function returned. This function * should be called repeatedly while `le_editstate' is LE_STATE_EDITING. */ void read_next(void) { static bool incomplete_wchar = false; static bool keycode_ambiguous = false; assert(le_editstate == LE_EDITSTATE_EDITING); bool timeout = false; char c = pop_prebuffer(); if (c != '\0') goto direct_first_buffer; le_display_update(true); le_display_flush(); /* wait for and read the next byte */ if (keycode_ambiguous) timeout = !wait_for_input(STDIN_FILENO, true, get_read_timeout()); else wait_for_input(STDIN_FILENO, true, -1); if (!timeout) { switch (read(STDIN_FILENO, &c, 1)) { case 0: incomplete_wchar = keycode_ambiguous = false; le_editstate = LE_EDITSTATE_ERROR; return; case 1: break; case -1: switch (errno) { case EAGAIN: #if EAGAIN != EWOULDBLOCK case EWOULDBLOCK: #endif case EINTR: return; default: xerror(errno, Ngt("cannot read input")); incomplete_wchar = keycode_ambiguous = false; le_editstate = LE_EDITSTATE_ERROR; return; } default: assert(false); } if (has_meta_bit(c)) sb_ccat(sb_ccat(&reader_first_buffer, ESCAPE_CHAR), c & ~META_BIT); else direct_first_buffer: sb_ccat(&reader_first_buffer, c); } if (incomplete_wchar || le_next_verbatim) goto process_wide; /* process the content in the first buffer */ keycode_ambiguous = false; while (reader_first_buffer.length > 0) { /* check if `reader_first_buffer' is a special sequence */ int firstchar = (unsigned char) reader_first_buffer.contents[0]; trieget_T tg; if (firstchar == le_interrupt_char) tg = make_trieget(Key_interrupt); else if (firstchar == le_eof_char) tg = make_trieget(Key_eof); else if (firstchar == le_kill_char) tg = make_trieget(Key_kill); else if (firstchar == le_erase_char) tg = make_trieget(Key_erase); else tg = trie_get(le_keycodes, reader_first_buffer.contents, reader_first_buffer.length); switch (tg.type) { case TG_NOMATCH: goto process_wide; case TG_AMBIGUOUS: if (timeout) { case TG_EXACTMATCH: sb_remove(&reader_first_buffer, 0, tg.matchlength); wb_cat(&reader_second_buffer, tg.value.keyseq); continue; } else { keycode_ambiguous = true; } /* falls thru! */ case TG_PREFIXMATCH: goto process_keymap; } } /* convert bytes in the first buffer into wide characters and append to the * second buffer */ process_wide: while (reader_first_buffer.length > 0) { wchar_t wc; size_t n = mbrtowc(&wc, reader_first_buffer.contents, reader_first_buffer.length, &reader_state); incomplete_wchar = false; switch (n) { case 0: // read null character sb_clear(&reader_first_buffer); append_to_second_buffer(L'\0'); break; case (size_t) -1: // conversion error lebuf_print_alert(true); memset(&reader_state, 0, sizeof reader_state); sb_clear(&reader_first_buffer); le_next_verbatim = false; goto process_keymap; case (size_t) -2: // more bytes needed incomplete_wchar = true; sb_clear(&reader_first_buffer); goto process_keymap; default: sb_remove(&reader_first_buffer, 0, n); append_to_second_buffer(wc); break; } } /* process key mapping for wide characters in the second buffer */ process_keymap: while (reader_second_buffer.length > 0) { register wchar_t c; trieget_T tg = trie_getw( le_current_mode->keymap, reader_second_buffer.contents); switch (tg.type) { case TG_NOMATCH: assert(reader_second_buffer.length > 0); if (reader_second_buffer.length > 1) c = L'\0'; else c = reader_second_buffer.contents[0]; le_invoke_command(le_current_mode->default_command, c); wb_clear(&reader_second_buffer); break; case TG_EXACTMATCH: assert(tg.matchlength > 0); c = reader_second_buffer.contents[tg.matchlength - 1]; le_invoke_command(tg.value.cmdfunc, c); wb_remove(&reader_second_buffer, 0, tg.matchlength); break; case TG_PREFIXMATCH: case TG_AMBIGUOUS: return; /* For an unmatched control sequence, `cmd_self_insert' should not * receive any part of the sequence as argument (because the sequence * should not be inserted in the main buffer), so the input is passed * to the default command iff the input is a usual character. * For a matched control sequence, the last character of the sequence * is passed to the command so that commands like `cmd_digit_argument' * work. */ } if (le_editstate != LE_EDITSTATE_EDITING) break; } } /* Returns a timeout value to be passed to the `wait_for_input' function. * The value is taken from the $YASH_LE_TIMEOUT variable. */ int get_read_timeout(void) { #ifndef LE_TIMEOUT_DEFAULT #define LE_TIMEOUT_DEFAULT 100 #endif const wchar_t *v = getvar(L VAR_YASH_LE_TIMEOUT); if (v != NULL) { int i; if (xwcstoi(v, 0, &i)) return i; } return LE_TIMEOUT_DEFAULT; } /* Appends `s' to the prebuffer. String `s' is freed in this function. */ void le_append_to_prebuffer(char *s) { if (reader_prebuffer.contents == NULL) sb_initwith(&reader_prebuffer, s); else sb_catfree(&reader_prebuffer, s); } /* Removes and returns the next character in the prebuffer if available; * otherwise, returns '\0'. */ char pop_prebuffer(void) { if (reader_prebuffer.contents != NULL) { char result = reader_prebuffer.contents[0]; sb_remove(&reader_prebuffer, 0, 1); if (reader_prebuffer.length == 0) { sb_destroy(&reader_prebuffer); reader_prebuffer.contents = NULL; } return result; } return '\0'; } /* Tests if the specified character has the meta flag set. */ bool has_meta_bit(char c) { switch (shopt_le_convmeta) { case SHOPT_YES: break; case SHOPT_NO: return false; case SHOPT_AUTO: if (le_meta_bit8) break; else return false; } return (c & META_BIT) != 0; } trieget_T make_trieget(const wchar_t *keyseq) { return (trieget_T) { .type = TG_EXACTMATCH, .matchlength = 1, .value.keyseq = keyseq, }; } /* Appends the specified character to the second buffer. * If `le_next_verbatim' is true, the character is directly processed by the * default command. */ void append_to_second_buffer(wchar_t wc) { if (le_next_verbatim) { le_next_verbatim = false; le_invoke_command(le_current_mode->default_command, wc); } else { switch (wc) { case L'\0': break; case L'\\': wb_cat(&reader_second_buffer, Key_backslash); break; default: wb_wccat(&reader_second_buffer, wc); break; } } } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/compparse.h0000644000175000017500000000177612154557026016520 0ustar magicantmagicant/* Yash: yet another shell */ /* compparse.h: simple parser for command line completion */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_COMPPARSE_H #define YASH_COMPPARSE_H struct le_context_T; extern struct le_context_T *le_get_context(void) __attribute__((malloc,warn_unused_result)); #endif /* YASH_COMPPARSE_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/editing.d0000644000175000017500000000046312154557026016136 0ustar magicantmagicantediting.o: editing.c ../common.h ../config.h editing.h ../strbuf.h key.h \ ../alias.h ../xgetopt.h ../exec.h ../expand.h ../history.h ../job.h \ ../option.h ../path.h ../plist.h ../redir.h ../util.h ../xfnmatch.h \ ../yash.h complete.h ../xgetopt.h display.h ../input.h lineedit.h \ keymap.h terminfo.h yash-2.35/lineedit/lineedit.h0000644000175000017500000000365612154557026016323 0ustar magicantmagicant/* Yash: yet another shell */ /* lineedit.h: command line editing */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_LINEEDIT_H #define YASH_LINEEDIT_H #include #include "../input.h" enum le_state_T { LE_STATE_INACTIVE = 0, LE_STATE_ACTIVE = 1 << 0, LE_STATE_SUSPENDED = 1 << 1, LE_STATE_COMPLETING = 1 << 2, }; #define le_state_is_compdebug \ ((le_state & (LE_STATE_SUSPENDED | LE_STATE_COMPLETING)) \ == (LE_STATE_SUSPENDED | LE_STATE_COMPLETING)) enum le_editstate_T { LE_EDITSTATE_EDITING, // editing is on-going LE_EDITSTATE_DONE, // `le_readline' should return (successful) LE_EDITSTATE_ERROR, // `le_readline' should return (unsuccessful) LE_EDITSTATE_INTERRUPTED, // `le_readline' should return (interrupted) }; extern enum le_state_T le_state; extern enum le_editstate_T le_editstate; extern inputresult_T le_readline(struct promptset_T prompt, wchar_t **resultp) __attribute__((nonnull,warn_unused_result)); extern void le_suspend_readline(void); extern void le_resume_readline(void); extern void le_display_size_changed(void); extern _Bool le_next_verbatim; extern void le_append_to_prebuffer(char *s) __attribute__((nonnull)); #endif /* YASH_LINEEDIT_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/keymap.h0000644000175000017500000000431012154557026016000 0ustar magicantmagicant/* Yash: yet another shell */ /* keymap.h: mappings from keys to functions */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_KEYMAP_H #define YASH_KEYMAP_H #include #include "key.h" #include "../xgetopt.h" /* This structure describes an editing mode. */ typedef struct le_mode_T { le_command_func_T *default_command; struct trienode_T /* trie_T */ *keymap; } le_mode_T; /* mode indices */ typedef enum le_mode_id_T { LE_MODE_VI_INSERT, LE_MODE_VI_COMMAND, LE_MODE_VI_SEARCH, LE_MODE_EMACS, LE_MODE_EMACS_SEARCH, LE_MODE_CHAR_EXPECT, LE_MODE_N, // number of modes } le_mode_id_T; extern le_mode_T le_modes[LE_MODE_N]; extern le_mode_T *le_current_mode; static inline le_mode_id_T le_mode_to_id(le_mode_T *mode) __attribute__((nonnull,const)); static inline le_mode_T *le_id_to_mode(le_mode_id_T modeid) __attribute__((const)); #define LE_CURRENT_MODE (le_mode_to_id(le_current_mode)) extern void le_keymap_init(void); extern void le_set_mode(le_mode_id_T id); extern int bindkey_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char bindkey_help[], bindkey_syntax[]; #endif extern const struct xgetopt_T bindkey_options[]; /* Returns the mode ID of the specified mode. */ le_mode_id_T le_mode_to_id(le_mode_T *mode) { return (le_mode_id_T) (mode - le_modes); } /* Returns a pointer to the mode specified by the specified ID. */ le_mode_T *le_id_to_mode(le_mode_id_T modeid) { return &le_modes[modeid]; } #endif /* YASH_KEYMAP_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/display.d0000644000175000017500000000032612154557026016156 0ustar magicantmagicantdisplay.o: display.c ../common.h ../config.h display.h ../input.h \ ../strbuf.h lineedit.h ../history.h ../xgetopt.h ../job.h ../option.h \ ../plist.h ../util.h complete.h ../xgetopt.h editing.h key.h terminfo.h yash-2.35/lineedit/trie.d0000644000175000017500000000011212154557026015445 0ustar magicantmagicanttrie.o: trie.c ../common.h ../config.h trie.h key.h ../strbuf.h ../util.h yash-2.35/lineedit/keymap.d0000644000175000017500000000032412154557026015775 0ustar magicantmagicantkeymap.o: keymap.c ../common.h ../config.h keymap.h key.h ../xgetopt.h \ ../builtin.h ../exec.h ../xgetopt.h ../expand.h ../util.h ../xfnmatch.h \ complete.h ../plist.h editing.h ../strbuf.h trie.h commands.in yash-2.35/lineedit/keymap.c0000644000175000017500000005077712154557026016015 0ustar magicantmagicant/* Yash: yet another shell */ /* keymap.c: mappings from keys to functions */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "keymap.h" #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include "../builtin.h" #include "../exec.h" #include "../expand.h" #include "../util.h" #include "../xfnmatch.h" #include "complete.h" #include "editing.h" #include "key.h" #include "trie.h" /* Definition of editing modes. */ le_mode_T le_modes[LE_MODE_N]; /* The current editing mode. * Points to one of the modes in `le_modes'. */ le_mode_T *le_current_mode; /* Array of pairs of a command name and function. * Sorted by name. */ static const struct command_name_pair { const char *name; le_command_func_T *command; } commands[] = { #include "commands.in" }; /* Initializes `le_modes' if not yet initialized. * May be called more than once but does nothing if so. */ void le_keymap_init(void) { static bool initialized = false; if (initialized) return; initialized = true; trie_T *t; #define Set(key, cmd) \ (t = trie_setw(t, key, (trievalue_T) { .cmdfunc = (cmd) })) le_modes[LE_MODE_VI_INSERT].default_command = cmd_self_insert; t = trie_create(); Set(Key_backslash, cmd_self_insert); Set(Key_c_v, cmd_expect_verbatim); Set(Key_right, cmd_forward_char); Set(Key_left, cmd_backward_char); Set(Key_home, cmd_beginning_of_line); Set(Key_end, cmd_end_of_line); Set(Key_c_j, cmd_accept_line); Set(Key_c_m, cmd_accept_line); Set(Key_interrupt, cmd_abort_line); Set(Key_c_c, cmd_abort_line); Set(Key_eof, cmd_eof_if_empty); Set(Key_c_d, cmd_eof_if_empty); Set(Key_escape, cmd_setmode_vicommand); Set(Key_c_l, cmd_redraw_all); Set(Key_delete, cmd_delete_char); Set(Key_backspace, cmd_backward_delete_char); Set(Key_erase, cmd_backward_delete_char); Set(Key_c_h, cmd_backward_delete_char); Set(Key_c_w, cmd_backward_delete_semiword); Set(Key_kill, cmd_backward_delete_line); Set(Key_c_u, cmd_backward_delete_line); Set(Key_tab, cmd_complete_next_candidate); Set(Key_btab, cmd_complete_prev_candidate); Set(Key_down, cmd_next_history_eol); Set(Key_c_n, cmd_next_history_eol); Set(Key_up, cmd_prev_history_eol); Set(Key_c_p, cmd_prev_history_eol); le_modes[LE_MODE_VI_INSERT].keymap = t; le_modes[LE_MODE_VI_COMMAND].default_command = cmd_alert; t = trie_create(); Set(Key_escape, cmd_noop); Set(L"1", cmd_digit_argument); Set(L"2", cmd_digit_argument); Set(L"3", cmd_digit_argument); Set(L"4", cmd_digit_argument); Set(L"5", cmd_digit_argument); Set(L"6", cmd_digit_argument); Set(L"7", cmd_digit_argument); Set(L"8", cmd_digit_argument); Set(L"9", cmd_digit_argument); Set(L"0", cmd_bol_or_digit); Set(Key_c_j, cmd_accept_line); Set(Key_c_m, cmd_accept_line); Set(Key_interrupt, cmd_abort_line); Set(Key_c_c, cmd_abort_line); Set(Key_eof, cmd_eof_if_empty); Set(Key_c_d, cmd_eof_if_empty); Set(L"#", cmd_accept_with_hash); Set(L"i", cmd_setmode_viinsert); Set(Key_insert, cmd_setmode_viinsert); Set(Key_c_l, cmd_redraw_all); Set(L"l", cmd_forward_char); Set(L" ", cmd_forward_char); Set(Key_right, cmd_forward_char); Set(L"h", cmd_backward_char); Set(Key_left, cmd_backward_char); Set(Key_backspace, cmd_backward_char); Set(Key_erase, cmd_backward_char); Set(Key_c_h, cmd_backward_char); Set(L"W", cmd_forward_bigword); Set(L"E", cmd_end_of_bigword); Set(L"B", cmd_backward_bigword); Set(L"w", cmd_forward_viword); Set(L"e", cmd_end_of_viword); Set(L"b", cmd_backward_viword); Set(Key_home, cmd_beginning_of_line); Set(L"$", cmd_end_of_line); Set(Key_end, cmd_end_of_line); Set(L"^", cmd_first_nonblank); Set(L"f", cmd_find_char); Set(L"F", cmd_find_char_rev); Set(L"t", cmd_till_char); Set(L"T", cmd_till_char_rev); Set(L";", cmd_refind_char); Set(L",", cmd_refind_char_rev); Set(L"x", cmd_kill_char); Set(Key_delete, cmd_kill_char); Set(L"X", cmd_backward_kill_char); Set(L"P", cmd_put_before); Set(L"p", cmd_put); Set(L"u", cmd_undo); Set(L"U", cmd_undo_all); Set(Key_c_r, cmd_cancel_undo); Set(L".", cmd_redo); Set(L"|", cmd_go_to_column); Set(L"r", cmd_vi_replace_char); Set(L"I", cmd_vi_insert_beginning); Set(L"a", cmd_vi_append); Set(L"A", cmd_vi_append_to_eol); Set(L"R", cmd_vi_replace); Set(L"~", cmd_vi_switch_case_char); Set(L"y", cmd_vi_yank); Set(L"Y", cmd_vi_yank_to_eol); Set(L"d", cmd_vi_delete); Set(L"D", cmd_vi_delete_to_eol); Set(L"c", cmd_vi_change); Set(L"C", cmd_vi_change_to_eol); Set(L"S", cmd_vi_change_line); Set(L"s", cmd_vi_substitute); Set(L"_", cmd_vi_append_last_bigword); Set(L"@", cmd_vi_exec_alias); Set(L"v", cmd_vi_edit_and_accept); Set(L"=", cmd_vi_complete_list); Set(L"*", cmd_vi_complete_all); Set(Key_backslash, cmd_vi_complete_max); Set(L"?", cmd_vi_search_forward); Set(L"/", cmd_vi_search_backward); Set(L"n", cmd_search_again); Set(L"N", cmd_search_again_rev); Set(L"G", cmd_oldest_history_bol); Set(L"g", cmd_return_history_bol); Set(L"j", cmd_next_history_bol); Set(L"+", cmd_next_history_bol); Set(Key_down, cmd_next_history_bol); Set(Key_c_n, cmd_next_history_bol); Set(L"k", cmd_prev_history_bol); Set(L"-", cmd_prev_history_bol); Set(Key_up, cmd_prev_history_bol); Set(Key_c_p, cmd_prev_history_bol); le_modes[LE_MODE_VI_COMMAND].keymap = t; le_modes[LE_MODE_VI_SEARCH].default_command = cmd_srch_self_insert; t = trie_create(); Set(Key_c_v, cmd_expect_verbatim); Set(Key_interrupt, cmd_abort_line); Set(Key_c_c, cmd_abort_line); Set(Key_c_l, cmd_redraw_all); Set(Key_backslash, cmd_srch_self_insert); Set(Key_backspace, cmd_srch_backward_delete_char); Set(Key_erase, cmd_srch_backward_delete_char); Set(Key_c_h, cmd_srch_backward_delete_char); Set(Key_kill, cmd_srch_backward_delete_line); Set(Key_c_u, cmd_srch_backward_delete_line); Set(Key_c_j, cmd_srch_accept_search); Set(Key_c_m, cmd_srch_accept_search); Set(Key_escape, cmd_srch_abort_search); le_modes[LE_MODE_VI_SEARCH].keymap = t; le_modes[LE_MODE_EMACS].default_command = cmd_self_insert; t = trie_create(); Set(Key_backslash, cmd_self_insert); Set(Key_escape Key_c_i, cmd_insert_tab); Set(Key_c_q, cmd_expect_verbatim); Set(Key_c_v, cmd_expect_verbatim); Set(Key_escape "0", cmd_digit_argument); Set(Key_escape "1", cmd_digit_argument); Set(Key_escape "2", cmd_digit_argument); Set(Key_escape "3", cmd_digit_argument); Set(Key_escape "4", cmd_digit_argument); Set(Key_escape "5", cmd_digit_argument); Set(Key_escape "6", cmd_digit_argument); Set(Key_escape "7", cmd_digit_argument); Set(Key_escape "8", cmd_digit_argument); Set(Key_escape "9", cmd_digit_argument); Set(Key_escape "-", cmd_digit_argument); Set(Key_c_j, cmd_accept_line); Set(Key_c_m, cmd_accept_line); Set(Key_interrupt, cmd_abort_line); Set(Key_c_c, cmd_abort_line); Set(Key_eof, cmd_eof_or_delete); Set(Key_c_d, cmd_eof_or_delete); Set(Key_escape "#", cmd_accept_with_hash); Set(Key_c_l, cmd_redraw_all); Set(Key_right, cmd_forward_char); Set(Key_c_f, cmd_forward_char); Set(Key_left, cmd_backward_char); Set(Key_c_b, cmd_backward_char); Set(Key_escape "f", cmd_forward_emacsword); Set(Key_escape "F", cmd_forward_emacsword); Set(Key_escape "b", cmd_backward_emacsword); Set(Key_escape "B", cmd_backward_emacsword); Set(Key_home, cmd_beginning_of_line); Set(Key_c_a, cmd_beginning_of_line); Set(Key_end, cmd_end_of_line); Set(Key_c_e, cmd_end_of_line); Set(Key_c_rb, cmd_find_char); Set(Key_escape Key_c_rb, cmd_find_char_rev); Set(Key_delete, cmd_delete_char); Set(Key_backspace, cmd_backward_delete_char); Set(Key_erase, cmd_backward_delete_char); Set(Key_c_h, cmd_backward_delete_char); Set(Key_escape "d", cmd_kill_emacsword); Set(Key_escape "D", cmd_kill_emacsword); Set(Key_escape Key_backspace, cmd_backward_kill_emacsword); Set(Key_escape Key_erase, cmd_backward_kill_emacsword); Set(Key_escape Key_c_h, cmd_backward_kill_emacsword); Set(Key_c_k, cmd_forward_kill_line); Set(Key_kill, cmd_backward_kill_line); Set(Key_c_u, cmd_backward_kill_line); Set(Key_c_x Key_backspace, cmd_backward_kill_line); Set(Key_c_x Key_erase, cmd_backward_kill_line); Set(Key_c_y, cmd_put_left); Set(Key_escape "y", cmd_put_pop); Set(Key_escape "Y", cmd_put_pop); Set(Key_c_w, cmd_backward_kill_bigword); Set(Key_c_ul, cmd_undo); Set(Key_c_x Key_c_u, cmd_undo); Set(Key_c_x Key_kill, cmd_undo); Set(Key_escape Key_c_r, cmd_undo_all); Set(Key_escape "r", cmd_undo_all); Set(Key_escape "R", cmd_undo_all); Set(Key_tab, cmd_complete_next_candidate); Set(Key_btab, cmd_complete_prev_candidate); Set(Key_escape "=", cmd_complete_list); Set(Key_escape "?", cmd_complete_list); Set(Key_escape "*", cmd_complete_all); Set(Key_c_t, cmd_emacs_transpose_chars); Set(Key_escape "t", cmd_emacs_transpose_words); Set(Key_escape "T", cmd_emacs_transpose_words); Set(Key_escape "l", cmd_emacs_downcase_word); Set(Key_escape "L", cmd_emacs_downcase_word); Set(Key_escape "u", cmd_emacs_upcase_word); Set(Key_escape "U", cmd_emacs_upcase_word); Set(Key_escape "c", cmd_emacs_capitalize_word); Set(Key_escape "C", cmd_emacs_capitalize_word); Set(Key_escape Key_backslash, cmd_emacs_delete_horizontal_space); Set(Key_escape " ", cmd_emacs_just_one_space); Set(Key_c_s, cmd_emacs_search_forward); Set(Key_c_r, cmd_emacs_search_backward); Set(Key_escape "<", cmd_oldest_history_eol); Set(Key_escape ">", cmd_return_history_eol); Set(Key_down, cmd_next_history_eol); Set(Key_c_n, cmd_next_history_eol); Set(Key_up, cmd_prev_history_eol); Set(Key_c_p, cmd_prev_history_eol); le_modes[LE_MODE_EMACS].keymap = t; le_modes[LE_MODE_EMACS_SEARCH].default_command = cmd_srch_self_insert; t = trie_create(); Set(Key_c_v, cmd_expect_verbatim); Set(Key_c_m, cmd_accept_line); Set(Key_interrupt, cmd_abort_line); Set(Key_c_c, cmd_abort_line); Set(Key_c_l, cmd_redraw_all); Set(Key_backslash, cmd_srch_self_insert); Set(Key_backspace, cmd_srch_backward_delete_char); Set(Key_erase, cmd_srch_backward_delete_char); Set(Key_c_h, cmd_srch_backward_delete_char); Set(Key_kill, cmd_srch_backward_delete_line); Set(Key_c_u, cmd_srch_backward_delete_line); Set(Key_c_s, cmd_srch_continue_forward); Set(Key_c_r, cmd_srch_continue_backward); Set(Key_c_j, cmd_srch_accept_search); Set(Key_escape, cmd_srch_accept_search); Set(Key_c_g, cmd_srch_abort_search); le_modes[LE_MODE_EMACS_SEARCH].keymap = t; le_modes[LE_MODE_CHAR_EXPECT].default_command = cmd_expect_char; t = trie_create(); Set(Key_c_v, cmd_expect_verbatim); Set(Key_interrupt, cmd_abort_line); Set(Key_c_c, cmd_abort_line); Set(Key_backslash, cmd_expect_char); Set(Key_escape, cmd_abort_expect_char); le_modes[LE_MODE_CHAR_EXPECT].keymap = t; #undef Set } /* Sets the editing mode to the one specified by `id'. */ void le_set_mode(le_mode_id_T id) { assert(id < LE_MODE_N); le_current_mode = le_id_to_mode(id); } /* Generates completion candidates for editing command names matching the * pattern. */ /* The prototype of this function is declared in "complete.h". */ void generate_bindkey_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_BINDKEY)) return; le_compdebug("adding lineedit command name candidates"); if (!le_compile_cpatterns(compopt)) return; for (size_t i = 0; i < sizeof commands / sizeof *commands; i++) if (le_match_comppatterns(compopt, commands[i].name)) le_new_candidate(CT_BINDKEY, malloc_mbstowcs(commands[i].name), NULL, compopt); } /********** Built-in **********/ static int print_all_commands(void); static int set_key_binding( le_mode_id_T mode, const wchar_t *keyseq, const wchar_t *commandname) __attribute__((nonnull)); static le_command_func_T *get_command_from_name(const char *name) __attribute__((nonnull,pure)); static int command_name_compare(const void *p1, const void *p2) __attribute__((nonnull,pure)); static int print_binding(le_mode_id_T mode, const wchar_t *keyseq) __attribute__((nonnull)); static int print_binding_main( void *mode, const wchar_t *keyseq, le_command_func_T *cmd) __attribute__((nonnull)); static const char *get_command_name(le_command_func_T *command) __attribute__((nonnull,const)); /* Options for the "bindkey" built-in. */ const struct xgetopt_T bindkey_options[] = { { L'v', L"vi-insert", OPTARG_NONE, false, NULL, }, { L'a', L"vi-command", OPTARG_NONE, false, NULL, }, { L'e', L"emacs", OPTARG_NONE, false, NULL, }, { L'l', L"list", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "bindkey" built-in, which accepts the following options: * -v: select the "vi-insert" mode * -a: select the "vi-command" mode * -e: select the "emacs" mode * -l: list names of available commands */ int bindkey_builtin(int argc, void **argv) { bool list = false; le_mode_id_T mode = LE_MODE_N; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, bindkey_options, 0)) != NULL) { switch (opt->shortopt) { case L'a': mode = LE_MODE_VI_COMMAND; break; case L'e': mode = LE_MODE_EMACS; break; case L'v': mode = LE_MODE_VI_INSERT; break; case L'l': list = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } le_keymap_init(); if (list) { if (!validate_operand_count(argc - xoptind, 0, 0)) return Exit_ERROR; if (mode != LE_MODE_N) { xerror(0, Ngt("option combination is invalid")); return Exit_ERROR; } return print_all_commands(); } if (mode == LE_MODE_N) { xerror(0, Ngt("no option is specified")); return Exit_ERROR; } switch (argc - xoptind) { case 0:; /* print all key bindings */ le_mode_T *m = le_id_to_mode(mode); return trie_foreachw(m->keymap, print_binding_main, m); case 1: return print_binding(mode, ARGV(xoptind)); case 2: return set_key_binding(mode, ARGV(xoptind), ARGV(xoptind + 1)); default: return too_many_operands_error(2); } } /* Prints all available commands to the standard output. */ int print_all_commands(void) { for (size_t i = 0; i < sizeof commands / sizeof *commands; i++) if (!xprintf("%s\n", commands[i].name)) return Exit_FAILURE; return Exit_SUCCESS; } /* Binds the specified key sequence to the specified command. * If `commandname' is L"-", the binding is removed. * If the specified command is not found, it is an error. */ int set_key_binding( le_mode_id_T mode, const wchar_t *keyseq, const wchar_t *commandname) { if (keyseq[0] == L'\0') { xerror(0, Ngt("cannot bind an empty key sequence")); return Exit_FAILURE; } if (wcscmp(commandname, L"-") == 0) { /* delete key binding */ register trie_T *t = le_modes[mode].keymap; t = trie_removew(t, keyseq); le_modes[mode].keymap = t; } else { /* set key binding */ char *mbsname = malloc_wcstombs(commandname); if (mbsname == NULL) { xerror(EILSEQ, Ngt("unexpected error")); return Exit_FAILURE; } le_command_func_T *cmd = get_command_from_name(mbsname); free(mbsname); if (cmd) { register trie_T *t = le_modes[mode].keymap; t = trie_setw(t, keyseq, (trievalue_T) { .cmdfunc = cmd }); le_modes[mode].keymap = t; } else { xerror(0, Ngt("no such editing command `%ls'"), commandname); return Exit_FAILURE; } } return Exit_SUCCESS; } /* Returns the command function of the specified name. * Returns a null pointer if no such command is found. */ le_command_func_T *get_command_from_name(const char *name) { struct command_name_pair *cnp = bsearch(name, commands, sizeof commands / sizeof *commands, sizeof *commands, command_name_compare); return (cnp != NULL) ? cnp->command : 0; } int command_name_compare(const void *p1, const void *p2) { return strcmp((const char *) p1, ((const struct command_name_pair *) p2)->name); } /* Prints the binding for the given key sequence. */ int print_binding(le_mode_id_T mode, const wchar_t *keyseq) { trieget_T tg = trie_getw(le_modes[mode].keymap, keyseq); if ((tg.type & TG_EXACTMATCH) && tg.matchlength == wcslen(keyseq)) { return print_binding_main( le_id_to_mode(mode), keyseq, tg.value.cmdfunc); } else { xerror(0, Ngt("key sequence `%ls' is not bound"), keyseq); return Exit_FAILURE; } } /* Prints a command to restore the specified key binding. * `mode' must be a pointer to one of the modes in `le_modes'. */ int print_binding_main( void *mode, const wchar_t *keyseq, le_command_func_T *cmd) { const char *format; char modechar; wchar_t *keyseqquote; const char *commandname; switch (le_mode_to_id(mode)) { case LE_MODE_VI_INSERT: modechar = 'v'; break; case LE_MODE_VI_COMMAND: modechar = 'a'; break; case LE_MODE_VI_SEARCH: modechar = 'V'; break; case LE_MODE_EMACS: modechar = 'e'; break; case LE_MODE_EMACS_SEARCH: modechar = 'E'; break; case LE_MODE_CHAR_EXPECT: modechar = 'c'; break; default: assert(false); } if (keyseq[0] == L'-') format = "bindkey -%c -- %ls %s\n"; else format = "bindkey -%c %ls %s\n"; keyseqquote = quote_sq(keyseq); commandname = get_command_name(cmd); xprintf(format, modechar, keyseqquote, commandname); free(keyseqquote); return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Returns the name of the specified command. */ const char *get_command_name(le_command_func_T *command) { for (size_t i = 0; i < sizeof commands / sizeof *commands; i++) if (commands[i].command == command) return commands[i].name; return NULL; } #if YASH_ENABLE_HELP const char bindkey_help[] = Ngt( "set or print key bindings for line-editing" ); const char bindkey_syntax[] = Ngt( "\tbindkey -aev [key_sequence [command]]\n" "\tbindkey -l\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/lineedit/Makefile.in0000644000175000017500000000565012154557026016416 0ustar magicantmagicant# Makefile.in for yash: yet another shell # (C) 2007-2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . .POSIX: .SUFFIXES: .c .h .d .o .a @MAKE_SHELL@ topdir = .. subdir = lineedit CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LDLIBS = @LDLIBS@ AR = @AR@ ARFLAGS = @ARFLAGS@ SOURCES = complete.c compparse.c display.c editing.c keymap.c lineedit.c terminfo.c trie.c HEADERS = complete.h compparse.h display.h editing.h key.h keymap.h lineedit.h terminfo.h trie.h OBJS = complete.o compparse.o display.o editing.o keymap.o lineedit.o terminfo.o trie.o TARGET = lineedit.a YASH = @TARGET@ BYPRODUCTS = commands.in *.dSYM all: $(TARGET) .c.o: @rm -f $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< $(TARGET): $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) keymap.o: commands.in commands.in: editing.h -@echo creating $@... @grep 'cmd_.*/\*C\*/$$' $? | \ LC_ALL=C sed -e 's/\(cmd_[0-9a-zA-Z_]*\).*/\1/' -e 's/.*cmd_//' \ -e 'h' -e 's/_/-/g' -e 'G' -e 's/\n/ /' | \ LC_COLLATE=C sort -k 1 | \ sed -e 's/ /", cmd_/' -e 's/^/{ "/' -e 's/$$/, },/' > $@ DISTFILES = $(SOURCES) $(SOURCES:.c=.d) $(HEADERS) Makefile.in distfiles: makedeps $(DISTFILES) copy-distfiles: distfiles mkdir -p $(topdir)/$(DISTTARGETDIR) cp $(DISTFILES) $(topdir)/$(DISTTARGETDIR) makedeps: _PHONY @(cd $(topdir) && $(MAKE) $(YASH)) $(topdir)/$(YASH) $(topdir)/makedeps.yash $(SOURCES) # ctags conforms to POSIX, but etags and cscope do not. CTAGS = @CTAGS@ CTAGSARGS = @CTAGSARGS@ ETAGS = @ETAGS@ ETAGSARGS = @ETAGSARGS@ CSCOPE = @CSCOPE@ CSCOPEARGS = @CSCOPEARGS@ tags: $(SOURCES) $(HEADERS) $(CTAGS) $(CTAGSARGS) TAGS: $(SOURCES) $(HEADERS) $(ETAGS) $(ETAGSARGS) cscope: cscope.out cscope.out: $(SOURCES) $(HEADERS) $(CSCOPE) $(CSCOPEARGS) mostlyclean: -rm -rf $(OBJS) $(BYPRODUCTS) clean: mostlyclean -rm -rf $(TARGET) distclean: clean -rm -rf Makefile tags TAGS cscope.out maintainer-clean: distclean -rm -rf $(SOURCES:.c=.d) Makefile: Makefile.in $(topdir)/config.status @+(cd $(topdir) && $(MAKE) config.status) @(cd $(topdir) && $(SHELL) config.status $(subdir)/$@) .PHONY: all distfiles copy-distfiles makedeps cscope mostlyclean clean distclean maintainer-clean _PHONY: @MAKE_INCLUDE@ complete.d @MAKE_INCLUDE@ compparse.d @MAKE_INCLUDE@ display.d @MAKE_INCLUDE@ editing.d @MAKE_INCLUDE@ keymap.d @MAKE_INCLUDE@ lineedit.d @MAKE_INCLUDE@ terminfo.d @MAKE_INCLUDE@ trie.d yash-2.35/alias.d0000644000175000017500000000033412154557026014004 0ustar magicantmagicantalias.o: alias.c common.h config.h alias.h xgetopt.h builtin.h exec.h \ expand.h hashtable.h option.h parser.h input.h plist.h strbuf.h util.h \ xfnmatch.h lineedit/complete.h lineedit/../plist.h lineedit/../xgetopt.h yash-2.35/plist.h0000644000175000017500000001417612154557026014063 0ustar magicantmagicant/* Yash: yet another shell */ /* plist.h: modifiable list of pointers */ /* (C) 2007-2010 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_PLIST_H #define YASH_PLIST_H #include #define Size_max ((size_t) -1) // = SIZE_MAX extern size_t plcount(void *const *list) __attribute__((pure,nonnull)); static inline void **pldup(void *const *array, void *copy(const void *p)) __attribute__((malloc,warn_unused_result,nonnull(2))); extern void **plndup( void *const *array, size_t count, void *copy(const void *p)) __attribute__((malloc,warn_unused_result,nonnull(3))); extern void plfree(void **ary, void freer(void *elem)); typedef struct plist_T { void **contents; size_t length, maxlength; } plist_T; static inline plist_T *pl_init(plist_T *list) __attribute__((nonnull)); static inline plist_T *pl_initwith(plist_T *list, void **array, size_t length) __attribute__((nonnull)); extern plist_T *pl_initwithmax(plist_T *list, size_t max) __attribute__((nonnull)); static inline void pl_destroy(plist_T *list) __attribute__((nonnull)); static inline void **pl_toary(plist_T *list) __attribute__((nonnull)); extern plist_T *pl_setmax(plist_T *list, size_t newmax) __attribute__((nonnull)); extern plist_T *pl_ensuremax(plist_T *list, size_t max) __attribute__((nonnull)); extern plist_T *pl_clear(plist_T *list, void freer(void *elem)) __attribute__((nonnull(1))); extern plist_T *pl_replace( plist_T *restrict list, size_t i, size_t ln, void *const *restrict a, size_t an) __attribute__((nonnull)); static inline plist_T *pl_ninsert( plist_T *restrict list, size_t i, void *const *restrict a, size_t n) __attribute__((nonnull)); static inline plist_T *pl_insert( plist_T *restrict list, size_t i, void *const *restrict a) __attribute__((nonnull)); static inline plist_T *pl_ncat( plist_T *restrict list, void *const *restrict a, size_t n) __attribute__((nonnull)); static inline plist_T *pl_cat( plist_T *restrict list, void *const *restrict a) __attribute__((nonnull)); static inline plist_T *pl_remove(plist_T *list, size_t i, size_t n) __attribute__((nonnull)); extern plist_T *pl_add(plist_T *list, const void *p) __attribute__((nonnull(1))); #ifndef PLIST_DEFAULT_MAX #define PLIST_DEFAULT_MAX 7 #endif /* Clones the specified NULL-terminated array of pointers. * Each pointer element is passed to function `copy' and the return value is * assigned to a new array element. * If `array' is NULL, simply returns NULL. */ /* `xstrdup' and `copyaswcs' are suitable for `copy'. */ void **pldup(void *const *array, void *copy(const void *p)) { return plndup(array, Size_max, copy); } /* Initializes the specified pointer list as a new empty list. */ plist_T *pl_init(plist_T *list) { return pl_initwithmax(list, PLIST_DEFAULT_MAX); } /* Initializes the specified pointer list with the specified array. * `array' must be a NULL-terminated array of pointers to void containing * exactly `length' elements and must be allocated by malloc. * `array' must not be modified or freed after the call to this function. */ plist_T *pl_initwith(plist_T *list, void **array, size_t length) { list->contents = array; list->length = list->maxlength = length; #ifdef assert assert(list->contents[list->length] == NULL); #endif return list; } /* Frees the specified pointer list. * Note that the list elements are not `free'd in this function. */ void pl_destroy(plist_T *list) { free(list->contents); } /* Frees the specified pointer list and returns the contents. * The caller must `free' the return value and its elements if needed. * If all the elements are pointers to byte strings, the return value can be * safely cast to (char **). */ void **pl_toary(plist_T *list) { return list->contents; } /* Inserts the first `n' elements of array `a' at offset `i' in pointer list * `list'. * NULL elements in `a' are not treated specially. * If (list->length <= i), the array elements are appended to the list. * Array `a' must not be part of `list->contents'. */ plist_T *pl_ninsert( plist_T *restrict list, size_t i, void *const *restrict a, size_t n) { return pl_replace(list, i, 0, a, n); } /* Inserts the elements of array `a' at offset `i' in pointer list `list'. * Array `a' must be terminated by a NULL element, which is not inserted. * If (list->length <= i), the array elements are appended to the list. * Array `a' must not be a part of `list->contents'. */ plist_T *pl_insert(plist_T *restrict list, size_t i, void *const *restrict a) { return pl_replace(list, i, 0, a, plcount(a)); } /* Appends the first `n' elements of array `a' to pointer list `list'. * NULL elements in `a' are not treated specially. * Array `a' must not be a part of `list->contents'. */ plist_T *pl_ncat(plist_T *restrict list, void *const *restrict a, size_t n) { return pl_replace(list, Size_max, 0, a, n); } /* Inserts the elements of array `a' to pointer list `list'. * Array `a' must be terminated by a NULL element, which is not inserted. * Array `a' must not be a part of `list->contents'. */ plist_T *pl_cat(plist_T *restrict list, void *const *restrict a) { return pl_replace(list, Size_max, 0, a, plcount(a)); } /* Removes the `n' elements at offset `i' in pointer list `list'. * It's the caller's responsibility to free the objects pointed by the removed * pointers. */ plist_T *pl_remove(plist_T *list, size_t i, size_t n) { return pl_replace(list, i, n, (void *[]) { NULL, }, 0); } #undef Size_max #endif /* YASH_PLIST_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/exec.d0000644000175000017500000000046312154557026013642 0ustar magicantmagicantexec.o: exec.c common.h config.h exec.h xgetopt.h alias.h builtin.h \ expand.h history.h input.h job.h option.h parser.h path.h plist.h \ redir.h sig.h strbuf.h util.h variable.h xfnmatch.h yash.h \ lineedit/complete.h lineedit/../plist.h lineedit/../xgetopt.h \ lineedit/lineedit.h lineedit/../input.h yash-2.35/util.c0000644000175000017500000002052212154557026013670 0ustar magicantmagicant/* Yash: yet another shell */ /* util.c: miscellaneous utility functions */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "util.h" #include #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include "exec.h" #include "option.h" #include "plist.h" /********** Miscellaneous Utilities **********/ /* Computes `mainsize + count * elemsize', but aborts the program if the size is * too large. `elemsize' must not be zero. */ size_t addmul(size_t mainsize, size_t count, size_t elemsize) { assert(elemsize > 0); size_t arraysize = count * elemsize; size_t totalsize = mainsize + arraysize; if (arraysize / elemsize != count || totalsize < mainsize) alloc_failed(); return totalsize; } /********** Memory Utilities **********/ /* This function is called on memory allocation failure and * aborts the program after printing an error message. */ void alloc_failed(void) { xerror(ENOMEM, NULL); abort(); } /********** String Utilities **********/ #if !HAVE_STRNLEN /* Returns min(maxlen, strlen(s)). */ size_t xstrnlen(const char *s, size_t maxlen) { size_t result = 0; while (result < maxlen && s[result] != '\0') result++; return result; } #endif /* Returns a newly malloced copy of the specified string. * The copy is at most `len' bytes long. * Returns an exact copy if (strlen(s) <= len). * Aborts the program on malloc failure. */ char *xstrndup(const char *s, size_t len) { len = xstrnlen(s, len); char *result = xmalloc(len + 1); result[len] = '\0'; return memcpy(result, s, len); } #if !HAVE_WCSNLEN /* Returns min(maxlen, wcslen(s)). */ size_t xwcsnlen(const wchar_t *s, size_t maxlen) { size_t result = 0; while (result < maxlen && s[result] != L'\0') result++; return result; } #endif /* Returns a newly malloced copy of the specified string. * The copy is at most `len' characters long. * Returns an exact copy if (wcslen(s) <= len). * Aborts the program on malloc failure. */ wchar_t *xwcsndup(const wchar_t *s, size_t len) { len = xwcsnlen(s, len); wchar_t *result = xmallocn(len + 1, sizeof (wchar_t)); result[len] = L'\0'; return wmemcpy(result, s, len); } /* Converts the specified multibyte string into an integer value. * If successful, stores the integer value in `*resultp', sets `errno' to zero, * and returns true. Otherwise, sets `errno' to a non-zero error value and * returns false (the value of `*resultp' is undefined). * The conversion is considered successful if the string is not empty, the * `strtol' function does not set `errno' to non-zero, and there is no remaining * character after the value. * Spaces at the beginning of the string are ignored. */ bool xstrtoi(const char *s, int base, int *resultp) { long result; char *endp; if (*s == '\0') { errno = EINVAL; return false; } errno = 0; result = strtol(s, &endp, base); if (errno != 0) return false; if (*endp != '\0') { errno = EINVAL; return false; } if (result < INT_MIN || result > INT_MAX) { errno = ERANGE; return false; } *resultp = (int) result; return true; } /* Converts the specified wide string into an integer value. * If successful, stores the integer value in `*resultp', sets `errno' to zero, * and returns true. Otherwise, sets `errno' to a non-zero error value and * returns false (the value of `*resultp' is undefined). * The conversion is considered successful if the string is not empty, the * `wcstol' function does not set `errno' to non-zero, and there is no remaining * character after the value. * Spaces at the beginning of the string are ignored. */ bool xwcstoi(const wchar_t *s, int base, int *resultp) { long result; if (!xwcstol(s, base, &result)) return false; if (result < INT_MIN || result > INT_MAX) { errno = ERANGE; return false; } *resultp = (int) result; return true; } /* The `long' version of `xwcstoi'. */ bool xwcstol(const wchar_t *s, int base, long *resultp) { wchar_t *endp; if (*s == L'\0') { errno = EINVAL; return false; } errno = 0; *resultp = wcstol(s, &endp, base); if (errno != 0) return false; if (*endp != L'\0') { errno = EINVAL; return false; } return true; } /* The `unsigned long' version of `xwcstoi'. */ bool xwcstoul(const wchar_t *s, int base, unsigned long *resultp) { wchar_t *endp; if (*s == L'\0') { errno = EINVAL; return false; } errno = 0; *resultp = wcstoul(s, &endp, base); if (errno != 0) return false; if (*endp != L'\0') { errno = EINVAL; return false; } return true; } /* If string `s' starts with `prefix', returns a pointer to the byte right after * the prefix in `s'. Otherwise, returns NULL. * This function does not change the value of `errno'. */ char *matchstrprefix(const char *s, const char *prefix) { while (*prefix != '\0') { if (*prefix != *s) return NULL; prefix++, s++; } return (char *) s; } /* If string `s' starts with `prefix', returns a pointer to the character right * after the prefix in `s'. Otherwise, returns NULL. * This function does not change the value of `errno'. */ wchar_t *matchwcsprefix(const wchar_t *s, const wchar_t *prefix) { while (*prefix != L'\0') { if (*prefix != *s) return NULL; prefix++, s++; } return (wchar_t *) s; } /* Same as `xwcsdup', except that the argument and the return value are of type * (void *). */ void *copyaswcs(const void *p) { return xwcsdup(p); } /********** Error Utilities **********/ /* The name of the current shell process. This value is the first argument to * the main function of the shell. */ const wchar_t *yash_program_invocation_name; /* The basename of `yash_program_invocation_name'. */ const wchar_t *yash_program_invocation_short_name; /* The name of the currently executed built-in. */ const wchar_t *current_builtin_name = NULL; /* The number of calls to the `xerror' function. */ /* This value is reset each time before a built-in is invoked. */ unsigned yash_error_message_count = 0; /* Prints the specified error message to the standard error. * `format' is passed to `gettext' and the result is printed using `vfprintf'. * If `errno_' is non-zero, prints `strerror(errno_)' after the formatted * string. * `format' should not end with '\n' because this function automatically prints * a newline lastly. If (format == NULL && errno_ == 0), prints "unknown error". */ void xerror(int errno_, const char *restrict format, ...) { yash_error_message_count++; fprintf(stderr, "%ls: ", current_builtin_name != NULL ? current_builtin_name : yash_program_invocation_name); if (format == NULL && errno_ == 0) format = Ngt("unknown error"); if (format != NULL) { va_list ap; va_start(ap, format); vfprintf(stderr, gt(format), ap); va_end(ap); } if (errno_ != 0) { fprintf(stderr, (format == NULL) ? "%s" : ": %s", strerror(errno_)); } fputc('\n', stderr); } /* Prints a formatted string like `printf', but if failed to write to the * standard output, writes an error message to the standard error. * Returns true iff successful. When this function returns, the value of `errno' * may not be the one set by the `printf' function. */ /* The `format' string is not passed to `gettext'. */ bool xprintf(const char *restrict format, ...) { va_list ap; int result; va_start(ap, format); result = vprintf(format, ap); va_end(ap); if (result >= 0) { return true; } else { xerror(errno, Ngt("cannot print to the standard output")); return false; } } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/sig.d0000644000175000017500000000042512154557026013476 0ustar magicantmagicantsig.o: sig.c common.h config.h sig.h xgetopt.h builtin.h exec.h expand.h \ job.h option.h parser.h input.h redir.h siglist.h signum.h strbuf.h \ util.h yash.h xfnmatch.h lineedit/complete.h lineedit/../plist.h \ lineedit/../xgetopt.h lineedit/lineedit.h lineedit/../input.h yash-2.35/xgetopt.c0000644000175000017500000003660312154557026014414 0ustar magicantmagicant/* Yash: yet another shell */ /* xgetopt.c: command option parser */ /* (C) 2012-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "xgetopt.h" #include #include #include #if LIST_AMBIGUOUS_OPTIONS # include #endif #include #include #include "option.h" #include "util.h" static struct xgetopt_T *search_argv(void); static struct xgetopt_T *parse_short_option(void); static struct xgetopt_T *found_short_option( const struct xgetopt_T *restrict opt) __attribute__((nonnull)); static struct xgetopt_T *parse_long_option(void); static struct xgetopt_T *found_long_option(const wchar_t *eq, const struct xgetopt_T *restrict opt) __attribute__((nonnull)); static struct xgetopt_T *finish_parsing_current_argument( const struct xgetopt_T *restrict opt) __attribute__((nonnull)); static struct xgetopt_T *parse_separate_option_argument(bool shortopt, const struct xgetopt_T *restrict opt) __attribute__((nonnull)); static void argshift(void); static struct xgetopt_T *done(void); static struct xgetopt_T *no_such_option(const wchar_t *s) __attribute__((nonnull)); static struct xgetopt_T *ambiguous_long_option(const wchar_t *s, size_t namelen) __attribute__((nonnull)); static struct xgetopt_T *option_argument_is_missing( bool shortopt, const struct xgetopt_T *opt) __attribute__((nonnull)); static struct xgetopt_T *unwanted_long_option_argument( const wchar_t *s, const struct xgetopt_T *opt) __attribute__((nonnull)); static struct xgetopt_T *sentinel(void) __attribute__((pure)); /* When an option that takes an argument was parsed, a pointer to the argument * is assigned to this variable. */ wchar_t *xoptarg; /* A pointer to the NULL-terminated array of pointers to wide strings that are * being parsed. */ static void **argv; /* The index to array `argv' to which the next found option should be moved. * In other words, `xoptind - 1' is the index of the last parsed option string * (or its argument). */ int xoptind = 0; /* The index of the element in array `argv' that should be parsed next. */ static int argvindex; /* The index of the character in the currently parsed argument string that * should be parsed next. */ static int charindex; /* An array of xgetopt_T's that specifies the set of options accepted by the * parser. */ static const struct xgetopt_T *opts; /* A set of option flags for the current parsing. */ static enum xgetoptopt_T getoptopt; /* Parses options for a command. * * When starting parsing of a new set of arguments, firstly `xoptind' must be * set to 0. Then, this function must be repeatedly called with the same * arguments. One option is parsed for each call. * * `argv_' is a pointer to a NULL-terminated array whose elements are pointers * to wide strings that are parsed. The array elements are reordered while * parsing so that all the options come before the operands unless doing the * POSIX parsing. * `opts_' is a pointer to an array of xgetopt_T structures that specify options * accepted by the parser. The array must terminated by a xgetopt_T structure * whose `shortopt' member is L'\0'. * `getoptopt_' is bitwise OR of zero or more xgetoptopt_T flags that specify * the way parsing is done: * XGETOPT_POSIX: Do the POSIX parsing, that is, parse options before the * first operand only. * XGETOPT_DIGIT: Negative numbers like "-1" are not treated as options. * In the POSIXly correct mode, XGETOPT_POSIX is always assumed and * XGETOPT_DIGIT is ignored. * * When a valid option is parsed, this function returns a pointer to the * xgetopt_T structure (in the `opts_' array) corresponding to the parsed * option. * Moreover, if the option takes an argument, `xoptarg' is assigned a pointer to * the argument; Otherwise, `xoptarg' is set to NULL. * * When an option is parsed but it is not in the `opts_' array or a required * option argument is missing, this function prints an error message and returns * a pointer to the last xgetopt_T structure in `opts_', whose `shortopt' member * is L'\0'. * * When there is no more option, a NULL pointer is returned and `xoptind' is set * to the index of the first operand in the `argv_' array. (If there are no * operands, `xoptind' is the index of the terminating NULL pointer in `argv_'.) * * The xgetopt_T structure contains the following members: * shortopt: A character representing a single-character option. * If `shortopt' is L'-', it is not parsed as a single-char option. * longopt: A pointer to a string representing a long option (not including * the preceding "--"). If `longopt' is a NULL pointer, it is not * parsed as a long option. * optarg: One of the optarg_T values, which specify if the option takes an * argument. * posix: In the POSIXly correct mode, this flag must be true for the * option to be accepted. * ptr: Not used in the `xgetopt' function. */ struct xgetopt_T *xgetopt( void **restrict argv_, const struct xgetopt_T *restrict opts_, enum xgetoptopt_T getoptopt_) { if (xoptind == 0) { argv = argv_; opts = opts_; getoptopt = getoptopt_; xoptind = argvindex = charindex = 1; /* reset the state */ } /* sanity check */ assert(argv_ == argv); assert(opts_ == opts); assert(getoptopt_ == getoptopt); assert(xoptind <= argvindex); return search_argv(); } /* Searches `argv' to find a candidate of an option. */ struct xgetopt_T *search_argv(void) { enum xgetoptopt_T opt = posixly_correct ? XGETOPT_POSIX : getoptopt; const wchar_t *arg; for (; (arg = argv[argvindex]) != NULL; argvindex++) { if (arg[0] == L'-') { if (arg[1] == L'-') /* `arg' starts with "--" */ return parse_long_option(); if (arg[1] != L'\0') if (!(opt & XGETOPT_DIGIT) || !iswdigit(arg[1])) return parse_short_option(); } /* `arg' is not a option */ if (opt & XGETOPT_POSIX) break; } /* no more options! */ return done(); } /* Parses `argv[argvindex]' as single-character options. */ struct xgetopt_T *parse_short_option(void) { const wchar_t *arg = argv[argvindex]; assert((size_t) charindex < wcslen(arg)); /* A hyphen should not be regarded as an option because the hyphen character * is used as a sentinel in the xgetopt_T structure to indicate that a * single-character option is not available. */ if (arg[charindex] == L'-') return no_such_option(arg); for (const struct xgetopt_T *opt = opts; opt->shortopt != L'\0'; opt++) if (opt->posix || !posixly_correct) if (opt->shortopt == arg[charindex]) return found_short_option(opt); return no_such_option(arg); } /* This function is called when a single-character option was found. * `opt' is a pointer to the option in the xgetopt_T array, which is returned by * this function unless an option argument is expected but missing. */ struct xgetopt_T *found_short_option(const struct xgetopt_T *restrict opt) { const wchar_t *arg = argv[argvindex]; if (opt->optarg == OPTARG_NONE) { /* the option doesn't take an argument */ if (arg[charindex + 1] != L'\0') { /* we have a next option in the same argument string */ charindex++; return (struct xgetopt_T *) opt; } else { /* no options are remaining in this argument string */ return finish_parsing_current_argument(opt); } } else { /* the option takes an argument */ xoptarg = (wchar_t *) &arg[charindex + 1]; if (*xoptarg == L'\0' && opt->optarg == OPTARG_REQUIRED) { /* the option argument is split from the option like "-x arg" */ return parse_separate_option_argument(true, opt); } else { /* the option argument is in the same string like "-xarg" */ return finish_parsing_current_argument(opt); } } } /* Parses `argv[argvindex]' as a long option. */ struct xgetopt_T *parse_long_option(void) { const wchar_t *arg = argv[argvindex]; if (arg[2] == L'\0') { /* `arg' is "--" */ argshift(); return done(); } if (posixly_correct) return no_such_option(arg); /* identify the long option */ const struct xgetopt_T *match = NULL; size_t namelen = wcscspn(&arg[2], L"="); for (const struct xgetopt_T *opt = opts; opt->shortopt != L'\0'; opt++) { if (!opt->posix && posixly_correct) continue; if (opt->longopt == NULL) continue; if (wcsncmp(opt->longopt, &arg[2], namelen) != 0) continue; if (opt->longopt[namelen] == L'\0') { /* exact match */ match = opt; break; } /* partial match: `&arg[2]' starts with `opt->longopt' */ if (match == NULL) /* first partial match */ match = opt; else /* more than one partial match */ return ambiguous_long_option(arg, namelen); } if (match == NULL) return no_such_option(arg); return found_long_option(&arg[namelen + 2], match); } /* This function is called when a long option was found. * `eq' is a pointer to the first L'=' in `argv[argvindex]' (or the terminating * null character if there is no L'='). * `opt' is a pointer to the option in the xgetopt_T array, which is returned by * this function unless an option argument is expected but missing. */ struct xgetopt_T *found_long_option(const wchar_t *eq, const struct xgetopt_T *restrict opt) { if (opt->optarg == OPTARG_NONE) { /* the option doesn't take an argument */ if (*eq != L'\0') return unwanted_long_option_argument(argv[argvindex], opt); return finish_parsing_current_argument(opt); } /* the option takes an argument */ if (*eq != L'\0') { /* the argument is specified after L'=' like "--option=argument" */ xoptarg = (wchar_t *) &eq[1]; return finish_parsing_current_argument(opt); } /* no option argument in `argv[argvindex]' */ switch (opt->optarg) { case OPTARG_OPTIONAL: /* the optional argument is not given */ return finish_parsing_current_argument(opt); case OPTARG_REQUIRED: /* the argument is split from the option like "--option argument" */ return parse_separate_option_argument(false, opt); case OPTARG_NONE: assert(false); } assert(false); } /* This function is called when an option was parsed in an argument string and * the argument has no more options to be parsed. * Before calling this function, `argvindex' must be set to the index of the * argument in `argv' that was just parsed. This function moves * `argv[argvindex]' to `argv[xoptind]' using the `argshift' function and then * increments `argvindex' and `xoptind'. * `charindex' is reset to 1. * `opt' is the option that was parsed, which is returned by this function. */ struct xgetopt_T *finish_parsing_current_argument( const struct xgetopt_T *restrict opt) { argshift(); charindex = 1; return (struct xgetopt_T *) opt; } /* This function is called when an option that takes an argument was found and * the argument is separate from the option string. * `shortopt' must be true iff the option is a single-character option. * `xoptarg' is set to `argv[argvindex+1]', which is supposed to be the option * argument. `argv[argvindex]' and `argv[argvindex+1]' are moved to * `argv[xoptind]' and `argv[xoptind+1]', respectively, and then `argvindex' and `xoptind' are each incremented by 2. * `charindex' is reset to 1. * `opt' is the option that was parsed, which is returned by this function * unless the argument is missing. */ struct xgetopt_T *parse_separate_option_argument(bool shortopt, const struct xgetopt_T *restrict opt) { xoptarg = argv[argvindex + 1]; if (xoptarg == NULL) return option_argument_is_missing(shortopt, opt); argshift(); argshift(); charindex = 1; return (struct xgetopt_T *) opt; } /* Reorders array elements. The `argv[argvindex]' is moved to `argv[xoptind]'. * Elements `argv[argvindex+1]', `argv[argvindex+2]', ..., `argv[xoptind]' are * moved to `argv[argvindex]', `argv[argvindex+1]', ..., `argv[xoptind-1]', * respectively. After reordering, `argvindex' and `xoptind' are each * incremented by 1. */ void argshift(void) { void *s = argv[argvindex]; assert(argvindex >= xoptind); for (int i = argvindex; i > xoptind; i--) argv[i] = argv[i - 1]; argv[xoptind] = s; argvindex++, xoptind++; } /* This function is called when there is no more option to be parsed. * Returns NULL. */ struct xgetopt_T *done(void) { #ifndef NDEBUG argv = NULL; opts = NULL; #endif return NULL; } /* Prints an error message that says that string `s' is not a valid option. * Returns the sentinel value that indicates an error. */ struct xgetopt_T *no_such_option(const wchar_t *s) { xerror(0, Ngt("`%ls' is not a valid option"), s); return sentinel(); } /* Prints an error message that says that string `s' is an ambiguous option. * `namelen' is the length of the long option name in `s', not including the * beginning "--", up to (but not including) L'=' or the end of the string. * Returns the sentinel value that indicates an error. */ struct xgetopt_T *ambiguous_long_option(const wchar_t *s, size_t namelen) { xerror(0, Ngt("option `%ls' is ambiguous"), s); #if LIST_AMBIGUOUS_OPTIONS for (const struct xgetopt_T *opt = opts; opt->shortopt != L'\0'; opt++) if (opt->longopt != NULL && wcsncmp(opt->longopt, &s[2], namelen) == 0) fprintf(stderr, "\t--%ls\n", opt->longopt); #else (void) namelen; #endif return sentinel(); } /* Prints an error message that says that an option argument is missing. * `shortopt' must be true iff the erroneous option is a single-character * option. * `opt' is a pointer to the erroneous option in the array given to the * `xgetopt' function. * Returns the sentinel value that indicates an error. */ struct xgetopt_T *option_argument_is_missing( bool shortopt, const struct xgetopt_T *opt) { if (shortopt) xerror(0, Ngt("the -%lc option requires an argument"), (wint_t) opt->shortopt); else xerror(0, Ngt("the --%ls option requires an argument"), opt->longopt); return sentinel(); } /* Prints an error message that says that a long option that does not take an * argument was specified with an argument. * `s' is a pointer to the erroneous argument string. * `opt' is a pointer to the erroneous option in the array given to the * `xgetopt' function. * Returns the sentinel value that indicates an error. */ struct xgetopt_T *unwanted_long_option_argument( const wchar_t *s, const struct xgetopt_T *opt) { xerror(0, Ngt("%ls: the --%ls option does not take an argument"), s, opt->longopt); return sentinel(); } /* Returns a pointer to the sentinel element of the specified xgetopt_T array. * A sentinel element is the first element whose `shortopt' is L'\0', which * indicates the end of the array. */ struct xgetopt_T *sentinel(void) { const struct xgetopt_T *opt = opts; while (opt->shortopt != L'\0') opt++; return (struct xgetopt_T *) opt; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/NEWS0000644000175000017500000007130012154557026013246 0ustar magicantmagicantHistory of Yash Legend: +: new feature -: removed feature =: specification change *: bug fix x: new bug ---------------------------------------------------------------------- Yash 2.35 + '--traceall' option. + New completion scripts for: git-clean, git-grep, git-ls-remote, git-submodule, git-whatchanged + Updated completion scripts for: git-cherry-pick, git-rebase (Git 1.8.1.4), ssh, ssh-add, ssh-keygen (OpenSSH 6.2) = The condition for exiting the shell when the -e option is enabled has been changed in accordance with the 2013 edition of POSIX.1-2008. = The "++" and "--" operators are no longer supported in the POSIXly-correct mode. = The $RANDOM variable now always returns random numbers, ignoring the value from the environment variable, if any. = If yash encounters a too long line that cannot be handled while reading a history file, it now tries to keep reading the rest of the file rather than stopping reading. = Very long command lines are no longer saved in the history file. * Minor fix in a syntax error message. * Minor fix in completion script for "git", "ssh" and "rsync". ---------------------------------------------------------------------- Yash 2.34 + New "test" built-in operator: =~, -o (unary) + New completion scripts for: configure, git-name-rev, git-request-pull, make, rsync = A syntax error or expansion error in .yash_profile or .yashrc no longer makes the shell exit even when the shell is not interactive. = In line-editing, overwritten characters are now restored when you hit the backspace key. = In line-editing, the undo history is no longer saved for each backspace. * Fixes in completion scripts for "git". ---------------------------------------------------------------------- Yash 2.33 = The "help" built-in now prints brief usage of built-ins. = Some error messages for command syntax error have been revised. = Some built-ins now check command syntax more strictly. * The "set" built-in aborts the shell on a command syntax error as specified in POSIX. ---------------------------------------------------------------------- Yash 2.32 + Man page and HTML manual in English and Japanese. = The "help" built-in now prints part of the man page. * Fixes in completion scripts for "git". ---------------------------------------------------------------------- Yash 2.31 + Completion of directory stack indices in extended tilde expansion. + New option for the "complete" built-in: --dirstack-index + Completion for "svn" version 1.7. * Fixes in "git", "tar" and "su" completion scripts. ---------------------------------------------------------------------- Yash 2.30 * Fixed pathname completion for redirections. + New completion scripts for: svn, git, gitg, gitk, and gitx. * Minor fixes in completion scripts. ---------------------------------------------------------------------- Yash 2.29 + An alias value now can contain newlines. * Fixed invalid memory access on printing an empty array using the "typeset" built-in. * The function body is now correctly executed in a subshell when the body is defined using the (...) compound command. * In line-editing, the undo command can now be applied only to the history entry that is being edited. ---------------------------------------------------------------------- Yash 2.28 = In an interactive shell, mail check is now done before job status report. * Fixed arithmetic expansion evaluating some expressions that should not be evaluated. * Fixed the "array" built-in removing the wrong elements when positive and negative indices are intermixed with the -d option. * Fixed the EXIT trap being wrongly executed after a command-not- found error. * The EXIT trap is now executed with the correct redirection when the last command had redirection. * The "exec" built-in now correctly exports arrays that are just assigned. * ${#@} is now correctly expanded to an array of integers that represent the lengths of array elements. * Fixed infinite loop in sequential brace expansion. * Fixed configuration file parsing in completion of the "ssh" command. * The "-T" option of the "ln" and "mv" commands now can be completed. * The EXIT trap now can be completed. ---------------------------------------------------------------------- Yash 2.27 * Minor bug fixes. + New completion scripts for: awk, chsh, gawk, nawk, pgawk, scp, sftp, ssh-add, ssh-agent, ssh-keygen, su, sudo, sudoedit, and useradd. * Fix in completion scripts for the "set" and "tar" commands. ---------------------------------------------------------------------- Yash 2.26 + New option for the "return" built-in: -n (--no-return) = Error messages have been revised. = Shell option names have been generalized: Option names are now case-insensitive. Non-alphanumeric characters are ignored in option names. Options can be inverted by prefixing "no" to their names. = "case foo in (esac) bar; esac" is now rejected in the POSIXly correct mode. = The "-o noexec" option is now ignored in an interactive shell. = New mail notification is now printed only when the mailbox file is not empty. = "printf %c ''" now prints nothing as "printf %c" do. = In an invocation of the "complete" built-in with the -A or -R option, the pattern is now matched against the last component of the pathname when generating pathname candidates with the -f option. * Function names containing an '=' sign can now be specified as arguments to the typeset and unset built-ins (with the -f option). * Fixed the exit status of iterative execution that was interrupted by SIGINT. + New completion scripts for: bsdtar, eview, evim, gex, gnutar, gtar, return, rgview, rgvim, rview, rvim, slogin, ssh, tar, and which. * Many fixes in completion scripts for: bash, chmod, dash, less, mksh, set, sh, and umask. ---------------------------------------------------------------------- Yash 2.25 = In the completion candidate list, options are now sorted case- insensitively. = While executing a completion function, the $IFS is reset to the default value. + New completion scripts for: bash, csplit, dash, diff, ed, egrep, env, ex, expand, fgrep, file, find, fold, getconf, grep, gview, gvim, gvimdiff, head, iconv, id, join, ksh, less, ln, locale, man, mesg, mkdir, mkfifo, mksh, more, mv, newgrp, nice, nl, nohup, od, paste, patch, pathchk, pr, ps, renice, rm, rmdir, sed, sh, sort, split, stty, tail, tee, time, touch, tr, uname, uniq, vi, view, vim, vimdiff, wc, who, xargs, and yash. * Many fixes in completion scripts for: cat, cd, chgrp, chmod, chown, cmp, comm, cp, crontab, cut, date, df, du, exec, ls, and set. ---------------------------------------------------------------------- Yash 2.24 + New option for the "." built-in: -L + New options for the "command" built-in: -a, -f, -k - Removed the -B option for the "command" built-in. = Fixed configuration process so that the shell can handle all kinds of signals on FreeBSD. = [line-editing] New command completion mechanism. The "complete" built-in now has new syntax and semantics. Completion settings are now autoloaded from $YASH_LOADPATH. + New completion scripts for: basename, bg, cat, chgrp, chmod, chown, cmp, comm, command, cp, crontab, cut, date, df, du, export, popd, pushd, readonly, type, ".", and "[". = Revised completion scripts for: alias, array, bindkey, break, cd, complete, continue, dirs, disown, echo, eval, exec, exit, fc, fg, getopts, hash, help, history, jobs, kill, ls, printf, pwd, read, set, suspend, test, trap, typeset, ulimit, umask, unalias, unset, and wait. - Removed completion script for the "return" built-in. = Short options now come before long options in a completion candidate list. * Symbolic links to non-existent files can now be completed. * Other fixes in command completion. * Fixed invalid memory access on parameter expansion failure in redirection. ---------------------------------------------------------------------- Yash 2.23 * Traps are no longer handled during completion to avoid messing up the display. * Fixed invalid memory access during completion. When the notify option is enabled, the shell was wrongly trying to notify the job status while executing a candidate generator function. * The "-o verbose" option is now disabled during completion to suppress the auto-loaded script being printed. * Fixed completion script for the "kill" built-in. ---------------------------------------------------------------------- Yash 2.22 + New "test" built-in operators: -G, -O, -N + Completion settings are now autoloaded from $YASH_COMPPATH. + New completion scripts for: alias, array, bindkey, break, cd, complete, continue, dirs, disown, echo, eval, exec, exit, fc, fg, getopts, hash, help, history, jobs, kill, ls, printf, pwd, read, return, set, suspend, test, trap, typeset, ulimit, umask, unalias, unset, and wait. * Fix a bug that was causing a signal received by a just-created subshell to be wrongly ignored. * Other bug fixes ---------------------------------------------------------------------- Yash 2.21 + Command line completion = In an interactive shell, the value of $LINENO is now reset to 1 every time a command is input and executed. * The "function" keyword was not recognized by "command -v". * Fixed handling of SIGINT so that the interactive shell properly gets back to normal after receiving SIGINT. * Input reading functions rewritten, including some bug fixes. ---------------------------------------------------------------------- Yash 2.20 + Function definition using the "function" keyword. = The "-nt" and "-ot" operators of the "test" built-in now consider a non-existent file older in favor of Korn shell. = [line-editing] some editing commands have been renamed: vi-change-all -> vi-change-line vi-yank-and-change-all -> vi-yank-all-change-line vi-append-end -> vi-append-to-eol * [line-editing] the clear-and-redraw-all command was broken. ---------------------------------------------------------------------- Yash 2.19 + The "ulimit" built-in is now available on FreeBSD. + In mail checking, the timestamp of the mail file is now compared by the nanosecond if possible. + [line-editing] new line-editing commands: oldest-history-bol, newest-history-bol, return-history-bol, prev-history-bol, next-history-bol, beginning-search-forward, beginning-search-backward = Faster filename pattern matching. = [line-editing] the "accept-line" command no longer accepts a failing history search result. = [line-editing] the following commands have been changed not to move the cursor to the beginning of the line: oldest-history, newest-history, return-history, prev-history, next-history The new commands whose names end with "-bol" provide the previous behaviors. * Fixed broken output of array assignment traces. * [line-editing] the "vi-edit-and-accept" command now handles the count. * [line-editing] fixed the cursor position after the search-again-forward/backward command in the emacs-like mode. ---------------------------------------------------------------------- Yash 2.18 + New operators for string comparison in the "test" built-in: ==, ===, !==, <, <=, >, >= + Operators "-nt" and "-ot" in the "test" built-in now compares the modification time by the nanosecond if possible. + '--default-directory' option for the "cd" and "pushd" built-in. + '--remove-duplicates' option for the "pushd" built-in. + The right prompt and the styler prompt. + '--le-alwaysrp' option. = The interpretation of escape sequences to change the font in $PS1 and $PS2 has been changed. = $PS3 no longer initialized. = Escape sequences are now interpreted in $PS4 as well as in $PS1 and $PS2. = The "echo" and "printf" built-ins now can print a null character. * [line-editing] $LINES and $COLUMNS were wrongly ignored. * [line-editing] fixed font color for some terminals. ---------------------------------------------------------------------- Yash 2.17 + '--le-visiblebell' option. + New operators for version comparison in the "test" built-in: -veq, -vne, -vgt, -vge, -vlt, -vle + [line-editing] "eof" command = The "typeset" built-in now prints only local variables when invoked without the -g option or operands. = The "typeset" built-in now prints function definitions in a pretty format. = When not in POSIXly-correct mode, commands in command substitu- tion are now parsed when the command containing the substitution is parsed. * Fixed the parse error on parameter expansion "${#}". * Fixed the "wait" built-in wrongly trying to wait for non-parent processes when invoked in a subshell. * [line-editing] vi-replace-char command was broken. * Many other bug fixes ---------------------------------------------------------------------- Yash 2.16 + '--curbg' and '--curstop' options. = '--curasync' option is now set by default. = Changed exit status of a while/until loop whose body is empty. = The "return" and "exit" built-ins now accepts an exit status of 256 or larger. = The "echo" built-in now interprets octal escapes only beginning with a backslash followed by a zero. * Fixed a syntax error of a special built-in invoked thru the "command" built-in causing the non-interactive shell to exit. * Fixed the exit status of the shell when the EXIT trap is set. * The '--allexport' option was wrongly ignored by the "read" and "getopts" built-ins. * Fixed segfaults and other errors in the "getopts" built-in. * [line-editing] Fixed the vi-replace-char command causing invalid memory access. * [line-editing] Fixed the emacs-just-one-space command not leaving space(s). ---------------------------------------------------------------------- Yash 2.15 + An interactive shell now can be interrupted by SIGINT. + Bracket expressions in pathname expansion are now fully supported (provided that libc's regex implementation is correct). = The "suspend" built-in now requires the -f option to suspend an interactive shell that is a session leader. = The shell no longer automatically sets the $YASH_LE_TIMEOUT variable. = A job-control shell now stops itself when invoked in the background. = A job-control shell no longer ignores SIGTTOU by default. = The '--nocaseglob' option no longer affects pattern matching in parameter expansions of the form "${var#xxx}", "${var%xxx}", etc. * Fixed pathname expansion on redirection target. * Couldn't set a signal handler to the default by the "trap" built-in if the signal was ignored on invocation of an inter- active shell. * Fixed accidental interruption of built-ins by signals. * Fixed parser so that a non-simple command is properly parsed after alias substitution. * Various bug fixes ---------------------------------------------------------------------- Yash 2.14 + The -l option for the "bindkey" built-in. + Negative array indices are now allowed. = $PWD is now set to "/" (rather than "/..") after "cd /..". = The "command" built-in with the -vb option now ignores shell keywords, aliases and functions. = Most of the built-ins now prints an error message and returns non-zero when they cannot print something to the standard output. = The "pwd" and "times" built-ins now fail when an operand is given. = The shell no longer exits when an assignment for a special built-in failed if not in POSIXly-correct mode. * "cd //" was failing if the current directory is "/". * Invoking the "bindkey" built-in in the yashrc file was causing an invalid memory access. * The "command" built-in with the -vb option was failing to find regular built-ins that are not in $PATH. * The "dirs" command was going into an infinite loop if given an argument. * The -c and -d options are wrongly rejected by the "ulimit" built-in. * The "fg" built-in now refuses more than one operands in POSIXly- correct mode, as described in the help. ---------------------------------------------------------------------- Yash 2.13 + "history" built-in + The -i option for the "eval", "break" and "continue" built-ins. + The value of the $COMMAND_NOT_FOUND_HANDLER variable is now executed when a command is not found. - '--autocd' option = The exit status is now one when the "return" built-in is used outside a function in an interactive shell. = Revised command search and execution. * The shell would not exit after the "exit" built-in twice in a row when you have $PROMPT_COMMAND set and you have stopped jobs. * The "notifyle" option not working with $PROMPT_COMMAND set. * [line-editing] Redoing was broken. * [line-editing] The command line was not redrawn after trap handling. * [line-editing] Fixed some bugs in the vi-edit-and-accept command. ---------------------------------------------------------------------- Yash 2.12 + Emacs-like line-editing. + "bindkey" built-in. + The $PROMPT_COMMAND variable now can be an array. + The value of the $YASH_AFTER_CD variable is now executed after the working directory was changed. = The "fg" and "bg" built-in now always sends SIGCONT to the continued job. = The "exit" built-in now warns about stopped jobs even when executed after the "fg", "bg", "disown" or "wait" built-in. * In vi-like line-editing, the wrong text was put after 30th yank. * In vi-like line-editing, the "s" command cannot be used if the cursor is at the beginning of line ---------------------------------------------------------------------- Yash 2.11 + Added the "--histspace" and "--le-noconvmeta" options. + Support for the $HISTRMDUP variable. + Support for the $YASH_LE_TIMEOUT variable. + The "kill" built-in with the "-l" option now accepts signal names as operands. = The "--le-convmeta" option now is a Boolean option. = The "$-" special parameter now includes the "l" flag if the shell is a login shell. * An empty case command "case i in (*) esac" now always returns the exit status of zero. * Quoted words were incorrectly expanded with backslashes when the "-f" option is set. * Fixed invalid memory access in the "v" command of vi-like line-editing. ---------------------------------------------------------------------- Yash 2.10 + History search in line-editing. = Empty lines are no longer stored in the history. = In the vi-like line-editing, "cw" and "cW" now work as in vi. * Setting the "notifyle" option caused a segfault if yash was configured with line-editing disabled. * In line-editing, undoing a change to a history entry did not restore the cursor position properly. * Some fixes for invalid memory access during line-editing. ---------------------------------------------------------------------- Yash 2.9 + Line-editing in the interactive mode. x Line-editing is not fully implemented. + Multiple instances of shell that use the same file for the history file now share the history. - The "history" built-in has been removed. = Now non-ASCII alphabets are allowed in variable names. = Now nested parameter expansions must be enclosed by braces. = The "help" built-in now prints an error message if the specified built-in is not found. * Fixed floating-point arithmetics in arithmetic expansions. * Fixed parser for arithmetic expansions that was incorrectly rejecting identifiers that start with underscores. * Fixed parser that had trouble parsing parameter expansions containing the hash sign like "${#=x}". * Fixed the help message for the "pwd" built-in. ---------------------------------------------------------------------- Yash 2.8 + Brace expansion with delta: {a..b..c} + The "command" built-in's -b and -B options now can be used with the -v and -V options. = Yash now conforms to POSIX.1-2008. . The "read" built-in now always removes trailing white-spaces from the input. . The results of tilde expansion are no longer subject to field splitting and pathname expansion. . The "pwd" built-in with the -P option no longer sets the $PWD variable. . "cd -L foo/.." is no more the same as "cd -L ." in that it is an error when the directory "foo" does not exist. . The "command" built-in's -p option now can be used with the -v and -V options. . In POSIXly-correct mode, all asynchronous commands now ignore SIGINT and SIGQUIT (even when job control is active). * When executing commands edited by the "fc" built-in, the $? variable was incorrectly assigned the exit status of the editor invoked by "fc". * Backslashes, commas and braces in $IFS were incorrectly ignored in field splitting. * Pathname expansion failed if we do not have the read permission for the specified directory even when we only need the search permission. * The signal mask of commands invoked by the shell now inherits that of the shell (except for trapped signals). * The "command" built-in now properly handles directories given as the commands when the "autocd" option is on. ---------------------------------------------------------------------- Yash 2.7 + Parameter expansion ${array[index]:=value} now allows assignment to an empty array element. + Here-string by the "<<<" operator. + New redirection operator ">>|" opens a pipe. - Loop pipes no longer supported. = The $IFS variable is always initialized to the default value when the shell is invoked. * The "echo" and "printf" built-ins now print an error message on failure. * A quoted period at the beginning of a filename was not properly matching during filename expansion. ---------------------------------------------------------------------- Yash 2.6 + Added the -q option to the fc built-in. + Compound commands may now contain no commands inside. * "alias -p" now prints commands with proper escape. * In POSIXly-correct mode, a semicolon followed by the identifier followed by "for" is now treated as an error. * Global aliases are now allowed after compound commands. * The "fg" and "wait" built-ins were causing invalid memory access when the "-o notify" option is enabled. ---------------------------------------------------------------------- Yash 2.5 = Redirection of FDs used by the shell is now error. * Some redirection syntax errors were overlooked. * Fixed the "sig.y" test failure. * When an "exec" command with redirections is enclosed in a brace with redirections, the redirections to the brace are now properly closed after execution. * Fixed parsing error of a comment after the identifier of a for statement. ---------------------------------------------------------------------- Yash 2.4 = The long option for the -p option of the "jobs" built-in has been changed from "--pid-only" to "--pgid-only". * Trap of SIGCHLD, SIGINT, SIGTERM, SIGQUIT, SIGTSTP, SIGTTOU were wrongly set to "ignore" in some condition. * Signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGTSTP, SIGTTOU were mistakenly reset in some moments. * Fixed the exit status of the "wait" built-in returned when interrupted by a signal. * Fixed file access permission test * "command -V xxx/yyy" now prints an error message if "xxx/yyy" is not a valid command. ---------------------------------------------------------------------- Yash 2.3 = Now changing LC_CTYPE immediately takes effect if the shell is interactive and not in the POSIXly-correct mode. * Fixed parameter expansion: empty words are now expanded properly. * Fixed a race condition, which was causing some signals ignored. * Assignments using the typeset/readonly/export built-ins failed to update the shell's internal data. This caused the shell to keep using the old PATH after the PATH has been changed. ---------------------------------------------------------------------- Yash 2.2 + "help", "pushd", "popd" and "dirs" built-ins = The value of $PWD set by the "cd" built-in is fixed. It now has a correct value when changing to a relative path from the root directory. * Pathname expansion not properly performed for patterns including "." or "..". ---------------------------------------------------------------------- Yash 2.1 + Array variables + "array", "echo", "printf" and "test" built-ins + The -A option for the "read" built-in * The colon flag in a parameter expansion like "${FOO:-bar}" was ignored if the value of the parameter begins with a certain character. * The readonly attribute was ignored when an assignment occurs against a command invocation * Passing "=" as a name to the "unset" built-in incorrectly unset the positional parameters and caused a potential invalid memory access. * Field splitting on variable values that consist only of spaces produced wrong results. * Test of file access permission now uses the effective user/group IDs rather than the real user/group IDs. ---------------------------------------------------------------------- Yash 2.0 + "history" built-in + Command redirection * A POSIXly-correct non-interactive shell exits when a paticular error occurred on a special built-in according to POSIX. * Alias substitution routines were improved. * Other bug fixes ---------------------------------------------------------------------- Yash 2.0 beta2 + Command history + "type", "hash" and "fc" built-ins = If the "command" built-in with the -V option fails to find a command, an message is printed. * Invocation of an external command with an assignent to the $PATH variable caused an invalid memory access. * Single quote not parsed properly in some circumstances. * Other bug fixes ---------------------------------------------------------------------- Yash 2.0 beta1 + "read", "getopts" and "command" built-ins + '--autocd' and '--curasync' option + Mail check feature + The prompt command = The "readonly" and "export" built-ins now affects global variables by default. * The standard input is no longer buffered * The "typeset" built-in now allows any characters other than '=' for variable names. * The special parameter $? reflects the exit status of a command substitution in a variable assignment. * Many other bug fixes ---------------------------------------------------------------------- Yash 2.0 beta0 + "eval", "exec", ".", "times", "umask", "typeset", "export", "readonly", "unset", "shift" and "trap" built-ins + "wait" built-in now can be interrupted + Arithmetic expansions + Interactive shell now notifies the process killed by a signal - "/etc/profile" and "~/.profile" are no longer sourced on start-up * Fixed token delimitation in alias substitution * Fixed token delimitation on assignments without values * Many other bug fixes ---------------------------------------------------------------------- Yash 2.0 alpha2 + Initialization files such as "/etc/profile" and "~/.yashrc" are now sourced on start-up. + '--noprofile', '--norcfile' and '--rcfile' options + "pwd", "set", "exit", "return", "break", "continue", "jobs", "fg", "bg", "wait", "disown", "alias" and "unalias" built-ins * '--nocaseglob' was misinterpreted as '-c'. * It was not fully case-insensitive when '--nocaseglob' is on. * If job control is off, an interactive shell no longer prints changed status of jobs before prompt. = Error handling for unset parameters was improved. = The help message for 'yash --help' is now much briefer. ---------------------------------------------------------------------- Yash 2.0 alpha1 + New options implemented: -x, -h, -a = The default value of 'PS3' is not set in POSIXly-correct mode. + 'configure' accepts new '--no-undefined' option + ":", "true", "false", "cd" built-ins * Command hashtable is now cleared when PATH is assigned. * Assertion failure when a null character is input * Many other bug fixes ---------------------------------------------------------------------- Yash 2.0 alpha0 (the first release of version 2.x) x Arithmetic expansion is not implemented x Built-ins are not implemented at all yash-2.35/COPYING0000644000175000017500000004310312154557026013602 0ustar magicantmagicant GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. yash-2.35/makesignum.d0000644000175000017500000000006512154557026015054 0ustar magicantmagicantmakesignum: makesignum.c common.h config.h siglist.h yash-2.35/yash.c0000644000175000017500000004243612154557026013667 0ustar magicantmagicant/* Yash: yet another shell */ /* yash.c: basic functions of the shell */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "yash.h" #include #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #if YASH_ENABLE_ALIAS # include "alias.h" #endif #include "builtin.h" #include "configm.h" #include "exec.h" #include "expand.h" #if YASH_ENABLE_HISTORY # include "history.h" #endif #include "input.h" #include "job.h" #include "option.h" #include "parser.h" #include "path.h" #include "redir.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" extern int main(int argc, char **argv) __attribute__((nonnull)); static struct input_file_info_T *new_input_file_info(int fd, size_t bufsize) __attribute__((malloc,warn_unused_result)); static void execute_profile(const wchar_t *profile); static void execute_rcfile(const wchar_t *rcfile); static void execute_file(const wchar_t *path); static void print_help(void); static void print_version(void); static void parse_and_exec(struct parseparam_T *pinfo, bool finally_exit) __attribute__((nonnull(1))); static bool input_is_interactive_terminal(const parseparam_T *pinfo) __attribute__((nonnull)); /* The process ID of the shell. * This value does not change in a subshell. */ pid_t shell_pid; /* The process group ID of the shell. * In a job-controlled subshell, this value is set to the subshell's pgid. */ pid_t shell_pgid; /* Set to true when the shell has been initialized. */ bool shell_initialized; /* If this flag is true when the "exit" built-in is invoked, the -f option is * assumed to be specified. */ static bool forceexit; /* The next value of `forceexit'. */ bool nextforceexit; /* The `input_file_info_T' structure for reading from the standard input. */ struct input_file_info_T *stdin_input_file_info; /* The "main" function. The execution of the shell starts here. */ int main(int argc, char **argv) { void *wargv[argc + 1]; const wchar_t *shortest_name; setvbuf(stdout, NULL, _IOLBF, BUFSIZ); setvbuf(stderr, NULL, _IOLBF, BUFSIZ); setlocale(LC_ALL, ""); #if HAVE_GETTEXT bindtextdomain(PACKAGE_NAME, LOCALEDIR); textdomain(PACKAGE_NAME); #endif /* convert arguments into wide strings */ for (int i = 0; i < argc; i++) { wargv[i] = malloc_mbstowcs(argv[i]); if (wargv[i] == NULL) { fprintf(stderr, gt("%s: cannot convert the argument `%s' " "into a wide character string"), argv[0], argv[i]); fprintf(stderr, gt("%s: the argument is replaced with an empty string\n"), argv[0]); wargv[i] = xwcsdup(L""); } } wargv[argc] = NULL; /* parse argv[0] */ yash_program_invocation_name = wargv[0]; yash_program_invocation_short_name = wcsrchr(yash_program_invocation_name, L'/'); if (yash_program_invocation_short_name != NULL) yash_program_invocation_short_name++; else yash_program_invocation_short_name = yash_program_invocation_name; command_name = yash_program_invocation_name; is_login_shell = (yash_program_invocation_name[0] == L'-'); shortest_name = yash_program_invocation_short_name; if (shortest_name[0] == L'-') shortest_name++; if (wcscmp(shortest_name, L"sh") == 0) posixly_correct = true; shell_pid = getpid(); shell_pgid = getpgrp(); stdin_input_file_info = new_input_file_info(STDIN_FILENO, 1); init_cmdhash(); init_homedirhash(); init_environment(); init_signal(); init_shellfds(); init_job(); init_builtin(); #if YASH_ENABLE_ALIAS init_alias(); #endif struct shell_invocation_T options = { .profile = NULL, .rcfile = NULL, }; int optresult = parse_shell_options(argc, wargv, &options); if (optresult != Exit_SUCCESS) exit(optresult); if (options.version) print_version(); if (options.help) print_help(); if (options.version || options.help) exit(yash_error_message_count == 0 ? Exit_SUCCESS : Exit_FAILURE); init_variables(); union { wchar_t *command; int fd; } input; const char *inputname; if (shopt_cmdline && shopt_stdin) exit(mutually_exclusive_option_error(L'c', L's')); if (shopt_cmdline) { input.command = wargv[xoptind++]; if (input.command == NULL) { xerror(0, Ngt("the -c option is specified " "but no command is given")); exit(Exit_ERROR); } if (xoptind < argc) { inputname = argv[xoptind]; command_name = wargv[xoptind++]; } else { inputname = posixly_correct ? "sh -c" : "yash -c"; } } else { if (argc == xoptind) shopt_stdin = true; if (shopt_stdin) { input.fd = STDIN_FILENO; inputname = NULL; if (!options.is_interactive_set && argc == xoptind && isatty(STDIN_FILENO) && isatty(STDERR_FILENO)) is_interactive = true; unset_nonblocking(STDIN_FILENO); } else { inputname = argv[xoptind]; command_name = wargv[xoptind]; xoptind++; input.fd = move_to_shellfd(open(inputname, O_RDONLY)); if (input.fd < 0) { int errno_ = errno; xerror(errno_, Ngt("cannot open file `%s'"), inputname); exit(errno_ == ENOENT ? Exit_NOTFOUND : Exit_NOEXEC); } } } #if YASH_ENABLE_LINEEDIT /* enable line editing if interactive and connected to a terminal */ if (!options.lineedit_set && shopt_lineedit == SHOPT_NOLINEEDIT) if (is_interactive && isatty(STDIN_FILENO) && isatty(STDERR_FILENO)) set_lineedit_option(SHOPT_VI); #endif is_interactive_now = is_interactive; if (!options.do_job_control_set) do_job_control = is_interactive; if (do_job_control) { open_ttyfd(); if (do_job_control) ensure_foreground(); } set_signals(); set_positional_parameters(&wargv[xoptind]); if (is_login_shell && !posixly_correct && !options.noprofile) if (getuid() == geteuid() && getgid() == getegid()) execute_profile(options.profile); if (is_interactive && !options.norcfile) if (getuid() == geteuid() && getgid() == getegid()) execute_rcfile(options.rcfile); shell_initialized = true; if (shopt_cmdline) exec_wcs(input.command, inputname, true); else exec_input(input.fd, inputname, XIO_SUBST_ALIAS | XIO_FINALLY_EXIT | (is_interactive ? XIO_INTERACTIVE : 0)); assert(false); } struct input_file_info_T *new_input_file_info(int fd, size_t bufsize) { struct input_file_info_T *info = xmallocs(sizeof *info, bufsize, sizeof *info->buf); info->fd = fd; info->bufpos = info->bufmax = 0; info->bufsize = bufsize; memset(&info->state, 0, sizeof info->state); // initial shift state return info; } /* Executes "$HOME/.yash_profile". */ void execute_profile(const wchar_t *profile) { if (profile != NULL) { execute_file(profile); return; } wchar_t *path = parse_and_expand_string(L"$HOME/.yash_profile", NULL, false); execute_file(path); free(path); } /* Executes the initialization file. * `rcfile' is the filename to source. * If `rcfile' is NULL, it defaults to "$HOME/.yashrc". * In the POSIXly-correct mode, `rcfile' is ignored and "$ENV" is used. */ void execute_rcfile(const wchar_t *rcfile) { if (posixly_correct) { const wchar_t *env = getvar(L VAR_ENV); if (env == NULL) return; wchar_t *path = parse_and_expand_string(env, "$ENV", false); execute_file(path); free(path); return; } if (rcfile != NULL) { execute_file(rcfile); return; } wchar_t *path = parse_and_expand_string(L"$HOME/.yashrc", NULL, false); execute_file(path); free(path); } /* Executes the specified file if `path' is non-NULL. */ void execute_file(const wchar_t *path) { if (path == NULL) return; char *mbspath = malloc_wcstombs(path); if (mbspath == NULL) return; int fd = move_to_shellfd(open(mbspath, O_RDONLY)); if (fd >= 0) { exec_input(fd, mbspath, XIO_SUBST_ALIAS); remove_shellfd(fd); xclose(fd); } free(mbspath); } /* Exits the shell with the specified exit status. * When this function is first called and `status' is negative, the value of * `laststatus' is used for `status'. When this function is called again and * `status' is negative, the value for the first call is used. * This function executes the EXIT trap. * This function never returns. * This function is reentrant and exits immediately if reentered. */ void exit_shell_with_status(int status) { static int exitstatus = -1; if (status >= 0) laststatus = status; assert(laststatus >= 0); if (exitstatus < 0) { exitstatus = laststatus; execute_exit_trap(); } else { if (status >= 0) exitstatus = status; } #if YASH_ENABLE_HISTORY finalize_history(); #endif exit(exitstatus); } /* Prints the help message to the standard output. */ void print_help(void) { #if YASH_ENABLE_HELP const char *shell_name = posixly_correct ? "sh" : "yash"; xprintf(gt( "Syntax:\n" "\t%s [option...] [filename [argument...]]\n" "\t%s [option...] -c command [command_name [argument...]]\n" "\t%s [option...] -s [argument...]\n"), shell_name, shell_name, shell_name); xprintf("\n"); print_shopts(true); xprintf(gt("Try `man yash' for details.\n")); #endif /* YASH_ENABLE_HELP */ } /* Prints the version info to the standard output. */ void print_version(void) { xprintf(gt("Yet another shell, version %s\n"), PACKAGE_VERSION); xprintf(PACKAGE_COPYRIGHT "\n"); xprintf(gt("This is free software licensed under GNU GPL version 2.\n" "You can modify and redistribute it, but there is NO WARRANTY.\n")); if (shopt_verbose) { xprintf(gt("\nEnabled features:\n")); xprintf("" #ifndef NDEBUG " * DEBUG\n" #endif #if YASH_ENABLE_ALIAS " * alias\n" #endif #if YASH_ENABLE_ARRAY " * array\n" #endif #if YASH_ENABLE_DIRSTACK " * dirstack\n" #endif #if YASH_ENABLE_HELP " * help\n" #endif #if YASH_ENABLE_HISTORY " * history\n" #endif #if YASH_ENABLE_LINEEDIT " * lineedit\n" #endif #if HAVE_GETTEXT " * nls\n" #endif #if YASH_ENABLE_PRINTF " * printf/echo\n" #endif #if YASH_ENABLE_SOCKET " * socket\n" #endif #if YASH_ENABLE_TEST " * test\n" #endif #if YASH_ENABLE_ULIMIT " * ulimit\n" #endif ); } } /********** Functions to Execute Commands **********/ /* Parses the specified wide string and executes it as commands. * `name' is printed in an error message on syntax error. `name' may be NULL. * If there are no commands in `code', `laststatus' is set to zero. */ void exec_wcs(const wchar_t *code, const char *name, bool finally_exit) { struct input_wcs_info_T iinfo = { .src = code, }; struct parseparam_T pinfo = { .print_errmsg = true, .enable_verbose = false, #if YASH_ENABLE_ALIAS .enable_alias = true, #endif .filename = name, .lineno = 1, .input = input_wcs, .inputinfo = &iinfo, .interactive = false, }; parse_and_exec(&pinfo, finally_exit); } /* Parses the input from the specified file descriptor and executes commands. * The file descriptor must be either STDIN_FILENO or a shell FD. If the file * descriptor is STDIN_FILENO, XIO_FINALLY_EXIT must be specified in `options'. * If `name' is non-NULL, it is printed in an error message on syntax error. * If XIO_INTERACTIVE is specified, the input is considered interactive. * If there are no commands in the input, `laststatus' is set to zero. */ void exec_input(int fd, const char *name, exec_input_options_T options) { struct parseparam_T pinfo = { .print_errmsg = true, .enable_verbose = true, #if YASH_ENABLE_ALIAS .enable_alias = options & XIO_SUBST_ALIAS, #endif .filename = name, .lineno = 1, .interactive = options & XIO_INTERACTIVE, }; struct input_interactive_info_T intrinfo; struct input_file_info_T *inputinfo; if (fd == STDIN_FILENO) inputinfo = stdin_input_file_info; else inputinfo = new_input_file_info(fd, BUFSIZ); if (pinfo.interactive) { intrinfo.fileinfo = inputinfo; intrinfo.prompttype = 1; pinfo.input = input_interactive; pinfo.inputinfo = &intrinfo; } else { pinfo.input = input_file; pinfo.inputinfo = inputinfo; } parse_and_exec(&pinfo, options & XIO_FINALLY_EXIT); assert(inputinfo != stdin_input_file_info); free(inputinfo); } /* Parses the input using the specified `parseparam_T' and executes commands. * If no commands were executed, `laststatus' is set to Exit_SUCCESS. */ void parse_and_exec(parseparam_T *pinfo, bool finally_exit) { bool executed = false; if (pinfo->interactive) disable_return(); for (;;) { if (pinfo->interactive) { set_laststatus_if_interrupted(); forceexit = nextforceexit; nextforceexit = false; pinfo->lineno = 1; } else { if (need_break()) goto out; } and_or_T *commands; switch (read_and_parse(pinfo, &commands)) { case PR_OK: if (commands != NULL) { if (shopt_exec || is_interactive) { exec_and_or_lists(commands, finally_exit && !pinfo->interactive && pinfo->lastinputresult == INPUT_EOF); executed = true; } andorsfree(commands); } break; case PR_EOF: if (!executed) laststatus = Exit_SUCCESS; if (!finally_exit) goto out; if (shopt_ignoreeof && input_is_interactive_terminal(pinfo)) { fprintf(stderr, gt("Use `exit' to leave the shell.\n")); } else { wchar_t argv0[] = L"EOF"; exit_builtin(1, (void *[]) { argv0, NULL }); } break; case PR_SYNTAX_ERROR: if (shell_initialized && !is_interactive_now) exit_shell_with_status(Exit_SYNERROR); if (!pinfo->interactive) { laststatus = Exit_SYNERROR; goto out; } break; case PR_INPUT_ERROR: laststatus = Exit_ERROR; goto out; } } out: cancel_return(); if (finally_exit) exit_shell(); } bool input_is_interactive_terminal(const parseparam_T *pinfo) { if (!pinfo->interactive) return false; struct input_interactive_info_T *ir = pinfo->inputinfo; return isatty(ir->fileinfo->fd); } /********** Built-ins **********/ /* Options for the "exit" and "suspend" built-ins. */ const struct xgetopt_T force_help_options[] = { { L'f', L"force", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "exit" built-in. * If the shell is interactive, there are stopped jobs and the -f flag is not * specified, then prints a warning message and does not exit. */ int exit_builtin(int argc, void **argv) { const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, force_help_options, 0)) != NULL) { switch (opt->shortopt) { case L'f': forceexit = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return special_builtin_syntax_error(Exit_ERROR); } } if (!validate_operand_count(argc - xoptind, 0, 1)) return special_builtin_syntax_error(Exit_ERROR); size_t sjc; if (is_interactive_now && !forceexit && (sjc = stopped_job_count()) > 0) { fprintf(stderr, ngt("You have a stopped job!", "You have %zu stopped jobs!", sjc), sjc); fprintf(stderr, gt(" Use `exit' again to exit anyway.\n")); forceexit = nextforceexit = true; return Exit_FAILURE; } int status; const wchar_t *statusstr = ARGV(xoptind); if (statusstr != NULL) { if (!xwcstoi(statusstr, 10, &status) || status < 0) { xerror(0, Ngt("`%ls' is not a valid integer"), statusstr); status = Exit_ERROR; special_builtin_syntax_error(status); } } else { status = -1; } exit_shell_with_status(status); assert(false); } #if YASH_ENABLE_HELP const char exit_help[] = Ngt( "exit the shell" ); const char exit_syntax[] = Ngt( "\texit [-f] [exit_status]\n" ); #endif /* The "suspend" built-in, which accepts the following options: * -f: suspend even if it may cause a deadlock. */ int suspend_builtin(int argc, void **argv) { bool force = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, force_help_options, 0)) != NULL) { switch (opt->shortopt) { case L'f': force = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (argc != xoptind) return too_many_operands_error(0); if (!force && is_interactive_now && getsid(0) == shell_pgid) { xerror(0, Ngt("refusing to suspend because of a possible deadlock.\n" "Use the -f option to suspend anyway.")); return Exit_FAILURE; } stop_myself(); if (doing_job_control_now) ensure_foreground(); return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } #if YASH_ENABLE_HELP const char suspend_help[] = Ngt( "suspend the shell" ); const char suspend_syntax[] = Ngt( "\tsuspend [-f]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/INSTALL.ja0000644000175000017500000004357412154557026014205 0ustar magicantmagicant====================================================================== Yash ビルド・インストールガイド ====================================================================== 分ã‹ã‚‹äººå‘ã‘ワンライナー: ./configure && make && sudo make install ---------------------------------------------------------------------- 目次: 1. Yash をビルドã™ã‚‹ã®ã«å¿…è¦ãªã‚‚ã® 2. コンフィギュレーション 3. ビルドã¨ãƒ†ã‚¹ãƒˆ 4. インストールã¨ã‚¢ãƒ³ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ« 5. æ›´ãªã‚‹ã‚³ãƒ³ãƒ•ィギュレーションオプション ---------------------------------------------------------------------- 1. Yash をビルドã™ã‚‹ã®ã«å¿…è¦ãªã‚‚ã® Yash 㯠C99 (ISO/IEC 9899:1999, 拡張版 C 言語) ã§æ›¸ã‹ã‚ŒãŸãƒ—ログラム㪠ã®ã§ã€ãƒ“ルドã™ã‚‹ã«ã¯ C99 ã®ã‚³ãƒ³ãƒ‘イラãŒå¿…è¦ã§ã™ã€‚ãŠä½¿ã„ã®ã‚·ã‚¹ãƒ†ãƒ ã« C99 ã®ã‚³ãƒ³ãƒ‘イラãŒãªã„å ´åˆã¯ã€ã¾ãšãれをインストールã—ã¦ãã ã•ã„。C99 ã®ã‚³ãƒ³ãƒ‘イラ㌠`c99' コマンドã¨ã—ã¦ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—ã¦ã‚ã‚‹å ´åˆã¯ã€ãれ㧠å分ã§ã™ã€‚ã¾ãŸæ¯”較的新ã—ã„ GNU Compiler Collection ã® `gcc' コマンド㌠インストールã—ã¦ã‚ã‚‹å ´åˆã¯ã€ãれãŒä½¿ãˆã¾ã™ã€‚ã“れら以外㮠C99 ã®ã‚³ãƒ³ãƒ‘ イラを使用ã—ãŸã„å ´åˆã¯ã€ã‚³ãƒ³ãƒ•ィギュレーションã§ãれを指定ã—ã¦ãã ã•ã„。 Yash ã®ãƒ“ルド㯠`make' コマンドã«ã‚ˆã£ã¦è‡ªå‹•化ã•れã¦ã„ã¾ã™ã®ã§ã€ã‚³ãƒ³ãƒ‘ イラã«åŠ ãˆã¦ `make' コマンドãŒå¿…è¦ã§ã™ã€‚POSIX è¦æ ¼ã«æº–æ‹ ã—㟠`make' コ マンドを使用ã™ã‚‹ã“ã¨ã‚’推奨ã—ã¾ã™ã€‚GNU Make ã§æ­£ã—ãビルドã§ãã‚‹ã“ã¨ã‚’ ç¢ºèªæ¸ˆã¿ã§ã™ã€‚ä»–ã® `make' コマンドã§ã‚‚多ãã®å ´åˆã¯å•題ã‚りã¾ã›ã‚“。 Yash 㯠POSIX è¦æ ¼ (IEEE Std 1003.1, 2008 Edition) ã§å®šç¾©ã•れ㟠API ã‚’ 使用ã—ã¦ã„ã¾ã™ã€‚ãŠä½¿ã„ã®ã‚·ã‚¹ãƒ†ãƒ ãŒ POSIX ã«å¯¾å¿œã—ã¦ã„ãªã„å ´åˆã€ãƒ“ルド ã«å¤±æ•—ã—ãŸã‚Šæ­£ã—ã動作ã—ãªã‹ã£ãŸã‚Šã™ã‚‹å¯èƒ½æ€§ãŒã‚りã¾ã™ã€‚ Yash ã¯å„言語ã«ç¿»è¨³ã•れãŸãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’表示ã™ã‚‹ãŸã‚ã« `gettext' 関数を使 用ã—ã¾ã™ã€‚GNU/Linux ãŠã‚ˆã³ Solaris ã®æœ€è¿‘ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯ã€`gettext' é–¢æ•°ã¯æ¨™æº– C ライブラリã«çµ„ã¿è¾¼ã¾ã‚Œã¦ã„ã‚‹ã®ã§ã€ãã®ã¾ã¾ã§å•題ã‚りã¾ã› ん。他ã®ã‚·ã‚¹ãƒ†ãƒ ã§ã¯ã€`gettext' 関数㯠`libintl' ã¨ã„ã†å¤–部ライブラリ ã§æä¾›ã•れã¾ã™ã€‚ãŠä½¿ã„ã®ã‚·ã‚¹ãƒ†ãƒ ã« `libintl' ライブラリãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ« ã•れã¦ã„ãªã„å ´åˆã¯ã€ã¾ãšãれをインストールã™ã‚‹ã‹ã€ã¾ãŸã¯ã‚³ãƒ³ãƒ•ィギュレ ーションã§å›½éš›åŒ–対応を無効化ã—ã¦ãã ã•ã„。 Yash ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ç·¨é›†æ©Ÿèƒ½ã‚’実ç¾ã™ã‚‹ãŸã‚ã« `curses' ライブラリを使 用ã—ã¾ã™ã€‚ãŠä½¿ã„ã®ã‚·ã‚¹ãƒ†ãƒ ã« `curses' ライブラリãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•れã¦ã„ ãªã„å ´åˆã¯ã€ã¾ãšãれをインストールã™ã‚‹ã‹ã€ã¾ãŸã¯ã‚³ãƒ³ãƒ•ィギュレーション ã§ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ç·¨é›†æ©Ÿèƒ½ã‚’無効化ã—ã¦ãã ã•ã„。 ---------------------------------------------------------------------- 2. コンフィギュレーション コンフィギュレーションã§ã¯ãƒ“ルドã§ä½¿ç”¨ã•れるã„ãã¤ã‹ã®ãƒ•ァイルãŒç”Ÿæˆã• れã¾ã™ã€‚ã“れらã®ãƒ•ァイルã«ã¯ã€ã‚·ã‚¹ãƒ†ãƒ ã§åˆ©ç”¨å¯èƒ½ãªæ©Ÿèƒ½ã®ç¨®é¡žã‚„ yash ã‚’ ã©ã“ã«ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã™ã‚‹ã‹ãªã©ã¨ã„ã£ãŸæƒ…å ±ãŒå…¥ã£ã¦ã„ã¾ã™ã€‚ コンフィギュレーション㯠`configure' ã¨ã„ã†åå‰ã®ã‚·ã‚§ãƒ«ã‚¹ã‚¯ãƒªãƒ—トã«ã‚ˆ ã£ã¦è¡Œã‚れã¾ã™ã€‚コンフィギュレーションを実行ã™ã‚‹ã«ã¯ã€`cd' コマンド㧠ãŠä½¿ã„ã®ã‚·ã‚§ãƒ«ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ `configure' スクリプトãŒã‚るディレ クトリã«å¤‰æ›´ã—ãŸå¾Œã€`sh configure' ã¨å…¥åŠ›ã—ã¦ãã ã•ã„。 コンフィギュレーションã«ãŠã„ã¦ã€`configure' スクリプトを起動ã™ã‚‹éš›ã«ã‚ª プションや変数を与ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“れã«ã‚ˆã‚Šã€ * ビルドã§ä½¿ç”¨ã™ã‚‹ã‚³ãƒ³ãƒ‘イラやアーカイム* ビルドã—㟠yash ã§ä½¿ç”¨å¯èƒ½ãªæ©Ÿèƒ½ * yash 本体や関連ファイルをインストールã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒª 等を指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ 例ãˆã°ã€ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³ç·¨é›†æ©Ÿèƒ½ã‚’無効化ã—ã¦ãƒ“ルドã™ã‚‹ã«ã¯ã€ã‚¹ã‚¯ãƒªãƒ—トを `sh configure --disable-lineedit' ã¨å…¥åŠ›ã—ã¦å®Ÿè¡Œã—ã¾ã™ã€‚ã¾ãŸ `cc' コマ ンドをコンパイラã¨ã—ã¦ãƒ“ルドã§ä½¿ç”¨ã™ã‚‹ã«ã¯ã€`sh configure CC=cc' ã¨ã— ã¾ã™ã€‚ 以下ã«ã€ã‚³ãƒ³ãƒ•ã‚£ã‚®ãƒ¥ãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ã§æŒ‡å®šå¯èƒ½ãªã‚ªãƒ—ション・変数を挙ã’ã¾ã™ã€‚ 以下ã¯ã€yash ã®ç‰¹å®šã®æ©Ÿèƒ½ã‚’有効化・無効化ã™ã‚‹ã‚ªãƒ—ションã§ã™ã€‚デフォル トã§ã¯ã€yash ã¯ã™ã¹ã¦ã®æ©Ÿèƒ½ãŒæœ‰åйãªçŠ¶æ…‹ã§ãƒ“ルドã•れã¾ã™ã€‚ --enable-alias --disable-alias エイリアスãŠã‚ˆã³ãれを扱ã†ãŸã‚ã® `alias', `unalias' 組込ã¿ã‚³ãƒž ンドを有効・無効ã«ã—ã¾ã™ã€‚ --enable-array --disable-array é…列を処ç†ã™ã‚‹ãŸã‚ã® `array' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’有効・無効ã«ã—ã¾ ã™ã€‚ã“ã®æ©Ÿèƒ½ã‚’無効ã«ã—ã¦ã‚‚ã€é…列変数ãã®ã‚‚ã®ã¯å¸¸ã«ã‚µãƒãƒ¼ãƒˆã•れ ã¾ã™ã€‚ --enable-dirstack --disable-dirstack ディレクトリスタックãŠã‚ˆã³ãれを扱ã†ãŸã‚ã® `dirs', `pushd', `popd' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’有効・無効ã«ã—ã¾ã™ã€‚ --enable-help --disable-help `help' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’有効・無効ã«ã—ã¾ã™ã€‚ --enable-history --disable-history コマンド履歴を扱ã†ãŸã‚ã® `fc', `history' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’有効 ・無効ã«ã—ã¾ã™ã€‚ --enable-lineedit --disable-lineedit 対話シェルã®ãŸã‚ã®è¡Œç·¨é›†æ©Ÿèƒ½ã‚’有効・無効ã«ã—ã¾ã™ã€‚ã“ã®æ©Ÿèƒ½ã‚’有 効ã«ã™ã‚‹ã«ã¯ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´æ©Ÿèƒ½ã‚‚有効ã«ã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。 --enable-printf --disable-printf `printf', `echo' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’有効・無効ã«ã—ã¾ã™ã€‚ --enable-socket --disable-socket ソケットリダイレクトを有効・無効ã«ã—ã¾ã™ã€‚ã“ã®æ©Ÿèƒ½ã‚’有効ã«ã™ã‚‹ã«ã¯ã€ ãŠä½¿ã„ã®ã‚·ã‚¹ãƒ†ãƒ ãŒã‚½ã‚±ãƒƒãƒˆã‚’サãƒãƒ¼ãƒˆã—ã¦ã„ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ --enable-test --disable-test `test', `[' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’有効・無効ã«ã—ã¾ã™ã€‚ --enable-ulimit --disable-ulimit `ulimit' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚’有効・無効ã«ã—ã¾ã™ã€‚ã“ã®æ©Ÿèƒ½ã‚’有効ã«ã™ã‚‹ ã«ã¯ã€ãŠä½¿ã„ã®ã‚·ã‚¹ãƒ†ãƒ ã®æ¨™æº– C ライブラリ㌠`getrlimit' ãŠã‚ˆã³ `setrlimit' 関数をサãƒãƒ¼ãƒˆã—ã¦ã„ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ 以下ã®ã‚ªãƒ—ション㯠yash ã®å‹•作を指定ã—ã¾ã™: --default-loadpath=... Yash ã‚’èµ·å‹•ã—ãŸã¨ãã€$YASH_LOADPATH 変数をã“ã®å€¤ã«åˆæœŸåŒ–ã—ã¾ã™ã€‚ (デフォルト: /yash) 以下ã®ã‚ªãƒ—ションã¯ãƒ•ァイルã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆã‚’指定ã—ã¾ã™: --prefix=... インストール先ã®åŸºæœ¬å…ˆé ­ãƒ‘ス (デフォルト: /usr/local) --exec-prefix=... 実行å¯èƒ½ãƒã‚¤ãƒŠãƒªã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆã®åŸºæœ¬å…ˆé ­ãƒ‘ス (デフォルト: ) --bindir=... 実行å¯èƒ½ãƒã‚¤ãƒŠãƒªã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒª (デフォルト: /bin) --datarootdir=... 実行å¯èƒ½ãƒã‚¤ãƒŠãƒªä»¥å¤–ã®ãƒ•ァイルã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆã®åŸºæœ¬å…ˆé ­ãƒ‘ス (デフォルト: /share) --datadir=... 補助スクリプトã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆ (デフォルト: ) --localedir=... 地域化対応用メッセージデータファイルã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆ (デフォルト: /locale) --mandir=... Roff å½¢å¼ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆ (デフォルト: /man) --docdir=... Roff å½¢å¼ä»¥å¤–ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆ (デフォルト: /doc/yash) --htmldir=... HTML å½¢å¼ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆ (デフォルト: ) 以下ã®å¤‰æ•°ã¯ãƒ“ルドã§ä½¿ç”¨ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã¨ãã®ã‚ªãƒ—ションを指定ã™ã‚‹ã®ã«ä½¿ãˆ ã¾ã™: CC=... ビルドã§ä½¿ç”¨ã™ã‚‹ã‚³ãƒ³ãƒ‘イラ兼リンカコマンドを指定ã—ã¾ã™ã€‚ CFLAGS=... コンパイル時ã«ã‚³ãƒ³ãƒ‘ã‚¤ãƒ©ã«æ¸¡ã™ã‚ªãƒ—ションを指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚³ ンフィギュレーションã§è‡ªå‹•çš„ã«è¨­å®šã•れるオプションを上書ãã—ã¾ã™ã€‚ CADDS=... コンパイル時ã«ã‚³ãƒ³ãƒ‘ã‚¤ãƒ©ã«æ¸¡ã™è¿½åŠ ã®ã‚ªãƒ—ションを指定ã—ã¾ã™ã€‚CFLAGS ã§æŒ‡å®šã•れるデフォルトã®ã‚ªãƒ—ションã®ã»ã‹ã«ã‚ªãƒ—ションを追加ã™ã‚‹éš›ã« ã“ã®å¤‰æ•°ã‚’指定ã—ã¦ãã ã•ã„。 LDFLAGS=... リンク時ã«ãƒªãƒ³ã‚«ã«æ¸¡ã™ã‚ªãƒ—ションを指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚³ãƒ³ãƒ•ã‚£ ギュレーションã§è‡ªå‹•çš„ã«è¨­å®šã•れるオプションを上書ãã—ã¾ã™ã€‚ã“ã®å¤‰ æ•°ã«ã¯ãƒªãƒ³ã‚¯ã™ã‚‹ãƒ©ã‚¤ãƒ–ラリを指定ã™ã‚‹ã‚ªãƒ—ションã¯å«ã¾ã‚Œã¾ã›ã‚“。(下 記 LDLIBS å‚ç…§) LDADDS=... リンク時ã«ãƒªãƒ³ã‚«ã«æ¸¡ã™è¿½åŠ ã®ã‚ªãƒ—ションを指定ã—ã¾ã™ã€‚LDFLAGS ã§æŒ‡å®š ã•れるデフォルトã®ã‚ªãƒ—ションã®ã»ã‹ã«ã‚ªãƒ—ションを追加ã™ã‚‹éš›ã«ã“ã®å¤‰ 数を指定ã—ã¦ãã ã•ã„。 LDLIBS=... 実行å¯èƒ½ãƒã‚¤ãƒŠãƒªã¨ãƒªãƒ³ã‚¯ã•ã›ã‚‹ãƒ©ã‚¤ãƒ–ラリを指定ã™ã‚‹ãŸã‚ã®ãƒªãƒ³ã‚«ã‚ªãƒ— ションを指定ã—ã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚³ãƒ³ãƒ•ィギュレーションã§è‡ªå‹•çš„ã«è¨­å®š ã•れるオプションを上書ãã—ã¾ã™ã€‚ AR=... ビルドã§ä½¿ç”¨ã™ã‚‹ã‚¢ãƒ¼ã‚«ã‚¤ãƒã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã—ã¾ã™ã€‚ ARFLAGS=... ãƒã‚¤ãƒŠãƒªã‚¢ãƒ¼ã‚«ã‚¤ãƒ–を作æˆã™ã‚‹éš›ã«ã‚¢ãƒ¼ã‚«ã‚¤ãƒã«æ¸¡ã™ã‚ªãƒ—ションを指定㗠ã¾ã™ã€‚ã“ã®å¤‰æ•°ã¯ã‚³ãƒ³ãƒ•ィギュレーションã§è‡ªå‹•çš„ã«è¨­å®šã•れるオプショ ンを上書ãã—ã¾ã™ã€‚ LINGUAS=... 地域化対応用ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒ‡ãƒ¼ã‚¿ã‚’インストールã™ã‚‹ãƒ­ã‚±ãƒ¼ãƒ«ã‚’指定ã—ã¾ ã™ã€‚複数ã®ãƒ­ã‚±ãƒ¼ãƒ«ã‚’指定ã™ã‚‹ã«ã¯ã€ãƒ­ã‚±ãƒ¼ãƒ«åを空白ã§åŒºåˆ‡ã£ã¦ãã ã• ã„。(å…¨ã¦ã®ãƒ­ã‚±ãƒ¼ãƒ«åを一ã¤ã® LINGUAS 変数ã§ä¸€åº¦ã«æŒ‡å®šã™ã‚‹å¿…è¦ãŒã‚ りã¾ã™ã€‚シェルã‹ã‚‰ `configure' スクリプトを起動ã™ã‚‹éš›ã«å¤‰æ•°ã®å€¤å…¨ 体をé©åˆ‡ã«ã‚¯ã‚©ãƒ¼ãƒˆã—ã¦ãã ã•ã„。) INSTALL=... インストール時ã«ä½¿ç”¨ã™ã‚‹ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ©ã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã—ã¾ã™ã€‚ ---------------------------------------------------------------------- 3. ビルドã¨ãƒ†ã‚¹ãƒˆ コンフィギュレーションãŒã§ããŸã‚‰ã€ã‚·ã‚§ãƒ«ã‹ã‚‰ `make' コマンドを実行ã—㦠yash をビルドã—ã¦ãã ã•ã„。`make' コマンドãŒã‚³ãƒ³ãƒ‘イラやリンカをé©åˆ‡ãª é †åºã§èµ·å‹•ã—ã¦ã€yash ã®å®Ÿè¡Œå¯èƒ½ãƒã‚¤ãƒŠãƒªã‚’生æˆã—ã¾ã™ã€‚ Yash ã®ãƒ“ãƒ«ãƒ‰ãŒæ¸ˆã‚“ã ã‚‰ã€yash ãŒæ­£ã—ãæ©Ÿèƒ½ã™ã‚‹ã‹ã©ã†ã‹ `make test' ã‚’ 実行ã™ã‚‹ã“ã¨ã§ãƒ†ã‚¹ãƒˆã§ãã¾ã™ã€‚(実際ã«ã¯ã€`make' ã‚’ã›ãšã«ã„ããªã‚Š `make test' ã‚’ã—ã¦ã‚‚æ§‹ã„ã¾ã›ã‚“。テストå‰ã«è‡ªå‹•çš„ã«ãƒ“ルドãŒè¡Œã‚れã¾ã™ã€‚) ---------------------------------------------------------------------- 4. インストールã¨ã‚¢ãƒ³ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ« ビルドãŒã§ããŸã‚‰ã€`make install' を実行ã™ã‚‹ã“ã¨ã§ yash をインストール ã§ãã¾ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã“ã¨ã§ã€yash ã®å®Ÿè¡Œå¯èƒ½ãƒã‚¤ãƒŠãƒªã¨ yash ãŒä½¿ç”¨ã™ã‚‹è£œåŠ©ãƒ•ã‚¡ã‚¤ãƒ«ãŒã™ã¹ã¦ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•れã¾ã™ã€‚コンフィギュレー ションã§ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆã‚’指定ã—ãªã‹ã£ãŸå ´åˆã¯ã€ä»¥ä¸‹ã®ãƒ‡ãƒ•ォルトディレク トリã«ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•れã¾ã™ã€‚ 実行å¯èƒ½ãƒã‚¤ãƒŠãƒª: /usr/local/bin 補助シェルスクリプト: /usr/local/share/yash 地域化対応用データ: /usr/local/share/locale Roff å½¢å¼ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«: /usr/local/share/man HTML å½¢å¼ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«: /usr/local/share/doc/yash ã»ã¨ã‚“ã©ã®ã‚·ã‚¹ãƒ†ãƒ ã§ã¯ã€ã“れらã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ãƒ•ァイルをインストール㙠るã«ã¯ç‰¹åˆ¥ãªæ¨©é™ãŒå¿…è¦ã¨ãªã‚Šã¾ã™ã€‚権é™ã‚’å–å¾—ã™ã‚‹ãŸã‚ã« `sudo' ç­‰ã®ã‚³ãƒž ンドを使用ã—ã¦ãã ã•ã„。ã¾ãŸä»£ã‚りã«åˆ¥ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«å…ˆãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’コ ãƒ³ãƒ•ã‚£ã‚®ãƒ¥ãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ã§æŒ‡å®šã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ `make install' ã®ä»£ã‚りã«ã€`make install-binary' を実行ã—ã¦å®Ÿè¡Œå¯èƒ½ãƒ イナリã®ã¿ã‚’インストールã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã¾ãŸ `make install-data' ã§ä»–ã®è£œåŠ©ãƒ•ã‚¡ã‚¤ãƒ«ã®ã¿ã‚’インストールã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ `make install' ã¾ãŸã¯ `make install-binary' ã®ä»£ã‚りã«ã€ `make install-strip' ã¾ãŸã¯ `make install-binary-strip' ã‚’ãれãžã‚Œä½¿ç”¨ ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“れらã¯ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ä¸­ã«ãƒã‚¤ãƒŠãƒªã‹ã‚‰ãƒ‡ãƒãƒƒã‚°ç”¨æƒ…å ± を削除ã™ã‚‹ã“ã¨ã§ãƒ•ァイルサイズをå°ã•ãã—ã¾ã™ã€‚ Yash をアンインストールã™ã‚‹ã«ã¯ã€`make uninstall' を実行ã—ã¦ãã ã•ã„。 `make uninstall-binary' ãŠã‚ˆã³ `make uninstall-data' を使ã†ã¨å®Ÿè¡Œå¯èƒ½ ãƒã‚¤ãƒŠãƒªãŠã‚ˆã³ãã®ä»–ã®è£œåŠ©ãƒ•ã‚¡ã‚¤ãƒ«ã®ã¿ã‚’ãれãžã‚Œã‚¢ãƒ³ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã™ã‚‹ã“ ã¨ã‚‚ã§ãã¾ã™ã€‚ ---------------------------------------------------------------------- 5. æ›´ãªã‚‹ã‚³ãƒ³ãƒ•ィギュレーションオプション `configure' スクリプトを実行ã™ã‚‹ã“ã¨ã§ã‚³ãƒ³ãƒ•ィギュレーションを行ã£ãŸå¾Œã€ `config.h' ファイルを直接編集ã™ã‚‹ã“ã¨ã§ã•ら㫠yash をカスタマイズã™ã‚‹ ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã“ã§è¿°ã¹ã‚‹ã‚ªãƒ—ションã¯å¤šãã®äººã«ã¨ã£ã¦ã¯é–¢å¿ƒã®ãªã„ã“ ã¨ãªã®ã§ã€`configure' スクリプトã§è¨­å®šã§ãるよã†ã«ã¯ãªã£ã¦ã„ã¾ã›ã‚“。 オプションã¯ã€`config.h' ãƒ•ã‚¡ã‚¤ãƒ«å†…ã«æ‰€å®šã®ãƒžã‚¯ãƒ­ã‚’定義ã™ã‚‹ã“ã¨ã§è¨­å®š ã§ãã¾ã™ã€‚オプションã¯ã€ãƒ–ーリアンオプションã¨ãれ以外ã®ã‚ªãƒ—ションã¨ã« 分ã‹ã‚Œã¾ã™ã€‚ブーリアンオプションã¯ã€ãƒžã‚¯ãƒ­ã®å€¤ã‚’ 0 ä»¥å¤–ã®æ•´æ•°å€¤ã¨ã—㦠定義ã™ã‚‹ã¨æœ‰åйã«ãªã‚Šã€0 ã¨ã—ã¦å®šç¾©ã™ã‚‹ã‹æœªå®šç¾©ã®ã¾ã¾ã«ã™ã‚‹ã¨ç„¡åйã«ãªã‚Š ã¾ã™ã€‚éžãƒ–ーリアンオプションã«ã¤ã„ã¦ã¯ã€ãƒ‡ãƒ•ォルトã®å€¤ã‚’マクロåã®æ¨ªã« 示ã—ã¦ã‚りã¾ã™ã€‚ #define ALIAS_LIST_MAX 30 ã“ã®ãƒžã‚¯ãƒ­ã¯æ­£ã®æ•´æ•°å€¤ã¨ã—ã¦å®šç¾©ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ ã“ã®ãƒžã‚¯ãƒ­ã¯ã€ä¸€åº¦ã«å†å¸°çš„ã«å±•é–‹ã§ãã‚‹ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®æ•°ã‚’指定ã—ã¾ã™ã€‚ #define DOUBLE_DIVISION_BY_ZERO_ERROR 1 /* ブーリアンオプション */ ã“ã®ãƒžã‚¯ãƒ­ã‚’éž 0 値ã«è¨­å®šã™ã‚‹ã¨ã€å°æ•°ã®ã‚¼ãƒ­ã«ã‚ˆã‚‹é™¤ç®—をエラーã¨ã—ã¾ã™ã€‚ デフォルトã§ã¯ã€ã‚¼ãƒ­ã«ã‚ˆã‚‹é™¤ç®—ã¯æœ‰åйãªçµæžœ (例ãˆã°ç„¡é™å¤§) ã‚’è¿”ã™ã¨ä»®å®š ã•れã¾ã™ã€‚ #define FG_DONT_SAVE_TERMINAL 1 /* ブーリアンオプション */ 端末ã®è¨­å®šã‚’æ“作ã™ã‚‹ãƒ—ログラムãŒãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§èµ·å‹•ã•れã€å¾Œã§ `fg' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å†é–‹ã•れãŸå ´åˆã€ç«¯æœ«ã®è¨­å®šãŒãŠã‹ã—ãªã¾ã¾æ®‹ã‚‹ã“ã¨ãŒã‚り ã¾ã™ã€‚ãã®ãŸã‚デフォルトã§ã¯ `fg' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ãƒ—ログラムをå†é–‹ã•ã› ã‚‹å‰ã«ç«¯æœ«ã®è¨­å®šã‚’ä¿å­˜ã—ã€å¾Œã§è¨­å®šã‚’å…ƒã«æˆ»ã—ã¾ã™ã€‚ã—ã‹ã—ã“ã®ãƒžã‚¯ãƒ­ãŒéž 0 値ã«è¨­å®šã—ã¦ã‚ã‚‹ã¨ã€`fg' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã“ã®ã‚ˆã†ãªå›žé¿ç­–ã‚’å–りã¾ã› ん。 #define FIXED_SIGNAL_AS_ERROR 1 /* ブーリアンオプション */ éžå¯¾è©±ãƒ¢ãƒ¼ãƒ‰ã®ã‚·ã‚§ãƒ«ãŒèµ·å‹•ã™ã‚‹éš›ã«å…ƒã‹ã‚‰ã‚·ã‚°ãƒŠãƒ«ãƒãƒ³ãƒ‰ãƒ©ãŒã€Œç„¡è¦–ã€ã«è¨­ 定ã•れã¦ã„ãŸå ´åˆã€`trap' 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã§å¾Œã‹ã‚‰ãれを解除ã™ã‚‹ã“ã¨ã¯ã§ ããªã„㨠POSIX è¦æ ¼ã§å®šã‚られã¦ã„ã¾ã™ã€‚ã“ã®ã‚ªãƒ—ションã¯ã€ã“ã®ã‚ˆã†ãªå ´ åˆã«ãŠã‘ã‚‹ `trap' コマンドã®å‹•作を指定ã—ã¾ã™ã€‚ã“ã®ãƒžã‚¯ãƒ­ãŒéž 0 値ã«è¨­ 定ã•れã¦ã„ã‚‹å ´åˆã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ã€ãã†ã§ãªã„å ´åˆ ã¯ã€ã‚³ãƒžãƒ³ãƒ‰ã¯ä½•もエラーãŒç„¡ã‹ã£ãŸã‹ã®ã‚ˆã†ã«æŒ¯ã‚‹èˆžã„ã¾ã™ã€‚ãªãŠã€ã„ã¥ã‚Œ ã®å ´åˆã‚‚ã€å½“該シグナルãƒãƒ³ãƒ‰ãƒ©ã¯è§£é™¤ã•れã¾ã›ã‚“。 #define FORMAT_INDENT_WIDTH 3 ã“ã®ãƒžã‚¯ãƒ­ã¯ 0 ä»¥ä¸Šã®æ•´æ•°å€¤ã¨ã—ã¦å®šç¾©ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ ã“ã®ãƒžã‚¯ãƒ­ã¯ã€ã‚·ã‚§ãƒ«ãŒã‚³ãƒžãƒ³ãƒ‰ã‚’æ•´å½¢ã—ã¦å‡ºåŠ›ã™ã‚‹éš›ã®ã‚¤ãƒ³ãƒ‡ãƒ³ãƒˆã®å¹…を指 定ã—ã¾ã™ã€‚ #define MAX_HISTSIZE 1000000 ã“ã®ãƒžã‚¯ãƒ­ã¯ (INT_MAX / 10) ã‚’è¶…ãˆãªã„æ­£ã®æ•´æ•°å€¤ã¨ã—ã¦å®šç¾©ã™ã‚‹å¿…è¦ãŒã‚ りã¾ã™ã€‚ ã“ã®ãƒžã‚¯ãƒ­ã¯å±¥æ­´é …ç›®ã®æœ€å¤§å€‹æ•°ã‚’指定ã—ã¾ã™ã€‚ #define HISTORY_MIN_MAX_NUMBER 100000 ã“ã®ãƒžã‚¯ãƒ­ã¯ 32768 以上㮠10 ã®å†ªã¨ã—ã¦å®šç¾©ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ ã“ã®ãƒžã‚¯ãƒ­ã¯ã€å±¥æ­´ã®ç•ªå·ãŒ 1 ã«æˆ»ã‚‹ç›´å‰ã®å±¥æ­´ã®ç•ªå·ã‚’指定ã—ã¾ã™ã€‚(履歴 ãŒéžå¸¸ã«ãŸãã•ã‚“ã‚ã‚‹å ´åˆã¯ã“ã®ãƒžã‚¯ãƒ­ã®å€¤ä»¥ä¸Šã®ç•ªå·ã§ 1 ã«æˆ»ã‚‹å ´åˆã‚‚゠りã¾ã™ã€‚) #define DEFAULT_HISTSIZE 500 ã“ã®ãƒžã‚¯ãƒ­ã¯ 128 ä»¥ä¸Šã®æ•´æ•°ã¨ã—ã¦å®šç¾©ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ ã“ã®ãƒžã‚¯ãƒ­ã¯ãƒ‡ãƒ•ォルトã®å±¥æ­´ã‚µã‚¤ã‚ºã‚’指定ã—ã¾ã™ã€‚ #define LIST_AMBIGUOUS_OPTIONS 1 /* ブーリアンオプション */ ã“ã®ãƒžã‚¯ãƒ­ãŒéž 0 値ã«è¨­å®šã—ã¦ã‚ã‚‹å ´åˆã€ã‚·ã‚§ãƒ«ã®èµ·å‹•ã¾ãŸã¯çµ„è¾¼ã¿ã‚³ãƒžãƒ³ ドã®å‘¼ã³å‡ºã—ã«ãŠã„ã¦æŒ‡å®šã•れãŸã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæ›–æ˜§ãªæ™‚ã€ãã®ã‚ªãƒ—ションå㫠マッãƒã™ã‚‹ã‚ªãƒ—ションåã®ãƒªã‚¹ãƒˆã‚’出力ã—ã¾ã™ã€‚ #define SHELLFDMINMAX 100 ã“ã®ãƒžã‚¯ãƒ­ã®å€¤ã¯ 10 ä»¥ä¸Šã®æ•´æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“。ã“ã®å€¤ã¯ã€ã‚·ã‚§ãƒ«ãŒå†…部ã§ä½¿ç”¨ã™ã‚‹ãƒ•ァイルディスクリプタã®ä¸‹é™ã‚’指定ã—ã¾ã™ã€‚ #define YASH_DISABLE_SUPERUSER 1 /* ブーリアンオプション */ ã“ã®ãƒžã‚¯ãƒ­ã‚’éž 0 値ã«è¨­å®šã™ã‚‹ã¨ã€ãƒ¦ãƒ¼ã‚¶ ID ㌠0 ã®ãƒ¦ãƒ¼ã‚¶ã‚’管ç†è€…権é™ã‚’ æŒã¤ãƒ¦ãƒ¼ã‚¶ã¨ã—ã¦ç‰¹åˆ¥æ‰±ã„ã—ãªã„よã†ã«ã—ã¾ã™ã€‚デフォルトã§ã¯ã€UID ㌠0 ã®ãƒ¦ãƒ¼ã‚¶ã¯ã‚¢ã‚¯ã‚»ã‚¹æ¨©é™ã®ãƒã‚§ãƒƒã‚¯ãªã©ã«ãŠã„ã¦ä»–ã®ãƒ¦ãƒ¼ã‚¶ã¨ã¯ç•°ãªã‚‹æ‰±ã„ã‚’ å—ã‘ã¾ã™ã€‚ yash-2.35/expand.d0000644000175000017500000000025112154557026014170 0ustar magicantmagicantexpand.o: expand.c common.h config.h expand.h arith.h exec.h xgetopt.h \ input.h option.h parser.h path.h plist.h sig.h strbuf.h util.h \ variable.h xfnmatch.h yash.h yash-2.35/history.c0000644000175000017500000014354712154557026014431 0ustar magicantmagicant/* Yash: yet another shell */ /* history.c: command history management */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "history.h" #include #include #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include #include #include #include #include "builtin.h" #include "exec.h" #include "job.h" #include "option.h" #include "path.h" #include "redir.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" #include "yash.h" /* The maximum size of history list (<= INT_MAX / 10) */ #ifndef MAX_HISTSIZE #define MAX_HISTSIZE 1000000 #endif #if MAX_HISTSIZE > INT_MAX / 10 #error MAX_HISTSIZE is too large #endif /* The minimum value of `max_number', * which must be at least 32768 according to POSIX. */ /* Must be a power of 10. */ #ifndef HISTORY_MIN_MAX_NUMBER #define HISTORY_MIN_MAX_NUMBER 100000 #endif #if HISTORY_MIN_MAX_NUMBER < 32768 #error HISTORY_MIN_MAX_NUMBER is too small #endif /* The default size of the history list, * which must be at least 128 according to POSIX. */ #ifndef DEFAULT_HISTSIZE #define DEFAULT_HISTSIZE 500 #endif #if DEFAULT_HISTSIZE < 128 #error DEFAULT_HISTSIZE is too small #endif #if DEFAULT_HISTSIZE > HISTORY_MIN_MAX_NUMBER #error DEFAULT_HISTSIZE cannot be larger than HISTORY_MIN_MAX_NUMBER #endif /* The main history list. */ histlist_T histlist = { .link = { Histlist, Histlist, }, .count = 0, }; /* History entries are stored in this doubly-linked list. * The `Newest' (`link.prev') member points to the newest entry and the `Oldest' * (`link.next') member points to the oldest entry. When there's no entries, * `Newest' and `Oldest' point to `histlist' itself. */ /* The maximum limit of the number of an entry. * Must always be no less than `histsize' or `HISTORY_MIN_MAX_NUMBER'. * The number of any entry is not greater than this value. */ static unsigned max_number = HISTORY_MIN_MAX_NUMBER; /* The size limit of the history list. */ static unsigned histsize = DEFAULT_HISTSIZE; /* When a new entry is added, if there are entries that has the same value as * the new entry in the `histrmdup' newest entries, those entries are removed.*/ static unsigned histrmdup = 0; /* File stream for the history file. */ static FILE *histfile = NULL; /* The revision number of the history file. A valid revision number is * non-negative. */ static long histfilerev = -1; /* The number of lines in the history file, not including the signature. * When this number reaches the threshold, the history file is refreshed. */ static size_t histfilelines = 0; /* Indicates if the history file should be flushed before it is unlocked. */ static bool histneedflush = false; /* The current time returned by `time' */ static time_t now = (time_t) -1; /* If true, the history is locked, that is, readonly. */ static bool hist_lock = false; struct search_result_T { histlink_T *prev, *next; }; static void update_time(void); static void set_histsize(unsigned newsize); static histentry_T *new_entry(unsigned number, time_t time, const char *line) __attribute__((nonnull)); static bool need_remove_entry(unsigned number) __attribute__((pure)); static void remove_entry(histentry_T *e) __attribute__((nonnull)); static void remove_last_entry(void); static void clear_all_entries(void); static struct search_result_T search_entry_by_number(unsigned number) __attribute__((pure)); static histlink_T *get_nth_newest_entry(unsigned n) __attribute__((pure)); static histlink_T *search_entry_by_prefix(const char *prefix) __attribute__((nonnull,pure)); static bool search_result_is_newer( struct search_result_T sr1, struct search_result_T sr2) __attribute__((pure)); static bool entry_is_newer(const histentry_T *e1, const histentry_T *e2) __attribute__((nonnull,pure)); static void add_histfile_pid(pid_t pid); static void remove_histfile_pid(pid_t pid); static void clear_histfile_pids(void); static void write_histfile_pids(void); static FILE *open_histfile(void); static bool lock_histfile(short type); static bool read_line(FILE *restrict f, xwcsbuf_T *restrict buf) __attribute__((nonnull)); static bool try_read_line(FILE *restrict f, xwcsbuf_T *restrict buf) __attribute__((nonnull)); static long read_signature(void); static void read_history_raw(void); static void read_history(void); static void parse_history_entry(const wchar_t *line) __attribute__((nonnull)); static void parse_removed_entry(const wchar_t *numstr) __attribute__((nonnull)); static void parse_process_id(const wchar_t *numstr) __attribute__((nonnull)); static void update_history(bool refresh); static void maybe_refresh_file(void); static int wprintf_histfile(const wchar_t *format, ...) __attribute__((nonnull)); static void write_signature(void); static void write_history_entry(const histentry_T *entry) __attribute__((nonnull)); static void refresh_file(void); static void add_history_line(const wchar_t *line, size_t maxlen) __attribute__((nonnull)); static void remove_duplicates(const char *line) __attribute__((nonnull)); /* Updates the value of `now'. */ void update_time(void) { now = time(NULL); } /* Changes `histsize' to `newsize' and accordingly sets `max_number'. */ /* `histsize' is set only once in initialization. */ void set_histsize(unsigned newsize) { if (newsize > MAX_HISTSIZE) newsize = MAX_HISTSIZE; if (newsize == 0) newsize = 1; histsize = newsize; max_number = HISTORY_MIN_MAX_NUMBER; while (max_number < 2 * histsize) max_number *= 10; /* `max_number' is the smallest power of 10 that is not less than * 2 * histsize. */ } /* Adds a new history entry to the end of `histlist'. * Some oldest entries may be removed in this function if they conflict with the * new one or the list is full. */ histentry_T *new_entry(unsigned number, time_t time, const char *line) { assert(!hist_lock); assert(number > 0); assert(number <= max_number); while (need_remove_entry(number)) remove_entry(ashistentry(histlist.Oldest)); histentry_T *new = xmallocs(sizeof *new, strlen(line) + 1, sizeof *new->value); new->Prev = histlist.Newest; new->Next = Histlist; histlist.Newest = new->Prev->next = &new->link; new->number = number; new->time = time; strcpy(new->value, line); histlist.count++; assert(histlist.count <= histsize); return new; } bool need_remove_entry(unsigned number) { if (histlist.count == 0) return false; if (histlist.count >= histsize) return true; unsigned oldest = ashistentry(histlist.Oldest)->number; unsigned newest = ashistentry(histlist.Newest)->number; if (oldest <= newest) return oldest <= number && number <= newest; else return oldest <= number || number <= newest; } /* Removes the specified entry from `histlist'. */ void remove_entry(histentry_T *entry) { assert(!hist_lock); assert(&entry->link != Histlist); entry->Prev->next = entry->Next; entry->Next->prev = entry->Prev; histlist.count--; free(entry); } /* Removes the newest entry. */ void remove_last_entry(void) { if (histlist.count > 0) remove_entry(ashistentry(histlist.Newest)); } /* Renumbers all the entries in `histlist', starting from 1. */ void renumber_all_entries(void) { assert(!hist_lock); if (histlist.count > 0) { unsigned num = 0; for (histlink_T *l = histlist.Oldest; l != Histlist; l = l->next) ashistentry(l)->number = ++num; assert(num == histlist.count); } } /* Removes all entries in the history list. */ void clear_all_entries(void) { assert(!hist_lock); histlink_T *l = histlist.Oldest; while (l != Histlist) { histlink_T *next = l->next; free(ashistentry(l)); l = next; } histlist.Oldest = histlist.Newest = Histlist; histlist.count = 0; } /* Searches for the entry that has the specified `number'. * If there is such an entry in the history, the both members of the returned * `search_result_T' structure will be pointers to the entry. Otherwise, the * returned structure will contain pointers to the nearest neighbor entries. * (If there is not the neighbor in either direction, the pointer will be * `Histlist'.) */ struct search_result_T search_entry_by_number(unsigned number) { struct search_result_T result; if (histlist.count == 0) { result.prev = result.next = Histlist; return result; } unsigned oldestnum = ashistentry(histlist.Oldest)->number; unsigned nnewestnum = ashistentry(histlist.Newest)->number; unsigned nnumber = number; if (nnewestnum < oldestnum) { if (nnumber <= nnewestnum) nnumber += max_number; nnewestnum += max_number; } if (nnumber < oldestnum) { result.prev = Histlist; result.next = histlist.Oldest; return result; } else if (nnumber > nnewestnum) { result.prev = histlist.Newest; result.next = Histlist; return result; } histlink_T *l; if (2 * (nnumber - oldestnum) < nnewestnum - oldestnum) { /* search from the oldest */ l = histlist.Oldest; while (number < ashistentry(l)->number) l = l->next; while (number > ashistentry(l)->number) l = l->next; result.next = l; if (number != ashistentry(l)->number) l = l->prev; result.prev = l; } else { /* search from the newest */ l = histlist.Newest; while (number > ashistentry(l)->number) l = l->prev; while (number < ashistentry(l)->number) l = l->prev; result.prev = l; if (number != ashistentry(l)->number) l = l->next; result.next = l; } return result; } /* Returns the nth newest entry (or the oldest entry if `n' is too big). * Returns `Histlist' if `n' is zero or the history is empty. */ histlink_T *get_nth_newest_entry(unsigned n) { if (histlist.count <= n) return histlist.Oldest; histlink_T *l = Histlist; while (n-- > 0) l = l->prev; return l; } /* Searches for the newest entry whose value begins with the specified `prefix'. * Returns `Histlist' if not found. */ histlink_T *search_entry_by_prefix(const char *prefix) { histlink_T *l; for (l = histlist.Newest; l != Histlist; l = l->prev) if (matchstrprefix(ashistentry(l)->value, prefix) != NULL) break; return l; } /* Returns true iff `sr1' is newer than `sr2'. * For each search_result_T structure, the `prev' and `next' members must not be * both `Histlist'. */ bool search_result_is_newer( struct search_result_T sr1, struct search_result_T sr2) { if (sr1.prev == Histlist || sr2.next == Histlist) return false; if (sr1.next == Histlist || sr2.prev == Histlist) return true; return entry_is_newer(ashistentry(sr1.prev), ashistentry(sr2.prev)) || entry_is_newer(ashistentry(sr1.next), ashistentry(sr2.next)); } /* Returns true iff `e1' is newer than `e2'. */ bool entry_is_newer(const histentry_T *e1, const histentry_T *e2) { assert(histlist.count > 0); unsigned n1 = e1->number; unsigned n2 = e2->number; unsigned newest = ashistentry(histlist.Newest)->number; unsigned oldest = ashistentry(histlist.Oldest)->number; return (n1 <= newest && newest < oldest && oldest <= n2) || (n2 <= n1 && (oldest <= n2 || n1 <= newest)); } /********** Process ID list **********/ struct pidlist_T { size_t count; pid_t *pids; }; /* The process IDs of processes that share the history file. * The `pids' member may be null when the `count' member is zero. */ static struct pidlist_T histfilepids = { 0, NULL, }; /* Adds `pid' to `histfilepids'. `pid' must be positive. */ void add_histfile_pid(pid_t pid) { assert(pid > 0); for (size_t i = 0; i < histfilepids.count; i++) if (histfilepids.pids[i] == pid) return; /* don't add if already added */ histfilepids.pids = xreallocn(histfilepids.pids, histfilepids.count + 1, sizeof *histfilepids.pids); histfilepids.pids[histfilepids.count++] = pid; } /* If `pid' is non-zero, removes `pid' from `histfilepids'. * If `pid' is zero, removes process IDs of non-existent processes from * `histfilepids'. */ void remove_histfile_pid(pid_t pid) { for (size_t i = 0; i < histfilepids.count; ) { if (pid != 0 ? histfilepids.pids[i] == pid : !process_exists(histfilepids.pids[i])) { memmove(&histfilepids.pids[i], &histfilepids.pids[i + 1], (histfilepids.count - i - 1) * sizeof *histfilepids.pids); histfilepids.count--; histfilepids.pids = xreallocn(histfilepids.pids, histfilepids.count, sizeof *histfilepids.pids); } else { i++; } } } /* Clears `histfilepids'. */ void clear_histfile_pids(void) { free(histfilepids.pids); histfilepids = (struct pidlist_T) { 0, NULL, }; } /* Writes process IDs in `histfilepids' to the history file. */ /* This function does not return any error status. The caller should check * `ferror' for the file. */ void write_histfile_pids(void) { assert(histfile != NULL); for (size_t i = 0; i < histfilepids.count; i++) wprintf_histfile(L"p%jd\n", (intmax_t) histfilepids.pids[i]); histfilelines += histfilepids.count; } /********** History file functions **********/ /***** FORMAT OF THE HISTORY FILE ***** * * The first line of the history file has the following form: * #$# yash history v0 rXXX * where `XXX' is the revision number of the file. The revision number is * incremented each time the file is refreshed. * * The rest of the file consists of lines containing history data, each entry * per line. The type of entry is determined by the first character of the line: * 0-9 or A-F history entry * c history entry cancellation * d history entry deletion * p shell process addition/elimination info * others ignored line * * A history entry has the following form: * NNN:TTT COMMAND * where `NNN' is the entry number, `TTT' is the time of the command, and * `COMMAND' is the command. Both `NNN' and `TTT' are uppercase hexadecimal * non-negative numbers. `COMMAND' may contain any characters except newline and * null. * * A history entry cancellation consists of a single character `c'. It cancels * the previous history entry. * * A history entry deletion has the form: * dNNN * where `NNN' is the number of the entry to be removed (hexadecimal). * * A shell process addition/elimination is in the form: * pXXX * where `XXX' is the process id (decimal integer). For addition `XXX' is * positive and for elimination `XXX' is negative. */ /* Opens the history file. * Returns NULL on failure. */ FILE *open_histfile(void) { const wchar_t *vhistfile = getvar(L VAR_HISTFILE); if (vhistfile == NULL) return NULL; char *mbshistfile = malloc_wcstombs(vhistfile); if (mbshistfile == NULL) return NULL; int fd = open(mbshistfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); free(mbshistfile); if (fd < 0) return NULL; struct stat st; if (fstat(fd, &st) < 0 || !S_ISREG(st.st_mode) || (st.st_mode & (S_IRWXG | S_IRWXO))) { xclose(fd); return NULL; } fd = move_to_shellfd(fd); if (fd < 0) return NULL; FILE *f = fdopen(fd, "r+"); if (f == NULL) { remove_shellfd(fd); xclose(fd); } return f; } /* Locks the history file, which must have been open. * `type' must be one of `F_RDLCK', `F_WRLCK' and `F_UNLCK'. * If `type' is `F_UNLCK', the buffer for the history file is flushed before * unlocking the file. * When another process is holding a lock for the file, this process will be * blocked until the lock is freed. * Returns true iff successful. */ bool lock_histfile(short type) { if (type == F_UNLCK && histneedflush) { histneedflush = false; fflush(histfile); /* We only flush the history file after writing. POSIX doesn't define * the behavior of flush without writing. We don't use fseek instead of * fflush because fseek is less reliable than fflush. In some * implementations (including glibc), fseek doesn't flush the file. */ } struct flock flock = { .l_type = type, .l_whence = SEEK_SET, .l_start = 0, .l_len = 0, /* to the end of file */ }; int fd = fileno(histfile); int result; while ((result = fcntl(fd, F_SETLKW, &flock)) == -1 && errno == EINTR); return result != -1; } /* Reads one line from file `f'. * The line is appended to buffer `buf', which must have been initialized. * The terminating newline is not left in `buf'. * On failure, false is returned, in which case the contents of `buf' is * unspecified. * If there is no more line in the file, false is returned. * This function may ignore lines longer than LINE_MAX. */ bool read_line(FILE *restrict f, xwcsbuf_T *restrict buf) { bool accept_current_line = true; size_t initial_length = buf->length; for (;;) { if (try_read_line(f, buf)) { if (accept_current_line) return true; /* Read one more line and accept it. */ accept_current_line = true; } else { if (feof(f) || ferror(f)) return false; /* Now, the position of `f' is in the middle of a very long line * that should be ignored. */ accept_current_line = false; } wb_truncate(buf, initial_length); } } /* Reads one line from file `f'. * The line is appended to buffer `buf', which must have been initialized. * If a line was read successfully, true is returned. The terminating newline is * not left in `buf'. * The return value is false if: * * an error occurred (ferror()), * * the end of the input was reached (feof()), or * * the current line is too long (at least LINE_MAX characters), in which case * the position of `f' is left in the middle of the current line. * The contents of `buf' is unspecified if the return value is false. */ bool try_read_line(FILE *restrict f, xwcsbuf_T *restrict buf) { #if FGETWS_BROKEN wb_ensuremax(buf, LINE_MAX); #endif while (fgetws(&buf->contents[buf->length], buf->maxlength - buf->length + 1, f)) { size_t len = wcslen(&buf->contents[buf->length]); if (len == 0) return false; buf->length += len; if (buf->contents[buf->length - 1] == L'\n') { wb_truncate(buf, buf->length - 1); return true; } if (buf->length > LINE_MAX) return false; /* Too long line. Give up. */ wb_ensuremax(buf, buf->length + 80); } return false; } /* Reads the signature of the history file (`histfile') and checks if it is a * valid signature. * If valid: * - the file is positioned just after the signature, * - the return value is the revision of the file (non-negative). * Otherwise: * - the file position is undefined, * - the return value is negative. */ /* The history file should be locked. */ long read_signature(void) { xwcsbuf_T buf; long rev = -1; const wchar_t *s; assert(histfile != NULL); rewind(histfile); if (!read_line(histfile, wb_init(&buf))) goto end; s = matchwcsprefix(buf.contents, L"#$# yash history v0 r"); if (s == NULL || !iswdigit(s[0])) goto end; if (!xwcstol(s, 10, &rev)) rev = -1; end: wb_destroy(&buf); return rev; } /* Reads history entries from the history file, which must have been open. * The file format is assumed a simple text, one entry per line. * The file is read from the current position. * The entries that were read from the file are appended to `histlist'. */ /* The file should be locked. */ /* This function does not return any error status. The caller should check * `ferror' and/or `feof' for the file. */ void read_history_raw(void) { xwcsbuf_T buf; assert(histfile != NULL); wb_init(&buf); while (read_line(histfile, &buf)) { char *line = malloc_wcstombs(buf.contents); if (line != NULL) { new_entry(next_history_number(), -1, line); free(line); } wb_clear(&buf); } wb_destroy(&buf); } /* Reads history entries from the history file. * The file is read from the current position. * The entries that were read from the file are appended to `histlist'. * `update_time' must be called before calling this function. */ /* The file should be locked. */ /* This function does not return any error status. The caller should check * `ferror' and/or `feof' for the file. */ void read_history(void) { xwcsbuf_T buf; assert(histfile != NULL); wb_init(&buf); while (read_line(histfile, &buf)) { histfilelines++; switch (buf.contents[0]) { case L'0': case L'1': case L'2': case L'3': case L'4': case L'5': case L'6': case L'7': case L'8': case L'9': case L'A': case L'B': case L'C': case L'D': case L'E': case L'F': parse_history_entry(buf.contents); break; case L'c': remove_last_entry(); break; case L'd': parse_removed_entry(buf.contents + 1); break; case L'p': parse_process_id(buf.contents + 1); break; } wb_clear(&buf); } wb_destroy(&buf); } void parse_history_entry(const wchar_t *line) { unsigned long num; time_t time; wchar_t *end; char *value; assert(iswxdigit(line[0])); errno = 0; num = wcstoul(line, &end, 0x10); if (errno || end[0] == L'\0' || num > max_number) return; if (end[0] == L':' && iswxdigit(end[1])) { unsigned long long t; errno = 0; t = wcstoull(&end[1], &end, 0x10); if (errno || end[0] == L'\0') time = -1; else if (t > (unsigned long long) now) time = now; else time = (time_t) t; } else { time = -1; } if (!iswspace(end[0])) return; value = malloc_wcstombs(&end[1]); if (value != NULL) { new_entry((unsigned) num, time, value); free(value); } } void parse_removed_entry(const wchar_t *numstr) { unsigned long num; wchar_t *end; if (histlist.count == 0) return; if (numstr[0] == L'\0') return; errno = 0; num = wcstoul(numstr, &end, 0x10); if (errno || (*end != L'\0' && !iswspace(*end))) return; if (num > max_number) return; struct search_result_T sr = search_entry_by_number((unsigned) num); if (sr.prev == sr.next) remove_entry(ashistentry(sr.prev)); } void parse_process_id(const wchar_t *numstr) { intmax_t num; wchar_t *end; if (numstr[0] == L'\0') return; errno = 0; num = wcstoimax(numstr, &end, 10); if (errno || (*end != L'\0' && !iswspace(*end))) return; if (num > 0) add_histfile_pid((pid_t) num); else if (num < 0) remove_histfile_pid((pid_t) -num); /* XXX: this cast and negation may be unsafe */ } /* Re-reads history from the history file. * Changes that have been made to the file by other shell processes are brought * into this shell's history. The current data in this shell's history may be * changed. * If `refresh' is true, this function may call `refresh_file'. * On failure, `histfile' is closed and set to NULL. * `update_time' must be called before calling this function. * After calling this function, `histfile' must not be read without * repositioning. */ /* The history file should be locked (F_WRLCK if `refresh' is true or F_RDLCK if * `refresh' is false). * This function must be called just before writing to the history file. */ void update_history(bool refresh) { bool posfail; fpos_t pos; long rev; if (histfile == NULL) return; assert(!hist_lock); #if WIO_BROKEN posfail = true; #else posfail = fgetpos(histfile, &pos); #endif rev = read_signature(); if (rev < 0) goto error; if (!posfail && rev == histfilerev) { /* The revision has not been changed. Just read new entries. */ fsetpos(histfile, &pos); read_history(); } else { /* The revision has been changed. Re-read everything. */ clear_all_entries(); clear_histfile_pids(); add_histfile_pid(shell_pid); histfilerev = rev; histfilelines = 0; read_history(); } if (ferror(histfile) || !feof(histfile)) goto error; if (refresh) maybe_refresh_file(); return; error: close_history_file(); } /* Refreshes the history file if it is time to do that. * `histfile' must not be NULL. */ void maybe_refresh_file(void) { assert(histfile != NULL); if (histfilelines > 20 && histfilelines / 2 >= histlist.count + histfilepids.count) { remove_histfile_pid(0); refresh_file(); } } /* Like `fwprintf(histfile, format, ...)', but the `histneedflush' flag is set. */ int wprintf_histfile(const wchar_t *format, ...) { va_list ap; int result; histneedflush = true; va_start(ap, format); result = vfwprintf(histfile, format, ap); va_end(ap); return result; } /* Writes the signature with an incremented revision number, after emptying the * file. */ /* This function does not return any error status. The caller should check * `ferror' for the file. */ void write_signature(void) { assert(histfile != NULL); rewind(histfile); while (ftruncate(fileno(histfile), 0) < 0 && errno == EINTR); if (histfilerev < 0 || histfilerev == LONG_MAX) histfilerev = 0; else histfilerev++; wprintf_histfile(L"#$# yash history v0 r%ld\n", histfilerev); histfilelines = 0; } /* Writes the specified entry to the history file. */ /* The file should be locked. */ /* This function does not return any error status. The caller should check * `ferror' for the file. */ void write_history_entry(const histentry_T *entry) { assert(histfile != NULL); /* don't print very long line */ if (xstrnlen(entry->value, LINE_MAX) >= LINE_MAX) return; if (entry->time >= 0) wprintf_histfile(L"%X:%lX %s\n", entry->number, (unsigned long) entry->time, entry->value); else wprintf_histfile(L"%X %s\n", entry->number, entry->value); histfilelines++; } /* Clears and rewrites the contents of the history file. * The file will have a new revision number. */ /* The file should be locked. */ /* This function does not return any error status. The caller should check * `ferror' for the file. */ void refresh_file(void) { write_signature(); write_histfile_pids(); for (const histlink_T *l = histlist.Oldest; l != Histlist; l = l->next) write_history_entry(ashistentry(l)); } /********** External functions **********/ /* Initializes history function if not yet initialized. * If the shell is not interactive, history is never initialized. */ void maybe_init_history(void) { static bool initialized = false; if (!is_interactive_now || initialized) return; initialized = true; /* set `histsize' */ const wchar_t *vhistsize = getvar(L VAR_HISTSIZE); if (vhistsize != NULL && vhistsize[0] != L'\0') { unsigned long size; if (xwcstoul(vhistsize, 10, &size)) set_histsize(size); } /* set `histrmdup' */ const wchar_t *vhistrmdup = getvar(L VAR_HISTRMDUP); if (vhistrmdup != NULL && vhistrmdup[0] != L'\0') { unsigned long rmdup; if (xwcstoul(vhistrmdup, 10, &rmdup)) histrmdup = (rmdup <= histsize) ? rmdup : histsize; } update_time(); /* open the history file and read it */ histfile = open_histfile(); if (histfile != NULL) { lock_histfile(F_WRLCK); histfilerev = read_signature(); if (histfilerev < 0) { rewind(histfile); read_history_raw(); goto refresh; } read_history(); if (ferror(histfile) || !feof(histfile)) { close_history_file(); return; } remove_histfile_pid(0); if (histfilepids.count == 0) { renumber_all_entries(); refresh: refresh_file(); } else { maybe_refresh_file(); } add_histfile_pid(shell_pid); wprintf_histfile(L"p%jd\n", (intmax_t) shell_pid); histfilelines++; lock_histfile(F_UNLCK); } } /* Closes the history file after writing info on the shell process that is * exiting. */ void finalize_history(void) { if (!is_interactive_now || histfile == NULL) return; hist_lock = false; lock_histfile(F_WRLCK); update_time(); update_history(true); if (histfile != NULL) { wprintf_histfile(L"p%jd\n", (intmax_t) -shell_pid); // histfilelines++; close_history_file(); } } /* Closes the history file if open. */ void close_history_file(void) { hist_lock = false; if (histfile == NULL) return; /* By closing the file descriptor for the history file, the file is * automatically unlocked. */ // lock_histfile(F_UNLCK); remove_shellfd(fileno(histfile)); fclose(histfile); histfile = NULL; } /* Calculates the number of the next new entry. */ unsigned next_history_number(void) { unsigned number; if (histlist.count == 0) { number = 1; } else { number = ashistentry(histlist.Newest)->number + 1; if (number > max_number) number = 1; } return number; } /* Adds the specified `line' to the history. * Must not be called while the history is locked. * If `line' contains newlines, `line' is separated into multiple entries. * Only lines that contain graph-class characters are added to the history. * If the `shopt_histspace' option is enabled and the `line' starts with a * blank, the `line' is not added. */ void add_history(const wchar_t *line) { if (shopt_histspace && iswblank(line[0])) return; maybe_init_history(); assert(!hist_lock); if (histfile != NULL) lock_histfile(F_WRLCK); update_time(); update_history(true); for (;;) { size_t len = wcscspn(line, L"\n"); add_history_line(line, len); line += len; if (line[0] == L'\0') break; line++; } if (histfile != NULL) lock_histfile(F_UNLCK); } /* Adds the specified `line' to the history. * If the line is longer than `maxlen' characters, only the first `maxlen' * characters are added. * The string added to the history must not contain newlines. * `histfile' must be locked and `update_time' and `update_history' must have * been called. * If the string does not contain any graph-class characters, it is not added * to the history. */ void add_history_line(const wchar_t *line, size_t maxlen) { /* Check if `line' contains `graph' characters */ for (size_t i = 0; ; i++) { if (i >= maxlen || line[i] == L'\0') return; assert(line[i] != L'\n'); if (iswgraph(line[i])) break; } char *mbsline = malloc_wcsntombs(line, maxlen); if (mbsline != NULL) { histentry_T *entry; remove_duplicates(mbsline); entry = new_entry(next_history_number(), now, mbsline); if (histfile != NULL) write_history_entry(entry); free(mbsline); } } /* Removes entries whose value is the same as `line' in the `histrmdup' newest * entries. * `histfile' must be locked and `update_history' must have been called. */ void remove_duplicates(const char *line) { histlink_T *l = histlist.Newest; for (unsigned i = histrmdup; i > 0 && l != Histlist; i--) { histlink_T *prev = l->prev; histentry_T *e = ashistentry(l); if (strcmp(e->value, line) == 0) { if (histfile != NULL) { wprintf_histfile(L"d%X\n", e->number); histfilelines++; } remove_entry(e); } l = prev; } } /* Returns the history entry that has the specified `number', or `Histlist' if * there is no such entry. */ const histlink_T *get_history_entry(unsigned number) { struct search_result_T sr = search_entry_by_number((unsigned) number); return (sr.prev == sr.next) ? sr.prev : Histlist; } #if YASH_ENABLE_LINEEDIT /* Calls `maybe_init_history' or `update_history' and locks the history. */ void start_using_history(void) { if (!hist_lock) { if (histfile != NULL) { lock_histfile(F_RDLCK); update_time(); update_history(false); if (histfile != NULL) lock_histfile(F_UNLCK); } else { maybe_init_history(); } hist_lock = true; } } /* Unlocks the history. */ void end_using_history(void) { hist_lock = false; } #endif /* YASH_ENABLE_LINEEDIT */ /********** Built-ins **********/ enum fcprinttype_T { FC_FULL, FC_NUMBERED, FC_UNNUMBERED, FC_RAW, }; static struct search_result_T fc_search_entry(const wchar_t *name, int number) __attribute__((nonnull)); static void fc_update_history(void); static void fc_remove_last_entry(void); static histlink_T *fc_search_entry_by_prefix(const wchar_t *prefix) __attribute__((nonnull)); static int fc_print_entries( FILE *f, const histentry_T *first, const histentry_T *last, bool reverse, enum fcprinttype_T type) __attribute__((nonnull)); static const char *fc_time_to_str(time_t time) __attribute__((pure)); static int fc_exec_entry(const histentry_T *entry, const wchar_t *old, const wchar_t *new, bool quiet) __attribute__((nonnull(1))); static int fc_edit_and_exec_entries( const histentry_T *first, const histentry_T *last, bool reverse, const wchar_t *editor, bool quiet) __attribute__((nonnull(1,2))); static void fc_read_history(FILE *f, bool quiet) __attribute__((nonnull)); static void history_clear_all(void); static int history_delete(const wchar_t *s) __attribute__((nonnull)); static int history_read(const wchar_t *s) __attribute__((nonnull)); static int history_write(const wchar_t *s) __attribute__((nonnull)); static void history_refresh_file(void); const struct xgetopt_T fc_options[] = { { L'e', L"editor", OPTARG_REQUIRED, true, NULL, }, { L'l', L"list", OPTARG_NONE, true, NULL, }, { L'n', L"no-numbers", OPTARG_NONE, true, NULL, }, { L'q', L"quiet", OPTARG_NONE, false, NULL, }, { L'r', L"reverse", OPTARG_NONE, true, NULL, }, { L's', L"silent", OPTARG_NONE, true, NULL, }, { L'v', L"verbose", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "fc" built-in, which accepts the following options: * -e: specify the editor to edit history * -l: list history * -n: don't print entry numbers * -r: reverse entry order * -s: execute without editing * -v: print time for each entry */ int fc_builtin(int argc, void **argv) { const wchar_t *editor = NULL; bool list = false, quiet = false, rev = false, silent = false; enum fcprinttype_T ptype = FC_NUMBERED; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, fc_options, XGETOPT_DIGIT))) { switch (opt->shortopt) { case L'e': editor = xoptarg; break; case L'l': list = true; break; case L'n': ptype = FC_UNNUMBERED; break; case L'q': quiet = true; break; case L'r': rev = true; break; case L's': silent = true; break; case L'v': ptype = FC_FULL; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } /* error checks */ if (editor && list) return mutually_exclusive_option_error(L'e', L'l'); if (editor && silent) return mutually_exclusive_option_error(L'e', L's'); if (list && quiet) return mutually_exclusive_option_error(L'l', L'q'); if (list && silent) return mutually_exclusive_option_error(L'l', L's'); if (rev && silent) return mutually_exclusive_option_error(L'r', L's'); if (ptype != FC_NUMBERED && !list) { xerror(0, Ngt("the -n or -v option must be used with the -l option")); return Exit_ERROR; } if (!validate_operand_count(argc - xoptind, 0, silent ? 1 : 2)) return Exit_ERROR; if (hist_lock) { xerror(0, Ngt("cannot be used during line-editing")); return Exit_FAILURE; } maybe_init_history(); if (list) { fc_update_history(); } else { /* remove the entry for this "fc" command */ fc_remove_last_entry(); } if (histlist.count == 0) { if (list) { return Exit_SUCCESS; } else { xerror(0, Ngt("the command history is empty")); return Exit_FAILURE; } } /* parse */ const wchar_t *old = NULL, *new = NULL; if (silent && xoptind < argc) { wchar_t *eq = wcschr(ARGV(xoptind), L'='); if (eq != NULL) { eq[0] = L'\0'; old = ARGV(xoptind); new = &eq[1]; xoptind++; } } /* parse */ const wchar_t *vfirst = (xoptind < argc) ? ARGV(xoptind++) : NULL; int nfirst; struct search_result_T lfirst; if (vfirst != NULL) { if (!xwcstoi(vfirst, 10, &nfirst) /* || nfirst == 0 */) nfirst = 0; } else { nfirst = list ? -16 : -1; } lfirst = fc_search_entry(vfirst, nfirst); if (lfirst.prev == Histlist && lfirst.next == Histlist) return Exit_FAILURE; /* main part of our work with the -s flag */ if (silent) { if (lfirst.prev != lfirst.next) { assert(vfirst != NULL); xerror(0, Ngt("no such history entry `%ls'"), vfirst); return Exit_FAILURE; } return fc_exec_entry(ashistentry(lfirst.prev), old, new, quiet); } /* parse */ const wchar_t *vlast = (xoptind < argc) ? ARGV(xoptind++) : NULL; int nlast; struct search_result_T llast; if (vlast != NULL) { if (!xwcstoi(vlast, 10, &nlast) /* || nlast == 0 */) nlast = 0; } else if (list) { nlast = -1; } else { llast = lfirst; goto check_rev; } llast = fc_search_entry(vlast, nlast); if (llast.prev == Histlist && llast.next == Histlist) return Exit_FAILURE; check_rev: if (search_result_is_newer(lfirst, llast)) { struct search_result_T temp = lfirst; lfirst = llast; llast = temp; rev = !rev; } assert(lfirst.next != Histlist); assert(llast.prev != Histlist); const histentry_T *efirst = ashistentry(lfirst.next); const histentry_T *elast = ashistentry(llast.prev); if (list) return fc_print_entries(stdout, efirst, elast, rev, ptype); else return fc_edit_and_exec_entries(efirst, elast, rev, editor, quiet); } /* Searches for the specified entry. * The `prev' and `next' members of the returned structure will be `Histlist' * if the prefix search fails. */ struct search_result_T fc_search_entry(const wchar_t *name, int number) { struct search_result_T result; if (number == 0) { result.prev = result.next = fc_search_entry_by_prefix(name); } else if (number > 0) { result = search_entry_by_number((unsigned) number); assert(result.prev != Histlist || result.next != Histlist); } else { number = -number; result.next = get_nth_newest_entry((unsigned) number); if ((unsigned) number > histlist.count) result.prev = Histlist; else result.prev = result.next; assert(result.prev != Histlist || result.next != Histlist); } return result; } void fc_update_history(void) { if (histfile != NULL) { lock_histfile(F_RDLCK); update_time(); update_history(false); if (histfile != NULL) lock_histfile(F_UNLCK); } } void fc_remove_last_entry(void) { if (histfile != NULL) { lock_histfile(F_WRLCK); update_time(); update_history(true); remove_last_entry(); if (histfile != NULL) { wprintf_histfile(L"c\n"); histfilelines++; lock_histfile(F_UNLCK); } } else { remove_last_entry(); } } /* Finds the newest entry that begins with the specified prefix. * Prints an error message and returns `Histlist' if not found. */ histlink_T *fc_search_entry_by_prefix(const wchar_t *prefix) { char *s = malloc_wcstombs(prefix); if (s == NULL) return Histlist; histlink_T *l = search_entry_by_prefix(s); free(s); if (l == Histlist) xerror(0, Ngt("no such history entry beginning with `%ls'"), prefix); return l; } /* Print history entries between `first' and `last'. * Only byte-oriented output functions are used for `f'. * An error message is printed on error. */ int fc_print_entries( FILE *f, const histentry_T *first, const histentry_T *last, bool reverse, enum fcprinttype_T type) { const histentry_T *start, *end, *e; if (!reverse) start = first, end = last; else start = last, end = first; e = start; for (;;) { int r; switch (type) { case FC_FULL: r = fprintf(f, "%u\t%s\t%s\n", e->number, fc_time_to_str(e->time), e->value); break; case FC_NUMBERED: r = fprintf(f, "%u\t%s\n", e->number, e->value); break; case FC_UNNUMBERED: r = fprintf(f, "\t%s\n", e->value); break; case FC_RAW: r = fprintf(f, "%s\n", e->value); break; default: assert(false); } if (r < 0) { xerror(errno, Ngt("cannot print to the standard output")); return Exit_FAILURE; } if (e == end) break; e = ashistentry(!reverse ? e->Next : e->Prev); } return Exit_SUCCESS; } /* Converts time to a string. * The return value is valid until the next call to this function. */ const char *fc_time_to_str(time_t time) { static char s[80]; if (time >= 0) { size_t size = strftime(s, sizeof s, "%c", localtime(&time)); if (size > 0) return s; } s[0] = '?', s[1] = '\0'; return s; } /* Executes the value of `entry'. * If `old' is not NULL, the first occurrence of `old' in the command is * replaced with `new' before execution (but the entry's value is unchanged). * If `quiet' is false, prints the command before execution. */ int fc_exec_entry(const histentry_T *entry, const wchar_t *old, const wchar_t *new, bool quiet) { wchar_t *code = malloc_mbstowcs(entry->value); if (code == NULL) { xerror(EILSEQ, Ngt("unexpected error")); return Exit_ERROR; } if (old != NULL) { xwcsbuf_T buf; wchar_t *p; wb_initwith(&buf, code); p = wcsstr(buf.contents, old); if (p != NULL) wb_replace(&buf, p - buf.contents, wcslen(old), new, SIZE_MAX); code = wb_towcs(&buf); } add_history(code); if (!quiet) printf("%ls\n", code); exec_wcs(code, "fc", false); free(code); return laststatus; } /* Invokes the editor to let the user edit the history entries between `first' * and `last' and executes the edited entries. */ int fc_edit_and_exec_entries( const histentry_T *first, const histentry_T *last, bool reverse, const wchar_t *editor, bool quiet) { char *temp; int fd; FILE *f; pid_t cpid; int savelaststatus; fd = create_temporary_file(&temp, S_IRUSR | S_IWUSR); if (fd < 0) { xerror(errno, Ngt("cannot create a temporary file to edit history")); goto error1; } f = fdopen(fd, "w"); if (f == NULL) { xerror(errno, Ngt("cannot open temporary file `%s'"), temp); xclose(fd); goto error2; } savelaststatus = laststatus; cpid = fork_and_reset(0, true, 0); if (cpid < 0) { // fork failed xerror(0, Ngt("cannot invoke the editor to edit history")); fclose(f); if (unlink(temp) < 0) xerror(errno, Ngt("failed to remove temporary file `%s'"), temp); error2: free(temp); error1: return Exit_FAILURE; } else if (cpid > 0) { // parent process fclose(f); wchar_t **namep = wait_for_child( cpid, doing_job_control_now ? cpid : 0, doing_job_control_now); if (namep != NULL) { *namep = malloc_wprintf(L"%ls %s", editor ? editor : L"${FCEDIT:-ed}", temp); } if (laststatus != Exit_SUCCESS) { xerror(0, Ngt("the editor returned a non-zero exit status")); fd = -1; } else { fd = move_to_shellfd(open(temp, O_RDONLY)); if (fd < 0) xerror(errno, Ngt("cannot read commands from file `%s'"), temp); } if (unlink(temp) < 0) xerror(errno, Ngt("failed to remove temporary file `%s'"), temp); free(temp); if (fd < 0) return Exit_FAILURE; f = fdopen(fd, "r"); fc_read_history(f, quiet); lseek(fd, 0, SEEK_SET); laststatus = savelaststatus; exec_input(fd, "fc", XIO_SUBST_ALIAS); remove_shellfd(fd); fclose(f); return laststatus; } else { // child process fc_print_entries(f, first, last, reverse, FC_RAW); fclose(f); wchar_t *command = malloc_wprintf(L"%ls %s", (editor != NULL) ? editor : L"${FCEDIT:-ed}", temp); free(temp); exec_wcs(command, "fc", true); #ifndef NDEBUG free(command); #endif assert(false); } } void fc_read_history(FILE *f, bool quiet) { xwcsbuf_T buf; if (histfile != NULL) lock_histfile(F_WRLCK); update_time(); update_history(false); wb_init(&buf); while (read_line(f, &buf)) { if (!quiet) printf("%ls\n", buf.contents); add_history_line(buf.contents, buf.length); wb_clear(&buf); } wb_destroy(&buf); if (histfile != NULL) { maybe_refresh_file(); lock_histfile(F_UNLCK); } } #if YASH_ENABLE_HELP const char fc_help[] = Ngt( "list or re-execute command history" ); const char fc_syntax[] = Ngt( "\tfc [-qr] [-e editor] [first [last]]\n" "\tfc -s [-q] [old=new] [first]\n" "\tfc -l [-nrv] [first [last]]\n" ); #endif /* Options for the "history" built-in. */ const struct xgetopt_T history_options[] = { { L'c', L"clear", OPTARG_NONE, true, NULL, }, { L'd', L"delete", OPTARG_REQUIRED, true, NULL, }, { L'r', L"read", OPTARG_REQUIRED, true, NULL, }, { L's', L"set", OPTARG_REQUIRED, true, NULL, }, { L'w', L"write", OPTARG_REQUIRED, true, NULL, }, { L'F', L"flush-file", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "history" built-in, which accepts the following options: * -c: clear whole history * -d: remove history entry * -r: read history from a file * -s: add history entry * -w: write history into a file * -F: flush history file */ int history_builtin(int argc, void **argv) { if (hist_lock) { xerror(0, Ngt("cannot be used during line-editing")); return Exit_FAILURE; } maybe_init_history(); bool hasoption = false, removedthis = false; int result = Exit_SUCCESS; /* process options */ const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, history_options, 0)) != NULL) { hasoption = true; switch (opt->shortopt) { case L'c': history_clear_all(); break; case L'd': result = history_delete(xoptarg); break; case L'r': result = history_read(xoptarg); break; case L's': if (!removedthis) { fc_remove_last_entry(); removedthis = true; } add_history(xoptarg); break; case L'w': result = history_write(xoptarg); break; case L'F': history_refresh_file(); break; #if YASH_ENABLE_HELP case L'-': result = print_builtin_help(ARGV(0)); break; #endif default: return Exit_ERROR; } if (result != Exit_SUCCESS) return result; } /* print history */ int count; if (xoptind < argc) { if (!validate_operand_count(argc - xoptind, 0, 1)) return Exit_ERROR; if (!xwcstoi(ARGV(xoptind), 10, &count)) { xerror(errno, Ngt("`%ls' is not a valid integer"), ARGV(xoptind)); return Exit_ERROR; } if (count <= 0) return Exit_SUCCESS; } else if (!hasoption) { count = INT_MAX; } else { return Exit_SUCCESS; } fc_update_history(); histlink_T *start = get_nth_newest_entry((unsigned) count); if (start == Histlist) return Exit_SUCCESS; return fc_print_entries(stdout, ashistentry(start), ashistentry(histlist.Newest), false, FC_NUMBERED); } /* Clears all the history. */ void history_clear_all(void) { if (histfile != NULL) { lock_histfile(F_WRLCK); update_history(false); } clear_all_entries(); if (histfile != NULL) { refresh_file(); lock_histfile(F_UNLCK); } } /* Deletes a history entry specified by the argument string. */ int history_delete(const wchar_t *s) { int n; histlink_T *l; if (histfile != NULL) { lock_histfile(F_WRLCK); update_time(); update_history(true); } if (!xwcstoi(s, 10, &n) || n == 0) { l = fc_search_entry_by_prefix(s); } else { if (n >= 0) { struct search_result_T sr = search_entry_by_number((unsigned) n); l = (sr.prev == sr.next) ? sr.prev : Histlist; } else { if (n != INT_MIN) n = -n; else n = INT_MAX; l = get_nth_newest_entry((unsigned) n); } if (l == Histlist) xerror(0, Ngt("no such history entry `%ls'"), s); } if (l != Histlist) { histentry_T *e = ashistentry(l); if (histfile != NULL) { wprintf_histfile(L"d%X\n", e->number); histfilelines++; } remove_entry(e); } if (histfile != NULL) lock_histfile(F_UNLCK); return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Reads history from the specified file. */ int history_read(const wchar_t *s) { FILE *f; /* The `fc_read_history' function assumes the argument stream wide-oriented. * We don't pass `stdin' to `fc_read_history' so that it remains * non-oriented. */ if (wcscmp(s, L"-") == 0) { int fd = copy_as_shellfd(STDIN_FILENO); if (fd < 0) goto error; f = fdopen(fd, "r"); } else { char *mbsfilename = malloc_wcstombs(s); if (mbsfilename == NULL) goto error; f = fopen(mbsfilename, "r"); free(mbsfilename); } if (f == NULL) goto error; fc_read_history(f, true); if ((ferror(f) != 0) | (fclose(f) != 0)) goto error; return Exit_SUCCESS; error: xerror(0, Ngt("cannot read history from file `%ls'"), s); return Exit_FAILURE; } /* Writes history into the specified file. */ int history_write(const wchar_t *s) { FILE *f; fc_update_history(); if (histlist.count == 0) return Exit_SUCCESS; if (wcscmp(s, L"-") == 0) { f = stdout; } else { char *mbsfilename = malloc_wcstombs(s); if (mbsfilename == NULL) goto error; f = fopen(mbsfilename, "w"); free(mbsfilename); if (f == NULL) goto error; } int result = fc_print_entries(f, ashistentry(histlist.Oldest), ashistentry(histlist.Newest), false, FC_RAW); if (f != stdout) if (fclose(f) != 0) goto error; return result; error: xerror(0, Ngt("cannot write history to file `%ls'"), s); return Exit_FAILURE; } /* Refreshes the history file. */ void history_refresh_file(void) { if (histfile != NULL) { lock_histfile(F_WRLCK); update_time(); update_history(false); if (histfile != NULL) { remove_histfile_pid(0); refresh_file(); lock_histfile(F_UNLCK); } } } #if YASH_ENABLE_HELP const char history_help[] = Ngt( "manage command history" ); const char history_syntax[] = Ngt( "\thistory [-cF] [-d entry] [-s command] [-r file] [-w file] [count]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/path.d0000644000175000017500000000025212154557026013646 0ustar magicantmagicantpath.o: path.c common.h config.h path.h xgetopt.h builtin.h exec.h \ expand.h hashtable.h option.h plist.h redir.h sig.h strbuf.h util.h \ variable.h xfnmatch.h yash.h yash-2.35/xfnmatch.d0000644000175000017500000000010412154557026014516 0ustar magicantmagicantxfnmatch.o: xfnmatch.c common.h config.h xfnmatch.h strbuf.h util.h yash-2.35/tests/0000755000175000017500000000000012154557026013710 5ustar magicantmagicantyash-2.35/tests/array.y.tst0000644000175000017500000000237512154557026016040 0ustar magicantmagicant# array.y.tst: yash-specific test of the array builtin # vim: set ft=sh ts=8 sts=4 sw=4 noet: ary=(test of array) array aaa 1 2 3 echo 1 $? array echo 2 $? array aaa 1 2 3 4 5 6 7 8 9 echo 3 $? $aaa array -d aaa echo 4 $? $aaa array -d aaa -1 6 90 2 9 -7 2 -20 8 0 echo 5 $? $aaa array -i aaa 0 0 echo 6 $? $aaa array -i aaa 2 2 3 echo 7 $? $aaa array -i aaa 6 6 echo 8 $? $aaa array -i aaa -1 8 echo 9 $? $aaa array -i aaa 100 9 echo 10 $? $aaa array -i aaa -100 ! echo 11 $? $aaa array -s aaa 1 0 array -s aaa 2 1 array -s aaa 10 - echo 12 $? $aaa array -s aaa 100 x || array -s aaa -100 x || echo 13 $? $aaa echo ===== 1 ===== echo ===== 1 ===== >&2 array --no-such-option echo array no-such-option $? array -d echo array insufficient-operands d 0 $? array -i foo echo array insufficient-operands i 1 $? array -s foo 0 echo array insufficient-operands s 2 $? array -s foo 0 - X echo array too-many-operands s 4 $? (array >&- 2>/dev/null) echo array output error $? readonly aaa array aaa echo array readonly 1 $? array aaa 1 2 3 echo array readonly 2 $? array -d aaa echo array readonly 3 $? array -d aaa 1 2 echo array readonly 4 $? array -i aaa 3 echo array readonly 5 $? array -i aaa 3 1 2 echo array readonly 6 $? array -s aaa 2 - echo array readonly 7 $? echo $aaa yash-2.35/tests/dot.t0000644000175000017500000000036212154557026014664 0ustar magicantmagicant# used by builtin.p.tst and builtin.y.tst as a sourced script # vim: set ft=sh ts=8 sts=4 sw=4 noet: echo -"$@"- count=$# if [ $# -ne 0 ]; then set -- . ./dot.t fi echo returning -"$@"- if true; then return fi echo not reached yash-2.35/tests/option.p.tst0000644000175000017500000000602212154557026016212 0ustar magicantmagicant# option.p.tst: test of shell options for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: # XXX: test of the -m and -b options are not supported tmp="${TESTTMP}/option.p.tmp" echo ===== -a ===== set -a echo "$-" | grep -Fq a || echo 'no a in $-' >&2 unset foo bar foo=123 env | grep ^foo= set +o allexport bar=456 env | grep ^bar= echo ===== -e ===== set -e echo "$-" | grep -Fq e || echo 'no e in $-' >&2 false | (echo ok group; false; echo not reached) | cat ! false if false; then echo if error elif false; then echo elif error else false || echo ok if fi i=0 while [ x"$i" != x"1" ]; do echo "$i"; i=1; done i=0 until [ x"$i" = x"1" ]; do echo "$i"; i=1; done set +o errexit false test $? -eq 0; echo 1-$? $INVOKE $TESTEE -ce 'false; echo not reached' test $? -eq 0; echo 2-$? $INVOKE $TESTEE -ce '{ false; }; echo not reached' test $? -eq 0; echo 3-$? $INVOKE $TESTEE -ce '( false; ); echo not reached' test $? -eq 0; echo 4-$? $INVOKE $TESTEE -ce 'if true; then false; fi; echo not reached' test $? -eq 0; echo 5-$? $INVOKE $TESTEE -e <<\END for i in 1 2 3 do echo a $i test $i -ne 2 echo b $i done echo not reached END test $? -eq 0; echo 6-$? $INVOKE $TESTEE -e <<\END case i in (i) echo 7 false echo not reached esac echo not reached END test $? -eq 0; echo 7-$? $INVOKE $TESTEE -e <<\END while true; do echo 8 false echo not reached done echo not reached END test $? -eq 0; echo 8-$? $INVOKE $TESTEE -e <<\END until false; do echo 9 false echo not reached done echo not reached END test $? -eq 0; echo 9-$? $INVOKE $TESTEE -ce 'true && false; echo not reached' test $? -eq 0; echo 10-$? $INVOKE $TESTEE -ce 'false || false; echo not reached' test $? -eq 0; echo 11-$? $INVOKE $TESTEE -e <<\END for i in i; do ! echo 12 # this should not exit done test $? -ne 0 echo 12-$? END echo ===== -f ===== set -f echo "$-" | grep -Fq f || echo 'no f in $-' >&2 echo /* set +o noglob echo ===== -n ===== $INVOKE $TESTEE -n <&2 unset none if (echo $none) 2>/dev/null; then echo ng nounset; else echo ok nounset; fi set +o nounset $INVOKE $TESTEE -u 2>/dev/null <<\END $none echo ng nounset 2 END echo ===== -v ===== echo ===== -v ===== >&2 $INVOKE $TESTEE -v <<\END echo "$-" | grep -Fq v || echo 'no v in $-' >&2 var=123 echo ${var#1} END echo ===== -x ===== echo ===== -x ===== >&2 $INVOKE $TESTEE -x <<\END (echo "$-" | grep -Fq x) 2>/dev/null || echo 'no x in $-' >&2 var=123 echo ${var#1} END if ! { set -o xtrace && set +x; } 2>/dev/null then echo set -o xtrace +x: ng fi echo ===== ignoreeof ===== # XXX We cannot actually test 'ignoreeof' since input from terminal is required. # Here we check if 'ignoreeof' is ignored in a non-interactive shell $INVOKE $TESTEE -o ignoreeof <<\END echo ignoreeof END echo ok echo ===== -o +o ===== set -aeu set -o > "$tmp" saveset=$(set +o) set +aeu eval "$saveset" set -o | diff "$tmp" - && echo ok rm -f "$tmp" # test of -C option is in "redir.p.tst" yash-2.35/tests/input.y.err0000644000175000017500000000055412154557026016034 0ustar magicantmagicant% echo \ > ok % cat < here-document > ok > END % PS1='${PWD##"${PWD}"}? ' ? PS1= % PROMPT_COMMAND='echo prompt_command >&2' prompt_command % (exit \ > 1) prompt_command % echo $? prompt_command % unset PROMPT_COMMAND % PS1='${PWD##"${PWD}"}$(echo \?) ' ? PS1='! !! $ ' ! !! $ PS1='\a \e \n \r \\ $ '   \ $ PS1='$ ' $ PS2='\\ > ' $ echo \ \ > ok $ PS1= yash-2.35/tests/input.p.tst0000644000175000017500000000043112154557026016037 0ustar magicantmagicant# input.p.tst: test of input processing for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: # The root user's default $PS1 value is not defined in POSIX, # so we don't test it. $INVOKE $TESTEE -iv +m input.p.t 3>&2 2>/dev/null $INVOKE $TESTEE <f1 pushd "$tmp/2"; echo 2 $?; >f2 pushd "$tmp/3"; echo 3 $?; >f3 pushd "$tmp/4"; echo 4 $?; >f4 dirs >"$tmp/out"; echo 5 $? diff - "$tmp/out" <"$tmp/out"; echo 6 $? diff - "$tmp/out" </dev/null; echo 7 $? echo *; popd >/dev/null; echo 8 $? echo *; popd >/dev/null; echo 9 $? echo *; popd >/dev/null; echo 10 $? if [ x"$PWD" = x"$tmp" ]; then echo ok fi echo */* pushd 1 dirs -c echo $? cd - >/dev/null echo */* echo ===== 1 ===== pushd "$tmp/1" pushd "$tmp/2" pushd "$tmp/3" pushd "$tmp/4" dirs | sed -e 's;/.*/;;' dirs -v | sed -e 's;/.*/;;' echo ===== 2 ===== pushd dirs | sed -e 's;/.*/;;' pushd dirs | sed -e 's;/.*/;;' echo ===== 3 ===== pushd +3 pushd -2 dirs | sed -e 's;/.*/;;' echo ===== 4 ===== popd +1 popd -2 dirs | sed -e 's;/.*/;;' echo ===== 5 ===== pushd +0 pushd -2 dirs | sed -e 's;/.*/;;' echo ===== 6 ===== pushd --default-directory="$tmp/4" "$tmp/1" pushd --default-directory="$tmp/4" dirs | sed -e 's;/.*/;;' echo ===== 7 ===== pushd --default-directory=+2 dirs | sed -e 's;/.*/;;' echo ===== 8 ===== pushd "$tmp/1" pushd "$tmp/2" pushd "$tmp/1" pushd "$tmp/2" pushd --remove-duplicates "$tmp/1" dirs | sed -e 's;/.*/;;' echo ===== dirs -v +0 -0 | sed -e 's;/.*/;;' dirs +2 -2 | sed -e 's;/.*/;;' echo ===== 9 ===== echo ===== 9 ===== >&2 unset DIRSTACK popd echo empty popd $? cd "$tmp" ( cd "$tmp/1" pushd - | sed -e 's;/.*/;;' ) pushd --default-directory=- 2>/dev/null # no such file echo pushd hyphen $? cd "$origpwd" rm -fr "$tmp" echo ===== 10 ===== echo ===== 10 ===== >&2 $INVOKE $TESTEE <<\END readonly DIRSTACK pushd . echo pushd dirstack unset $? popd echo popd dirstack unset $? dirs >"$TESTTMP/dirstack.y.tmp" echo dirs dirstack unset $? diff - "$TESTTMP/dirstack.y.tmp" <<<"$PWD" dirs -c echo dirs -c dirstack unset $? END $INVOKE $TESTEE <<\END pushd . readonly DIRSTACK pushd . echo pushd dirstack readonly $? popd echo popd dirstack readonly $? dirs >"$TESTTMP/dirstack.y.tmp" echo dirs dirstack readonly $? diff - "$TESTTMP/dirstack.y.tmp" </dev/null echo pushd no-such-dir $? pushd / pushd +5 echo pushd index out of range $? (pushd - >&- 2>/dev/null) echo pushd output error $? END $INVOKE $TESTEE <<\END pushd / popd --no-such-option echo popd no-such-option $? popd too-many operands echo popd too-many-operands $? popd +5 echo popd index out of range $? (popd >&- 2>/dev/null) echo popd output error $? popd >/dev/null popd echo popd dirstack empty $? END $INVOKE $TESTEE <<\END pushd / dirs --no-such-option echo dirs no-such-option $? dirs +5 echo dirs index out of range $? (dirs >&- 2>/dev/null) echo dirs output error $? END rm -f "$TESTTMP/dirstack.y.tmp" yash-2.35/tests/test.y.tst0000644000175000017500000001272712154557026015703 0ustar magicantmagicant# test.y.tst: yash-specific test of the test builtin # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp="${TESTTMP}/test.y.tmp" mkdir "$tmp" || exit cd "$tmp" || exit umask u=rwx,go= command -V test | grep -v "^test: a regular built-in " command -V [ | grep -v "^\[: a regular built-in " tt () { printf "%s: " "$*" test "$@" printf "%d " $? [ "$@" ] printf "%d\n" $? } echo ===== tt tt "" tt 1 tt -- tt -n tt -z tt -t tt ! "" tt ! 1 tt ! 000 echo ===== # skip some tests when i'm root : ${EUID:=$(id -u)} if [ "$EUID" -eq 0 ]; then isroot=true else isroot=false fi mkfifo fifo ln -s fifo fifolink ln -s gid reglink touch gid uid readable1 readable2 readable3 writable1 writable2 writable3 ln gid gidhard mkdir sticky chown $(id -u):$(id -g) gid chmod g+xs gid chmod u+xs uid chmod =,u=r readable1 chmod =,g=r readable2 chmod =,o=r readable3 chmod =,u=w writable1 chmod =,g=w writable2 chmod =,o=w writable3 chmod +t sticky echo "exit 0" >> executable1 cp executable1 executable2 cp executable1 executable3 chmod u+x executable1 chmod g+x executable2 chmod o+x executable3 touch -t 200001010000 older touch -t 200101010000 newer touch -a -t 200101010000 old; touch -m -t 200001010000 old touch -a -t 200001010000 new; touch -m -t 200101010000 new # check of the -b, -c, -G and -S operators are skipped # check of the -t operator is in job.y.tst tt -d . tt -d fifolink tt -e . tt -e fifolink tt -e no_such_file tt -f gid tt -f reglink tt -f fifolink tt -f . tt -f no_such_file tt -g gid tt -g uid tt -h fifolink tt -h reglink tt -h gid tt -h no_such_file #tt -k sticky tt -k gid tt -L fifolink tt -L reglink tt -L gid tt -L no_such_file tt -N new tt -N old tt -n "" tt -n 0 tt -n 1 tt -n abcde tt -O . tt -p fifo tt -p . tt -r readable1 if $isroot; then cat <' a tt a '>=' a tt abc123xyz =~ 'c[[:digit:]]*x' tt -axyzxyzaxyz- =~ 'c[[:digit:]]*x' tt -axyzxyzaxyz- =~ '-(a|xyz)*-' tt abc123xyz =~ '-(a|xyz)*-' tt ! -n "" tt ! -n 0 tt ! -n 1 tt ! -n abcde tt ! -z "" tt ! -z 0 tt ! -z 1 tt ! -z abcde tt "(" "" ")" tt "(" 0 ")" tt "(" abcde ")" echo ===== tt -3 -eq -3 tt 90 -eq 90 tt 0 -eq 0 tt -3 -eq 90 tt -3 -eq 0 tt 90 -eq 0 tt -3 -ne -3 tt 90 -ne 90 tt 0 -ne 0 tt -3 -ne 90 tt -3 -ne 0 tt 90 -ne 0 tt -3 -lt -3 tt -3 -lt 0 tt 0 -lt 90 tt 0 -lt -3 tt 90 -lt -3 tt 0 -lt 0 tt -3 -le -3 tt -3 -le 0 tt 0 -le 90 tt 0 -le -3 tt 90 -le -3 tt 0 -le 0 tt -3 -gt -3 tt -3 -gt 0 tt 0 -gt 90 tt 0 -gt -3 tt 90 -gt -3 tt 0 -gt 0 tt -3 -ge -3 tt -3 -ge 0 tt 0 -ge 90 tt 0 -ge -3 tt 90 -ge -3 tt 0 -ge 0 tt XXXXX -ot newer tt XXXXX -ot XXXXX tt newer -ot XXXXX tt older -ot newer tt newer -ot newer tt newer -ot older tt XXXXX -nt newer tt XXXXX -nt XXXXX tt newer -nt XXXXX tt older -nt newer tt older -nt older tt newer -nt older tt XXXXX -ef newer tt XXXXX -ef XXXXX tt newer -ef XXXXX tt older -ef newer tt older -ef older tt newer -ef older tt gid -ef gidhard tt gid -ef reglink echo ===== tt "" -veq "" tt "" -vne "" tt "" -vgt "" tt "" -vge "" tt "" -vlt "" tt "" -vle "" tt 0 -veq 0 tt 0 -vne 0 tt 0 -vgt 0 tt 0 -vge 0 tt 0 -vlt 0 tt 0 -vle 0 tt 0 -veq 1 tt 0 -vne 1 tt 0 -vgt 1 tt 0 -vge 1 tt 0 -vlt 1 tt 0 -vle 1 tt 1 -veq 0 tt 1 -vne 0 tt 1 -vgt 0 tt 1 -vge 0 tt 1 -vlt 0 tt 1 -vle 0 tt 01 -veq 0001 tt 02 -vle 0100 tt .%=01 -veq .%=0001 tt .%=02 -vle .%=0100 tt 0.01.. -veq 0.1.. tt 0.01.0 -vlt 0.1.. tt 0.01.0 -vlt 0.1.: tt 0.01.0 -veq 0.1. tt 0.01.0 -vle 0.1.a0 tt 1.2.3 -vle 1.3.2 tt -2 -vle -3 echo ===== tt "" -a "" tt "" -a 1 tt 1 -a "" tt 1 -a 1 tt "" -o "" tt "" -o 1 tt 1 -o "" tt 1 -o 1 tt "(" 12345 = 12345 ")" tt "(" 12345 = abcde ")" tt "(" "(" 12345 = 12345 ")" ")" tt "(" "(" 12345 = abcde ")" ")" tt 1 -a "(" 1 = 0 -o "(" 2 = 2 ")" ")" -a "(" = ")" tt "" -a 0 -o 0 # -a has higher precedence than -o tt 0 -o 0 -a "" # -a has higher precedence than -o tt ! "" -a "" # 4-argument test: ! ( "" -a "" ) tt "(" ! "" -a "" ")" # many-argument test: ! has higher precedence than -a tt ! "(" "" -a "" ")" tt "(" ! "" ")" -a "" tt -n = -o -o -n = -n # ( -n = -o ) -o ( -n = -n ) => true tt -n = -a -n = -n # ( -n = ) -a ( -n = -n ) => true echo ===== ( set -o allexport tt -o allexpor tt -o allexport tt -o allexportttttttttttttt tt -o \?allexpor tt -o \?allexport tt -o \?allexportttttttttttttt ) ( set +o allexport tt -o allexpor tt -o allexport tt -o allexportttttttttttttt tt -o \?allexpor tt -o \?allexport tt -o \?allexportttttttttttttt ) echo ===== test 1 2 3 2>/dev/null # invalid expression echo "1 2 3: $?" cd "${TESTTMP}" rm -fr "$tmp" yash-2.35/tests/run-test.sh0000644000175000017500000001273512154557026016035 0ustar magicantmagicant# run-test.sh: runs tests specified by $TESTEE and $TEST_ITEMS # (C) 2007-2011 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # log file rm -f "${logfile:=test.log}" exec 3>&1 exec >"${logfile}" echo "========== Yash Test Log ==========" echo printf 'Test started at: ' LC_TIME=C date echo # make temporary directory : ${TMPDIR:=$PWD} case "$TMPDIR" in /*) ;; *) echo "\$TMPDIR is not an absolute path" echo "\$TMPDIR must be an absolute path" >&2 exit 1 esac case "$TMPDIR" in */) TESTTMP=${TMPDIR}test.$$ ;; *) TESTTMP=${TMPDIR}/test.$$ ;; esac trap 'rm -rf "$TESTTMP"; exit' EXIT HUP INT QUIT ABRT ALRM TERM PIPE USR1 USR2 printf 'Test directory is: %s\n' "$TESTTMP" if ! mkdir -m u=rwx,go= "$TESTTMP"; then echo Cannot create temporary directory echo Cannot create temporary directory >&2 trap - EXIT exit 1 fi printf 'uname -i = '; uname -i 2>/dev/null || echo \? printf 'uname -n = '; uname -n 2>/dev/null || echo \? printf 'uname -m = '; uname -m 2>/dev/null || echo \? printf 'uname -o = '; uname -o 2>/dev/null || echo \? printf 'uname -p = '; uname -p 2>/dev/null || echo \? printf 'uname -r = '; uname -r 2>/dev/null || echo \? printf 'uname -s = '; uname -s 2>/dev/null || echo \? printf 'uname -v = '; uname -v 2>/dev/null || echo \? echo "PATH=$PATH" export INVOKE TESTEE TESTTMP export LC_MESSAGES=POSIX LC_CTYPE="${LC_ALL-${LC_CTYPE-${LANG}}}" LANG=POSIX unset CDPATH ENV HISTFILE HISTSIZE MAIL MAILCHECK MAILPATH IFS LC_ALL unset YASH_AFTER_CD COMMAND_NOT_FOUND_HANDLER HANDLED PROMPT_COMMAND umask u=rwx,go= checkskip() case "$1" in alias.y|alias.p) $INVOKE $TESTEE -c 'PATH=; alias' >/dev/null 2>&1 ;; array.y) $INVOKE $TESTEE -c 'type array' 2>/dev/null | \ grep '^array: a regular built-in' >/dev/null ;; dirstack.y) $INVOKE $TESTEE -c 'type pushd' 2>/dev/null | \ grep '^pushd: a regular built-in' >/dev/null ;; job.y) # ensure that /dev/tty is available and that we're in foreground ./checkfg ;; help.y) $INVOKE $TESTEE -c 'type help' 2>/dev/null | \ grep '^help: a regular built-in' >/dev/null ;; history.y) HISTFILE= $INVOKE $TESTEE -i +m --norcfile -c 'PATH=; fc -l' \ >/dev/null 2>&1 ;; lineedit.y) $INVOKE $TESTEE -c 'type bindkey' 2>/dev/null | \ grep '^bindkey: a regular built-in' >/dev/null ;; printf.y) $INVOKE $TESTEE -c 'type printf' 2>/dev/null | \ grep '^printf: a regular built-in' >/dev/null ;; test.y) $INVOKE $TESTEE -c 'type test' 2>/dev/null | \ grep '^test: a regular built-in' >/dev/null ;; esac printf 'Effective user ID: %s\n' "${EUID=$(id -u)}" if [ "$EUID" -eq 0 ]; then isroot=true else isroot=false fi if diff -u /dev/null /dev/null >/dev/null 2>&1; then diff='diff -u' elif diff -c /dev/null /dev/null >/dev/null 2>&1; then diff='diff -c' else diff='diff' fi diffresult() { if $isroot && [ -r "$x.$2" ]; then y="$x.$2" elif [ -r "$x.$1" ]; then y="$x.$1" else y="/dev/null" fi echo "Diff to the expected output:" $diff "$y" "${TESTTMP}/test.$1" } echo printf 'Testing %s for %s\n' "${TESTEE:=../yash}" "${TEST_ITEMS:=*.tst}" printf 'Testing %s for %s\n' "${TESTEE:=../yash}" "${TEST_ITEMS:=*.tst}" >&3 failed=0 for x in $TEST_ITEMS do x="${x%.tst}" printf '%-12s' "$x" >&3 echo echo echo ====================================================================== printf '========== %-16s ==========\n' "$x" echo ====================================================================== echo case "$x" in *.p) INVOKE='./invoke sh' ;; * ) INVOKE= ;; esac if ! checkskip "$x" then echo " * SKIPPED *" echo echo "skipped" >&3 continue fi $INVOKE $TESTEE "$x.tst" \ >|"${TESTTMP}/test.out" 2>|"${TESTTMP}/test.err" 3>&- echo ">>>>>>>>>>>>>>> $x.tst STDOUT >>>>>>>>>>>>>>>" cat "${TESTTMP}/test.out" echo "<<<<<<<<<<<<<<< $x.tst STDOUT <<<<<<<<<<<<<<<" echo diffresult out oux outresult=$? echo echo ">>>>>>>>>>>>>>> $x.tst STDERR >>>>>>>>>>>>>>>" cat "${TESTTMP}/test.err" echo "<<<<<<<<<<<<<<< $x.tst STDERR <<<<<<<<<<<<<<<" echo diffresult err erx errresult=$? if [ $outresult -eq 0 ] && [ $errresult -eq 0 ] then echo ok >&3 else echo FAILED >&3 : $(( failed += 1 )) fi done echo echo ====================================================================== echo ====================================================================== echo printf 'Test finished at: ' LC_TIME=C date echo if [ 0 -eq $failed ] then printf '%s passed all of %s.\n' "${TESTEE}" "${TEST_ITEMS}" printf '%s passed all of %s.\n' "${TESTEE}" "${TEST_ITEMS}" >&3 else printf '%s failed %d of %s.\n' "${TESTEE}" "${failed}" "${TEST_ITEMS}" printf '%s failed %d of %s. See test.log for more info.\n' \ "${TESTEE}" "${failed}" "${TEST_ITEMS}" >&3 false fi # vim: set ts=8 sts=4 sw=4 noet: yash-2.35/tests/prompt.y.erx0000644000175000017500000000033512154557026016221 0ustar magicantmagicant# printf 'posix PS1={%s}\n' "$PS1" # printf 'posix PS2={%s}\n' "$PS2" # printf 'posix PS4={%s}\n' "$PS4" # exit # printf 'yash PS1={%s}\n' "$PS1" # printf 'yash PS2={%s}\n' "$PS2" # printf 'yash PS4={%s}\n' "$PS4" # exit yash-2.35/tests/parser.p.out0000644000175000017500000000174612154557026016203 0ustar magicantmagicant123 abc abc abc abc $var ${var} $var ${var} $var ${var} abc abc abc abc $var ${var} abc abc abc abc $var ${var} $(echo $var ${var} "$var" "${var}") single double assignments line foo line echo 7 10 foo 12 bar 1 0 ===== 0 ===== abc bc a ===== 1 ===== comment# # very very long line pipeline | test of sequential ; lists asynchronous list another async ok ===== 2 ===== true and false or or and and newline or newline ===== 3 ===== compound list another compound list} subshell another subshell yet another subshell ===== 4 ===== if construct dummy ok! dummy dummy ok! dummy ok! 1 2 line concatenation ok (if) ===== 5 ===== 0 0 10 10 3 1 2 2 2 1 3 line concatenation ok (while) ===== 6 ===== 1 1 2 2 2 2 3 3 parser.p.out parser.p.tst 1 1 2 2 2 2 3 3 in 0 1 ===== 7 ===== 0 ok 2 * foo one two 3 foo four 5 line concatenation ok (case) ===== 8 ===== function function line concatenation ok (func) func3 function func3 function 2 func4 re-redirected redirected ===== 9 ===== OK 1 OK 2 lineno=395 yash-2.35/tests/history.y.out0000644000175000017500000000661512154557026016421 0ustar magicantmagicantfc: a semi-special built-in 1 2 3 1 echo 1 2 echo 2 3 echo 3 4 fc -l 0 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 echo $? 6 echo 6 7 echo 7 8 echo 8 9 echo 9 10 echo 10 11 echo 11 12 echo 12 13 echo 13 14 echo 14 15 echo 15 16 echo 16 17 echo 17 18 echo 18 19 echo 19 20 fc -l 21 fc -l -1 10 echo 10 11 echo 11 12 echo 12 13 echo 13 23 fc -l 23 21 22 fc -l 10 13 21 fc -l -1 13 echo 13 12 echo 12 11 echo 11 10 echo 10 21 fc -l -1 22 fc -l 10 13 23 fc -l 23 21 echo 19 fc -l 27 28 29 echo 29 29 echo 27 27 27 fc -l -n 'echo 1' 20 echo 19 fc -l fc -l -n 'echo 18' 20 echo 18 echo 19 fc -l 35 36 37 38 39 echo 39 39 echo 39 39 fc: the editor returned a non-zero exit status echo 36 echo 37 echo 38 echo ok 36 37 38 ok echo 38 echo 37 echo 36 echo ok 38 37 36 ok 36 37 38 ok 54 echo ok 55 fc -l -2 ===== inner shell 53 echo 38 54 echo ok 55 fc -l -2 56 echo ===== 57 $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF2 58 echo inner shell; fc -l 53 59 EOF2 60 echo inner shell; fc -l 53 ===== ===== 1 ===== 31 32 33 19 echo 36 20 echo 37 21 echo 38 22 echo ok 23 fc -l -2 24 echo ===== 25 $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF2 26 echo inner shell; fc -l 53 27 EOF2 28 echo inner shell; fc -l 53 29 echo ===== 30 exit 31 echo 31 32 echo 32 33 echo 33 34 fc -l ===== 2 ===== 31 28 echo 32 29 echo 33 30 fc -l 31 echo 31 32 history 5 28 echo 32 29 echo 33 30 fc -l 31 echo 31 32 history 5 1 2 3 echo 1 echo 2 echo 3 history -w - a b c echo 1 echo 2 echo 3 history -w - history -w "${TESTTMP}"/history2 -c 1 echo a 2 echo b 3 echo c 4 cat "${TESTTMP}"/history2 5 history -r "${TESTTMP}"/history2 -r - <<\END 6 echo x 7 END 8 echo 1 9 echo 2 10 echo 3 11 history -w - 12 history -w "${TESTTMP}"/history2 -c 13 echo x 14 1 15 2 16 3 17 history ===== 3 ===== 1 2 3 4 5 6 7 1 echo 1 3 echo 3 4 echo 4 5 echo 5 7 echo 7 8 history -d 2 -d 6; fc -l 3 echo 3 4 echo 4 5 echo 5 5 echo 5 4 echo 4 3 echo 3 5 echo 5 4 echo 4 3 echo 3 3 echo 3 4 echo 4 5 echo 5 echo 3 echo 4 echo 5 3 4 5 echo 5 echo 4 echo 3 5 4 3 echo 5 echo 4 echo 3 5 4 3 echo 3 echo 4 echo 5 3 4 5 1 echo 1 3 echo 3 3 echo 3 1 echo 1 3 echo 3 1 echo 1 1 echo 1 3 echo 3 ===== 4 ===== ===== 5 ===== 1 1 1 2 1 2 1 2 3 1 2 3 1 2 3 4 1 2 3 4 1 2 3 4 5 4 3 2 1 echo 1 echo 2 echo 3 echo 4 echo 1 echo 2 echo 3 echo 4 echo 1 echo 2 echo 5 echo 4 echo 3 echo 2 echo 1 fc -ln ===== 6 ===== 32753 : 15 32754 : 14 32755 : 13 32756 : 12 32757 : 11 32758 : 10 32759 : 9 32760 : 8 32761 : 7 32762 : 6 32763 : 5 32764 : 4 32765 : 3 32766 : 2 32767 : 1 32768 fc -l 32740 : 28 32741 : 27 32742 : 26 32743 : 25 32744 : 24 32745 : 23 32746 : 22 32747 : 21 32748 : 20 32749 : 19 32750 : 18 32751 : 17 32752 : 16 32753 : 15 32754 : 14 32755 : 13 ===== histspace ===== a b c d e f g 1 echo a 2 echo b 3 set --histspace 4 echo c 5 echo f 6 echo g 7 fc -l ===== error ===== fc no-such-option 2 fc invalid-option-combination l e 2 fc invalid-option-combination s e 2 fc invalid-option-combination l q 2 fc invalid-option-combination l s 2 fc invalid-option-combination r s 2 fc invalid-option-combination n 2 fc invalid-option-combination v 2 fc history-empty 2 1 fc history-empty 3 1 fc history-empty 5 1 fc history-empty 6 1 fc no-such-entry 1 1 fc no-such-entry 2 1 fc no-such-entry 3 1 fc too-many-operands 1 2 fc too-many-operands 2 2 fc too-many-operands 3 2 history no-such-option 2 history too-many-operands 2 history output error 1 history no-such-entry 1 history no-such-file 1 1 history no-such-file 2 1 yash-2.35/tests/init.y.err0000644000175000017500000000050212154557026015631 0ustar magicantmagicant===== 1 ===== ===== 2 ===== ===== 3 ===== ===== 4 ===== ===== 5 ===== ===== 6 ===== ===== 7 ===== ===== 8 ===== ===== 9 ===== ===== 10 ===== ===== 11 ===== ===== 12 ===== ===== 13 ===== ===== 14 ===== ===== error 1 ===== ===== error 2 ===== ===== non-existing 1 ===== ===== non-existing 2 ===== ===== non-existing 3 ===== yash-2.35/tests/checkfg.d0000644000175000017500000000002512154557026015444 0ustar magicantmagicantcheckfg.o: checkfg.c yash-2.35/tests/alias.p.tst0000644000175000017500000000206712154557026016000 0ustar magicantmagicant# alias.p.tst: test of aliases for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp=${TESTTMP}/alias.p.tmp \unalias -a 2>/dev/null alias c=cat alias=alias echo alias | c alias echo='echo ' echo c c \echo c c ec\ ho echo c c alias echo='echo hello' echo world unalias echo echo world alias if=: then=: fi=: 2>/dev/null if true; then echo reserved words; fi unalias if then fi 2>/dev/null alias 8=echo @!,%=echo 8"$tmp" alias unalias=: \unalias -a eval alias -- $(cat "$tmp") alias | sort | diff - "$tmp" && echo restored echo ===== if command -v echo >/dev/null 2>&1; then commandv='command -v' aliasdef=$($commandv alias) unalias alias $commandv alias eval "$aliasdef" [ x"$($commandv alias)" = x"$aliasdef" ] || echo not restored else echo alias fi if command -V echo >/dev/null 2>&1; then alias pqr=xyz case "$(command -V pqr)" in *pqr*xyz* | *xyz*pqr* ) ;; * ) printf '%s\n' "$(command -V pqr)" ;; esac fi rm -f "$tmp" yash-2.35/tests/path.p.tst0000644000175000017500000000430512154557026015640 0ustar magicantmagicant# path.p.tst: test of pathname handling for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp=${TESTTMP}/path.p.tmp echo ===== pathname expansion ===== if [ "$(id -u)" -eq 0 ]; then # cannot test as root because file permissions are ignored cat <"pathexp/unreadable/file" echo 1 pathexp/un*able/file echo 2 pathexp/un*able/f*le echo 3 pathexp/unreadable/f*le chmod a-r pathexp/unreadable echo 4 pathexp/un*able/file echo 5 pathexp/un*able/f*le echo 6 pathexp/unreadable/f*le chmod a-x pathexp/unreadable echo 7 pathexp/un*able/file echo 8 pathexp/un*able/f*le echo 9 pathexp/unreadable/f*le chmod a+rx pathexp/unreadable ) fi echo ===== cd builtin ===== HOME=/ ORIGPWD=$PWD mkdir -p "$tmp/dir/dir" if [ x"$(cd; echo $PWD)" = x"$HOME" ]; then echo cd \$HOME fi cd "$tmp" if [ x"$ORIGPWD" = x"$OLDPWD" ]; then echo cd \$OLDPWD fi cd -- - >"$tmp/path.p.tmp" if [ x"$PWD" = x"$ORIGPWD" ] && [ x"$PWD" = x"$(cat "$tmp/path.p.tmp")" ]; then echo cd \$PWD fi ln -s . "$tmp/path.p.link" cd -LP "$tmp/path.p.link" if [ x"$PWD" = x"$(pwd -P)" ]; then echo cd -P fi cd -PL "$tmp/path.p.link" if [ x"$PWD" = x"$tmp/path.p.link" ] && [ x"$PWD" = x"$(pwd)" ]; then echo cd -L fi cd "$tmp/path.p.link" if [ x"$PWD" = x"$tmp/path.p.link" ] && [ x"$PWD" = x"$(pwd)" ]; then echo cd -L default fi cd "$tmp" CDPATH=$tmp/dir/dir:$tmp/dir cd dir >"$tmp/path.p.tmp" if [ x"$PWD" = x"$tmp/dir/dir" ] && [ x"$PWD" = x"$(cat "$tmp/path.p.tmp")" ] then echo cd \$CDPATH 1 fi cd ../.. mv "$tmp/dir/dir" "$tmp/dir/dir2" CDPATH=$tmp/dir:$tmp/dir/dir2 cd dir if [ x"$PWD" = x"$tmp/dir" ]; then echo cd \$CDPATH 2 fi echo cd canonicalization "$(CDPATH=/ cd dev)" echo ===== umask builtin ===== umask=$(umask) umask 0 umask a-r umask ugo+r umask u-rw,u-x umask go+x=u umask -S umask "${umask}" [ x"${umask}" = x"$(umask)" ] && echo ok echo ===== hash builtin ===== PATH= hash 2>/dev/null cd "$TESTTMP" rm -fr "$tmp" yash-2.35/tests/lineedit.y.err0000644000175000017500000000064512154557026016473 0ustar magicantmagicantbindkey: `--no-such-option' is not a valid option bindkey: no option is specified bindkey: too many operands are specified bindkey: no operand is expected bindkey: no such editing command `no-such-command' bindkey: cannot bind an empty key sequence bindkey: key sequence `~~~' is not bound complete: `--no-such-option' is not a valid option complete: the complete built-in can be used during command line completion only yash-2.35/tests/fnmatch.p.tst0000644000175000017500000001440312154557026016324 0ustar magicantmagicant# fnmatch.p.tst: test of pattern matching for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: case a in a) echo 1; esac case a in b) echo 2; esac case a in A) echo 3; esac case \a in a) echo 11; esac case \a in b) echo 12; esac case \a in A) echo 13; esac case a in \a) echo 21; esac case a in \b) echo 22; esac case a in \A) echo 23; esac case \a in \a) echo 31; esac case \a in \b) echo 32; esac case \a in \A) echo 33; esac case 'a' in a) echo 41; esac case 'a' in b) echo 42; esac case 'a' in A) echo 43; esac case a in 'a') echo 51; esac case a in 'b') echo 52; esac case a in 'A') echo 53; esac case 'a' in 'a') echo 61; esac case 'a' in 'b') echo 62; esac case 'a' in 'A') echo 63; esac case "a" in a) echo 71; esac case "a" in b) echo 72; esac case "a" in A) echo 73; esac case a in "a") echo 81; esac case a in "b") echo 82; esac case a in "A") echo 83; esac case "a" in "a") echo 91; esac case "a" in "b") echo 92; esac case "a" in "A") echo 93; esac sq=\' dq=\" bs=\\ case \' in \' ) echo 111; esac case \' in "'" ) echo 112; esac case \' in $sq ) echo 113; esac case \' in "$sq") echo 114; esac case "'" in \' ) echo 121; esac case "'" in "'" ) echo 122; esac case "'" in $sq ) echo 123; esac case "'" in "$sq") echo 124; esac case $sq in \' ) echo 131; esac case $sq in "'" ) echo 132; esac case $sq in $sq ) echo 133; esac case $sq in "$sq") echo 134; esac case "$sq" in \' ) echo 141; esac case "$sq" in "'" ) echo 142; esac case "$sq" in $sq ) echo 143; esac case "$sq" in "$sq") echo 144; esac case \" in \" ) echo 211; esac case \" in '"' ) echo 212; esac case \" in $dq ) echo 213; esac case \" in "$dq") echo 214; esac case '"' in \" ) echo 221; esac case '"' in '"' ) echo 222; esac case '"' in $dq ) echo 223; esac case '"' in "$dq") echo 224; esac case $dq in \" ) echo 231; esac case $dq in '"' ) echo 232; esac case $dq in $dq ) echo 233; esac case $dq in "$dq") echo 234; esac case "$dq" in \" ) echo 241; esac case "$dq" in '"' ) echo 242; esac case "$dq" in $dq ) echo 243; esac case "$dq" in "$dq") echo 244; esac case \\ in \\ ) echo 311; esac case \\ in '\' ) echo 312; esac case \\ in "\\" ) echo 313; esac case \\ in $bs ) echo 314; esac case \\ in "$bs") echo 315; esac case '\' in \\ ) echo 321; esac case '\' in '\' ) echo 322; esac case '\' in "\\" ) echo 323; esac case '\' in $bs ) echo 324; esac case '\' in "$bs") echo 325; esac case "\\" in \\ ) echo 331; esac case "\\" in '\' ) echo 332; esac case "\\" in "\\" ) echo 333; esac case "\\" in $bs ) echo 334; esac case "\\" in "$bs") echo 335; esac case $bs in \\ ) echo 341; esac case $bs in '\' ) echo 342; esac case $bs in "\\" ) echo 343; esac case $bs in $bs ) echo 344; esac case $bs in "$bs") echo 345; esac case "$bs" in \\ ) echo 351; esac case "$bs" in '\' ) echo 352; esac case "$bs" in "\\" ) echo 353; esac case "$bs" in $bs ) echo 354; esac case "$bs" in "$bs") echo 355; esac case \'"'"$sq"$sq" in "$sq"$sq"'"\') echo 391; esac case \"'"'$dq"$dq" in "$dq"$dq'"'\") echo 392; esac case \\'\'"\\"$bs"$bs" in "$bs"$bs"\\"'\'\\) echo 393; esac n= case '' in '' ) echo 1011; esac case '' in "" ) echo 1012; esac case '' in $n ) echo 1013; esac case '' in "$n") echo 1014; esac case "" in '' ) echo 1021; esac case "" in "" ) echo 1022; esac case "" in $n ) echo 1023; esac case "" in "$n") echo 1024; esac case $n in '' ) echo 1031; esac case $n in "" ) echo 1032; esac case $n in $n ) echo 1033; esac case $n in "$n") echo 1034; esac case "$n" in '' ) echo 1041; esac case "$n" in "" ) echo 1042; esac case "$n" in $n ) echo 1043; esac case "$n" in "$n") echo 1044; esac case $n''"""$n" in "$n"""''$n) echo 1099; esac case a in a ) echo 2001; esac case aa in a ) echo 2002; esac case a in aa) echo 2003; esac case aa in aa) echo 2004; esac case a in ? ) echo 2011; esac case a in * ) echo 2012; esac case a in ?*) echo 2013; esac case a in *?) echo 2014; esac case a in ??) echo 2015; esac case a in **) echo 2016; esac case aa in ? ) echo 2021; esac case aa in * ) echo 2022; esac case aa in ?*) echo 2023; esac case aa in *?) echo 2024; esac case aa in ??) echo 2025; esac case aa in **) echo 2026; esac case '' in ?) echo 2101; esac case '' in *) echo 2102; esac case \\ in ?) echo 2111; esac case \\ in *) echo 2112; esac case "'" in ?) echo 2121; esac case "'" in *) echo 2122; esac case '"' in ?) echo 2131; esac case '"' in *) echo 2132; esac case a in [[:lower:]]) echo 3001 lower ; esac case a in [[:upper:]]) echo 3001 upper ; esac case a in [[:alpha:]]) echo 3001 alpha ; esac case a in [[:digit:]]) echo 3001 digit ; esac case a in [[:alnum:]]) echo 3001 alnum ; esac case a in [[:punct:]]) echo 3001 punct ; esac case a in [[:graph:]]) echo 3001 graph ; esac case a in [[:print:]]) echo 3001 print ; esac case a in [[:cntrl:]]) echo 3001 cntrl ; esac case a in [[:blank:]]) echo 3001 blank ; esac case a in [[:space:]]) echo 3001 space ; esac case a in [[:xdigit:]]) echo 3001 xdigit; esac case a in [[.a.]] ) echo 3002; esac case 1 in [0-2] ) echo 3003; esac case 1 in [[.0.]-[.2.]]) echo 3004; esac case a in [!a] ) echo 3005; esac case 1 in [!0-2] ) echo 3006; esac case a in [[=a=]] ) echo 3007; esac case \. in ["."]) echo 3101; esac case \[ in ["."]) echo 3102; esac case \" in ["."]) echo 3103; esac case \\ in ["."]) echo 3104; esac case \] in ["."]) echo 3105; esac case \. in [\".]) echo 3111; esac case \[ in [\".]) echo 3112; esac case \" in [\".]) echo 3113; esac case \\ in [\".]) echo 3114; esac case \] in [\".]) echo 3115; esac case \. in [\.] ) echo 3121; esac case \[ in [\.] ) echo 3122; esac case \" in [\.] ) echo 3123; esac case \\ in [\.] ) echo 3124; esac case \] in [\.] ) echo 3125; esac case \. in "[.]") echo 3131; esac case \[ in "[.]") echo 3132; esac case \" in "[.]") echo 3133; esac case \\ in "[.]") echo 3134; esac case \] in "[.]") echo 3135; esac case \. in [\]] ) echo 3141; esac case \[ in [\]] ) echo 3142; esac case \" in [\]] ) echo 3143; esac case \\ in [\]] ) echo 3144; esac case \] in [\]] ) echo 3145; esac case \. in ["]"]) echo 3151; esac case \[ in ["]"]) echo 3152; esac case \" in ["]"]) echo 3153; esac case \\ in ["]"]) echo 3154; esac case \] in ["]"]) echo 3155; esac yash-2.35/tests/parser.p.tst0000644000175000017500000001135012154557026016176 0ustar magicantmagicant# parser.p.tst: test of syntax parser for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp="${TESTTMP}/parser.p.tmp" var=abc echo 1\2\ 3 echo $var ${var} "$var" "${var}" '$var' '${var}' echo \$var \${var} "\$var" "\${var}" echo $(echo $var ${var} "$var" "${var}" '$var' '${var}') echo "$(echo $var ${var} "$var" "${var}" '$var' '${var}')" echo '$(echo $var ${var} "$var" "${var}")' echo single \ ' ' echo double \ " " foo= bar= multiple=assignments one=line echo $multiple $one multiple=foo ; one=& (one\ =bar) echo $multiple $one echo $(echo echo) $((1 + 2 * 3)) echo dummy >/dev/null exec /dev/null echo $? $foo bar=bar >$(echo /dev/null; exit 12) echo $? $bar foo=$(echo $?; exit 1) <&$(echo $?; exit 2) echo $? $foo echo ===== 0 ===== # echo $var ${var#a} ${var%%b*} e\ c\ h\ o\ \ $\ v\ a\ r\ \ $\ {\ v\ a\ r\ #\ a\ }\ \ ${var\ %\ %\ b\ *\ } echo ===== 1 ===== echo comment# \# # comment echo very very lo\ ng line echo pipeline \| | cat | cat \ | cat echo test ;echo of echo sequential \;; echo lists ; echo asynchronous list\ & wait $! (echo another async; false) & if ! wait $!; then echo ok; fi echo ===== 2 ===== true && echo true and false && echo false and true || echo true or false || echo false or false && echo and || echo or true || echo or && echo and true && echo and newline false\ |\ |\ echo or newline echo ===== 3 ===== { echo compound list;}| cat { echo another echo compound list\ } } 2>&1|cat (echo subshell|cat)| cat ( echo another echo subshell\ )2>&1|cat echo yet another subshell|( cat;) echo ===== 4 ===== if true; then echo if construct; fi if # comment ok echo dummy false then echo no! else echo ok! fi if if true; then false; else true; fi then echo no!; elif echo dummy; echo dummy; then echo ok!; else echo no!; fi if false; then echo no!; elif true &&! echo dummy; then echo no!; elif false ||! false; then echo ok!; fi if if (true) then (echo 1) fi then echo 2 fi # if true;then echo line concatenation ok \(if\) # fi i\ f\ \ true\ ;\ t\ h\ e\ n\ \ echo line concatenation ok \(if\) f\ i echo ===== 5 ===== while false; do true; done; echo $? until true; do true; done; echo $? while [ $? = 0 ]; do (exit 10) done; echo $? until ! [ $? = 0 ]; do (exit 10) done; echo $? set 1 '2 2' 3 while # comment ok [ $# != 0 ] do echo $# $1 shift done w\ h\ i\ l\ e echo line concatenation ok \(while\) false;\ d\ o\ echo ng d\ o\ n\ e echo ===== 6 ===== for i in 1 '2 2' 3; do echo $i; echo "$i"; done for i # comment in parser.p.* # comment do # comment echo $i # comment done # comment # for index in 1 '2 2' 3;do echo $index; echo "$index";done f\ o\ r\ \ i\ n\ d\ e\ x\ \ i\ n\ \ 1 '2 2' 3\ ;\ d\ o\ echo $index; echo "$index";\ d\ o\ n\ e for in in in; do echo $in; done false for i in; do :; done echo $? (exit 2) for i in 1; do (exit 1); done echo $? echo ===== 7 ===== false case 123 in esac echo $? case 123 in esac case 123 in * | esac ) esac i='' case 123 # comment ok in # comment ok ${i:=2}) echo ng\;;; (x|y|z) echo ng;; (dummy) ;; foo | 1$i*3 ) echo ok false esac if [ $? != 0 ]; then echo $i; fi case '*' in # comment ok '*') echo '*' ;; *) echo ng ;; esac for i in 1 '2 2' 3 4 5; do case $i in 1 | 4 ) echo foo if [ $i = 1 ]; then echo one; else echo four; fi ;; 2 ) echo ng ;; (*2" "[1-3]*) echo two;; (\*) echo ng;; (*) echo $i;; esac done # case case in false)echo ng;;(c*e)echo line concatenation ok \(case\);esac c\ a\ s\ e\ \ c\ a\ s\ e\ \ i\ n\ \ f\ a\ l\ s\ e\ )\ echo ng\ ;\ ;\ (\ c\ *\ e\ )\ echo line concatenation ok \(case\)\ ;\ e\ s\ a\ c echo ===== 8 ===== func () { echo function } func func # func2 () (echo line concatenation ok \(func\)) f\ u\ \ n\ c\ 2\ (\ )\ # split function def. (echo line concatenation ok \(func\)) func2 func3 () if true; then echo func3; fi func3 func func3 func if $INVOKE $TESTEE -s 2>/dev/null </dev/null func4 funcredir () { echo redirected echo re-redirected >&3 } \ >"$tmp" funcredir 3>&1 >/dev/null cat "$tmp" funcredir2 ( ) # comment { echo not-redirected } funcredir2 >/dev/null echo ===== 9 ===== $INVOKE $TESTEE <<\END exec cat OK 1 END $INVOKE $TESTEE <<\END cat OK 2 END echo lineno=$LINENO rm -f "$tmp" yash-2.35/tests/parser.y.tst0000644000175000017500000001722512154557026016216 0ustar magicantmagicant# parser.y.tst: yash-specific test of syntax parser # vim: set ft=sh ts=8 sts=4 sw=4 noet: echo ===== for ===== # semicolon after identifier only allowed in non-posix mode set 1 2 3 for i; do echo $i; done for i; do echo $i; done echo ===== empty compound commands ===== (exit 1) () ( ) { } { } echo a $? (exit 1) if then fi if then fi if then elif then else fi if then elif then else fi echo b $? (exit 1) for _ in; do done echo c1 $? (exit 1) for _ in do done echo c2 $? (exit 1) for _ in 1 2 3; do done echo c3 $? while false; do done echo d1 $? false until do done echo d2 $? i=3 while do if [ $i -eq 0 ]; then break; fi i=$((i-1)) echo $i done until do echo not reached done false case _ in (*) esac echo e1 $? echo ===== function ===== func () function func ( ) { echo func 1; } func func function func() { echo func 2; } func function func if true then echo func 3 else echo X 3 fi func function "func" (echo func 4) func funcname=Z func () function X"Y$(echo $funcname)" for i in func do unset -f $i echo func 5 done func XYZ typeset -fp | sed 's/^ *//' function X:Z { echo non-portable name } typeset -fp X:Z | sed 's/^ *//' f\ u\ n\ c\ t\ i\ o\ \ n\ \ f"u\ n"c \ (\ ) { echo func 6; } func echo ===== error ===== $INVOKE $TESTEE <<\END if true; then echo error missing semicolon 1; fi echo error missing semicolon 2 echo error missing semicolon 3 END $INVOKE $TESTEE <<\END ) echo error right paren END $INVOKE $TESTEE <<\END } echo error right brace END $INVOKE $TESTEE <<\END ;; echo error double semicolon END $INVOKE $TESTEE <<\END then echo error then 1 END $INVOKE $TESTEE <<\END if true; then :; then echo error then 2 END $INVOKE $TESTEE <<\END else echo error else 1 END $INVOKE $TESTEE <<\END if true; else echo error else 2 END $INVOKE $TESTEE <<\END elif echo error elif 1 END $INVOKE $TESTEE <<\END if true; elif echo error elif 2 END $INVOKE $TESTEE <<\END fi echo error fi 1 END $INVOKE $TESTEE <<\END if true; fi echo error fi 2 END $INVOKE $TESTEE <<\END if true; then :; elif true; fi echo error fi 3 END $INVOKE $TESTEE <<\END do echo error do END $INVOKE $TESTEE <<\END done echo error done 1 END $INVOKE $TESTEE <<\END while false; done echo error done 2 END $INVOKE $TESTEE <<\END esac echo error esac END $INVOKE $TESTEE <<\END ! ! echo error ! 1 echo error ! 2 END $INVOKE $TESTEE <<\END : | : | ! echo error ! 3 echo error ! 4 END $INVOKE $TESTEE <<\END in echo error in END $INVOKE $TESTEE <<\END echo no command after pipe | END $INVOKE $TESTEE -c '; echo no command before semicolon' $INVOKE $TESTEE -c '& echo no command before ampersand' $INVOKE $TESTEE -c '| echo no command before pipe' $INVOKE $TESTEE -c '(;)' $INVOKE $TESTEE -c '(&)' $INVOKE $TESTEE -c '(| echo no command before pipe)' $INVOKE $TESTEE -c 'echo \ invalid left parenthesis \ (' $INVOKE $TESTEE -c '\foo () { echo invalid left parenthesis; }' $INVOKE $TESTEE -c 'array=( 1 2 3 ' $INVOKE $TESTEE -c 'array=( foo ;)' $INVOKE $TESTEE -c '<' $INVOKE $TESTEE -c '<>' $INVOKE $TESTEE -c '<&#' $INVOKE $TESTEE -c '>' $INVOKE $TESTEE -c '>|' $INVOKE $TESTEE -c '>&' $INVOKE $TESTEE -c '>> \ #' $INVOKE $TESTEE -c '>>|' $INVOKE $TESTEE <<\END cat << END $INVOKE $TESTEE <<\END cat <<- \ END $INVOKE $TESTEE <<\END cat <<< END $INVOKE $TESTEE -c 'echo "foo' $INVOKE $TESTEE -c 'echo ${foo-"bar}' $INVOKE $TESTEE -c "echo \\ 'foo " $INVOKE $TESTEE -c 'echo ${}' $INVOKE $TESTEE -c 'echo ${}}' $INVOKE $TESTEE -c 'echo ${&}' $INVOKE $TESTEE -c 'echo ${foo[]}' $INVOKE $TESTEE -c 'echo ${foo[,2]}' $INVOKE $TESTEE -c 'echo ${foo[2,]}' $INVOKE $TESTEE -c 'echo ${foo[}' $INVOKE $TESTEE -c 'echo ${foo[1}' $INVOKE $TESTEE -c 'echo ${foo[1,2}' $INVOKE $TESTEE -c 'echo ${foo' $INVOKE $TESTEE -c 'echo ${foo:}' $INVOKE $TESTEE -c 'echo ${foo:' $INVOKE $TESTEE -c 'echo ${foo!' $INVOKE $TESTEE -c 'echo ${foo:#bar}' $INVOKE $TESTEE -c 'echo ${foo:%bar}' $INVOKE $TESTEE -c 'echo ${foo#bar' $INVOKE $TESTEE -c 'echo ${foo%bar' $INVOKE $TESTEE -c 'echo ${foo/bar' $INVOKE $TESTEE -c 'echo ${foo/bar/baz' $INVOKE $TESTEE -c 'echo ${#foo-bar}' $INVOKE $TESTEE -c 'echo ${#foo+bar}' $INVOKE $TESTEE -c 'echo ${#foo?bar}' $INVOKE $TESTEE -c 'echo ${#foo=bar}' $INVOKE $TESTEE -c 'echo ${#foo#bar}' $INVOKE $TESTEE -c 'echo ${#foo%bar}' $INVOKE $TESTEE -c 'echo ${#foo/bar}' $INVOKE $TESTEE -c 'echo ${#foo/bar/baz}' $INVOKE $TESTEE -c 'echo $(echo missing right parenthesis ' $INVOKE $TESTEE -c 'echo `echo missing backquote ' $INVOKE $TESTEE -c 'echo `echo missing backquote \` ' $INVOKE $TESTEE -c 'echo missing double-quote `echo \ "foo`' $INVOKE $TESTEE -c 'echo missing backquote \ `echo foo \` echo bar`' $INVOKE $TESTEE -c 'echo $((echo missing right parenthesis' echo = >&2 $INVOKE $TESTEE -c 'echo $((echo missing right parenthesis)' $INVOKE $TESTEE --posix <<\END ( ) END $INVOKE $TESTEE --posix <<\END ( # comment ) END $INVOKE $TESTEE --posix <<\END { } END $INVOKE $TESTEE --posix <<\END { # comment } END $INVOKE $TESTEE -c '(' $INVOKE $TESTEE -c '{' $INVOKE $TESTEE -c '{ ( }' $INVOKE $TESTEE -c '( { )' $INVOKE $TESTEE --posix <<\END if then :; elif :; then :; else :; fi END $INVOKE $TESTEE --posix <<\END if :; then elif :; then :; else :; fi END $INVOKE $TESTEE --posix <<\END if :; then :; elif then :; else :; fi END $INVOKE $TESTEE --posix <<\END if :; then :; elif :; then else :; fi END $INVOKE $TESTEE --posix <<\END if :; then :; elif :; then :; else fi END $INVOKE $TESTEE -c 'if' $INVOKE $TESTEE -c 'if :; then echo then missing; elif' $INVOKE $TESTEE -c 'if :; then echo fi missing' $INVOKE $TESTEE -c 'if :; then :; else echo fi missing' $INVOKE $TESTEE -c '{ if }' $INVOKE $TESTEE -c '{ if :; then echo then missing; elif }' $INVOKE $TESTEE -c '{ if :; then echo fi missing; }' $INVOKE $TESTEE -c '{ if :; then :; else echo fi missing; }' $INVOKE $TESTEE <<\END for do echo missing variable done END $INVOKE $TESTEE -c 'for = do echo invalid variable; done' $INVOKE $TESTEE -c 'for _ in 1 2 3>/dev/null; do echo redirection in for; done' $INVOKE $TESTEE --posix -c 'for _; do echo invalid semicolon; done' $INVOKE $TESTEE -c 'for _ echo do missing; done' $INVOKE $TESTEE --posix <<\END for _ do done END $INVOKE $TESTEE --posix <<\END for _ do # comment done END $INVOKE $TESTEE -c 'for _ do' $INVOKE $TESTEE -c '{ for }' $INVOKE $TESTEE -c '{ for _ }' $INVOKE $TESTEE -c '{ for _ in }' $INVOKE $TESTEE -c '{ for _ in; }' $INVOKE $TESTEE -c '{ for _ do }' $INVOKE $TESTEE -c '{ for _ in; do }' $INVOKE $TESTEE --posix <<\END while do :; done END $INVOKE $TESTEE --posix <<\END until do :; done END $INVOKE $TESTEE --posix <<\END while :; do done END $INVOKE $TESTEE --posix <<\END until :; do done END $INVOKE $TESTEE -c 'while' $INVOKE $TESTEE -c 'while do' $INVOKE $TESTEE -c 'until' $INVOKE $TESTEE -c 'until do' $INVOKE $TESTEE -c '{ while }' $INVOKE $TESTEE -c '{ while do }' $INVOKE $TESTEE -c '{ until }' $INVOKE $TESTEE -c '{ until do }' $INVOKE $TESTEE <<\END case # comment in esac END $INVOKE $TESTEE -c 'case' $INVOKE $TESTEE -c 'case ""' $INVOKE $TESTEE -c 'case "" in' $INVOKE $TESTEE -c 'case ; echo no word after case' $INVOKE $TESTEE -c '{ case "" }' $INVOKE $TESTEE -c '{ case "" in *) }' $INVOKE $TESTEE <<\END case "" in ( END $INVOKE $TESTEE <<\END case "" in (x|y| END $INVOKE $TESTEE -c 'case "" in >/dev/null' $INVOKE $TESTEE -c 'case "" in "" esac' $INVOKE $TESTEE -c 'case "" in "" | "" esac' $INVOKE $TESTEE --posix -c 'case "" in (esac) :; esac' $INVOKE $TESTEE --posix -c 'function f() { echo posix function; }' $INVOKE $TESTEE <<\END function # comment { echo no word after function; } END $INVOKE $TESTEE -c 'function f() echo non-compound function body' $INVOKE $TESTEE -c 'f (' $INVOKE $TESTEE -c 'f() echo non-compound function body' $INVOKE $TESTEE <<\END cat <<'a b' END yash-2.35/tests/input.y.out0000644000175000017500000000010312154557026016041 0ustar magicantmagicant===== input.p.t ===== ok here-document ok ===== input.t ===== 1 ok yash-2.35/tests/expand.y.out0000644000175000017500000001037612154557026016176 0ustar magicantmagicant~+ ~- expand.y.tst 1 b nest $ + nest $ - nest $ = nest $ ? nest $ # nest $ % nest $ / ## length=1 #- length=0 ifunset=3 #? length=1 error=3 #+ #= 3 3 #/ X X #% 123/xxx/789 xxx/456/789 123/456/789 123/456/xxx 123/456/789 123-456-789 123/4/6/789 123/456/789 x 19 1 2 3 4 5 19 1 2 3 4 5 foo bar 1-2-3 1 2 3 ===== 1 ===== -2- 2 2 1-2-3 1-2-3 5 ===== 2 ===== 1 22 3 3 4 4 5 -0- 1 22 3 3 4 4 5 -1- 1 22 3 3 4 4 5 -2- 5 -3- 1 -4- 22 -5- 3 3 -6- 4 4 -7- 5 -8- 1 22 3 3 -9- 22 3 3 4 4 -10- 3 3 4 4 5 -11- 4 4 5 -12- 5 -13- -14- 1 22 3 3 4 4 5 -20- 3 -21- 3 3 -22- 1 22 3 3 4 4 5 -30- 1 22 3 3 4 4 5 -31- ===== 3 ===== -- 1 22 3 3 4 4 5 -0- 1 22 3 3 4 4 5 -1- 1 22 3 3 4 4 5 -2- 5 -3- 1 -4- 22 -5- 3 3 -6- 4 4 -7- 5 -8- 1 22 3 3 -9- 22 3 3 4 4 -10- 3 3 4 4 5 -11- 4 4 5 -12- 5 -13- -14- 1 22 3 3 4 4 5 -20- 3 -21- 3 3 -22- 1 22 3 3 4 4 5 -30- 1 22 3 3 4 4 5 -31- ===== 4 ===== 1 22 3 3 4 4 5 -0- 1 22 3 3 4 4 5 -1- 1 22 3 3 4 4 5 -2- 5 -3- 1 -4- 22 -5- 3 3 -6- 4 4 -7- 5 -8- 1 22 3 3 -9- 22 3 3 4 4 -10- 3 3 4 4 5 -11- 4 4 5 -12- 5 -13- -14- 1 22 3 3 4 4 5 -20- 3 -21- 2 -22- 1 22 3 3 4 4 5 -30- 1 22 3 3 4 4 5 -31- ===== 5 ===== 3 3 4 4 ===== 6 ===== [][][] - - 1 [1][][] - 2 - 1 [1][2][] 0 [1][2][] ary=1:2: ===== 7 ===== abcd abcd abcd 4 . a b c d . . d c b a . === a === . . . a ab abc abcd . abcd . b bc bcd . bcd . c cd . cd . d . d . . . . . d . d . c cd . cd . b bc bcd . bcd . a ab abc abcd . abcd . a ab abc abcd . abcd === b === . . . abcd abc ab a . . bcd bc b . . cd c . . d . . . . . . d . . cd c . . bcd bc b . . abcd abc ab a . . abcd abc ab a . ===== 8 ===== a b c d a b c d a b c d 4 . a b c d . . d c b a . ${a[0,0]} = ${a[0,1]} = ${a[0,2]} = ${a[0,3]} = ${a[0,4]} = ${a[0,5]} = ${a[0,-1]} = ${a[0,-2]} = ${a[0,-3]} = ${a[0,-4]} = ${a[0,-5]} = ${a[0,-0]} = ${a[1,0]} = ${a[1,1]} = a ${a[1,2]} = a b ${a[1,3]} = a b c ${a[1,4]} = a b c d ${a[1,5]} = a b c d ${a[1,-1]} = a b c d ${a[1,-2]} = a b c ${a[1,-3]} = a b ${a[1,-4]} = a ${a[1,-5]} = ${a[1,-0]} = ${a[2,0]} = ${a[2,1]} = ${a[2,2]} = b ${a[2,3]} = b c ${a[2,4]} = b c d ${a[2,5]} = b c d ${a[2,-1]} = b c d ${a[2,-2]} = b c ${a[2,-3]} = b ${a[2,-4]} = ${a[2,-5]} = ${a[2,-0]} = ${a[3,0]} = ${a[3,1]} = ${a[3,2]} = ${a[3,3]} = c ${a[3,4]} = c d ${a[3,5]} = c d ${a[3,-1]} = c d ${a[3,-2]} = c ${a[3,-3]} = ${a[3,-4]} = ${a[3,-5]} = ${a[3,-0]} = ${a[4,0]} = ${a[4,1]} = ${a[4,2]} = ${a[4,3]} = ${a[4,4]} = d ${a[4,5]} = d ${a[4,-1]} = d ${a[4,-2]} = ${a[4,-3]} = ${a[4,-4]} = ${a[4,-5]} = ${a[4,-0]} = ${a[5,0]} = ${a[5,1]} = ${a[5,2]} = ${a[5,3]} = ${a[5,4]} = ${a[5,5]} = ${a[5,-1]} = ${a[5,-2]} = ${a[5,-3]} = ${a[5,-4]} = ${a[5,-5]} = ${a[5,-0]} = ${a[-0,0]} = ${a[-0,1]} = ${a[-0,2]} = ${a[-0,3]} = ${a[-0,4]} = ${a[-0,5]} = ${a[-0,-1]} = ${a[-0,-2]} = ${a[-0,-3]} = ${a[-0,-4]} = ${a[-0,-5]} = ${a[-0,-0]} = ${a[-1,0]} = ${a[-1,1]} = ${a[-1,2]} = ${a[-1,3]} = ${a[-1,4]} = d ${a[-1,5]} = d ${a[-1,-1]} = d ${a[-1,-2]} = ${a[-1,-3]} = ${a[-1,-4]} = ${a[-1,-5]} = ${a[-1,-0]} = ${a[-2,0]} = ${a[-2,1]} = ${a[-2,2]} = ${a[-2,3]} = c ${a[-2,4]} = c d ${a[-2,5]} = c d ${a[-2,-1]} = c d ${a[-2,-2]} = c ${a[-2,-3]} = ${a[-2,-4]} = ${a[-2,-5]} = ${a[-2,-0]} = ${a[-3,0]} = ${a[-3,1]} = ${a[-3,2]} = b ${a[-3,3]} = b c ${a[-3,4]} = b c d ${a[-3,5]} = b c d ${a[-3,-1]} = b c d ${a[-3,-2]} = b c ${a[-3,-3]} = b ${a[-3,-4]} = ${a[-3,-5]} = ${a[-3,-0]} = ${a[-4,0]} = ${a[-4,1]} = a ${a[-4,2]} = a b ${a[-4,3]} = a b c ${a[-4,4]} = a b c d ${a[-4,5]} = a b c d ${a[-4,-1]} = a b c d ${a[-4,-2]} = a b c ${a[-4,-3]} = a b ${a[-4,-4]} = a ${a[-4,-5]} = ${a[-4,-0]} = ${a[-5,0]} = ${a[-5,1]} = a ${a[-5,2]} = a b ${a[-5,3]} = a b c ${a[-5,4]} = a b c d ${a[-5,5]} = a b c d ${a[-5,-1]} = a b c d ${a[-5,-2]} = a b c ${a[-5,-3]} = a b ${a[-5,-4]} = a ${a[-5,-5]} = ${a[-5,-0]} = ===== 9 ===== {1..9 {1.9} 1..9} 1 2 3 4 5 6 7 8 9 9 10 11 111 112 113 114 115 116 117 118 119 120 121 122 123 9 8 7 6 5 4 3 2 1 11 10 9 123 122 121 120 119 118 117 116 115 114 113 112 111 1 3 5 1 4 7 10 13 16 19 1 1 {0..0..0} 5 3 1 19 16 13 10 7 4 1 1 -11 -13 -15 -17 -19 a1b a2b a3b a4b a1b a2b a3b a4b ab a555b a1b3c a1b4c a2b3c a2b4c ab1cd ab2cd a3d ab1cd ab2cd a3d 1 2 a1'\"2b a3b {1,2,3} {4,5,6} ab ab ===== 10 ===== pre/postfix 1 3 3 1 1 yash-2.35/tests/sig.y.tst0000644000175000017500000001115112154557026015474 0ustar magicantmagicant# sig.y.tst: yash-specific test of signal handling # vim: set ft=sh ts=8 sts=4 sw=4 noet: command -b ulimit -c 0 2>/dev/null echo ===== kill ===== # check various syntaxes of kill kill -s CHLD $$ $$ echo kill 1 $? kill -n CHLD $$ $$ echo kill 2 $? kill -s 0 $$ $$ echo kill 3 $? kill -n 0 $$ $$ echo kill 4 $? kill -sCHLD $$ $$ echo kill 5 $? kill -nCHLD $$ $$ echo kill 6 $? kill -s0 $$ $$ echo kill 7 $? kill -n0 $$ $$ echo kill 8 $? kill -CHLD $$ $$ echo kill 9 $? kill -0 $$ $$ echo kill 10 $? kill -s CHLD -- $$ $$ echo kill 11 $? kill -n CHLD -- $$ $$ echo kill 12 $? kill -s 0 -- $$ $$ echo kill 13 $? kill -n 0 -- $$ $$ echo kill 14 $? kill -sCHLD -- $$ $$ echo kill 15 $? kill -nCHLD -- $$ $$ echo kill 16 $? kill -s0 -- $$ $$ echo kill 17 $? kill -n0 -- $$ $$ echo kill 18 $? kill -CHLD -- $$ $$ echo kill 19 $? kill -0 -- $$ $$ echo kill 20 $? kill -l >/dev/null echo kill 21 $? kill -l -v >/dev/null echo kill 22 $? kill -v -l >/dev/null echo kill 23 $? kill -lv >/dev/null echo kill 24 $? kill -vl >/dev/null echo kill 25 $? kill -v >/dev/null echo kill 26 $? kill -l -- 3 9 15 echo kill 27 $? kill -lv -- 3 9 15 >/dev/null echo kill 28 $? kill -s chld $$ $$ echo kill 29 $? kill -schld $$ $$ echo kill 30 $? kill -s SIGCHLD $$ $$ echo kill 31 $? kill -sSIGCHLD $$ $$ echo kill 32 $? kill -s sigchld $$ $$ echo kill 33 $? kill -ssigchld $$ $$ echo kill 34 $? kill -SIGCHLD $$ $$ echo kill 35 $? kill -SiGcHlD $$ $$ echo kill 36 $? echo ===== trap ===== trap 'echo trapped' USR1 echo trap 1 $? trap '' USR2 echo trap 2 $? while kill -s 0 $$; do sleep 1; done 2>/dev/null& kill -s USR2 $! kill -s USR1 $! wait $! kill -l $? trap -p USR1 USR2 INT echo trap 3 $? trap - USR1 USR2 INT echo trap 4 $? { $INVOKE $TESTEE -c 'trap "echo EXIT 1" EXIT; ./_no_such_command_ ' $INVOKE $TESTEE -c 'trap "echo EXIT 2" EXIT; (./_no_such_command_)' $INVOKE $TESTEE -ce 'trap "echo EXIT 3" EXIT; ./_no_such_command_ ' $INVOKE $TESTEE -ce 'trap "echo EXIT 4" EXIT; (./_no_such_command_)' $INVOKE $TESTEE -c 'trap "echo EXIT 5" EXIT; ./_no_such_command_ ; :' $INVOKE $TESTEE -c 'trap "echo EXIT 6" EXIT; (./_no_such_command_); :' $INVOKE $TESTEE -ce 'trap "echo EXIT 7" EXIT; ./_no_such_command_ ; :' $INVOKE $TESTEE -ce 'trap "echo EXIT 8" EXIT; (./_no_such_command_); :' $INVOKE $TESTEE -c 'trap "echo EXIT 9" EXIT; ./_no_such_command_ ; (:)' $INVOKE $TESTEE -c 'trap "echo EXIT 10" EXIT; (./_no_such_command_); (:)' $INVOKE $TESTEE -ce 'trap "echo EXIT 11" EXIT; ./_no_such_command_ ; (:)' $INVOKE $TESTEE -ce 'trap "echo EXIT 12" EXIT; (./_no_such_command_); (:)' } 2>/dev/null echo ===== signals ===== export SIG $INVOKE $TESTEE -i +m --norcfile 2>/dev/null <<\END # SIGINT, SIGTERM and SIGQUIT are ignored if interactive kill -s INT $$ echo INT ignored kill -s TERM $$ echo TERM ignored kill -s QUIT $$ echo QUIT ignored # SIGINT and SIGQUIT are still ignored in subshells if job control is disabled # SIGTERM is not ignored in subshells $INVOKE $TESTEE -c 'kill -s INT $$' & \ wait $! >/dev/null echo INT $? $INVOKE $TESTEE -c 'kill -s TERM $$' & \ wait $! >/dev/null kill -l $? $INVOKE $TESTEE -c 'kill -s QUIT $$' & \ wait $! >/dev/null echo QUIT $? END # `cd's before `kill's are there because core dumps, if any, should be created # in a temporary directory echo ===== signals +i +m F ===== for SIG in ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 do $INVOKE $TESTEE -c +i +m 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done for SIG in CHLD URG do $INVOKE $TESTEE -c +i +m 'cd "$TESTTMP"; kill -s $SIG $$' echo $SIG $? done echo ===== signals -i +m F ===== for SIG in ABRT ALRM BUS FPE HUP ILL KILL PIPE SEGV USR1 USR2 do $INVOKE $TESTEE -ci +m --norcfile 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done for SIG in CHLD URG do $INVOKE $TESTEE -ci +m --norcfile 'cd "$TESTTMP"; kill -s $SIG $$' echo $SIG $? done echo ===== signals +i +m T ===== for SIG in ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done for SIG in CHLD URG do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' echo $SIG $? done echo ===== signals -i +m T ===== $INVOKE $TESTEE -i +m --norcfile 2>/dev/null <<\END export SIG for SIG in ABRT ALRM BUS FPE HUP ILL KILL PIPE QUIT SEGV TERM USR1 USR2 do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done for SIG in CHLD URG do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' echo $SIG $? done for SIG in INT INT INT do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done kill -l $? END yash-2.35/tests/alias.y.tst0000644000175000017500000000613012154557026016004 0ustar magicantmagicant# alias.y.tst: yash-specific test of aliases # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp="${TESTTMP}/alias.y.tmp" alias # prints nothing: yash has not predefined aliases echo $? alias -g A=a B=b C=c singlequote=\' -- ---=- echo $? C B A -A- -B- -C- \A "B" 'C' --- alias --global \C \singlequote C='| cat' echo pipe alias C alias -p >"$tmp" unalias -a . "$tmp" alias --prefix | diff - "$tmp" && echo restored unalias --all alias # prints nothing alias c='cat' alias -g P=')|c' echo complex alias | (c|(c P)|c unalias -a alias -g a='a a ' echo a a a alias foobar=' FOO=BAR ' e='env' alias -g G=' |grep' foobar e G '^FOO=' unalias -a alias cc=' ( c ) ' c='cat' echo ok | cc | cc | cc |\ cc alias i=if if=fi i true; then echo if; fi alias i='if true; then echo if; fi' i alias f=false ff='FOO=BAR f' fff='>/dev/null ff' ffff='! fff' ! f echo $? ! ff echo $? ! fff echo $? ffff echo $? alias -g v=V FOO=BAR echo v FOO=BAR echo 3>/dev/null v unalias -a alias -g N='>/dev/null' alias -p \N echo null N # prints nothing N echo null # prints nothing (echo null) N # prints nothing { echo null; } N # prints nothing if :; then echo null; fi N # prints nothing if if :; then :; fi then if :; then echo null; fi fi N # prints nothing if if :; then :; fi then if :; then echo null; fi N fi # prints nothing if if echo null; then :; fi N then if :; then :; fi fi # prints nothing unalias -a alias test=echo func() { echo "$(test ok)"; } func cat >"$tmp" <<\END func() { echo "$(test ok)"; } test foo END . -A "$tmp" && . --no-alias "$tmp" echo $? func unalias -a alias test=echo alias -g global=alias null='/dev/null' nullout='> null' te\ st line continuation 1 dummy=dummy te\ st line continuation 2 test line continuation 3 glo\ bal { test not printed 4; } nullou\ t { test not printed 5; } > nul\ l array=(foo glo\ bal bar) test line continuation 6 $array unalias -a alias c='cat <&- 2>/dev/null) echo alias output error 1 $? (alias alias >&- 2>/dev/null) echo alias output error 2 $? (alias -p alias >&- 2>/dev/null) echo alias output error 3 $? unalias --no-such-option echo unalias no-such-option $? unalias -a operand echo unalias too-many-operands $? unalias echo unalias insufficient-operand $? unalias alias unalias alias echo unalias no-such-alias $? rm -f "$tmp" yash-2.35/tests/prompt.y.tst0000644000175000017500000000057012154557026016236 0ustar magicantmagicant# prompt.y.tst: test of interactive prompt # vim: set ft=sh ts=8 sts=4 sw=4 noet: $INVOKE $TESTEE -iv +m -o posix <<\END printf 'posix PS1={%s}\n' "$PS1" printf 'posix PS2={%s}\n' "$PS2" printf 'posix PS4={%s}\n' "$PS4" exit END $INVOKE $TESTEE -iv +m --norcfile <<\END printf 'yash PS1={%s}\n' "$PS1" printf 'yash PS2={%s}\n' "$PS2" printf 'yash PS4={%s}\n' "$PS4" exit END yash-2.35/tests/alias.p.out0000644000175000017500000000014012154557026015763 0ustar magicantmagicantalias cat c c c echo cat c hello world world reserved words IO_NUMBER @!,% restored ===== alias yash-2.35/tests/array.y.err0000644000175000017500000000103312154557026016004 0ustar magicantmagicantarray: index 100 is out of range (the actual size of array $aaa is 11) array: index -100 is out of range (the actual size of array $aaa is 11) ===== 1 ===== array: `--no-such-option' is not a valid option array: this command requires an operand array: this command requires 2 operands array: this command requires 3 operands array: too many operands are specified array: $aaa is read-only array: $aaa is read-only array: $aaa is read-only array: $aaa is read-only array: $aaa is read-only array: $aaa is read-only array: $aaa is read-only yash-2.35/tests/help.y.tst0000644000175000017500000000262212154557026015645 0ustar magicantmagicant# help.y.tst: yash-specific test of the help builtin # vim: set ft=sh ts=8 sts=4 sw=4 noet: help >/dev/null 2>&1 echo ===== 1 $? help help >/dev/null 2>&1 echo ===== 2 $? help : true false set cd pwd hash umask >/dev/null 2>&1 echo ===== 3 $? help typeset export readonly unset shift getopts read >/dev/null 2>&1 echo ===== 4 $? help trap kill jobs fg bg wait disown >/dev/null 2>&1 echo ===== 5 $? help return break continue eval . exec command type times exit suspend \ >/dev/null 2>&1 echo ===== 6 $? case "$(type alias 2>/dev/null)" in *builtin*) help alias unalias >/dev/null 2>&1 esac echo ===== 7 $? case "$(type array 2>/dev/null)" in *builtin*) help array >/dev/null 2>&1 esac echo ===== 8 $? case "$(type pushd 2>/dev/null)" in *builtin*) help pushd popd dirs >/dev/null 2>&1 esac echo ===== 9 $? case "$(type fc 2>/dev/null)" in *builtin*) help fc history >/dev/null 2>&1 esac echo ===== 10 $? case "$(type ulimit 2>/dev/null)" in *builtin*) help ulimit >/dev/null 2>&1 esac echo ===== 11 $? case "$(type echo 2>/dev/null)" in *builtin*) help echo printf >/dev/null 2>&1 esac echo ===== 12 $? case "$(type test 2>/dev/null)" in *builtin*) help test [ >/dev/null 2>&1 esac echo ===== 13 $? case "$(type bindkey 2>/dev/null)" in *builtin*) help bindkey >/dev/null 2>&1 esac echo ===== 14 $? help --no-such-option echo help no-such-option $? help XXX echo help no-such-builtin $? yash-2.35/tests/redir.y.tst0000644000175000017500000000254512154557026016026 0ustar magicantmagicant# redir.y.tst: yash-specific test of redirections # vim: set ft=sh ts=8 sts=4 sw=4 noet: temp="${TESTTMP}/redir.y.tmp" echo ===== unclosed here-documents ===== $INVOKE $TESTEE -c 'echo 1; cat <&- 4>&- 5>&- 6>&- exec 4>>|3; echo 4-3 >&4; exec 4>&-; cat <&3; exec 3<&- exec 4>>|6; echo 4-6 >&4; exec 4>&-; cat <&6; exec 6<&- exec 5>>|3; echo 5-3 >&5; exec 5>&-; cat <&3; exec 3<&- exec 5>>|6; echo 5-6 >&5; exec 5>&-; cat <&6; exec 6<&- exec 5>>|4; echo 5-4 >&5; exec 5>&-; cat <&4; exec 4<&- exec 3>>|6; echo 3-6 >&3; exec 3>&-; cat <&6; exec 6<&- exec 3>>|4; echo 3-4 >&3; exec 3>&-; cat <&4; exec 4<&- (while read i; do if [ $i -lt 5 ]; then echo $((i+1)); else exit; fi done | { echo 0; tee "$temp"; }) >>|0 cat "$temp" rm -f "$temp" echo ===== command redirection ===== cat <(echo 1) cat <(echo 2)- echo >(cat) 3 | cat seq () { i=1 while [ "$i" -le "$1" ]; do echo "$i" i=$((i+1)) done unset i } seq 4 >(cat) | grep 4 grep 5 <(seq 5) ! $INVOKE $TESTEE -c '< (:)' 2>(cat>/dev/null) echo $? echo ===== here-string ===== var=foo cat <<<"" cat <<<123 cat <<< "$var" cat <<< "- -" yash-2.35/tests/prompt.y.out0000644000175000017500000000013012154557026016223 0ustar magicantmagicantposix PS1={$ } posix PS2={> } posix PS4={+ } yash PS1={\$ } yash PS2={> } yash PS4={+ } yash-2.35/tests/init.y.out0000644000175000017500000000165312154557026015660 0ustar magicantmagicant===== 1 ===== profile 1 file 1 profile 2 file 2 profile 3 main ===== 2 ===== profile 1 file 1 profile 2 file 2 profile 3 main ===== 3 ===== file 1 main ===== 4 ===== yashrc 1 file 1 yashrc 2 file 2 yashrc 3 main ===== 5 ===== yashrc 1 file 1 yashrc 2 file 2 yashrc 3 main ===== 6 ===== file 1 main ===== 7 ===== file 1 yashrc 1 file 1 yashrc 2 file 2 yashrc 3 main ===== 8 ===== profile 1 file 1 profile 2 file 2 profile 3 file 2 main ===== 9 ===== file 1 file 2 main ===== 10 ===== main ===== 11 ===== file 1 main ===== 12 ===== file 2 main ===== 13 ===== main ===== 14 ===== file 3 main ===== error 1 ===== error 1 error 2 error 2 expansion error $?=2 error 1 syntax error $?=258 error 1 expansion error $?=2 main ===== error 2 ===== error 1 error 2 error 2 expansion error $?=2 error 1 syntax error $?=258 error 1 expansion error $?=2 main ===== non-existing 1 ===== main ===== non-existing 2 ===== main ===== non-existing 3 ===== main yash-2.35/tests/job.p.out0000644000175000017500000000007412154557026015452 0ustar magicantmagicantecho wait ok echo wait 3 wait 0 echo wait 3 wait 1 wait 127 yash-2.35/tests/lineedit.y.tst0000644000175000017500000002660112154557026016515 0ustar magicantmagicant# lineedit.y.tst: yash-specific test of the bindkey/complete builtin # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp=$TESTTMP/lineedit.y.tmp mkdir "$tmp" echo ===== bindkey ===== bindkey -l | sort >"$tmp/l" sort <<\END | diff - "$tmp/l" noop alert self-insert insert-tab expect-verbatim digit-argument bol-or-digit accept-line abort-line eof eof-if-empty eof-or-delete accept-with-hash setmode-viinsert setmode-vicommand setmode-emacs expect-char abort-expect-char redraw-all clear-and-redraw-all forward-char backward-char forward-bigword end-of-bigword backward-bigword forward-semiword end-of-semiword backward-semiword forward-viword end-of-viword backward-viword forward-emacsword backward-emacsword beginning-of-line end-of-line go-to-column first-nonblank find-char find-char-rev till-char till-char-rev refind-char refind-char-rev delete-char delete-bigword delete-semiword delete-viword delete-emacsword backward-delete-char backward-delete-bigword backward-delete-semiword backward-delete-viword backward-delete-emacsword delete-line forward-delete-line backward-delete-line kill-char kill-bigword kill-semiword kill-viword kill-emacsword backward-kill-char backward-kill-bigword backward-kill-semiword backward-kill-viword backward-kill-emacsword kill-line forward-kill-line backward-kill-line put-before put put-left put-pop undo undo-all cancel-undo cancel-undo-all redo complete complete-next-candidate complete-prev-candidate complete-next-column complete-prev-column complete-next-page complete-prev-page complete-list complete-all complete-max clear-candidates vi-replace-char vi-insert-beginning vi-append vi-append-to-eol vi-replace vi-switch-case vi-switch-case-char vi-yank vi-yank-to-eol vi-delete vi-delete-to-eol vi-change vi-change-to-eol vi-change-line vi-yank-and-change vi-yank-and-change-to-eol vi-yank-and-change-line vi-substitute vi-append-last-bigword vi-exec-alias vi-edit-and-accept vi-complete-list vi-complete-all vi-complete-max vi-search-forward vi-search-backward emacs-transpose-chars emacs-transpose-words emacs-upcase-word emacs-downcase-word emacs-capitalize-word emacs-delete-horizontal-space emacs-just-one-space emacs-search-forward emacs-search-backward oldest-history newest-history return-history oldest-history-bol newest-history-bol return-history-bol oldest-history-eol newest-history-eol return-history-eol next-history prev-history next-history-bol prev-history-bol next-history-eol prev-history-eol srch-self-insert srch-backward-delete-char srch-backward-delete-line srch-continue-forward srch-continue-backward srch-accept-search srch-abort-search search-again search-again-rev search-again-forward search-again-backward beginning-search-forward beginning-search-backward END bindkey -v | sort >"$tmp/v" sort <<\END | diff - "$tmp/v" bindkey -v '\\' self-insert bindkey -v '\^V' expect-verbatim bindkey -v '\^J' accept-line bindkey -v '\^M' accept-line bindkey -v '\!' abort-line bindkey -v '\^C' abort-line bindkey -v '\#' eof-if-empty bindkey -v '\^D' eof-if-empty bindkey -v '\^[' setmode-vicommand bindkey -v '\^L' redraw-all bindkey -v '\R' forward-char bindkey -v '\L' backward-char bindkey -v '\H' beginning-of-line bindkey -v '\E' end-of-line bindkey -v '\X' delete-char bindkey -v '\B' backward-delete-char bindkey -v '\?' backward-delete-char bindkey -v '\^H' backward-delete-char bindkey -v '\^W' backward-delete-semiword bindkey -v '\$' backward-delete-line bindkey -v '\^U' backward-delete-line bindkey -v '\D' next-history-eol bindkey -v '\^N' next-history-eol bindkey -v '\U' prev-history-eol bindkey -v '\^P' prev-history-eol bindkey -v '\^I' complete-next-candidate bindkey -v '\bt' complete-prev-candidate END bindkey -v '\#' bindkey -v 'a' self-insert bindkey -v 'a' bindkey -v '\#' noop bindkey -v '\#' bindkey -v 'a' - bindkey -v 'a' 2>/dev/null; echo unbound 1 $? bindkey -v '\#' - bindkey -v '\#' 2>/dev/null; echo unbound 2 $? bindkey -v '\X' - bindkey -v '\X' 2>/dev/null; echo unbound 3 $? bindkey -v 'a' noop bindkey -v '\#' eof bindkey -v '\X' emacs-transpose-chars bindkey -v 'a' bindkey -v '\#' bindkey -v '\X' bindkey -v 'a' - bindkey -v '\\' - bindkey -v '\^V' - bindkey -v '\^J' - bindkey -v '\^M' - bindkey -v '\!' - bindkey -v '\^C' - bindkey -v '\#' - bindkey -v '\^D' - bindkey -v '\^[' - bindkey -v '\^L' - bindkey -v '\R' - bindkey -v '\L' - bindkey -v '\H' - bindkey -v '\E' - bindkey -v '\X' - bindkey -v '\B' - bindkey -v '\?' - bindkey -v '\^H' - bindkey -v '\^W' - bindkey -v '\$' - bindkey -v '\^U' - bindkey -v '\D' - bindkey -v '\^N' - bindkey -v '\U' - bindkey -v '\^P' - bindkey -v '\^I' - bindkey -v '\bt' - bindkey -v echo no bindings $? . "$tmp/v" bindkey --vi-insert | sort | diff - "$tmp/v" bindkey -a | sort >"$tmp/a" sort <<\END | diff - "$tmp/a" bindkey -a '\^[' noop bindkey -a '1' digit-argument bindkey -a '2' digit-argument bindkey -a '3' digit-argument bindkey -a '4' digit-argument bindkey -a '5' digit-argument bindkey -a '6' digit-argument bindkey -a '7' digit-argument bindkey -a '8' digit-argument bindkey -a '9' digit-argument bindkey -a '0' bol-or-digit bindkey -a '\^J' accept-line bindkey -a '\^M' accept-line bindkey -a '\!' abort-line bindkey -a '\^C' abort-line bindkey -a '\#' eof-if-empty bindkey -a '\^D' eof-if-empty bindkey -a '#' accept-with-hash bindkey -a 'i' setmode-viinsert bindkey -a '\I' setmode-viinsert bindkey -a '\^L' redraw-all bindkey -a 'l' forward-char bindkey -a ' ' forward-char bindkey -a '\R' forward-char bindkey -a 'h' backward-char bindkey -a '\L' backward-char bindkey -a '\B' backward-char bindkey -a '\?' backward-char bindkey -a '\^H' backward-char bindkey -a 'W' forward-bigword bindkey -a 'E' end-of-bigword bindkey -a 'B' backward-bigword bindkey -a 'w' forward-viword bindkey -a 'e' end-of-viword bindkey -a 'b' backward-viword bindkey -a '\H' beginning-of-line bindkey -a '$' end-of-line bindkey -a '\E' end-of-line bindkey -a '|' go-to-column bindkey -a '^' first-nonblank bindkey -a 'f' find-char bindkey -a 'F' find-char-rev bindkey -a 't' till-char bindkey -a 'T' till-char-rev bindkey -a ';' refind-char bindkey -a ',' refind-char-rev bindkey -a 'x' kill-char bindkey -a '\X' kill-char bindkey -a 'X' backward-kill-char bindkey -a 'P' put-before bindkey -a 'p' put bindkey -a 'u' undo bindkey -a 'U' undo-all bindkey -a '\^R' cancel-undo bindkey -a '.' redo bindkey -a 'r' vi-replace-char bindkey -a 'I' vi-insert-beginning bindkey -a 'a' vi-append bindkey -a 'A' vi-append-to-eol bindkey -a 'R' vi-replace bindkey -a '~' vi-switch-case-char bindkey -a 'y' vi-yank bindkey -a 'Y' vi-yank-to-eol bindkey -a 'd' vi-delete bindkey -a 'D' forward-kill-line bindkey -a 'c' vi-change bindkey -a 'C' vi-change-to-eol bindkey -a 'S' vi-change-line bindkey -a 's' vi-substitute bindkey -a '_' vi-append-last-bigword bindkey -a '@' vi-exec-alias bindkey -a 'v' vi-edit-and-accept bindkey -a '=' vi-complete-list bindkey -a '*' vi-complete-all bindkey -a '\\' vi-complete-max bindkey -a '?' vi-search-forward bindkey -a '/' vi-search-backward bindkey -a 'G' oldest-history-bol bindkey -a 'g' return-history-bol bindkey -a 'j' next-history-bol bindkey -a '+' next-history-bol bindkey -a '\D' next-history-bol bindkey -a '\^N' next-history-bol bindkey -a 'k' prev-history-bol bindkey -a -- '-' prev-history-bol bindkey -a '\U' prev-history-bol bindkey -a '\^P' prev-history-bol bindkey -a 'n' search-again bindkey -a 'N' search-again-rev END . "$tmp/a" bindkey --vi-command | sort | diff - "$tmp/a" bindkey -e | sort >"$tmp/e" sort <<\END | diff - "$tmp/e" bindkey -e '\\' self-insert bindkey -e '\^[\^I' insert-tab bindkey -e '\^Q' expect-verbatim bindkey -e '\^V' expect-verbatim bindkey -e '\^[0' digit-argument bindkey -e '\^[1' digit-argument bindkey -e '\^[2' digit-argument bindkey -e '\^[3' digit-argument bindkey -e '\^[4' digit-argument bindkey -e '\^[5' digit-argument bindkey -e '\^[6' digit-argument bindkey -e '\^[7' digit-argument bindkey -e '\^[8' digit-argument bindkey -e '\^[9' digit-argument bindkey -e '\^[-' digit-argument bindkey -e '\^J' accept-line bindkey -e '\^M' accept-line bindkey -e '\!' abort-line bindkey -e '\^C' abort-line bindkey -e '\#' eof-or-delete bindkey -e '\^D' eof-or-delete bindkey -e '\^[#' accept-with-hash bindkey -e '\^L' redraw-all bindkey -e '\R' forward-char bindkey -e '\^F' forward-char bindkey -e '\L' backward-char bindkey -e '\^B' backward-char bindkey -e '\^[f' forward-emacsword bindkey -e '\^[F' forward-emacsword bindkey -e '\^[b' backward-emacsword bindkey -e '\^[B' backward-emacsword bindkey -e '\H' beginning-of-line bindkey -e '\^A' beginning-of-line bindkey -e '\E' end-of-line bindkey -e '\^E' end-of-line bindkey -e '\^]' find-char bindkey -e '\^[\^]' find-char-rev bindkey -e '\X' delete-char bindkey -e '\B' backward-delete-char bindkey -e '\?' backward-delete-char bindkey -e '\^H' backward-delete-char bindkey -e '\^[d' kill-emacsword bindkey -e '\^[D' kill-emacsword bindkey -e '\^W' backward-kill-bigword bindkey -e '\^[\B' backward-kill-emacsword bindkey -e '\^[\?' backward-kill-emacsword bindkey -e '\^[\^H' backward-kill-emacsword bindkey -e '\^K' forward-kill-line bindkey -e '\$' backward-kill-line bindkey -e '\^U' backward-kill-line bindkey -e '\^X\B' backward-kill-line bindkey -e '\^X\?' backward-kill-line bindkey -e '\^Y' put-left bindkey -e '\^[y' put-pop bindkey -e '\^[Y' put-pop bindkey -e '\^_' undo bindkey -e '\^X\$' undo bindkey -e '\^X\^U' undo bindkey -e '\^[\^R' undo-all bindkey -e '\^[r' undo-all bindkey -e '\^[R' undo-all bindkey -e '\^I' complete-next-candidate bindkey -e '\bt' complete-prev-candidate bindkey -e '\^[=' complete-list bindkey -e '\^[?' complete-list bindkey -e '\^[*' complete-all bindkey -e '\^T' emacs-transpose-chars bindkey -e '\^[t' emacs-transpose-words bindkey -e '\^[T' emacs-transpose-words bindkey -e '\^[l' emacs-downcase-word bindkey -e '\^[L' emacs-downcase-word bindkey -e '\^[u' emacs-upcase-word bindkey -e '\^[U' emacs-upcase-word bindkey -e '\^[c' emacs-capitalize-word bindkey -e '\^[C' emacs-capitalize-word bindkey -e '\^[\\' emacs-delete-horizontal-space bindkey -e '\^[ ' emacs-just-one-space bindkey -e '\^S' emacs-search-forward bindkey -e '\^R' emacs-search-backward bindkey -e '\^[<' oldest-history-eol bindkey -e '\^[>' return-history-eol bindkey -e '\D' next-history-eol bindkey -e '\^N' next-history-eol bindkey -e '\U' prev-history-eol bindkey -e '\^P' prev-history-eol END . "$tmp/e" bindkey --emacs | sort | diff - "$tmp/e" bindkey -l >/dev/null; echo 1 $? bindkey -v >/dev/null; echo 2 $? bindkey -v '\^[' >/dev/null; echo 3 $? bindkey -v '\^[' setmode-viinsert; echo 4 $? for cmd in $(bindkey -l) do bindkey -v '!!!' $cmd || echo bindkey -v !!! $cmd $? bindkey -a '!!!' $cmd || echo bindkey -a !!! $cmd $? bindkey -e '!!!' $cmd || echo bindkey -e !!! $cmd $? done bindkey -v '!!!' - bindkey -a '!!!' - bindkey -e '!!!' - rm -fr "$tmp" echo ===== error ===== bindkey --no-such-option echo bindkey no-such-option $? bindkey --vi 2>/dev/null echo bindkey ambiguous-option 1 $? bindkey --vi 2>&1 | grep '^[^[:space:]]' # mind LIST_AMBIGUOUS_OPTIONS echo bindkey ambiguous-option 2 bindkey echo bindkey operand missing $? bindkey -v x y z echo bindkey too many operands 1 $? bindkey -l x echo bindkey too many operands 2 $? bindkey -v '\\' no-such-command echo bindkey invalid operand 1 $? bindkey -v '' abort-line echo bindkey invalid operand 2 $? bindkey -v '~~~' echo bindkey unbound sequence $? (bindkey -l >&- 2>/dev/null) echo bindkey output error 1 $? (bindkey -v >&- 2>/dev/null) echo bindkey output error 2 $? complete --no-such-option echo complete no-such-option $? complete echo complete not-completing $? yash-2.35/tests/expand.y.tst0000644000175000017500000001415712154557026016202 0ustar magicantmagicant# expand.y.tst: yash-specific test of word expansions # vim: set ft=sh ts=8 sts=4 sw=4 noet: [ ~+ = $PWD ] && echo \~+ cd . [ ~- = $OLDPWD ] && echo \~- var=123/456/789 asterisks='*****' echo expand.y.t${{asterisks#"**"}%"**"}st echo ${#$(echo a)} ${${`echo abc`#a}%c} [ x"${$+x}" != x"${$:+y}" ] && echo nest \$ + [ x"${$-x}" = x"${$:-y}" ] && echo nest \$ - [ x"${$=x}" = x"${$:=y}" ] && echo nest \$ = [ x"${$?x}" = x"${$:?y}" ] && echo nest \$ ? [ x"${$#x}" = x"${$##y}" ] && echo nest \$ \# [ x"${$%x}" = x"${$%%y}" ] && echo nest \$ % [ x"${$/x/y}" = x"${$:/x/y}" ] && echo nest \$ / set 1 22 333 echo \## length=${##} echo \#- length=${#-} ifunset=${#-""} echo \#? length=${#?} error=${#?error} echo \#+ ${#+} ${#:+} echo \#= ${#=} ${#:=} echo \#/ ${#/3/X} ${#:/3/X} echo \#% ${#%3} echo ${var/456/xxx} echo ${var/#123/xxx} ${var/#456/xxx} echo ${var/%789/xxx} ${var/%456/xxx} echo ${var//\//-} ${var//5//} ${var///-} echo ${var:/123*789/x} $INVOKE $TESTEE -c 'echo "${#*}"' x 1 22 333 4444 55555 $INVOKE $TESTEE -c 'echo "${#@}"' x 1 22 333 4444 55555 $INVOKE $TESTEE -c 'echo ${#*} ' x 1 22 333 4444 55555 $INVOKE $TESTEE -c 'echo ${#@} ' x 1 22 333 4444 55555 echo $((echo foo); (echo bar)) var=1-2-3 IFS= echo $var ${IFS:= -} $var unset IFS echo ===== 1 ===== echo "${var[2,4]}" echo "${var[3,3]}" "${var[3]}" echo "${var[4,3]}" echo "${var[0]}" echo "${var[@]}" "${var[*]}" ${var[#]} echo ===== 2 ===== echol () { typeset i # local for i; do printf "%s\n" "$i"; done } ary=(1 22 '3 3' 4" "4 5) echol "${ary}" -0- echol "${ary[@]}" -1- echol "${ary[*]}" -2- echol "${ary[#]}" -3- echol "${ary[1]}" -4- echol "${ary[2]}" -5- echol "${ary[3]}" -6- echol "${ary[4]}" -7- echol "${ary[5]}" -8- echol "${ary[1,3]}" -9- echol "${ary[2,4]}" -10- echol "${ary[3,5]}" -11- echol "${ary[4,6]}" -12- echol "${ary[5,7]}" -13- echol "${ary[6,8]}" -14- echol "${${ary}}" -20- echol "${${ary[3]}[1]}" -21- echol "${${ary[2,4]}[2]}" -22- echol ${ary} -30- echol ${ary[@]} -31- echo ===== 3 ===== set "$ary" unset -v ary echo "-$ary-" echol "${@}" -0- echol "${@[@]}" -1- echol "${@[*]}" -2- echol "${@[#]}" -3- echol "${@[1]}" -4- echol "${@[2]}" -5- echol "${@[3]}" -6- echol "${@[4]}" -7- echol "${@[5]}" -8- echol "${@[1,3]}" -9- echol "${@[2,4]}" -10- echol "${@[3,5]}" -11- echol "${@[4,6]}" -12- echol "${@[5,7]}" -13- echol "${@[6,8]}" -14- echol "${${@}}" -20- echol "${${@[3]}[1]}" -21- echol "${${@[2,4]}[2]}" -22- echol ${@} -30- echol ${@[@]} -31- echo ===== 4 ===== echol "${*}" -0- echol "${*[@]}" -1- echol "${*[*]}" -2- echol "${*[#]}" -3- echol "${*[1]}" -4- echol "${*[2]}" -5- echol "${*[3]}" -6- echol "${*[4]}" -7- echol "${*[5]}" -8- echol "${*[1,3]}" -9- echol "${*[2,4]}" -10- echol "${*[3,5]}" -11- echol "${*[4,6]}" -12- echol "${*[5,7]}" -13- echol "${*[6,8]}" -14- echol "${${*}}" -20- echol "${${*[3]}[1]}" -21- echol "${${*[2,4]}[2]}" -22- echol ${*} -30- echol ${*[@]} -31- echo ===== 5 ===== echol "${@[1 + (4 / 2), 5 - 1]}" echo ===== 6 ===== ary=('' '' '') printf '[%s]' "${ary[@]}"; echo echo - ${ary[1]=1} ${ary[2]=2} ${ary[3]=3} echo - ${ary[1]:=1} printf '[%s]' "${ary[@]}"; echo echo - ${ary[2]:=2} echo - ${ary[1]:=X} printf '[%s]' "${ary[@]}"; echo readonly ary ( echo - ${ary[3]:=3} ) 2>/dev/null [ $? -ne 0 ]; echo $? printf '[%s]' "${ary[@]}"; echo export ary env | grep ^ary= echo ===== 7 ===== s=abcd echo $s ${s[@]} ${s[*]} ${s[#]} echo ${s[0]} . ${s[1]} ${s[2]} ${s[3]} ${s[4]} . ${s[5]} echo ${s[-0]} . ${s[-1]} ${s[-2]} ${s[-3]} ${s[-4]} . ${s[-5]} echo === a === echo ${s[0,0]} . ${s[0,1]} ${s[0,2]} ${s[0,3]} ${s[0,4]} . ${s[0,5]} echo ${s[1,0]} . ${s[1,1]} ${s[1,2]} ${s[1,3]} ${s[1,4]} . ${s[1,5]} echo ${s[2,0]} . ${s[2,1]} ${s[2,2]} ${s[2,3]} ${s[2,4]} . ${s[2,5]} echo ${s[3,0]} . ${s[3,1]} ${s[3,2]} ${s[3,3]} ${s[3,4]} . ${s[3,5]} echo ${s[4,0]} . ${s[4,1]} ${s[4,2]} ${s[4,3]} ${s[4,4]} . ${s[4,5]} echo ${s[5,0]} . ${s[5,1]} ${s[5,2]} ${s[5,3]} ${s[5,4]} . ${s[5,5]} echo ${s[-0,0]} . ${s[-0,1]} ${s[-0,2]} ${s[-0,3]} ${s[-0,4]} . ${s[-0,5]} echo ${s[-1,0]} . ${s[-1,1]} ${s[-1,2]} ${s[-1,3]} ${s[-1,4]} . ${s[-1,5]} echo ${s[-2,0]} . ${s[-2,1]} ${s[-2,2]} ${s[-2,3]} ${s[-2,4]} . ${s[-2,5]} echo ${s[-3,0]} . ${s[-3,1]} ${s[-3,2]} ${s[-3,3]} ${s[-3,4]} . ${s[-3,5]} echo ${s[-4,0]} . ${s[-4,1]} ${s[-4,2]} ${s[-4,3]} ${s[-4,4]} . ${s[-4,5]} echo ${s[-5,0]} . ${s[-5,1]} ${s[-5,2]} ${s[-5,3]} ${s[-5,4]} . ${s[-5,5]} echo === b === echo ${s[0,-0]} . ${s[0,-1]} ${s[0,-2]} ${s[0,-3]} ${s[0,-4]} . ${s[0,-5]} echo ${s[1,-0]} . ${s[1,-1]} ${s[1,-2]} ${s[1,-3]} ${s[1,-4]} . ${s[1,-5]} echo ${s[2,-0]} . ${s[2,-1]} ${s[2,-2]} ${s[2,-3]} ${s[2,-4]} . ${s[2,-5]} echo ${s[3,-0]} . ${s[3,-1]} ${s[3,-2]} ${s[3,-3]} ${s[3,-4]} . ${s[3,-5]} echo ${s[4,-0]} . ${s[4,-1]} ${s[4,-2]} ${s[4,-3]} ${s[4,-4]} . ${s[4,-5]} echo ${s[5,-0]} . ${s[5,-1]} ${s[5,-2]} ${s[5,-3]} ${s[5,-4]} . ${s[5,-5]} echo ${s[-0,-0]} . ${s[-0,-1]} ${s[-0,-2]} ${s[-0,-3]} ${s[-0,-4]} . ${s[-0,-5]} echo ${s[-1,-0]} . ${s[-1,-1]} ${s[-1,-2]} ${s[-1,-3]} ${s[-1,-4]} . ${s[-1,-5]} echo ${s[-2,-0]} . ${s[-2,-1]} ${s[-2,-2]} ${s[-2,-3]} ${s[-2,-4]} . ${s[-2,-5]} echo ${s[-3,-0]} . ${s[-3,-1]} ${s[-3,-2]} ${s[-3,-3]} ${s[-3,-4]} . ${s[-3,-5]} echo ${s[-4,-0]} . ${s[-4,-1]} ${s[-4,-2]} ${s[-4,-3]} ${s[-4,-4]} . ${s[-4,-5]} echo ${s[-5,-0]} . ${s[-5,-1]} ${s[-5,-2]} ${s[-5,-3]} ${s[-5,-4]} . ${s[-5,-5]} echo ===== 8 ===== a=(a b c d) echo "$a" "${a[@]}" "${a[*]}" "${a[#]}" echo ${a[0]} . ${a[1]} ${a[2]} ${a[3]} ${a[4]} . ${a[5]} echo ${a[-0]} . ${a[-1]} ${a[-2]} ${a[-3]} ${a[-4]} . ${a[-5]} for i in 0 1 2 3 4 5 -0 -1 -2 -3 -4 -5; do for j in 0 1 2 3 4 5 -1 -2 -3 -4 -5 -0; do echo "\${a[$i,$j]} = ${a[$i,$j]}" done done echo ===== 9 ===== set -o braceexpand echo {1..9 {1.9} 1..9} echo {1..9} echo {9..11} echo {111..123} echo {9..1} echo {11..9} echo {123..111} echo {1..5..2} echo {1..19..3} echo {1..2..3} echo {1..1..1} echo {0..0..0} echo {5..1..-2} echo {19..1..-3} echo {1..1..-1} echo {-11..-19..-2} echo a{1..4}b echo a{1,2,3,4,,555}b echo a{1,2}b{3,4}c echo a{b{1,2}c,3}d echo a{b{1..2}c,3}d echo {1,,2} echo a{1\'\\\"2,3}b echo \{1,2,3} {4,5,6\} echo a{,}b echo ===== 10 ===== x=1 echo pre/postfix $((x++)) $((++x)) $((x--)) $((--x)) $((x)) yash-2.35/tests/redir.y.out0000644000175000017500000000031612154557026016015 0ustar magicantmagicant===== unclosed here-documents ===== 1 2 3 a4 b 5 c 6 c ok ===== pipe redirection ===== 4-3 4-6 5-3 5-6 5-4 3-6 3-4 1 2 3 4 5 ===== command redirection ===== 1 2 3 4 5 0 ===== here-string ===== 123 foo - - yash-2.35/tests/builtin.y.out0000644000175000017500000000371512154557026016364 0ustar magicantmagicant===== return break continue ===== return 10 return 11 break ok 2 break ok continue 1 continue ok continue 2 continue ok ===== eval ===== -i 1 2 1 2 1 2 4 1 2 break ok 1 2 continue ok 4 status1=0 status2=3 1 0 2 0 3 4 0 5 0 6 0 7 7-2 8 8-2 0 ===== . ===== -1 2 3- -- returning -- returning -- 0 -a b c- script1 dir/script1 dir/script2 ===== command ===== if: a shell keyword then: a shell keyword else: a shell keyword elif: a shell keyword fi: a shell keyword do: a shell keyword done: a shell keyword case: a shell keyword esac: a shell keyword while: a shell keyword until: a shell keyword for: a shell keyword function: a shell keyword {: a shell keyword }: a shell keyword !: a shell keyword in: a shell keyword command: no such command `_no_such_command_' 1 :: a special built-in .: a special built-in break: a special built-in continue: a special built-in eval: a special built-in exec: a special built-in exit: a special built-in export: a special built-in readonly: a special built-in return: a special built-in set: a special built-in shift: a special built-in times: a special built-in trap: a special built-in unset: a special built-in bg: a semi-special built-in cd: a semi-special built-in command: a semi-special built-in false: a semi-special built-in fg: a semi-special built-in getopts: a semi-special built-in jobs: a semi-special built-in kill: a semi-special built-in pwd: a semi-special built-in read: a semi-special built-in true: a semi-special built-in umask: a semi-special built-in wait: a semi-special built-in command: no such command `sh' ok echo command -b eval = 0 command -b cat = 127 command -e ls = 0 command -e exit 50 = 127 command exit 10 = 10 command -f testreg = 1 command -f echo = 127 command -vb cat = 1 command -ve exit = 1 cd: an alias for `cd_alias' alias cd='cd_alias' 1 =1= cd: a semi-special built-in =2= if: a shell keyword type: no such command `cd' slash a b C C 7 127 ===== exec ===== sh sh bar=456 baz=7:8:9 foo=123 bar=456 baz=7:8:9 foo=123 yash-2.35/tests/error.y.tst0000644000175000017500000002673412154557026016060 0ustar magicantmagicant# error.y.tst: yash-specific test of error handling # vim: set ft=sh ts=8 sts=4 sw=4 noet: # error tests for alias/unalias are in alias.y.tst # error tests for array are in array.y.tst # error tests for help are in help.y.tst # error tests for fg/bg are in job.y.tst # error tests for fc/history are in history.y.tst # error tests for pushd/popd/dirs are in dirstack.y.tst echo ===== consequences of shell errors ===== echo ===== consequences of shell errors ===== >&2 $INVOKE $TESTEE <<\END fi echo not printed END echo syntax error non-interactive $? cat >"${TESTTMP}/error.y.tmp" <<\END echo ok fi echo not reached END $INVOKE $TESTEE -i +m --norcfile 2>/dev/null <<\END return -n 1000 fi echo syntax error interactive mainshell $? x=$(. "${TESTTMP}/error.y.tmp") echo syntax error interactive subshell $? "[$x]" END rm -- "${TESTTMP}/error.y.tmp" $INVOKE $TESTEE <<\END . echo special builtin syntax error $? END $INVOKE $TESTEE <<\END getopts echo non-special builtin syntax error $? END $INVOKE $TESTEE <<\END exec 3>&- { exit >&3; } 2>/dev/null echo special builtin redirection error $? END $INVOKE $TESTEE <<\END exec 3>&- { cd . >&3; } 2>/dev/null echo non-special builtin redirection error $? END $INVOKE $TESTEE <<\END readonly ro=v ro=v : echo special builtin assignment error $? END $INVOKE $TESTEE <<\END readonly ro=v ro=v cd . echo non-special builtin assignment error $? END $INVOKE $TESTEE <<\END unset var eval ${var?} echo not printed END echo special builtin expansion error non-interactive $? $INVOKE $TESTEE -i +m --norcfile 2>/dev/null <<\END unset var eval ${var?} echo special builtin expansion error interactive mainshell $? ( eval ${var?} echo not reached ) echo special builtin expansion error interactive subshell $? END $INVOKE $TESTEE <<\END unset var cd ${var?} echo not printed END echo non-special builtin expansion error non-interactive $? $INVOKE $TESTEE -i +m --norcfile 2>/dev/null <<\END unset var cd ${var?} echo non-special builtin expansion error interactive mainshell $? ( cd ${var?} echo not reached ) echo non-special builtin expansion error interactive subshell $? END $INVOKE $TESTEE <<\END { ./no/such/command; } 2>/dev/null echo command not found error $? END echo ===== invocation ===== echo ===== invocation ===== >&2 $INVOKE $TESTEE -c echo -c $? $INVOKE $TESTEE -c -s echo -c and -s 1 $? $INVOKE $TESTEE -cs echo -c and -s 2 $? $INVOKE $TESTEE --cmdlin --stdi echo -c and -s 3 $? $INVOKE $TESTEE -o cmdlin -o stdi echo -c and -s 4 $? $INVOKE $TESTEE -c ++cmd-lin -o std_i <<\END echo this is not an error END echo -c and -s 5 $? $INVOKE $TESTEE --norc=file echo invalid option argument 1 $? $INVOKE $TESTEE --profile echo missing argument profile $? $INVOKE $TESTEE --rcfile echo missing argument rcfile $? $INVOKE $TESTEE --p 2>/dev/null echo ambiguous option $? echo ===== option ===== echo ===== option ===== >&2 # Tests of option ambiguity are in lineedit.y.tst # because option ambiguity occurs in the complete and bindkey built-ins only. exec -a echo option missing argument short $? exec --as echo option missing argument long $? exec -c- echo option no-such-option 1 $? exec -cXaY echo option no-such-option 2 $? exec --no-such-option echo option no-such-option 3 $? exec --cle=1 echo option invalid option argument $? echo ===== set ===== echo ===== set ===== >&2 set -c echo set -c $? set -i echo set -i $? set -l echo set -l $? set -s echo set -s $? set -V echo set -V $? set --cmdl echo set --cmdline $? set --interactive echo set --interactive $? set -o log-in echo set --login $? set --stdin echo set --stdin $? set --version echo set --version $? set --no-such-option echo set no-such-option 1 $? set -o no-such-option echo set no-such-option 2 $? (set >&- 2>/dev/null) echo set output error $? set --cu 2>/dev/null echo set ambiguous option 1 $? set --noh 2>/dev/null echo set ambiguous option 2 $? set -o nolog +o nolog -o echo set missing argument $? set -C- echo set invalid option 1 $? set -aXb echo set invalid option 2 $? $INVOKE $TESTEE --version=X echo set unexpected option argument $? echo ===== cd ===== echo ===== cd ===== >&2 cd --no-such-option echo cd no-such-option $? cd / / echo cd too-many-operands $? cd ./no/such/dir 2>/dev/null echo cd no-such-dir $? ( cd / (unset OLDPWD; cd -) echo cd no OLDPWD $? (unset HOME; cd) echo cd no HOME $? (cd - >&- 2>/dev/null) echo cd output error $? ) echo ===== pwd ===== echo ===== pwd ===== >&2 pwd --no-such-option echo pwd no-such-option $? pwd foo echo pwd invalid operand $? (pwd >&- 2>/dev/null) echo pwd output error $? echo ===== hash ===== echo ===== hash ===== >&2 hash --no-such-option echo hash no-such-option $? hash -a operand echo hash invalid operand $? hash ./no/such/command echo hash slash argument $? (PATH=; hash no_such_command) echo hash command not found $? hash ls (hash >&- 2>/dev/null) echo hash output error $? echo ===== umask ===== echo ===== umask ===== >&2 umask --no-such-option echo umask no-such-option $? umask too-many operands echo umask too-many-operands $? (umask >&- 2>/dev/null) echo umask output error $? echo ===== typeset ===== echo ===== typeset ===== >&2 typeset --no-such-option echo typeset no-such-option $? typeset -f -x foo echo typeset invalid-option-combination 1 $? typeset -f -X foo echo typeset invalid-option-combination 2 $? typeset -x -X foo echo typeset invalid-option-combination 3 $? (typeset >&- 2>/dev/null) echo typeset output error 1 $? (typeset -p >&- 2>/dev/null) echo typeset output error 2 $? (typeset -p PWD >&- 2>/dev/null) echo typeset output error 3 $? func() { :; } (typeset -f >&- 2>/dev/null) echo typeset output error 4 $? (typeset -fp >&- 2>/dev/null) echo typeset output error 5 $? (typeset -fp func >&- 2>/dev/null) echo typeset output error 6 $? typeset -r readonly=readonly typeset -r readonly=readonly echo typeset readonly $? echo ===== unset ===== echo ===== unset ===== >&2 unset --no-such-option echo unset no-such-option $? readonly -f func unset readonly echo unset readonly variable $? unset -f func echo unset readonly function $? echo ===== shift ===== echo ===== shift ===== >&2 shift --no-such-option echo shift no-such-option $? shift 10000 echo shift shifting too many $? echo ===== getopts ===== echo ===== getopts ===== >&2 getopts --no-such-option echo getopts no-such-option $? getopts echo getopts operands missing 1 $? getopts a echo getopts operands missing 2 $? getopts a:: var echo getopts invalid opt $? getopts abc var=iable echo getopts invalid var $? echo ===== read ===== echo ===== read ===== >&2 read --no-such-option echo read no-such-option $? read echo read operands missing $? read read <&- 2>/dev/null echo read input closed $? read foo b=r baz echo read invalid identifier $? echo ===== trap ===== echo ===== trap ===== >&2 trap --no-such-option echo trap no-such-option $? trap foo echo trap operands missing $? trap '' KILL echo trap KILL $? trap '' STOP echo trap STOP $? (trap 'echo trap' INT TERM; trap >&- 2>/dev/null) echo trap output error 1 $? (trap 'echo trap' INT TERM; trap -p >&- 2>/dev/null) echo trap output error 2 $? (trap 'echo trap' INT TERM; trap -p INT >&- 2>/dev/null) echo trap output error 3 $? trap '' NO-SUCH-SIGNAL echo trap no-such-signal $? echo ===== kill ===== echo ===== kill ===== >&2 kill --no-such-option echo kill no-such-option $? kill -l -n 0 echo kill invalid-option-combination l n $? kill -l -s INT echo kill invalid-option-combination l s $? kill echo kill operands missing $? kill -l 0 echo kill no-such-signal $? kill %100 echo kill no-such-job $? (kill -l >&- 2>/dev/null) echo kill output error 1 $? (kill -l HUP >&- 2>/dev/null) echo kill output error 2 $? echo ===== jobs kill ===== echo ===== jobs kill ===== >&2 jobs --no-such-option echo jobs no-such-option $? while kill -0 $$; do sleep 1; done 2>/dev/null& (jobs >&- 2>/dev/null) echo jobs output error $? jobs %100 echo jobs no-such-job 1 $? jobs %no_such_job echo jobs no-such-job 2 $? kill %while echo ===== wait ===== echo ===== wait ===== >&2 wait --no-such-option echo wait no-such-option $? wait %100 echo wait no-such-job 1 $? wait %no_such_job echo wait no-such-job 2 $? echo ===== return ===== echo ===== return ===== >&2 ( return --no-such-option echo return no-such-option $? ) ( return foo echo not printed ) echo return invalid operand 1 $? ( return -- -3 echo not printed ) echo return invalid operand 2 $? ( return 1 2 echo return too many operands $? ) $INVOKE $TESTEE -i +m --norcfile 3>&2 2>/dev/null <<\END PS1= exec 2>&3 return echo return reached END echo ===== break ===== echo ===== break ===== >&2 break --no-such-option echo break no-such-option $? ( break 1 foo echo break invalid operand 1 $? ) ( break echo break not in loop $? ) ( break -i echo break not in iteration $? ) ( break -i foo echo break invalid operand 2 $? ) echo ===== continue ===== echo ===== continue ===== >&2 continue --no-such-option echo continue no-such-option $? ( continue 1 foo echo continue invalid operand 1 $? ) ( continue echo continue not in loop $? ) ( continue -i echo continue not in iteration $? ) ( continue -i foo echo continue invalid operand 2 $? ) echo ===== eval ===== echo ===== eval ===== >&2 eval --no-such-option echo eval no-such-option $? echo ===== dot ===== echo ===== dot ===== >&2 . --no-such-option echo dot no-such-option $? . echo dot operand missing $? ( PATH= . no_such_command 2>/dev/null echo not printed ) echo dot script not found in PATH $? ( . "$TESTTMP/no/such/file" 2>/dev/null echo not printed ) echo dot file-not-found $? echo ===== exec ===== echo ===== exec ===== >&2 ( exec --no-such-option echo exec no-such-option $? ) ( PATH= exec no_such_command echo not printed ) 2>/dev/null echo exec command not found $? echo ===== command ===== echo ===== command ===== >&2 command --no-such-option echo command no-such-option $? command -a foo echo command invalid-option 1 $? command -k foo echo command invalid-option 2 $? (command -v command >&- 2>/dev/null) echo command output error $? (PATH=; command no_such_command) echo command no-such-command 1 $? echo =1= >&2 (PATH=; command -v no_such_command) echo command no-such-command 2 $? echo =2= >&2 (PATH=; command -V no_such_command) echo command no-such-command 3 $? echo ===== times ===== echo ===== times ===== >&2 times --no-such-option echo times no-such-option $? times foo echo times invalid operand $? (times >&- 2>/dev/null) echo times output error $? echo ===== exit ===== echo ===== exit ===== >&2 ( exit --no-such-option echo exit no-such-option $? ) ( exit foo echo not printed ) echo exit invalid operand 1 $? ( exit -- -3 echo not printed ) echo exit invalid operand 2 $? ( exit 1 2 echo exit too many operands $? ) echo ===== suspend ===== echo ===== suspend ===== >&2 suspend --no-such-option echo suspend no-such-option $? suspend foo echo suspend invalid operand $? echo ===== ulimit ===== echo ===== ulimit ===== >&2 if type ulimit 2>/dev/null | grep -q '^ulimit: a regular built-in'; then ulimit --no-such-option 2>/dev/null echo ulimit no-such-option $? ulimit -a -f echo ulimit invalid option $? (ulimit >&- 2>/dev/null) echo ulimit output error $? ulimit xxx echo ulimit invalid operand $? ulimit 0 0 echo ulimit too many operands 1 $? ulimit -a 0 echo ulimit too many operands 2 $? else cat <<\END ulimit no-such-option 2 ulimit invalid option 2 ulimit output error 1 ulimit invalid operand 2 ulimit too many operands 1 2 ulimit too many operands 2 2 END cat >&2 <<\END ulimit: the -a option cannot be used with the -f option ulimit: `xxx' is not a valid integer ulimit: too many operands are specified ulimit: no operand is expected END fi yash-2.35/tests/expand.p.tst0000644000175000017500000001211312154557026016157 0ustar magicantmagicant# expand.p.tst: test of word expansions for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: echol () for i do printf "%s\n" "$i"; done echo ===== tilde expansion ===== HOME=/tmp/home [ ~ = $HOME ] && echo \$HOME path=~:~ [ $path = $HOME:$HOME ] && echo path=~:~ echo \~home ~h\ome ~\/dir ~/\dir echo ===== parameter expansion ===== var=123/456/789 asterisks='*****' null= space=' ' unset unset echo $var ${var} "$var" "${var}" echo 1 $null 2 echo 1 "$null" 2 echo 1 $space 2 echo 1 "$space" 2 echol 1 -$null- 2 echol 1 "-$null-" 2 echol 1 -$space- 2 echol 1 "-$space-" 2 echo ${unset-"unset variable"} and ${var+"set variable"} echo 1 ${null:-null variable} 2 ${null:+null variable} 3 echo 1 ${unset-} 2 "${unset-}" 3 echo 1 ${unset-""} 2 "${unset-""}" 3 echo 1 ${unset-unset var} 2 "${unset-unset var}" 3 echo 1 ${unset-"unset var"} 2 echo 1 ${var+} 2 "${var+}" 3 echo 1 ${var+""} 2 "${var+""}" 3 echo 1 ${var+set var} 2 "${var+set var}" 3 echo 1 ${var+"set var"} 2 (: ${unset?"unset variable error"}) 2>&1 | grep "unset variable error" >/dev/null && echo "unset variable error" (: ${null:?"null variable error"}) 2>&1 | grep "null variable error" >/dev/null && echo "null variable error" echo ${var?} "${null?}" ${var:?} (: ${unset?}) 2>/dev/null || echo unset echo ${var=var} ${var:=VAR} echo ${null=null} ${null:=NULL} echo ${unset=UNSET} echo $var $null $unset echo ${var#*/} ${var##*/} ${var%/*} ${var%%/*} echo ${var#*/*} ${var##*/*} ${var%*/*} ${var%%*/*} echo ${var#x} ${var##x} ${var%x} ${var%%x} echo ${asterisks##*} "${asterisks#\*}" echo '${#var}='${#var} set 1 '2 2' 3 :& echo "$@" "$*" $# $? $- $! $0 >"${TESTTMP}/expand-1" echo "${@}" "${*}" ${#} ${?} ${-} ${!} ${0} >"${TESTTMP}/expand-2" diff "${TESTTMP}/expand-1" "${TESTTMP}/expand-2" rm -f "${TESTTMP}/expand-1" "${TESTTMP}/expand-2" echo ===== command substitution ===== echo '\$x' echo `echo '\$x'` echo $(echo '\$x') echo $( echo ')' ) echo $( echo abc # a comment with ) ) echo $( cat <<\eof a here-doc with ) eof ) cat <<\eof - $( cat <<-\end /dev/null end ) another here-doc eof echo ===== arithmetic expansion ===== x=1 echo $(( $(echo 3) + $x + "x" )) "$((\x + "x" + 'x'))" echo prefix $((+-+-5)) $((~~10)) $((!0)) $((!1)) $((!-1)) echo multiplicatives $((20*5/7%3)) echo additives $((5+7-3)) echo shifts $((10<<3>>2)) echo comparisons $((-1< -1)) $((-1< 0)) $((-1< 1)) \ $(( 0< -1)) $(( 0< 0)) $(( 0< 1)) \ $(( 1< -1)) $(( 1< 0)) $(( 1< 1)) echo comparisons $((-1<=-1)) $((-1<=0)) $((-1<=1)) \ $(( 0<=-1)) $(( 0<=0)) $(( 0<=1)) \ $(( 1<=-1)) $(( 1<=0)) $(( 1<=1)) echo comparisons $((-1> -1)) $((-1> 0)) $((-1> 1)) \ $(( 0> -1)) $(( 0> 0)) $(( 0> 1)) \ $(( 1> -1)) $(( 1> 0)) $(( 1> 1)) echo comparisons $((-1>=-1)) $((-1>=0)) $((-1>=1)) \ $(( 0>=-1)) $(( 0>=0)) $(( 0>=1)) \ $(( 1>=-1)) $(( 1>=0)) $(( 1>=1)) echo equalities $((-1==-1)) $((-1==0)) $((-1==1)) \ $(( 0==-1)) $(( 0==0)) $(( 0==1)) \ $(( 1==-1)) $(( 1==0)) $(( 1==1)) echo equalities $((-1!=-1)) $((-1!=0)) $((-1!=1)) \ $(( 0!=-1)) $(( 0!=0)) $(( 0!=1)) \ $(( 1!=-1)) $(( 1!=0)) $(( 1!=1)) echo logicals $((0&&0)) $((0&&2)) $((2&&0)) $((2&&2)) echo logicals $((0||0)) $((0||2)) $((2||0)) $((2||2)) echo logicals $((2&&(x=2))) $((0&&(x+=1))) $((x)) echo logicals $((0||(x=1))) $((2||(x+=1))) $((x)) echo conditionals $((1?2:3)) $((0?1:2)) $((1?9:(x=0))) $((0?x=0:9)) $((x)) echo assignments $((x=0)) $((x+=5)) $((x-=2)) $((x*=8)) $((x/=6)) \ $((x<<=2)) $((x>>=1)) $((x|=7)) $((x^=5)) $((x&=3)) $((x)) echo parentheses $(((x))) $((-(x))) $(((1+2)*3)) echo mul-add $((2*3+24/6-19%10)) echo add-shift $((2+3<<4)) $((50-2>>4)) echo shift-comp $((5<3<<1)) $((16>>1>10)) echo comp-equal $((1>2==3>=4)) $((1<2!=3<=4)) echo equal-and $((15&0==0)) $((0==0&15)) echo and-xor $((1&2^15)) $((15^2&1)) echo xor-or $((1^1|1)) $((1|1^1)) echo or-land $((3|0&&1)) $((1&&0|3)) echo land-lor $((0&&0||1)) $((1||0&&0)) echo lor-cond-assign $((0||1?2||0:0||0)) $((0||0?2||0:0||0)) \ $((0||1?1||0?x=2?3:4:5:6)) $((x)) $((0?y:x=1)) $((x)) \ $((x=0?1:2?3:4?5:6)) $((x)) echo $(((1*(2+3)<<(x&&x||0/0)))) unset unset $INVOKE $TESTEE -c 'echo unset-var $((0+unset+0)) $((unset))' echo ===== field splitting ===== unset foo bar IFS echo +${foo-1+2}+${bar-3+4}+ echo +${foo-1 2 +3}+${bar-4+ 5+ +6}+ IFS=" +" echo +${foo-1+2}+${bar-3+4}+ echo +${foo-1 2 +3}+${bar-4+ 5+ +6}+ set $foo bar '' xyz ''$foo'' abc for i do echo "-$i-"; done IFS=/ echo ~ echo ${foo-~} IFS='\' bar='1\2\3' echol ${foo-1\\\\2'\'3"\\"4} echol "${foo-1\\2}" echol [ $bar ] IFS=, echol ${foo-4,5\,6} echol "${foo-4,5\,6}" IFS=0 echol $(echo 'command0subst') echol $((99+2)) echo ===== IFS=" " set "" "" "" echol [ "$@" ] set 1 "" "" "" 5 echol [ "$@" ] echol [ $@ ] set -- "$@" echol [ "$@" ] set -- $@ echol [ "$@" ] echol [ "" "" ] echol [ '' '' ] echol [ """" ] echol [ '''' ] set "" echol [ "$@" ] echol [ "-$@-" ] set -- echol [ "$@" ] echol [ "-$@-" ] echo ===== set 1 '2 2' 3 echo $* echo "$*" IFS="" echo "$*" yash-2.35/tests/invoke.d0000644000175000017500000000002312154557026015343 0ustar magicantmagicantinvoke.o: invoke.c yash-2.35/tests/help.y.err0000644000175000017500000000011412154557026015615 0ustar magicantmagicanthelp: `--no-such-option' is not a valid option help: no such built-in `XXX' yash-2.35/tests/input.y.t0000644000175000017500000000032012154557026015476 0ustar magicantmagicantPS1='% ' exec 2>&3 PROMPT_COMMAND='echo prompt_command >&2' (exit \ 1) echo $? unset PROMPT_COMMAND PS1='${PWD##"${PWD}"}$(echo \?) ' PS1='! !! $ ' PS1='\a \e \n \r \\ $ ' PS1='$ ' PS2='\\ > ' echo \ ok PS1= yash-2.35/tests/sig.y.out0000644000175000017500000000204212154557026015470 0ustar magicantmagicant===== kill ===== kill 1 0 kill 2 0 kill 3 0 kill 4 0 kill 5 0 kill 6 0 kill 7 0 kill 8 0 kill 9 0 kill 10 0 kill 11 0 kill 12 0 kill 13 0 kill 14 0 kill 15 0 kill 16 0 kill 17 0 kill 18 0 kill 19 0 kill 20 0 kill 21 0 kill 22 0 kill 23 0 kill 24 0 kill 25 0 kill 26 0 QUIT KILL TERM kill 27 0 kill 28 0 kill 29 0 kill 30 0 kill 31 0 kill 32 0 kill 33 0 kill 34 0 kill 35 0 kill 36 0 ===== trap ===== trap 1 0 trap 2 0 USR1 trap -- 'echo trapped' USR1 trap -- '' USR2 trap 3 0 trap 4 0 EXIT 1 EXIT 2 EXIT 3 EXIT 4 EXIT 5 EXIT 6 EXIT 7 EXIT 8 EXIT 9 EXIT 10 EXIT 11 EXIT 12 ===== signals ===== INT ignored TERM ignored QUIT ignored INT 0 TERM QUIT 0 ===== signals +i +m F ===== ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 CHLD 0 URG 0 ===== signals -i +m F ===== ABRT ALRM BUS FPE HUP ILL KILL PIPE SEGV USR1 USR2 CHLD 0 URG 0 ===== signals +i +m T ===== ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 CHLD 0 URG 0 ===== signals -i +m T ===== ABRT ALRM BUS FPE HUP ILL KILL PIPE QUIT SEGV TERM USR1 USR2 CHLD 0 URG 0 INT yash-2.35/tests/builtin.p.tst0000644000175000017500000001032312154557026016347 0ustar magicantmagicant# builtin.p.tst: test of builtins for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: savepath=$PATH echo ===== : true false ===== : echo $? true echo $? ! false # "false" may return any non-zero status echo $? ( # a function may override a non-special builtin false () { true; } if false; then echo false true; fi # a non-regular builtin should be executed if not in PATH PATH= if : && true && false; then PATH=$savepath echo : true false else PATH=$savepath fi ) echo ===== return break continue ===== retfunc () { return 3 echo retfunc ng } retfunc echo $? retfunc () { (exit 4) return echo retfunc ng 2 } retfunc echo $? retfunc () { retfunc_inner () { return $1 } retfunc_inner 5 retfunc_inner=$? echo retfunc return $retfunc_inner } retfunc echo $? while true; do echo while ok break echo while ng done until false; do echo until ok break echo until ng done for i in 1 2 3 4; do echo for $i break echo for ng done i=0 while [ $i -eq 0 ]; do echo while $i i=1 continue echo while ng done i=0 until [ $i -ne 0 ]; do echo until $i i=1 continue echo until ng done for i in 1 2 3 4; do echo for $i continue echo for ng done for i in 1 2 3; do for j in 7 8 9; do echo $i $j if [ $i -eq 3 ]; then break 2 elif [ $j -eq 8 ]; then continue 2 fi done done k=0 for i in 1 2 3; do if true; then while true; do until false; do case $i in 1) for j in 7 8 9; do echo $i $j $k if [ $k -ne 0 ]; then break 3 fi k=1 done continue 3 ;; 2) while true; do until false; do echo i=2 break 4 done done ;; *) echo i=3 break 999 esac done done fi echo ! done echo done echo ===== exit ===== $INVOKE $TESTEE <<\END r () { return $1; } trap 'r 10' EXIT exit END echo exit 1 $? $INVOKE $TESTEE <<\END r () { return $1; } trap 'r 10' EXIT exit 20 END echo exit 2 $? $INVOKE $TESTEE <<\END r () { return $1; } trap 'r 10; exit' EXIT exit END echo exit 3 $? $INVOKE $TESTEE <<\END r () { return $1; } trap 'r 10; exit' EXIT exit 20 END echo exit 4 $? $INVOKE $TESTEE <<\END r () { return $1; } trap 'r 10; exit 30' EXIT exit END echo exit 5 $? $INVOKE $TESTEE <<\END r () { return $1; } trap 'r 10; exit 30' EXIT exit 20 END echo exit 6 $? echo ===== . ===== . ./dot.t echo $count echo ===== command ===== echo () { :; } command echo ok unset -f echo PATH= command -p echo PATH= PATH=$savepath case "$(command -v echo)" in /*/echo | /echo ) ;; * ) echo "\$(command -v echo) = $(command -v echo)" esac case "$(command -v ./invoke)" in /*/invoke ) ;; * ) echo "\$(command -v ./invoke) = $(command -v ./invoke)" esac if PATH= command -v _no_such_command_; then echo "\"command -v _no_such_command_\" returned zero status" >&2 fi $(command -v echo) command -v command -v retfunc command -v if command -v then command -v else command -v elif command -v fi command -v do command -v done command -v case command -v esac command -v while command -v until command -v for command -v { command -v } command -v ! command -v in [ x"$(command -v cat)" = x"$(command -v $(command -v cat))" ] || echo "\"command -v\" not idempotent" >&2 # output from "command -V echo" must include path for "echo" case "$(command -V echo)" in *$(command -v echo)*) ;; *) echo "\$(command -V echo) = $(command -V echo)" ;; esac ( command command exec >/dev/null echo not printed ) $INVOKE $TESTEE 2>/dev/null <<\END command exec 3<$TESTTMP/no.such.file echo ok exec 3<$TESTTMP/no_such_file echo not printed END PATH= command -p cat -u /dev/null echo ===== special builtins ===== { (: <"${TESTTMP}/no.such.file"; echo not reached - redir) (readonly ro=ro; ro=xx eval 'echo test'; echo not reached - assign) (unset unset; set ${unset?}; echo not reached - expansion) (. "${TESTTMP}/no.such.file"; echo not reached - dot not found) (break invalid argument; echo not reached - usage error) } 2>/dev/null echo ===== exec ===== $INVOKE $TESTEE -c 'exec echo exec' $INVOKE $TESTEE -c '(exec echo 1); exec echo 2' exec echo exec echo echo not reached yash-2.35/tests/dirstack.y.err0000644000175000017500000000112212154557026016471 0ustar magicantmagicant===== 9 ===== popd: the directory stack is empty ===== 10 ===== pushd: $DIRSTACK is not an array popd: $DIRSTACK is not an array dirs: $DIRSTACK is read-only pushd: $DIRSTACK is read-only popd: $DIRSTACK is read-only dirs: $DIRSTACK is read-only pushd: `--no-such-option' is not a valid option pushd: too many operands are specified pushd: index +5 is out of range popd: `--no-such-option' is not a valid option popd: too many operands are specified popd: index +5 is out of range popd: the directory stack is empty dirs: `--no-such-option' is not a valid option dirs: index +5 is out of range yash-2.35/tests/job.y.tst0000644000175000017500000000767712154557026015506 0ustar magicantmagicant# job.y.tst: yash-specific test of job control # vim: set ft=sh ts=8 sts=4 sw=4 noet: # all tests that use /dev/tty must be in this test command -b ulimit -c 0 2>/dev/null echo ===== fg bg suspend ===== set -m +o curstop sleep `echo 0`& fg $INVOKE $TESTEE -c 'suspend; echo 1' $INVOKE $TESTEE -c 'suspend; echo 2' $INVOKE $TESTEE -c 'suspend; echo 3' jobs fg %2 3 '%? echo 1' $INVOKE $TESTEE -c 'suspend; echo 4' jobs %% bg wait %% $INVOKE $TESTEE -c 'suspend' $INVOKE $TESTEE -c 'suspend' $INVOKE $TESTEE -c 'suspend; echo 7' bg %1 %2 wait bg '${' fg '? echo 7' >/dev/null $INVOKE $TESTEE -imc --norc 'echo 1; suspend; echo 2' kill -l $? bg >/dev/null wait %1 kill -l $? fg >/dev/null set +m echo ===== test ===== # test the -t operator of the test builtin exec 3<>/dev/tty 4>&- [ -t 3 ]; echo test 1 $? test -t 3; echo test 2 $? [ -t 4 ]; echo test 3 $? test -t 4; echo test 4 $? exec 3>&- echo ===== error ===== echo ===== error ===== >&2 $INVOKE $TESTEE -m <<\END fg --no-such-option echo fg no-such-option $? exit 100 & fg >&- 2>/dev/null END echo fg output error $? $INVOKE $TESTEE -m <<\END fg %100 echo fg no-such-job 1 $? fg %no_such_job echo fg no-such-job 2 $? set --posix exit 101 & exit 102 & fg %1 %2 echo fg too many args $? END fg echo fg +m $? $INVOKE $TESTEE -m <<\END bg --no-such-option echo bg no-such-option $? while kill -0 $$; do sleep 1; done 2>/dev/null& bg >&- 2>/dev/null echo bg output error $? kill %1 END set -m bg %100 echo bg no-such-job 1 $? bg %no_such_job echo bg no-such-job 2 $? set +m bg echo bg +m $? echo ===== signals ===== export SIG $INVOKE $TESTEE -im --norcfile 2>/dev/null <<\END # SIGINT, SIGTERM and SIGQUIT are ignored if interactive kill -s INT $$ echo INT ignored kill -s TERM $$ echo TERM ignored kill -s QUIT $$ echo QUIT ignored # but not in subshells $INVOKE $TESTEE -c 'kill -s INT $$' & \ wait $! >/dev/null kill -l $? $INVOKE $TESTEE -c 'kill -s TERM $$' & \ wait $! >/dev/null kill -l $? $INVOKE $TESTEE -c 'kill -s QUIT $$' & \ wait $! >/dev/null kill -l $? END set -m # SIGTSTP is ignored when job control is active kill -s TSTP $$ echo TSTP ignored # but not in subshells kill -s TTOU 0 && echo 1& wait %1 kill -l $? kill -s TSTP 0 && echo 2& wait %2 kill -l $? fg %1 %2 >/dev/null set +m # `cd's before `kill's are there because core dumps, if any, should be created # in a temporary directory echo ===== signals +i -m F ===== for SIG in ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 do $INVOKE $TESTEE -c +i -m 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done for SIG in CHLD URG do $INVOKE $TESTEE -c +i -m 'cd "$TESTTMP"; kill -s $SIG $$' echo $SIG $? done echo ===== signals -i -m F ===== for SIG in ABRT ALRM BUS FPE HUP ILL KILL PIPE SEGV USR1 USR2 do $INVOKE $TESTEE -ci -m --norcfile 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done for SIG in CHLD URG do $INVOKE $TESTEE -ci -m --norcfile 'cd "$TESTTMP"; kill -s $SIG $$' echo $SIG $? done echo ===== signals +i -m T ===== set -m for SIG in ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 do (cd "$TESTTMP"; kill -s $SIG 0) kill -l $? done for SIG in CHLD URG do (cd "$TESTTMP"; kill -s $SIG 0) echo $SIG $? done for SIG in TSTP TTIN TTOU STOP do (cd "$TESTTMP"; kill -s $SIG 0; echo $SIG!) kill -l $? fg %1 >/dev/null echo $SIG $? done set +m echo ===== signals -i -m T ===== $INVOKE $TESTEE -i -m --norcfile 2>/dev/null <<\END export SIG for SIG in ABRT ALRM BUS FPE HUP ILL KILL PIPE QUIT SEGV TERM USR1 USR2 do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done for SIG in CHLD URG do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' echo $SIG $? done for SIG in INT INT INT do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$' kill -l $? done kill -l $? for SIG in TSTP TTIN TTOU STOP do $INVOKE $TESTEE -c 'cd "$TESTTMP"; kill -s $SIG $$; echo $SIG!' kill -l $? fg %1 >/dev/null echo $SIG $? done END yash-2.35/tests/history.y.tst0000644000175000017500000001002512154557026016412 0ustar magicantmagicant# history.y.tst: yash-specific test of history # vim: set ft=sh ts=8 sts=4 sw=4 noet: export TMPHIST="${TESTTMP}/history.y.tmp" export RC="${TESTTMP}/history.y.rc" cat >"$RC" <<\END PS1='' PS2='' HISTFILE="$TMPHIST" HISTSIZE=30 unset HISTRMDUP END command -V fc command -V history | grep -v "^history: a regular built-in " unset FCEDIT $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF echo 1 echo 2 echo 3 fc -l echo $? echo 6 echo 7 echo 8 echo 9 echo 10 echo 11 echo 12 echo 13 echo 14 echo 15 echo 16 echo 17 echo 18 echo 19 fc -l fc -l -1 fc -l 10 13 fc -l 23 21 fc -l -r 10 13 fc -l -r 23 21 fc -l -n 'echo 1' 20 echo 27 echo 28 echo 29 fc -s fc -s 27 fc -s -q fc -s fc fc -s 1=18 echo 35 echo 36 echo 37 echo 38 echo 39 fc -e true #40 FCEDIT=true fc #41 fc -e false 2>&1 #42 fcedit() { echo 'echo ok' >>"$1"; } fc -e fcedit 36 38 #43-46 fc -e fcedit 38 36 #47-50 fc -e fcedit -rq 38 36 #51-54 fc -l -2 echo ===== $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF2 echo inner shell; fc -l 53 EOF2 echo ===== exit echo not executed EOF echo ===== 1 ===== $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF echo 31 echo 32 echo 33 fc -l EOF echo ===== 2 ===== $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF echo 31 history 5 history -d -2 -d 33 history 5 history -c echo 1 echo 2 echo 3 history -w - history -w "${TESTTMP}"/history2 -c echo a echo b echo c cat "${TESTTMP}"/history2 history -r "${TESTTMP}"/history2 -r - <<\END echo x END history -s 1 -s 2 -s 3 history rm -f "${TESTTMP}/history2" EOF echo ===== 3 ===== cat >"$RC" <<\END PS1='' PS2='' HISTFILE="$TMPHIST" HISTSIZE=30 HISTRMDUP=3 FCEDIT=true END >"$TMPHIST" $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF echo 1 echo 2 echo 3 echo 4 echo 5 echo 6 echo 7 history -d 2 -d 6; fc -l fc -l 2 6 fc -lr 2 6 fc -l 6 2 fc -lr 6 2 fc 2 6 fc -r 2 6 fc 6 2 fc -r 6 2 fc -l -- -10000 3 fc -lr -- -10000 3 fc -l -- 3 -10000 fc -lr -- 3 -10000 EOF echo ===== 4 ===== >"$TMPHIST" $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF history -c; fc -l # should print nothing with no error EOF echo ===== 5 ===== # test of $HISTRMDUP $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF echo 1 echo 1 echo 1 echo 2 echo 1 echo 2 echo 1 echo 2 echo 3 echo 1 echo 2 echo 3 echo 1 echo 2 echo 3 echo 4 echo 1 echo 2 echo 3 echo 4 echo 1 echo 2 echo 3 echo 4 echo 5 echo 4 echo 3 echo 2 echo 1 fc -ln EOF echo ===== 6 ===== >"$TMPHIST" ( i=32767 # < HISTORY_MIN_MAX_NUMBER while [ $i -gt 0 ]; do echo : $(( i-- )) done echo "fc -l" echo "fc -l 1 -15" ) | $INVOKE $TESTEE -i +m --rcfile="$RC" echo ===== histspace ===== >"$TMPHIST" $INVOKE $TESTEE -i +m --rcfile="$RC" <<\EOF echo a echo b set --histspace echo c echo d echo e set +o histspace echo f echo g fc -l EOF echo ===== error ===== fc --no-such-option echo fc no-such-option $? fc -l -e X echo fc invalid-option-combination l e $? fc -s -e X echo fc invalid-option-combination s e $? fc -l -q echo fc invalid-option-combination l q $? fc -l -s echo fc invalid-option-combination l s $? fc -r -s echo fc invalid-option-combination r s $? fc -n echo fc invalid-option-combination n $? fc -v echo fc invalid-option-combination v $? #fc -l #echo fc history-empty 1 $? fc echo fc history-empty 2 $? fc -s echo fc history-empty 3 $? #fc -l foo #echo fc history-empty 4 $? fc foo echo fc history-empty 5 $? fc -s foo echo fc history-empty 6 $? history -s 'entry' -s 'dummy 1' -s 'dummy 2' -s 'dummy 3' -s 'dummy 4' fc -l foo echo fc no-such-entry 1 $? fc foo echo fc no-such-entry 2 $? fc -s foo echo fc no-such-entry 3 $? fc -l entry dummy dummy echo fc too-many-operands 1 $? fc entry dummy dummy echo fc too-many-operands 2 $? fc -s entry dummy echo fc too-many-operands 3 $? history --no-such-option echo history no-such-option $? history 1 2 echo history too-many-operands $? (history >&- 2>/dev/null) echo history output error $? history -d foo echo history no-such-entry $? history -r "$TMPHIST/no/such/file" $? 2>/dev/null echo history no-such-file 1 $? history -w "$TMPHIST/no/such/file" $? 2>/dev/null echo history no-such-file 2 $? rm -f "$TMPHIST" "$RC" yash-2.35/tests/job.y.err0000644000175000017500000000046412154557026015447 0ustar magicantmagicant===== error ===== fg: `--no-such-option' is not a valid option fg: no such job `%100' fg: no such job `%no_such_job' fg: too many operands are specified fg: job control is disabled bg: `--no-such-option' is not a valid option bg: no such job `%100' bg: no such job `%no_such_job' bg: job control is disabled yash-2.35/tests/parser.y.out0000644000175000017500000000050612154557026016205 0ustar magicantmagicant===== for ===== 1 2 3 1 2 3 ===== empty compound commands ===== a 1 b 1 c1 1 c2 1 c3 1 d1 0 d2 0 2 1 0 e1 0 ===== function ===== func 1 func 2 func 3 func 4 func 5 XYZ() for i in func do unset -f ${i} echo func 5 done function 'X:Z'() { echo non-portable name } func 6 ===== error ===== missing double-quote missing backquote yash-2.35/tests/variable.p.out0000644000175000017500000000150312154557026016463 0ustar magicantmagicant4 some here document another here-document 14 line continuation 17 ===== 1 ===== var var var -123 456 789- -123 456 789- ===== 2 ===== xyz xyz ===== 3 ===== 1 $0=variable.p.tst 2 $0=sh 3 $0=sh 4 $0=command name ===== 4 ===== a 1 b 1 c 2 d 2 ===== set export ===== 123 456 - - save unset 123 xyz var unset xyz null ===== readonly ===== xyz readonly! -- xyz -- xyz xyz -- ===== function unset ===== ok ===== set shift ===== 2 3 a b c a b c shift 4 x y z y z z a b c 0 ===== getopts ===== 1 a unset b foo bar c unset ? 5 ===== 1 a -- a bc b unset ? 6 ===== 2 a unset b unset c unset d unset e unset ? 3 a unset b unset c unset d unset e unset ? 3 ===== 3 0 ? 1 unset ===== 4 0 ? unset 0 ? a 0 ? unset 0 : a ===== read ===== 1 2 3 1 2 3 4 5 1 2 3 1 2 34 5 1 2 3 ===== 1 2-3 4 5-6 7-8-9 1 2\ 3 4 5\-6-7\-8-9\ 2 3 4 6 7 8 0 1 2 unset yash-2.35/tests/prompt.y.oux0000644000175000017500000000013012154557026016227 0ustar magicantmagicantposix PS1={# } posix PS2={> } posix PS4={+ } yash PS1={\$ } yash PS2={> } yash PS4={+ } yash-2.35/tests/builtin.p.out0000644000175000017500000000076712154557026016357 0ustar magicantmagicant===== : true false ===== 0 0 0 false true : true false ===== return break continue ===== 3 4 retfunc 5 while ok until ok for 1 while 0 until 0 for 1 for 2 for 3 for 4 1 7 1 8 2 7 2 8 3 7 1 7 0 1 8 1 ! i=2 ! i=3 done ===== exit ===== exit 1 0 exit 2 20 exit 3 0 exit 4 20 exit 5 30 exit 6 30 ===== . ===== -- returning -- 0 ===== command ===== ok PATH= command -v retfunc if then else elif fi do done case esac while until for { } ! in ok ===== special builtins ===== ===== exec ===== exec 1 2 exec echo yash-2.35/tests/option.p.err0000644000175000017500000000017012154557026016166 0ustar magicantmagicant===== -v ===== echo "$-" | grep -Fq v || echo 'no v in $-' >&2 var=123 echo ${var#1} ===== -x ===== + var=123 + echo 23 yash-2.35/tests/redir.p.tst0000644000175000017500000000513112154557026016007 0ustar magicantmagicant# redir.p.tst: test of redirections for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp="${TESTTMP}/redir.p.tmp" echo Hello, >"$tmp" cat "$tmp" echo World. >>"$tmp" cat <"$tmp" 1>&1 echo redirection before command echo \2>"$tmp" echo 2\>/dev/null|cat - "$tmp" rm -f "$tmp" echo foo > \ "$tmp" [ -f "$tmp" ] && cat "$tmp" set -C echo bar >|"$tmp" (echo baz >"$tmp") 2>/dev/null || echo noclobber set +C cat "$tmp" echo ===== 1 ===== unset unset 2>&- echo 3>&1 complex 2>& ${unset--} redirection >& \3 <>/dev/null cat 2<& '0' 3>& 1 (&0) 2>/dev/null || echo not writable (>/dev/null <&1) 2>/dev/null || echo not readable exec 5>&1 exec >& - echo exec redirect >&5 exec >&5 5>&- echo exec redirect exec 4<>/dev/null cat >&4 <&4 # prints nothing $INVOKE $TESTEE -c 'exec >&5; echo not printed' 2>/dev/null $INVOKE $TESTEE -c 'command exec >&5; echo printed 1' 2>/dev/null { exec 4>&1; } 5>&1 echo exec in group >&4 { echo error >&5; } 2>/dev/null || echo file descriptor closed $INVOKE $TESTEE -c 'var="printed 2"; trap "echo \$var" EXIT >/dev/null' $INVOKE $TESTEE -c ' settrap() { trap "echo printed 3" EXIT echo not printed } settrap >/dev/null' $INVOKE $TESTEE -c ' { trap "echo printed 4" EXIT echo not printed } >/dev/null' echo ===== 2 ===== cat <"$tmp" Test of here-document. <"${TERM+}"> "'"''\\-\'\" END cat "$tmp" cat <<"END" >"$tmp" Test of here-document. <"${TERM+}"> "'"''\\-\'\" END cat "$tmp" cat <<-\ END - Test of here-document. <"${TERM+}"> "'"''\\-\'\" END cat <<-E\ ND - Test of here-document. <"${TERM+}"> "'"''\\-\'\" E ND cat </dev/null <<\END returnfunc () while do return -n return done eval 'echo 5; returnfunc; echo $?' eval -i 'echo 6' 'returnfunc' 'echo $?' eval 'echo 7; return; echo 7-2' eval -i 'echo 8' 'return; echo 8-2' 'echo $?' END echo ===== . ===== set a b c . ./dot.t 1 2 3 echo $count echo -"$@"- # test of autoload mkdir "$tmp/dir" cat >"$tmp/script1" <<\EOF echo script1 EOF cat >"$tmp/dir/script1" <<\EOF echo dir/script1 EOF cat >"$tmp/dir/script2" <<\EOF echo dir/script2 EOF YASH_LOADPATH=("$tmp/dummy" "$tmp" "$tmp/dir" "$tmp/dummy") . -L script1 . -L dir/script1 . --autoload script2 echo ===== command ===== command -V if then else elif fi do done case esac while until for function \ { } ! in PATH= command -V _no_such_command_ 3>&1 1>&2 2>&3 || echo $? command -V : . break continue eval exec exit export readonly return set shift \ times trap unset #TODO command -V newgrp command -V bg cd command false fg getopts jobs kill pwd read true umask wait testreg() { command -V $1 | grep -v "^$1: a regular built-in " } testreg typeset testreg disown testreg type command -Vb sh 2>&1 || PATH= command -vp sh >/dev/null && echo ok command -b eval echo echo echo command -b eval = $? command --builtin-command cat /dev/null 2>/dev/null echo command -b cat = $? command -e ls >/dev/null echo command -e ls = $? PATH= command --external-command exit 50 2>/dev/null echo command -e exit 50 = $? (command exit 10; echo not reached) echo command exit 10 = $? command -f testreg type echo command -f testreg = $? command --function echo 2>/dev/null echo command -f echo = $? type type | grep -v "^type: a regular built-in " command -vb cat echo command -vb cat = $? PATH= command -ve exit echo command -ve exit = $? ( cd() { command cd "$@"; } if command -vb alias >/dev/null 2>&1; then alias cd=cd_alias type cd command -va cd command -va echo || echo $? else echo "cd: an alias for \`cd_alias'" echo "alias cd='cd_alias'" echo 1 fi echo =1= type -b cd echo =2= type -k if type -k cd 2>&1 ) function slash/function () { echo slash "$@" return 7 } command -f slash/function a b "C C" echo $? unset -f slash/function command -bef slash/function 2>/dev/null echo $? rm -R "$tmp" echo ===== exec ===== (exec -a sh $TESTEE -c 'echo $0') (exec --as=sh $TESTEE -c 'echo $0') (foo=123 bar=456 baz=(7 8 9) exec -c env | grep -v ^_ | sort) (foo=123 bar=456 baz=(7 8 9) exec --clear env | grep -v ^_ | sort) yash-2.35/tests/job.p.tst0000644000175000017500000000053112154557026015453 0ustar magicantmagicant# job.p.tst: test of job control for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: echo echo & wait echo wait ok (echo echo; exit 3)& wait $! echo wait $? true & true & true & wait echo wait $? (exit 1)& p1=$! (exit 2)& p2=$! (exit 3)& p3=$! echo echo wait $p2 $p3 echo wait $? wait $p1 echo wait $? wait $p1 echo wait $? yash-2.35/tests/checkfg.c0000644000175000017500000000222412154557026015446 0ustar magicantmagicant/* checkfg.c: checks if the current process is in the foreground */ /* (C) 2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #define _POSIX_C_SOURCE 200112L #include #include #include int main(void) { int ttyfd = open("/dev/tty", O_RDWR | O_NOCTTY | O_NONBLOCK); if (ttyfd < 0) return EXIT_FAILURE; pid_t tpgid = tcgetpgrp(ttyfd); if (tpgid < 0) return EXIT_FAILURE; pid_t pgid = getpgrp(); return tpgid == pgid ? EXIT_SUCCESS : EXIT_FAILURE; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/tests/dirstack.y.out0000644000175000017500000000206112154557026016513 0ustar magicantmagicant1 0 2 0 3 0 4 0 5 0 6 0 f4 7 0 f3 8 0 f2 9 0 f1 10 0 ok 1/f1 2/f2 3/f3 4/f4 0 1/f1 2/f2 3/f3 4/f4 ===== 1 ===== 4 3 2 1 dirstack.y.tmp +0 -4 4 +1 -3 3 +2 -2 2 +3 -1 1 +4 -0 dirstack.y.tmp ===== 2 ===== 3 4 2 1 dirstack.y.tmp 4 3 2 1 dirstack.y.tmp ===== 3 ===== 3 1 4 2 dirstack.y.tmp ===== 4 ===== 3 2 dirstack.y.tmp ===== 5 ===== 3 2 dirstack.y.tmp ===== 6 ===== 4 1 3 2 dirstack.y.tmp ===== 7 ===== 3 4 1 2 dirstack.y.tmp ===== 8 ===== 1 2 2 3 4 2 dirstack.y.tmp ===== +0 -6 1 +6 -0 dirstack.y.tmp 2 4 ===== 9 ===== empty popd 1 dirstack.y.tmp pushd hyphen 1 ===== 10 ===== pushd dirstack unset 1 popd dirstack unset 1 dirs dirstack unset 0 dirs -c dirstack unset 1 pushd dirstack readonly 1 popd dirstack readonly 1 dirs dirstack readonly 0 dirs -c dirstack readonly 1 pushd no-such-option 2 pushd too-many-operands 2 pushd no-such-dir 1 pushd index out of range 1 pushd output error 0 popd no-such-option 2 popd too-many-operands 2 popd index out of range 1 popd output error 0 popd dirstack empty 1 dirs no-such-option 2 dirs index out of range 1 dirs output error 1 yash-2.35/tests/parser.y.err0000644000175000017500000002505312154557026016172 0ustar magicantmagicantsyntax error: `;' or `&' is missing syntax error: encountered `)' without a matching `(' syntax error: encountered `}' without a matching `{' syntax error: `;;' is used outside `case' syntax error: encountered `then' without a matching `if' or `elif' syntax error: encountered `then' without a matching `if' or `elif' syntax error: (maybe you missed `fi'?) syntax error: encountered `else' without a matching `if' and/or `then' syntax error: encountered `else' without a matching `if' and/or `then' syntax error: (maybe you missed `then'?) syntax error: encountered `elif' without a matching `if' and/or `then' syntax error: encountered `elif' without a matching `if' and/or `then' syntax error: (maybe you missed `then'?) syntax error: encountered `fi' without a matching `if' and/or `then' syntax error: encountered `fi' without a matching `if' and/or `then' syntax error: (maybe you missed `then'?) syntax error: encountered `fi' without a matching `if' and/or `then' syntax error: (maybe you missed `then'?) syntax error: encountered `do' without a matching `for', `while', or `until' syntax error: encountered `done' without a matching `do' syntax error: encountered `done' without a matching `do' syntax error: (maybe you missed `do'?) syntax error: encountered `esac' without a matching `case' syntax error: `!' cannot be used as a command name syntax error: `!' cannot be used as a command name syntax error: `in' cannot be used as a command name syntax error: a command is missing at the end of input yash -c:1: syntax error: a command is missing before `;' yash -c:1: syntax error: a command is missing before `&' yash -c:1: syntax error: a command is missing before `|' yash -c:1: syntax error: a command is missing before `;' yash -c:1: syntax error: a command is missing before `&' yash -c:1: syntax error: a command is missing before `|' yash -c:3: syntax error: invalid use of `(' yash -c:1: syntax error: invalid use of `(' yash -c:3: syntax error: `)' is missing yash -c:1: syntax error: `)' is missing yash -c:1: syntax error: the redirection target is missing yash -c:1: syntax error: the redirection target is missing yash -c:1: syntax error: the redirection target is missing yash -c:1: syntax error: the redirection target is missing yash -c:1: syntax error: the redirection target is missing yash -c:1: syntax error: the redirection target is missing yash -c:2: syntax error: the redirection target is missing yash -c:1: syntax error: the redirection target is missing syntax error: the end-of-here-document indicator is missing syntax error: the end-of-here-document indicator is missing syntax error: the redirection target is missing yash -c:1: syntax error: the double quotation is not closed yash -c:1: syntax error: the double quotation is not closed yash -c:1: syntax error: `}' is missing yash -c:3: syntax error: the single quotation is not closed yash -c:1: syntax error: the parameter name is missing or invalid yash -c:1: syntax error: the parameter name is missing or invalid yash -c:1: syntax error: the parameter name is missing or invalid yash -c:1: syntax error: the index is missing yash -c:1: syntax error: the index is missing yash -c:1: syntax error: the index is missing yash -c:1: syntax error: `]' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `]' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `]' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: invalid use of `:' in parameter expansion yash -c:1: syntax error: invalid use of `:' in parameter expansion yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: invalid character `!' in parameter expansion yash -c:1: syntax error: invalid use of `:' in parameter expansion yash -c:1: syntax error: invalid use of `:' in parameter expansion yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:1: syntax error: invalid use of `#' in parameter expansion yash -c:2: syntax error: `)' is missing yash -c:2: syntax error: the backquoted command substitution is not closed yash -c:2: syntax error: the backquoted command substitution is not closed command substitution:1: syntax error: the double quotation is not closed command substitution:2: syntax error: the backquoted command substitution is not closed yash -c:1: syntax error: `)' is missing yash -c:1: syntax error: `)' is missing = yash -c:1: syntax error: `)' is missing syntax error: commands are missing between `(' and `)' syntax error: commands are missing between `(' and `)' syntax error: commands are missing between `{' and `}' syntax error: commands are missing between `{' and `}' yash -c:1: syntax error: `)' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `)'?) yash -c:1: syntax error: encountered `)' without a matching `(' yash -c:1: syntax error: (maybe you missed `}'?) syntax error: commands are missing between `if' and `then' syntax error: commands are missing after `then' syntax error: commands are missing between `elif' and `then' syntax error: commands are missing after `then' syntax error: commands are missing after `else' yash -c:1: syntax error: `then' is missing yash -c:1: syntax error: `fi' is missing yash -c:1: syntax error: `then' is missing yash -c:1: syntax error: `fi' is missing yash -c:1: syntax error: `fi' is missing yash -c:1: syntax error: `fi' is missing yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `then'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `fi'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `then'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `fi'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `fi'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `fi'?) syntax error: an identifier is required after `for' yash -c:1: syntax error: `=' is not a valid identifier yash -c:1: syntax error: redirections are not allowed after `in' sh -c:1: syntax error: `;' is not allowed just after the identifier in a for loop yash -c:1: syntax error: `do' is missing syntax error: commands are missing between `do' and `done' syntax error: commands are missing between `do' and `done' yash -c:1: syntax error: `done' is missing yash -c:1: syntax error: `}' is not a valid identifier yash -c:1: syntax error: `do' is missing yash -c:1: syntax error: `done' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `do' is missing yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) yash -c:1: syntax error: `do' is missing yash -c:1: syntax error: `done' is missing yash -c:1: syntax error: `}' is missing yash -c:1: syntax error: `do' is missing yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) syntax error: commands are missing after `while' syntax error: commands are missing after `until' syntax error: commands are missing between `do' and `done' syntax error: commands are missing between `do' and `done' yash -c:1: syntax error: `do' is missing yash -c:1: syntax error: `done' is missing yash -c:1: syntax error: `done' is missing yash -c:1: syntax error: `do' is missing yash -c:1: syntax error: `done' is missing yash -c:1: syntax error: `done' is missing yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `do'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `do'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `done'?) syntax error: a word is required after `case' yash -c:1: syntax error: a word is required after `case' yash -c:1: syntax error: `in' is missing yash -c:1: syntax error: `esac' is missing yash -c:1: syntax error: `in' is missing yash -c:1: syntax error: `esac' is missing yash -c:1: syntax error: `esac' is missing yash -c:1: syntax error: a word is required after `case' yash -c:1: syntax error: `in' is missing yash -c:1: syntax error: `esac' is missing yash -c:1: syntax error: `in' is missing yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `esac'?) yash -c:1: syntax error: encountered `}' without a matching `{' yash -c:1: syntax error: (maybe you missed `esac'?) syntax error: a word is required after `(' syntax error: `esac' is missing syntax error: a word is required after `|' syntax error: `esac' is missing yash -c:1: syntax error: encountered an invalid character `>' in the case pattern yash -c:1: syntax error: `esac' is missing yash -c:1: syntax error: `)' is missing yash -c:1: syntax error: `)' is missing sh -c:1: syntax error: an unquoted `esac' cannot be the first case pattern sh -c:1: syntax error: `function' cannot be used as a command name syntax error: a word is required after `function' yash -c:1: syntax error: a function body must be a compound command yash -c:1: syntax error: `(' must be followed by `)' in a function definition yash -c:1: syntax error: a function body must be a compound command syntax error: the end-of-here-document indicator contains a newline yash-2.35/tests/option.y.tst0000644000175000017500000000405012154557026016222 0ustar magicantmagicant# option.y.tst: yash-specific test of shell options # vim: set ft=sh ts=8 sts=4 sw=4 noet: tmp="${TESTTMP}/option.y.tmp" mkdir -p "$tmp" echo ===== -h ===== set -h echo "$-" | grep -Fq h || echo 'no h in $-' >&2 hash -r hoptiontest () { cat /dev/null } echo $(hash | grep /cat\$ | wc -l) set +h echo ===== exec ===== # the noexec option is ineffective in an interactive shell $INVOKE $TESTEE -cin --norcfile +m 'echo printed; exit; echo not printed' echo ===== nocaseglob ===== set --no=caseglob echo O[OPQ]T*ON.y.tst OPTION.y.tst set +o no_casegl echo O[OPQ]T*ON.y.tst OPTION.y.tst cd "$tmp" echo ===== dotglob ===== touch .dotfile set --dotglo echo * set +o dotglob echo * echo ===== markdirs ===== mkdir dir set --markdirs echo di* set +o mark\ dirs echo di* echo ===== extendedglob ===== mkdir dir/dir2 touch dir/dir2/file mkdir anotherdir touch anotherdir/file ln -s ../../anotherdir dir/dir2/link ln -s ../dir anotherdir/loop set --extended-glob echo **/file echo ***/file set +oextended-glob echo **/file echo ***/file mv dir/dir2 dir/.dir2 set -o extended_glob echo dir/**/file echo dir/***/file echo dir/.**/file echo dir/.***/file set ++extended_glob echo dir/**/file echo dir/***/file echo dir/.**/file echo dir/.***/file echo ===== nullglob ===== set --nullglob echo n*ll f[o/b]r f?o/b*r 1 set +o nullglob echo n*ll f[o/b]r f?o/b*r 2 # test of braceexpand is in "expand.y.tst" cd - >/dev/null echo ===== traceall ===== $INVOKE $TESTEE 2>&1 >/dev/null <<\END COMMAND_NOT_FOUND_HANDLER='echo not found $@ >&2; HANDLED=1' set -xv no/such/command 1 set +o traceall no/such/command 2 set -o traceall no/such/command 3 END echo ===== posix ===== RANDOM=1 $INVOKE $TESTEE --posixly-correct -c 'echo "$((RANDOM))"' RANDOM=X $INVOKE $TESTEE ++posixly-correct -c 'echo "$((RANDOM % 1))"' RANDOM=X $INVOKE $TESTEE -c 'echo "$((RANDOM % 1))"' rm -fr "$tmp" echo ===== -o +o ===== set -aoerrexit -u set -o > "$tmp" saveset=$(set +o) set +aeu eval "$saveset" set -o | diff "$tmp" - && echo ok rm -f "$tmp" echo ===== abbr ==== typeset --ex >/dev/null yash-2.35/tests/alias.y.err0000644000175000017500000000074512154557026015770 0ustar magicantmagicantsyntax error: commands are missing between `if' and `then' syntax error: commands are missing between `(' and `)' syntax error: `!' cannot be used as a command name syntax error: `;;' is used outside `case' syntax error: a command is missing before `&' alias: `--no-such-option' is not a valid option alias: no such alias `alias' unalias: `--no-such-option' is not a valid option unalias: no operand is expected unalias: this command requires an operand unalias: no such alias `alias' yash-2.35/tests/test.y.out0000644000175000017500000000725212154557026015675 0ustar magicantmagicant===== : 1 1 : 1 1 1: 0 0 --: 0 0 -n: 0 0 -z: 0 0 -t: 0 0 ! : 0 0 ! 1: 1 1 ! 000: 1 1 ===== -d .: 0 0 -d fifolink: 1 1 -e .: 0 0 -e fifolink: 0 0 -e no_such_file: 1 1 -f gid: 0 0 -f reglink: 0 0 -f fifolink: 1 1 -f .: 1 1 -f no_such_file: 1 1 -g gid: 0 0 -g uid: 1 1 -h fifolink: 0 0 -h reglink: 0 0 -h gid: 1 1 -h no_such_file: 1 1 -k gid: 1 1 -L fifolink: 0 0 -L reglink: 0 0 -L gid: 1 1 -L no_such_file: 1 1 -N new: 0 0 -N old: 1 1 -n : 1 1 -n 0: 0 0 -n 1: 0 0 -n abcde: 0 0 -O .: 0 0 -p fifo: 0 0 -p .: 1 1 -r readable1: 0 0 -r readable2: 1 1 -r readable3: 1 1 -r writable1: 1 1 -r writable2: 1 1 -r writable3: 1 1 -s gid: 1 1 -s executable1: 0 0 -u gid: 1 1 -u uid: 0 0 -w readable1: 1 1 -w readable2: 1 1 -w readable3: 1 1 -w writable1: 0 0 -w writable2: 1 1 -w writable3: 1 1 -x .: 0 0 -x executable1: 0 0 -x executable2: 1 1 -x executable3: 1 1 -x reglink: 1 1 -z : 0 0 -z 0: 1 1 -z 1: 1 1 -z abcde: 1 1 ===== = : 0 0 1 = 1: 0 0 abcde = abcde: 0 0 0 = 1: 1 1 abcde = 12345: 1 1 ! = !: 0 0 = = =: 0 0 ( = ): 1 1 == : 0 0 1 == 1: 0 0 abcde == abcde: 0 0 0 == 1: 1 1 abcde == 12345: 1 1 ! == !: 0 0 == == ==: 0 0 ( == ): 1 1 != : 1 1 1 != 1: 1 1 abcde != abcde: 1 1 0 != 1: 0 0 abcde != 12345: 0 0 ! != !: 1 1 != != !=: 1 1 ( != ): 0 0 a === a: 0 0 a !== a: 1 1 a < a: 1 1 a <= a: 0 0 a > a: 1 1 a >= a: 0 0 abc123xyz =~ c[[:digit:]]*x: 0 0 -axyzxyzaxyz- =~ c[[:digit:]]*x: 1 1 -axyzxyzaxyz- =~ -(a|xyz)*-: 0 0 abc123xyz =~ -(a|xyz)*-: 1 1 ! -n : 0 0 ! -n 0: 1 1 ! -n 1: 1 1 ! -n abcde: 1 1 ! -z : 1 1 ! -z 0: 0 0 ! -z 1: 0 0 ! -z abcde: 0 0 ( ): 1 1 ( 0 ): 0 0 ( abcde ): 0 0 ===== -3 -eq -3: 0 0 90 -eq 90: 0 0 0 -eq 0: 0 0 -3 -eq 90: 1 1 -3 -eq 0: 1 1 90 -eq 0: 1 1 -3 -ne -3: 1 1 90 -ne 90: 1 1 0 -ne 0: 1 1 -3 -ne 90: 0 0 -3 -ne 0: 0 0 90 -ne 0: 0 0 -3 -lt -3: 1 1 -3 -lt 0: 0 0 0 -lt 90: 0 0 0 -lt -3: 1 1 90 -lt -3: 1 1 0 -lt 0: 1 1 -3 -le -3: 0 0 -3 -le 0: 0 0 0 -le 90: 0 0 0 -le -3: 1 1 90 -le -3: 1 1 0 -le 0: 0 0 -3 -gt -3: 1 1 -3 -gt 0: 1 1 0 -gt 90: 1 1 0 -gt -3: 0 0 90 -gt -3: 0 0 0 -gt 0: 1 1 -3 -ge -3: 0 0 -3 -ge 0: 1 1 0 -ge 90: 1 1 0 -ge -3: 0 0 90 -ge -3: 0 0 0 -ge 0: 0 0 XXXXX -ot newer: 0 0 XXXXX -ot XXXXX: 1 1 newer -ot XXXXX: 1 1 older -ot newer: 0 0 newer -ot newer: 1 1 newer -ot older: 1 1 XXXXX -nt newer: 1 1 XXXXX -nt XXXXX: 1 1 newer -nt XXXXX: 0 0 older -nt newer: 1 1 older -nt older: 1 1 newer -nt older: 0 0 XXXXX -ef newer: 1 1 XXXXX -ef XXXXX: 1 1 newer -ef XXXXX: 1 1 older -ef newer: 1 1 older -ef older: 0 0 newer -ef older: 1 1 gid -ef gidhard: 0 0 gid -ef reglink: 0 0 ===== -veq : 0 0 -vne : 1 1 -vgt : 1 1 -vge : 0 0 -vlt : 1 1 -vle : 0 0 0 -veq 0: 0 0 0 -vne 0: 1 1 0 -vgt 0: 1 1 0 -vge 0: 0 0 0 -vlt 0: 1 1 0 -vle 0: 0 0 0 -veq 1: 1 1 0 -vne 1: 0 0 0 -vgt 1: 1 1 0 -vge 1: 1 1 0 -vlt 1: 0 0 0 -vle 1: 0 0 1 -veq 0: 1 1 1 -vne 0: 0 0 1 -vgt 0: 0 0 1 -vge 0: 0 0 1 -vlt 0: 1 1 1 -vle 0: 1 1 01 -veq 0001: 0 0 02 -vle 0100: 0 0 .%=01 -veq .%=0001: 0 0 .%=02 -vle .%=0100: 0 0 0.01.. -veq 0.1..: 0 0 0.01.0 -vlt 0.1..: 1 1 0.01.0 -vlt 0.1.:: 1 1 0.01.0 -veq 0.1.: 1 1 0.01.0 -vle 0.1.a0: 1 1 1.2.3 -vle 1.3.2: 0 0 -2 -vle -3: 0 0 ===== -a : 1 1 -a 1: 1 1 1 -a : 1 1 1 -a 1: 0 0 -o : 1 1 -o 1: 0 0 1 -o : 0 0 1 -o 1: 0 0 ( 12345 = 12345 ): 0 0 ( 12345 = abcde ): 1 1 ( ( 12345 = 12345 ) ): 0 0 ( ( 12345 = abcde ) ): 1 1 1 -a ( 1 = 0 -o ( 2 = 2 ) ) -a ( = ): 0 0 -a 0 -o 0: 0 0 0 -o 0 -a : 0 0 ! -a : 0 0 ( ! -a ): 1 1 ! ( -a ): 0 0 ( ! ) -a : 1 1 -n = -o -o -n = -n: 0 0 -n = -a -n = -n: 0 0 ===== -o allexpor: 0 0 -o allexport: 0 0 -o allexportttttttttttttt: 1 1 -o ?allexpor: 0 0 -o ?allexport: 0 0 -o ?allexportttttttttttttt: 1 1 -o allexpor: 1 1 -o allexport: 1 1 -o allexportttttttttttttt: 1 1 -o ?allexpor: 0 0 -o ?allexport: 0 0 -o ?allexportttttttttttttt: 1 1 ===== 1 2 3: 2 yash-2.35/tests/resetsig.c0000644000175000017500000000265412154557026015710 0ustar magicantmagicant/* resetsig.c: invokes command with all signal handlers reset */ /* (C) 2009-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #define _POSIX_C_SOURCE 200112L #define _XOPEN_SOURCE 600 #include #include #include #include "../siglist.h" int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "resetsig: too few arguments\n"); return 2; } struct sigaction action; action.sa_handler = SIG_DFL; action.sa_flags = 0; sigemptyset(&action.sa_mask); sigprocmask(SIG_SETMASK, &action.sa_mask, NULL); for (const signal_T *s = signals; s->no != 0; s++) if (s->no != SIGKILL && s->no != SIGSTOP) sigaction(s->no, &action, NULL); execvp(argv[1], &argv[1]); perror("invoke: exec failed"); return 126; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/tests/input.p.t0000644000175000017500000000013212154557026015466 0ustar magicantmagicantPS1='% ' exec 2>&3 echo \ ok cat <. */ #define _POSIX_C_SOURCE 200112L #include #include int main(int argc, char **argv) { if (argc < 3) { fprintf(stderr, "invoke: too few arguments\n"); return 2; } char *givenname = argv[1]; char *invokedcommand = argv[2]; argv[2] = givenname; execvp(invokedcommand, &argv[2]); perror("invoke: exec failed"); return 126; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/tests/error.p.out0000644000175000017500000000067612154557026016041 0ustar magicantmagicant===== consequences of shell errors ===== syntax error ok special builtin syntax error ok non-special builtin syntax error ok special builtin redirection error ok non-special builtin redirection error ok special builtin assignment error ok non-special builtin assignment error ok special builtin expansion error ok non-special builtin expansion error ok command not found error ok ===== . ===== . PATH not found error ok . file not found error ok yash-2.35/tests/alias.y.out0000644000175000017500000000120712154557026016001 0ustar magicantmagicant0 0 c b a -A- -B- -C- A B C - C='c' singlequote=''\''' pipe alias restored complex alias a a a a a a FOO=BAR ok if if 0 0 0 0 V V alias -g N='>/dev/null' ok 0 line continuation 1 line continuation 2 line continuation 3 alias line continuation 6 foo alias bar c line continuation... in alias multi-line alias with here-document posix unparsed ok dummy 0 pipe 0 alias: a semi-special built-in unalias: a semi-special built-in alias no-such-option 2 alias no-such-alias 1 alias output error 1 1 alias output error 2 1 alias output error 3 1 unalias no-such-option 2 unalias too-many-operands 2 unalias insufficient-operand 2 unalias no-such-alias 1 yash-2.35/tests/array.y.out0000644000175000017500000000117112154557026016026 0ustar magicantmagicant1 0 aaa=('1' '2' '3') ary=('test' 'of' 'array') 2 0 3 0 1 2 3 4 5 6 7 8 9 4 0 1 2 3 4 5 6 7 8 9 5 0 1 4 5 7 6 0 0 1 4 5 7 7 0 0 1 2 3 4 5 7 8 0 0 1 2 3 4 5 6 7 9 0 0 1 2 3 4 5 6 7 8 10 0 0 1 2 3 4 5 6 7 8 9 11 0 ! 0 1 2 3 4 5 6 7 8 9 12 0 0 1 1 2 3 4 5 6 7 - 9 13 1 0 1 1 2 3 4 5 6 7 - 9 ===== 1 ===== array no-such-option 2 array insufficient-operands d 0 2 array insufficient-operands i 1 2 array insufficient-operands s 2 2 array too-many-operands s 4 2 array output error 1 array readonly 1 1 array readonly 2 1 array readonly 3 1 array readonly 4 1 array readonly 5 1 array readonly 6 1 array readonly 7 1 0 1 1 2 3 4 5 6 7 - 9 yash-2.35/tests/history.y.err0000644000175000017500000000165512154557026016401 0ustar magicantmagicantfc: `--no-such-option' is not a valid option fc: the -e option cannot be used with the -l option fc: the -e option cannot be used with the -s option fc: the -l option cannot be used with the -q option fc: the -l option cannot be used with the -s option fc: the -r option cannot be used with the -s option fc: the -n or -v option must be used with the -l option fc: the -n or -v option must be used with the -l option fc: the command history is empty fc: the command history is empty fc: the command history is empty fc: the command history is empty fc: no such history entry beginning with `foo' fc: no such history entry beginning with `foo' fc: no such history entry beginning with `foo' fc: too many operands are specified fc: too many operands are specified fc: too many operands are specified history: `--no-such-option' is not a valid option history: too many operands are specified history: no such history entry beginning with `foo' yash-2.35/tests/option.p.out0000644000175000017500000000043012154557026016204 0ustar magicantmagicant===== -a ===== foo=123 ===== -e ===== ok group ok if 0 0 1-1 2-1 3-1 4-1 5-1 a 1 b 1 a 2 6-1 7 7-1 8 8-1 9 9-1 10-1 11-1 12 12-0 ===== -f ===== /* ===== -n ===== ===== -u ===== ok nounset ===== -v ===== 23 ===== -x ===== 23 ===== ignoreeof ===== ignoreeof ok ===== -o +o ===== ok yash-2.35/tests/job.y.out0000644000175000017500000000302312154557026015460 0ustar magicantmagicant===== fg bg suspend ===== [1] sleep $(echo 0) [1] Stopped(SIGSTOP) ${INVOKE} ${TESTEE} -c 'suspend; echo 1' [2] - Stopped(SIGSTOP) ${INVOKE} ${TESTEE} -c 'suspend; echo 2' [3] + Stopped(SIGSTOP) ${INVOKE} ${TESTEE} -c 'suspend; echo 3' [2] ${INVOKE} ${TESTEE} -c 'suspend; echo 2' 2 [3] ${INVOKE} ${TESTEE} -c 'suspend; echo 3' 3 [1] ${INVOKE} ${TESTEE} -c 'suspend; echo 1' 1 [1] + Stopped(SIGSTOP) ${INVOKE} ${TESTEE} -c 'suspend; echo 4' [1] ${INVOKE} ${TESTEE} -c 'suspend; echo 4' 4 [1] ${INVOKE} ${TESTEE} -c 'suspend' [2] ${INVOKE} ${TESTEE} -c 'suspend' [3] ${INVOKE} ${TESTEE} -c 'suspend; echo 7' 7 1 STOP TTOU 2 ===== test ===== test 1 0 test 2 0 test 3 1 test 4 1 ===== error ===== fg no-such-option 2 fg output error 100 fg no-such-job 1 1 fg no-such-job 2 1 fg too many args 2 fg +m 1 bg no-such-option 2 bg output error 0 bg no-such-job 1 1 bg no-such-job 2 1 bg +m 1 ===== signals ===== INT ignored TERM ignored QUIT ignored INT TERM QUIT TSTP ignored TTOU TSTP 1 2 ===== signals +i -m F ===== ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 CHLD 0 URG 0 ===== signals -i -m F ===== ABRT ALRM BUS FPE HUP ILL KILL PIPE SEGV USR1 USR2 CHLD 0 URG 0 ===== signals +i -m T ===== ABRT ALRM BUS FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2 CHLD 0 URG 0 TSTP TSTP! TSTP 0 TTIN TTIN! TTIN 0 TTOU TTOU! TTOU 0 STOP STOP! STOP 0 ===== signals -i -m T ===== ABRT ALRM BUS FPE HUP ILL KILL PIPE QUIT SEGV TERM USR1 USR2 CHLD 0 URG 0 INT TSTP TSTP! TSTP 0 TTIN TTIN! TTIN 0 TTOU TTOU! TTOU 0 STOP STOP! STOP 0 yash-2.35/tests/error.y.err0000644000175000017500000001341712154557026016030 0ustar magicantmagicant===== consequences of shell errors ===== syntax error: encountered `fi' without a matching `if' and/or `then' .: this command requires an operand getopts: this command requires 2 operands ../yash: $ro is read-only ../yash: $ro is read-only ../yash: parameter `var' is not set ../yash: parameter `var' is not set ===== invocation ===== ../yash: the -c option is specified but no command is given ../yash: the -c option cannot be used with the -s option ../yash: the -c option cannot be used with the -s option ../yash: the -c option cannot be used with the -s option ../yash: the -c option cannot be used with the -s option ../yash: --norc=file: the --norcfile option does not take an argument ../yash: the --profile option requires an argument ../yash: the --rcfile option requires an argument ===== option ===== exec: the -a option requires an argument exec: the --as option requires an argument exec: `-c-' is not a valid option exec: `-cXaY' is not a valid option exec: `--no-such-option' is not a valid option exec: --cle=1: the --clear option does not take an argument ===== set ===== set: the cmdline option cannot be changed once the shell has been initialized set: the interactive option cannot be changed once the shell has been initialized set: the login option cannot be changed once the shell has been initialized set: the stdin option cannot be changed once the shell has been initialized set: `V' is not a valid option set: the cmdline option cannot be changed once the shell has been initialized set: the interactive option cannot be changed once the shell has been initialized set: the login option cannot be changed once the shell has been initialized set: the stdin option cannot be changed once the shell has been initialized set: `--version' is not a valid option set: `--no-such-option' is not a valid option set: `no-such-option' is not a valid option set: the -o option requires an argument set: `-' is not a valid option set: `X' is not a valid option ../yash: --version=X: the --version option does not take an argument ===== cd ===== cd: `--no-such-option' is not a valid option cd: too many operands are specified cd: $OLDPWD is not set cd: $HOME is not set ===== pwd ===== pwd: `--no-such-option' is not a valid option pwd: no operand is expected ===== hash ===== hash: `--no-such-option' is not a valid option hash: no operand is expected hash: `./no/such/command': a command name must not contain `/' hash: command `no_such_command' was not found in $PATH ===== umask ===== umask: `--no-such-option' is not a valid option umask: too many operands are specified ===== typeset ===== typeset: `--no-such-option' is not a valid option typeset: the -f option cannot be used with the -x option typeset: the -f option cannot be used with the -X option typeset: the -x option cannot be used with the -X option typeset: $readonly is read-only ===== unset ===== unset: `--no-such-option' is not a valid option unset: $readonly is read-only unset: function `func' is read-only ===== shift ===== shift: `--no-such-option' is not a valid option shift: 10000: cannot shift so many (there are only 0 positional parameters) ===== getopts ===== getopts: `--no-such-option' is not a valid option getopts: this command requires 2 operands getopts: this command requires 2 operands getopts: `a::' is not a valid option specification getopts: `var=iable' is not a valid variable name ===== read ===== read: `--no-such-option' is not a valid option read: this command requires an operand read: `b=r' is not a valid variable name ===== trap ===== trap: `--no-such-option' is not a valid option trap: this command requires 2 operands trap: SIGKILL cannot be trapped trap: SIGSTOP cannot be trapped trap: no such signal `NO-SUCH-SIGNAL' ===== kill ===== kill: no such signal `-NO-SUCH-OPTION' kill: the -n option cannot be used with the -l option kill: the -s option cannot be used with the -l option kill: this command requires an operand kill: no such signal `0' kill: no such job `%100' ===== jobs kill ===== jobs: `--no-such-option' is not a valid option jobs: no such job `%100' jobs: no such job `%no_such_job' kill: `%while' is not a job-controlled job ===== wait ===== wait: `--no-such-option' is not a valid option ===== return ===== return: `--no-such-option' is not a valid option return: `foo' is not a valid integer return: `-3' is not a valid integer return: too many operands are specified return: cannot be used in the interactive mode ===== break ===== break: `--no-such-option' is not a valid option break: too many operands are specified break: not in a loop break: not in an iteration break: no operand is expected ===== continue ===== continue: `--no-such-option' is not a valid option continue: too many operands are specified continue: not in a loop continue: not in an iteration continue: no operand is expected ===== eval ===== eval: `--no-such-option' is not a valid option ===== dot ===== .: `--no-such-option' is not a valid option .: this command requires an operand ===== exec ===== exec: `--no-such-option' is not a valid option ===== command ===== command: `--no-such-option' is not a valid option command: the -a or -k option must be used with the -v option command: the -a or -k option must be used with the -v option command: no such command `no_such_command' =1= =2= command: no such command `no_such_command' ===== times ===== times: `--no-such-option' is not a valid option times: no operand is expected ===== exit ===== exit: `--no-such-option' is not a valid option exit: `foo' is not a valid integer exit: `-3' is not a valid integer exit: too many operands are specified ===== suspend ===== suspend: `--no-such-option' is not a valid option suspend: no operand is expected ===== ulimit ===== ulimit: the -a option cannot be used with the -f option ulimit: `xxx' is not a valid integer ulimit: too many operands are specified ulimit: no operand is expected yash-2.35/tests/error.y.out0000644000175000017500000001071212154557026016042 0ustar magicantmagicant===== consequences of shell errors ===== syntax error non-interactive 2 syntax error interactive mainshell 1000 syntax error interactive subshell 2 [ok] special builtin syntax error 2 non-special builtin syntax error 2 special builtin redirection error 2 non-special builtin redirection error 2 special builtin assignment error 2 non-special builtin assignment error 2 special builtin expansion error non-interactive 2 special builtin expansion error interactive mainshell 2 special builtin expansion error interactive subshell 2 non-special builtin expansion error non-interactive 2 non-special builtin expansion error interactive mainshell 2 non-special builtin expansion error interactive subshell 2 command not found error 127 ===== invocation ===== -c 2 -c and -s 1 2 -c and -s 2 2 -c and -s 3 2 -c and -s 4 2 this is not an error -c and -s 5 0 invalid option argument 1 2 missing argument profile 2 missing argument rcfile 2 ambiguous option 2 ===== option ===== option missing argument short 2 option missing argument long 2 option no-such-option 1 2 option no-such-option 2 2 option no-such-option 3 2 option invalid option argument 2 ===== set ===== set -c 2 set -i 2 set -l 2 set -s 2 set -V 2 set --cmdline 2 set --interactive 2 set --login 2 set --stdin 2 set --version 2 set no-such-option 1 2 set no-such-option 2 2 set output error 1 set ambiguous option 1 2 set ambiguous option 2 2 set missing argument 2 set invalid option 1 2 set invalid option 2 2 set unexpected option argument 2 ===== cd ===== cd no-such-option 2 cd too-many-operands 2 cd no-such-dir 1 cd no OLDPWD 1 cd no HOME 1 cd output error 0 ===== pwd ===== pwd no-such-option 2 pwd invalid operand 2 pwd output error 1 ===== hash ===== hash no-such-option 2 hash invalid operand 2 hash slash argument 1 hash command not found 1 hash output error 1 ===== umask ===== umask no-such-option 2 umask too-many-operands 2 umask output error 1 ===== typeset ===== typeset no-such-option 2 typeset invalid-option-combination 1 2 typeset invalid-option-combination 2 2 typeset invalid-option-combination 3 2 typeset output error 1 1 typeset output error 2 1 typeset output error 3 1 typeset output error 4 1 typeset output error 5 1 typeset output error 6 1 typeset readonly 1 ===== unset ===== unset no-such-option 2 unset readonly variable 1 unset readonly function 1 ===== shift ===== shift no-such-option 2 shift shifting too many 1 ===== getopts ===== getopts no-such-option 2 getopts operands missing 1 2 getopts operands missing 2 2 getopts invalid opt 1 getopts invalid var 1 ===== read ===== read no-such-option 2 read operands missing 2 read input closed 1 read invalid identifier 1 ===== trap ===== trap no-such-option 2 trap operands missing 2 trap KILL 1 trap STOP 1 trap output error 1 1 trap output error 2 1 trap output error 3 1 trap no-such-signal 1 ===== kill ===== kill no-such-option 1 kill invalid-option-combination l n 2 kill invalid-option-combination l s 2 kill operands missing 2 kill no-such-signal 1 kill no-such-job 1 kill output error 1 1 kill output error 2 1 ===== jobs kill ===== jobs no-such-option 2 jobs output error 1 jobs no-such-job 1 1 jobs no-such-job 2 1 ===== wait ===== wait no-such-option 2 wait no-such-job 1 127 wait no-such-job 2 127 ===== return ===== return no-such-option 2 return invalid operand 1 2 return invalid operand 2 2 return too many operands 2 return reached ===== break ===== break no-such-option 2 break invalid operand 1 2 break not in loop 2 break not in iteration 2 break invalid operand 2 2 ===== continue ===== continue no-such-option 2 continue invalid operand 1 2 continue not in loop 2 continue not in iteration 2 continue invalid operand 2 2 ===== eval ===== eval no-such-option 2 ===== dot ===== dot no-such-option 2 dot operand missing 2 dot script not found in PATH 1 dot file-not-found 1 ===== exec ===== exec no-such-option 2 exec command not found 127 ===== command ===== command no-such-option 2 command invalid-option 1 2 command invalid-option 2 2 command output error 1 command no-such-command 1 127 command no-such-command 2 1 command no-such-command 3 1 ===== times ===== times no-such-option 2 times invalid operand 2 times output error 1 ===== exit ===== exit no-such-option 2 exit invalid operand 1 2 exit invalid operand 2 2 exit too many operands 2 ===== suspend ===== suspend no-such-option 2 suspend invalid operand 2 ===== ulimit ===== ulimit no-such-option 2 ulimit invalid option 2 ulimit output error 1 ulimit invalid operand 2 ulimit too many operands 1 2 ulimit too many operands 2 2 yash-2.35/tests/help.y.out0000644000175000017500000000027612154557026015645 0ustar magicantmagicant===== 1 0 ===== 2 0 ===== 3 0 ===== 4 0 ===== 5 0 ===== 6 0 ===== 7 0 ===== 8 0 ===== 9 0 ===== 10 0 ===== 11 0 ===== 12 0 ===== 13 0 ===== 14 0 help no-such-option 2 help no-such-builtin 1 yash-2.35/tests/sig.p.tst0000644000175000017500000000327312154557026015471 0ustar magicantmagicant# sig.p.tst: test of signal handling for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: command -b ulimit -c 0 2>/dev/null tmp="${TESTTMP}/sig.p.tmp" exec 2>/dev/null echo ===== kill ===== kill -l >/dev/null $INVOKE $TESTEE -c 'kill $$' & wait $! kill -l $? # an asynchronous command prevents itself from being killed by SIGINT/SIGQUIT $INVOKE $TESTEE -c 'cd /tmp; kill -s INT $$; echo SIGINT ' & wait $! $INVOKE $TESTEE -c 'cd /tmp; kill -s QUIT $$; echo SIGQUIT' & wait $! echo ===== trap ===== trap -- "" USR1 kill -s USR1 $$ echo ok 1 trap "" USR1 $INVOKE $TESTEE -c "kill -s USR1 $$ \$\$; echo ok 2" echo ok 3 trap '' USR1 trap 'echo USR2 trapped' USR2 $INVOKE $TESTEE -c 'kill -s USR1 $$; kill -s USR2 $$; echo not printed' & wait $! kill -l $? echo ok 4 trap 'trap - USR1; echo USR1 trapped' USR1 kill -s USR1 $$ $INVOKE $TESTEE -c 'kill -s USR1 $$' kill -l $? echo ok 5 trap 'echo trapped' USR1 USR2 trap >"$tmp" trap - USR1 trap command2 USR2 . "$tmp" rm -f "$tmp" kill -s USR1 $$ kill -s USR2 $$ echo ok 6 # in subshell traps other than ignore are cleared trap '' USR1 trap 'echo trapped' USR2 (trap | grep -v USR1) echo ok 7 # signals that were ignored on entry to a non-interactive shell cannot be # trapped or reset $INVOKE $TESTEE -c 'trap - USR1 2>/dev/null; kill -USR1 $$; kill -USR2 $$' kill -l $? # prints USR2. USR1 is still ignored $INVOKE $TESTEE -c 'trap : USR1 2>/dev/null; kill -USR1 $$; kill -USR2 $$' kill -l $? echo ok 8 # if the first operand is integer, all operands are considered as signal # specification and these signals' handlers are cancelled trap '' USR1 trap 2 USR1 $INVOKE $TESTEE -c 'kill -s USR1 $$; echo "not printed"' kill -l $? # prints USR1 yash-2.35/tests/sig.p.out0000644000175000017500000000022412154557026015457 0ustar magicantmagicant===== kill ===== TERM SIGINT SIGQUIT ===== trap ===== ok 1 ok 2 ok 3 USR2 ok 4 USR1 trapped USR1 ok 5 trapped trapped ok 6 ok 7 USR2 USR2 ok 8 USR1 yash-2.35/tests/error.p.tst0000644000175000017500000000330712154557026016036 0ustar magicantmagicant# error.p.tst: test of error handling for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: echo ===== consequences of shell errors ===== $INVOKE $TESTEE 2>/dev/null <<\END fi echo not printed END if [ $? -ne 0 ]; then echo syntax error ok; fi $INVOKE $TESTEE <<\END . 2>/dev/null echo not printed END if [ $? -ne 0 ]; then echo special builtin syntax error ok; fi $INVOKE $TESTEE <<\END getopts 2>/dev/null if [ $? -ne 0 ]; then echo non-special builtin syntax error ok; fi END $INVOKE $TESTEE <<\END exec 3>&- { exit >&3; } 2>/dev/null echo not printed END if [ $? -ne 0 ]; then echo special builtin redirection error ok; fi $INVOKE $TESTEE <<\END exec 3>&- { cd . >&3; } 2>/dev/null if [ $? -ne 0 ]; then echo non-special builtin redirection error ok; fi END $INVOKE $TESTEE <<\END readonly ro=v { ro=v :; } 2>/dev/null echo not printed END echo special builtin assignment error ok $INVOKE $TESTEE <<\END readonly ro=v { ro=v cd .; } 2>/dev/null echo non-special builtin assignment error ok END $INVOKE $TESTEE <<\END unset var { eval ${var?}; } 2>/dev/null echo not printed END if [ $? -ne 0 ]; then echo special builtin expansion error ok; fi $INVOKE $TESTEE <<\END unset var { cd ${var?}; } 2>/dev/null echo not printed END if [ $? -ne 0 ]; then echo non-special builtin expansion error ok; fi $INVOKE $TESTEE 2>/dev/null <<\END ./no/such/command END if [ $? -eq 127 ]; then echo command not found error ok; fi echo ===== . ===== $INVOKE $TESTEE 2>/dev/null <<\END PATH= . no_such_command echo not printed END if [ $? -ne 0 ]; then echo . PATH not found error ok; fi $INVOKE $TESTEE 2>/dev/null <<\END . ./no/such/command echo not printed END if [ $? -ne 0 ]; then echo . file not found error ok; fi yash-2.35/tests/option.y.out0000644000175000017500000000171712154557026016226 0ustar magicantmagicant===== -h ===== 1 ===== exec ===== printed ===== nocaseglob ===== option.y.tst OPTION.y.tst O[OPQ]T*ON.y.tst OPTION.y.tst ===== dotglob ===== . .. .dotfile * ===== markdirs ===== dir/ dir ===== extendedglob ===== anotherdir/file dir/dir2/file anotherdir/file anotherdir/loop/dir2/file dir/dir2/file dir/dir2/link/file anotherdir/file anotherdir/file dir/**/file dir/***/file dir/.dir2/file dir/.dir2/file dir/.dir2/link/file dir/**/file dir/***/file dir/.dir2/file dir/.dir2/file ===== nullglob ===== f[o/b]r 1 n*ll f[o/b]r f?o/b*r 2 ===== traceall ===== no/such/command 1 + no/such/command 1 + echo not found no/such/command 1 not found no/such/command 1 + HANDLED=1 set +o traceall + set +o traceall no/such/command 2 + no/such/command 2 not found no/such/command 2 set -o traceall + set -o traceall no/such/command 3 + no/such/command 3 + echo not found no/such/command 3 not found no/such/command 3 + HANDLED=1 ===== posix ===== 1 0 0 ===== -o +o ===== ok ===== abbr ==== yash-2.35/tests/init.y.tst0000644000175000017500000000653012154557026015662 0ustar magicantmagicant# option.y.tst: yash-specific test of shell options # vim: set ft=sh ts=8 sts=4 sw=4 noet: TESTTMP="${TESTTMP}/option.y.tmp" export TESTTMP mkdir -p "$TESTTMP" cat >"${TESTTMP}/.yash_profile" <<\END echo profile 1 . -- "${TESTTMP}/file1" echo profile 2 . -- "${TESTTMP}/file2" echo profile 3 END cat >"${TESTTMP}/.yashrc" <<\END echo yashrc 1 . -- "${TESTTMP}/file1" echo yashrc 2 . -- "${TESTTMP}/file2" echo yashrc 3 END cat >"${TESTTMP}/file1" <<\END echo file 1 END cat >"${TESTTMP}/file2" <<\END echo file 2 END cat >"${TESTTMP}/file3" <<\END echo file 3 END cat >"${TESTTMP}/error1" <<\END echo error 1 . "${TESTTMP}/error2" echo error 1 syntax error \$\?=$? unset var echo ${var?} echo error 1 expansion error \$\?=$? fi echo not reached END cat >"${TESTTMP}/error2" <<\END echo error 2 unset var echo ${var?} echo error 2 expansion error \$\?=$? fi echo not reached END export HOME= ENV= echo ===== 1 ===== echo ===== 1 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -l -c 'echo main' echo ===== 2 ===== echo ===== 2 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE --log-in -c 'echo main' echo ===== 3 ===== echo ===== 3 ===== >&2 $INVOKE $TESTEE -l --profile="${TESTTMP}/file1" -c 'echo main' echo ===== 4 ===== echo ===== 4 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -i +m -c 'echo main' echo ===== 5 ===== echo ===== 5 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE --interactive --nomonitor -c 'echo main' echo ===== 6 ===== echo ===== 6 ===== >&2 $INVOKE $TESTEE -i --rcfile="${TESTTMP}/file1" +m -c 'echo main' echo ===== 7 ===== echo ===== 7 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -il --profile="${TESTTMP}/file1" +m -c 'echo main' echo ===== 8 ===== echo ===== 8 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -il --rcfile="${TESTTMP}/file2" +m -c 'echo main' echo ===== 9 ===== echo ===== 9 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -il --profile="${TESTTMP}/file1" +m --rcfile="${TESTTMP}/file2" -c 'echo main' echo ===== 10 ===== echo ===== 10 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -c 'echo main' echo ===== 11 ===== echo ===== 11 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -il --profile="${TESTTMP}/file1" --norcfile +m -c 'echo main' echo ===== 12 ===== echo ===== 12 ===== >&2 HOME="${TESTTMP}" $INVOKE $TESTEE -il --noprofile --rcfile="${TESTTMP}/file2" +m -c 'echo main' echo ===== 13 ===== echo ===== 13 ===== >&2 HOME="${TESTTMP}" ENV='${HOME}/file3' $INVOKE $TESTEE --posix -c 'echo main' echo ===== 14 ===== echo ===== 14 ===== >&2 HOME="${TESTTMP}" ENV='${HOME}/file3' $INVOKE $TESTEE --posix -ci +m 'echo main' : =========================================================================== : echo ===== error 1 ===== echo ===== error 1 ===== >&2 $INVOKE $TESTEE -l --profile="${TESTTMP}/error1" -c 'echo main' 2>/dev/null echo ===== error 2 ===== echo ===== error 2 ===== >&2 $INVOKE $TESTEE -i --rcfile="${TESTTMP}/error1" +m -c 'echo main' 2>/dev/null : =========================================================================== : export HOME="${TESTTMP}/no.such.directory" unset ENV echo ===== non-existing 1 ===== echo ===== non-existing 1 ===== >&2 $INVOKE $TESTEE --posix -ci +m 'echo main' echo ===== non-existing 2 ===== echo ===== non-existing 2 ===== >&2 $INVOKE $TESTEE -cil +m 'echo main' echo ===== non-existing 3 ===== echo ===== non-existing 3 ===== >&2 (unset HOME && $INVOKE $TESTEE -cil +m 'echo main') rm -fr "$TESTTMP" yash-2.35/tests/resetsig.d0000644000175000017500000000004412154557026015700 0ustar magicantmagicantresetsig.o: resetsig.c ../siglist.h yash-2.35/tests/expand.p.out0000644000175000017500000000304612154557026016161 0ustar magicantmagicant===== tilde expansion ===== $HOME path=~:~ ~home ~home ~/dir /tmp/home/dir ===== parameter expansion ===== 123/456/789 123/456/789 123/456/789 123/456/789 1 2 1 2 1 2 1 2 1 -- 2 1 -- 2 1 - - 2 1 - - 2 unset variable and set variable 1 null variable 2 3 1 2 3 1 2 3 1 unset var 2 unset var 3 1 unset var 2 1 2 3 1 2 3 1 set var 2 set var 3 1 set var 2 unset variable error null variable error 123/456/789 123/456/789 unset 123/456/789 123/456/789 NULL UNSET 123/456/789 NULL UNSET 456/789 789 123/456 123 456/789 123/456 123/456/789 123/456/789 123/456/789 123/456/789 **** ${#var}=11 ===== command substitution ===== \$x $x \$x ) abc a here-doc with ) another here-doc ===== arithmetic expansion ===== 5 3 prefix 5 10 1 0 0 multiplicatives 2 additives 9 shifts 20 comparisons 0 1 1 0 0 1 0 0 0 comparisons 1 1 1 0 1 1 0 0 1 comparisons 0 0 0 1 0 0 1 1 0 comparisons 1 0 0 1 1 0 1 1 1 equalities 1 0 0 0 1 0 0 0 1 equalities 0 1 1 1 0 1 1 1 0 logicals 0 0 0 1 logicals 0 1 1 1 logicals 1 0 2 logicals 1 1 1 conditionals 2 2 9 9 1 assignments 0 5 3 24 4 16 8 15 10 2 2 parentheses 2 -2 9 mul-add 1 add-shift 80 3 shift-comp 1 0 comp-equal 1 0 equal-and 1 1 and-xor 15 15 xor-or 1 1 or-land 1 1 land-lor 1 1 lor-cond-assign 1 0 3 3 1 1 3 3 10 unset-var 0 0 ===== field splitting ===== +1+2+3+4+ +1 2 +3+4+ 5+ +6+ +1 2+3 4+ +1 2 3+4 5 6+ -bar- -- -xyz- -- -abc- /tmp/home /tmp/home 1\\2\3\4 1\2 [ 1 2 3 ] 4 5,6 4,5,6 command subst 1 1 ===== [ ] [ 1 5 ] [ 1 5 ] [ 1 5 ] [ 1 5 ] [ ] [ ] [ ] [ ] [ ] [ -- ] [ ] [ -- ] ===== 1 2 2 3 1 2 2 3 12 23 yash-2.35/tests/path.y.tst0000644000175000017500000000057312154557026015654 0ustar magicantmagicant# path.y.tst: yash-specific test of pathname handling # vim: set ft=sh ts=8 sts=4 sw=4 noet: echo ===== cd builtin ===== cd --default-directory="$TESTTMP" if [ x"$PWD" = x"$TESTTMP" ]; then echo cd --default-directory=\$TESTTMP fi mkdir -p ./- cd --default-directory="-" if [ x"$PWD" = x"$TESTTMP/-" ]; then echo cd --default-directory=- fi cd - >/dev/null rmdir ./- yash-2.35/tests/input.p.err0000644000175000017500000000012712154557026016017 0ustar magicantmagicant% echo \ > ok % cat < here-document > ok > END % PS1='${PWD##"${PWD}"}? ' ? PS1= yash-2.35/tests/lineedit.y.out0000644000175000017500000000120712154557026016505 0ustar magicantmagicant===== bindkey ===== bindkey -v '\#' eof-if-empty bindkey -v 'a' self-insert bindkey -v '\#' noop unbound 1 1 unbound 2 1 unbound 3 1 bindkey -v 'a' noop bindkey -v '\#' eof bindkey -v '\X' emacs-transpose-chars no bindings 0 1 0 2 0 3 0 4 0 ===== error ===== bindkey no-such-option 2 bindkey ambiguous-option 1 2 bindkey: option `--vi' is ambiguous bindkey ambiguous-option 2 bindkey operand missing 2 bindkey too many operands 1 2 bindkey too many operands 2 2 bindkey invalid operand 1 1 bindkey invalid operand 2 1 bindkey unbound sequence 1 bindkey output error 1 1 bindkey output error 2 1 complete no-such-option 2 complete not-completing 2 yash-2.35/tests/printf.y.tst0000644000175000017500000001722312154557026016222 0ustar magicantmagicant# printf.y.tst: yash-specific test of the echo and printf builtins # vim: set ft=sh ts=8 sts=4 sw=4 noet: echo ===== echo ===== unset ECHO_STYLE echo 123 456 789 echo 1 22 '3 3' "4 4" 5\ 5 testecho() { echo ===== ${ECHO_STYLE-unset} echo -n new echo line echo -n new line echo '1\a2\b3\c4' 5 echo '6\f7\n8\r9\t0\v!' echo '\0123\012\01x' '\123\12\1x' '\00411' echo -e '1\c2' echo -e -E '1\c2' echo -eE '1\c2' echo -ne 123 '-\c-' 456 echo } testecho ECHO_STYLE=SYSV testecho ECHO_STYLE=XSI testecho ECHO_STYLE=BSD testecho ECHO_STYLE=GNU testecho ECHO_STYLE=ZSH testecho ECHO_STYLE=DASH testecho ECHO_STYLE=RAW testecho echo ===== printf ===== printf '' printf '1\n' printf -- 'hello\n' ignored arguments printf 'multiple\nlines ' printf 'continued\n' echo ===== printf 'a\ab\bf\fr\rt\tv\v-\n' printf 'backslash \\\n' printf 'double-quote \"\n' printf "single-quote \\'\n" printf 'octal \11 \1000\n' echo ===== %% printf '%%\n' printf '%%\n' ignored arguments echo ===== %d printf '%d\n' printf '%d\n' 0 printf '%d ' 0 10 200 +345 -1278; echo 1 printf '%+d ' 1 20 +345 -1278; echo 2 printf '%+ d ' 1 20 +345 -1278; echo 3 printf '% d ' 1 20 +345 -1278; echo 4 printf '%+8d ' 1 20 +345 -1278; echo 5 printf '%+-8d ' 1 20 +345 -1278; echo 6 printf '%+08d ' 1 20 +345 -1278; echo 7 printf '%+-08d ' 1 20 +345 -1278; echo 8 printf '%+8.3d ' 1 20 +345 -1278; echo 9 printf '%d ' 00 011 0x1fE 0X1Fe \'a \"@; echo 10 echo ===== %i printf '%i\n' printf '%i\n' 0 printf '%i ' 0 10 200 +345 -1278; echo 1 printf '%+i ' 1 20 +345 -1278; echo 2 printf '%+ i ' 1 20 +345 -1278; echo 3 printf '% i ' 1 20 +345 -1278; echo 4 printf '%+8i ' 1 20 +345 -1278; echo 5 printf '%+-8i ' 1 20 +345 -1278; echo 6 printf '%+08i ' 1 20 +345 -1278; echo 7 printf '%+-08i ' 1 20 +345 -1278; echo 8 printf '%+8.3i ' 1 20 +345 -1278; echo 9 printf '%i ' 00 011 0x1fE 0X1Fe \'a \"@; echo 10 echo ===== %u printf '%u\n' printf '%u\n' 0 printf '%u ' 0 10 200 +345; echo 1 printf '%+u ' 1 20 +345; echo 2 printf '%+ u ' 1 20 +345; echo 3 printf '% u ' 1 20 +345; echo 4 printf '%8u ' 1 20 +345; echo 5 printf '%-8u ' 1 20 +345; echo 6 printf '%08u ' 1 20 +345; echo 7 printf '%-08u ' 1 20 +345; echo 8 printf '%8.3u ' 1 20 +345; echo 9 printf '%u ' 00 011 0x1fE 0X1Fe \'a \"@; echo 10 echo ===== %o printf '%o\n' printf '%o\n' 0 printf '%o ' 0 10 200 +345; echo 1 printf '%+o ' 1 20 +345; echo 2 printf '%+ o ' 1 20 +345; echo 3 printf '% o ' 1 20 +345; echo 4 printf '%8o ' 1 20 +345; echo 5 printf '%-8o ' 1 20 +345; echo 6 printf '%08o ' 1 20 +345; echo 7 printf '%-08o ' 1 20 +345; echo 8 printf '%8.3o ' 1 20 +345; echo 9 printf '%o ' 00 011 0x1fE 0X1Fe \'a \"@; echo 10 printf '%#.3o ' 0 3 010 0123 012345; echo 11 echo ===== %x printf '%x\n' printf '%x\n' 0 printf '%x ' 0 10 200 +345; echo 1 printf '%+x ' 1 20 +345; echo 2 printf '%+ x ' 1 20 +345; echo 3 printf '% x ' 1 20 +345; echo 4 printf '%8x ' 1 20 +345; echo 5 printf '%-8x ' 1 20 +345; echo 6 printf '%08x ' 1 20 +345; echo 7 printf '%-08x ' 1 20 +345; echo 8 printf '%8.3x ' 1 20 +345; echo 9 printf '%x ' 00 011 0x1fE 0X1Fe \'a \"@; echo 10 printf '%#x ' 00 011 0x1fE 0X1Fe \'a \"@; echo 11 echo ===== %X printf '%X\n' printf '%X\n' 0 printf '%X ' 0 10 200 +345; echo 1 printf '%+X ' 1 20 +345; echo 2 printf '%+ X ' 1 20 +345; echo 3 printf '% X ' 1 20 +345; echo 4 printf '%8X ' 1 20 +345; echo 5 printf '%-8X ' 1 20 +345; echo 6 printf '%08X ' 1 20 +345; echo 7 printf '%-08X ' 1 20 +345; echo 8 printf '%8.3X ' 1 20 +345; echo 9 printf '%X ' 00 011 0x1fE 0X1Fe \'a \"@; echo 10 printf '%#X ' 00 011 0x1fE 0X1Fe \'a \"@; echo 11 echo ===== %f printf '%f\n' printf '%f\n' 0 printf '%f ' 1 1.25 -1000.0; echo 1 printf '%+f ' 1 1.25 -1000.0; echo 2 printf '%+ f ' 1 1.25 -1000.0; echo 3 printf '% f ' 1 1.25 -1000.0; echo 4 printf '%+15f ' 1 1.25 -1000.0; echo 5 printf '%+-15f ' 1 1.25 -1000.0; echo 6 printf '%+015f ' 1 1.25 -1000.0; echo 7 printf '%+-015f ' 1 1.25 -1000.0; echo 8 printf '%+15.3f ' 1 1.25 -1000.0; echo 9 printf '%.0f ' 1 1.25 -1000.0; echo 10 printf '%#.0f ' 1 1.25 -1000.0; echo 11 echo ===== %F printf '%F\n' printf '%F\n' 0 printf '%F ' 1 1.25 -1000.0; echo 1 printf '%+F ' 1 1.25 -1000.0; echo 2 printf '%+ F ' 1 1.25 -1000.0; echo 3 printf '% F ' 1 1.25 -1000.0; echo 4 printf '%+15F ' 1 1.25 -1000.0; echo 5 printf '%+-15F ' 1 1.25 -1000.0; echo 6 printf '%+015F ' 1 1.25 -1000.0; echo 7 printf '%+-015F ' 1 1.25 -1000.0; echo 8 printf '%+15.3F ' 1 1.25 -1000.0; echo 9 printf '%.0F ' 1 1.25 -1000.0; echo 10 printf '%#.0F ' 1 1.25 -1000.0; echo 11 echo ===== %e printf '%e\n' printf '%e\n' 0 printf '%e ' 1 1.25 -1000.0; echo 1 printf '%+e ' 1 1.25 -1000.0; echo 2 printf '%+ e ' 1 1.25 -1000.0; echo 3 printf '% e ' 1 1.25 -1000.0; echo 4 printf '%+15e ' 1 1.25 -1000.0; echo 5 printf '%+-15e ' 1 1.25 -1000.0; echo 6 printf '%+015e ' 1 1.25 -1000.0; echo 7 printf '%+-015e ' 1 1.25 -1000.0; echo 8 printf '%+15.3e ' 1 1.25 -1000.0; echo 9 printf '%.0e ' 1 1.25 -1000.0; echo 10 printf '%#.0e ' 1 1.25 -1000.0; echo 11 echo ===== %E printf '%E\n' printf '%E\n' 0 printf '%E ' 1 1.25 -1000.0; echo 1 printf '%+E ' 1 1.25 -1000.0; echo 2 printf '%+ E ' 1 1.25 -1000.0; echo 3 printf '% E ' 1 1.25 -1000.0; echo 4 printf '%+15E ' 1 1.25 -1000.0; echo 5 printf '%+-15E ' 1 1.25 -1000.0; echo 6 printf '%+015E ' 1 1.25 -1000.0; echo 7 printf '%+-015E ' 1 1.25 -1000.0; echo 8 printf '%+15.3E ' 1 1.25 -1000.0; echo 9 printf '%.0E ' 1 1.25 -1000.0; echo 10 printf '%#.0E ' 1 1.25 -1000.0; echo 11 echo ===== %g printf '%g\n' printf '%g\n' 0 printf '%g ' 1 1.25 -1000.0 0.000025; echo 1 printf '%+g ' 1 1.25 -1000.0 0.000025; echo 2 printf '%+ g ' 1 1.25 -1000.0 0.000025; echo 3 printf '% g ' 1 1.25 -1000.0 0.000025; echo 4 printf '%+15g ' 1 1.25 -1000.0 0.000025; echo 5 printf '%+-15g ' 1 1.25 -1000.0 0.000025; echo 6 printf '%+015g ' 1 1.25 -1000.0 0.000025; echo 7 printf '%+-015g ' 1 1.25 -1000.0 0.000025; echo 8 printf '%+15.3g ' 1 1.25 -1000.0 0.000025; echo 9 printf '%+#15.3g ' 1 1.25 -1000.0 0.000025; echo 10 echo ===== %G printf '%G\n' printf '%G\n' 0 printf '%G ' 1 1.25 -1000.0 0.000025; echo 1 printf '%+G ' 1 1.25 -1000.0 0.000025; echo 2 printf '%+ G ' 1 1.25 -1000.0 0.000025; echo 3 printf '% G ' 1 1.25 -1000.0 0.000025; echo 4 printf '%+15G ' 1 1.25 -1000.0 0.000025; echo 5 printf '%+-15G ' 1 1.25 -1000.0 0.000025; echo 6 printf '%+015G ' 1 1.25 -1000.0 0.000025; echo 7 printf '%+-015G ' 1 1.25 -1000.0 0.000025; echo 8 printf '%+15.3G ' 1 1.25 -1000.0 0.000025; echo 9 printf '%+#15.3G ' 1 1.25 -1000.0 0.000025; echo 10 echo ===== %c printf '%c\n' printf '%c\n' '' printf '%c\n' a printf '%c\n' long arguments printf '%3c\n' b printf '%-3c\n' c echo ===== %s printf '%s\n' printf '%s\n' 'argument with space and newline' printf '%s\n' 'argument with backslash \\ and percent %%' printf '%5s ' 123 a long_argument; echo 1 printf '%5.2s ' 123 a long_argument; echo 2 printf '%-5s ' 123 a long_argument; echo 3 echo ===== %b printf '%b\n' printf '%b\n' 'argument with space and newline' printf '%b\n' 'argument with backslash \\ and percent %%' printf '%5b ' 123 a long_argument; echo 1 printf '%5.2b ' 123 a long_argument; echo 2 printf '%-5b ' 123 a long_argument; echo 3 printf '%-5.2b ' 123 a long_argument; echo 4 printf '%b\n' '1\a2\b3\c4' 5 printf '%b\n' '6\f7\n8\r9\t0\v!' printf '%b\n' '\0123\012\01x' '\123\12\1x' '\00411' echo ===== printf '%d\n' not_a_integer >/dev/null 2>&1 echo $? echo $(printf '%d\n' not_a_integer 2>/dev/null | wc -l) echo ===== error ===== printf --no-such-option echo printf no-such-option $? (printf foo >&- 2>/dev/null) echo printf output error $? printf echo printf operand missing $? printf '%d\n' foo 2>/dev/null echo printf invalid operand $? (echo foo >&- 2>/dev/null) echo echo output error $? yash-2.35/tests/path.y.out0000644000175000017500000000012012154557026015635 0ustar magicantmagicant===== cd builtin ===== cd --default-directory=$TESTTMP cd --default-directory=- yash-2.35/tests/path.p.out0000644000175000017500000000067712154557026015645 0ustar magicantmagicant===== pathname expansion ===== 1 pathexp/unreadable/file 2 pathexp/unreadable/file 3 pathexp/unreadable/file 4 pathexp/unreadable/file 5 pathexp/un*able/f*le 6 pathexp/unreadable/f*le 7 pathexp/un*able/file 8 pathexp/un*able/f*le 9 pathexp/unreadable/f*le ===== cd builtin ===== cd $HOME cd $OLDPWD cd $PWD cd -P cd -L cd -L default cd $CDPATH 1 cd $CDPATH 2 cd canonicalization /dev ===== umask builtin ===== u=,g=,o= ok ===== hash builtin ===== yash-2.35/tests/printf.y.err0000644000175000017500000000013212154557026016167 0ustar magicantmagicantprintf: `--no-such-option' is not a valid option printf: this command requires an operand yash-2.35/tests/variable.y.tst0000644000175000017500000001220312154557026016476 0ustar magicantmagicant# variable.y.tst: yash-specific test of variables # vim: set ft=sh ts=8 sts=4 sw=4 noet: printf "%s\n" IFS=["$IFS"] IFS= $INVOKE $TESTEE -c 'printf "%s\n" IFS=["$IFS"]' (unset IFS; $INVOKE $TESTEE -c 'printf "%s %s\n" IFS ${IFS+set}') ( unset IFS v='1 2 3' echo $v "${IFS=-}" $v ) RANDOM=123 (echo $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM RANDOM=456 echo $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM) >"${TESTTMP}/variable.y.tm1" (echo $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM RANDOM=456 echo $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM) >"${TESTTMP}/variable.y.tm2" diff "${TESTTMP}/variable.y.tm1" "${TESTTMP}/variable.y.tm2" && echo ok oldrand=$RANDOM rand=$RANDOM while [ "$oldrand" = "$rand" ]; do oldrand=$rand rand=$RANDOM done echo ===== 1 ===== func1 () { echo func1; } func2 () { echo func2; } func1; func2; func1 () { func1 () { echo re-defined func1; } func2 () { echo re-defined func2; } echo re-defined. } func2; func1; func2; func1; echo ===== 2 ===== echol () { typeset i # local for i do printf "%s\n" "$i" done } unset i ary=123 echol "$ary" ary=(1 22 '3 3' 4\ \ \ 4 5) echol "$ary" ary=456 echol "$ary" ary=(9\ 9 8' '8" "8 7 #comment ${ary/5/ }) echol "$ary" ary=(test of array) echo i "${i-unset}" ary0=() unset ary0 echo ary0 "${ary0-unset}" echo ===== 3 ===== ( YASH_AFTER_CD='echo -\> "$PWD"' cd / YASH_AFTER_CD=('echo cd' 'continue -i; echo ng' 'break -i' 'echo NG') cd "$OLDPWD" ) echo ===== 4 ===== ( savepath=$PATH COMMAND_NOT_FOUND_HANDLER='PATH=$savepath echo not found: "$@"' \ PATH= _no_such_command_ a b c echo exitstatus=$? _no_such_command_ a b c echo exitstatus=$? COMMAND_NOT_FOUND_HANDLER='echo cd "$@" && cd "$@" && HANDLED=1' / echo exitstatus=$? HANDLED=${HANDLED:-unset} PWD=$PWD "$OLDPWD" >/dev/null echo exitstatus=$? HANDLED=${HANDLED:-unset} ) 2>/dev/null COMMAND_NOT_FOUND_HANDLER=('echo not found: "$@"' \ 'HANDLED=1' 'unset COMMAND_NOT_FOUND_HANDLER') /dev /tmp # 2>/dev/null echo ${COMMAND_NOT_FOUND_HANDLER-unset} # handler is not called in handler COMMAND_NOT_FOUND_HANDLER='_no_such_command_' _no_such_command_ 2>/dev/null echo exitstatus=$? echo ===== 5 ===== $INVOKE $TESTEE <<\END echo $LINENO echo $LINENO \ \ func () { echo $LINENO echo $LINENO } echo $LINENO func END echo ===== $INVOKE $TESTEE -i +m --norcfile 2>/dev/null <<\END # in an interactive shell, $LINENO is reset for each command execution echo $LINENO echo $LINENO \ \ func () { echo $LINENO echo $LINENO } echo $LINENO func END echo ===== typeset export ===== func () { typeset foo=abc bar bar=def echo $foo$bar export foo bar=xyz $INVOKE $TESTEE -c 'echo $foo$bar' typeset -g baz qux=global typeset typeset -g | grep '^typeset baz$' } foo=foo bar=bar func $INVOKE $TESTEE -c 'echo $foo $bar' echo ${baz-unset} $qux func () { export -g baz qux export -p baz qux } func $INVOKE $TESTEE -c 'echo ${baz-unset} $qux' typeset -px baz qux typeset -X qux $INVOKE $TESTEE -c 'echo ${qux-unset}' echo ${qux-unset} export ary export -p ary env | grep "^ary=" ( ary=() typeset -p ary ) echo ===== unset readonly ===== unset foo bar baz qux $INVOKE $TESTEE -c 'echo ${foo-unset} ${bar-unset} ${baz-unset} ${qux-unset}' readonly ro=readonly echo $ro func () { typeset ro=local echo func $ro unset ro echo func $ro typeset ro ro=localagain echo func $ro readonly -x ro2=export $INVOKE $TESTEE -c 'echo $ro2' (ro2=xxx; unset ro2; $INVOKE $TESTEE -c 'echo $ro2') 2>/dev/null readonly -p } func unset ro3 ro3=dummy typeset -r ro3=ro3 typeset -pr ro ro3 for num in 1 2 3 4 5; do echo $num if [ $num = 3 ]; then readonly num fi done 2>/dev/null readonly ary ary=(cannot assign) 2>/dev/null readonly -p ary typeset -p ary echo $ary echo ===== function typeset/unset ===== func () { echo ok $? } function x=1 { echo equal } { typeset -fp func typeset -fp x=1 typeset -fp } | sed 's/^ *//' readonly -f func { func () { echo invalid re-definition; } } 2>/dev/null func unset -f func 2>/dev/null func unset -f x=1 typeset -fp x=1 2>/dev/null func echo ===== read ===== unset a printf "%s" '12\' | ( read a echo $? "$a" ) printf "%s" '12\' | ( read -r a echo $? "$a" ) echo ===== unset IFS a b c d e read -A a b c < / cd ===== 4 ===== not found: _no_such_command_ a b c exitstatus=127 exitstatus=127 cd / exitstatus=0 HANDLED=unset PWD=/ exitstatus=0 HANDLED=unset not found: /dev /tmp unset exitstatus=127 ===== 5 ===== 1 2 10 7 8 ===== 1 1 1 5 6 ===== typeset export ===== abcdef abcxyz typeset -x bar='xyz' typeset -x foo='abc' typeset baz foo bar unset global export baz export qux='global' unset global typeset -x baz typeset -x qux='global' unset global ary=('test' 'of' 'array') export ary ary=test:of:array ary=() typeset -x ary ===== unset readonly ===== unset unset unset unset readonly func local func readonly func localagain export export readonly ro2='export' typeset -r ro='readonly' typeset -r ro3='ro3' 1 2 3 ary=('test' 'of' 'array') readonly ary ary=('test' 'of' 'array') typeset -xr ary test of array ===== function typeset/unset ===== func() { echo ok ${?} } function 'x=1'() { echo equal } echol() { typeset i for i do printf "%s\n" "${i}" done } func() { echo ok ${?} } func1() { echo re-defined func1 } func2() { echo re-defined func2 } function 'x=1'() { echo equal } ok 2 ok 1 ok 1 ===== read ===== 1 12 1 12\ ===== 1 2 33 1 2 1 2 3 4 5 3 4 5 3 1 2 3 1 2 34 5 2 1 2 3 0 ===== 1 2-3 4 5-6 7-8 9 4 1 2\ 3 4 5\ 6 7\ 8 9\ 7 2 3 4 3 6 7 8 3 0 1 2 yash-2.35/tests/prompt.y.err0000644000175000017500000000033512154557026016213 0ustar magicantmagicant$ printf 'posix PS1={%s}\n' "$PS1" $ printf 'posix PS2={%s}\n' "$PS2" $ printf 'posix PS4={%s}\n' "$PS4" $ exit $ printf 'yash PS1={%s}\n' "$PS1" $ printf 'yash PS2={%s}\n' "$PS2" $ printf 'yash PS4={%s}\n' "$PS4" $ exit yash-2.35/tests/input.p.out0000644000175000017500000000003112154557026016030 0ustar magicantmagicantok here-document ok echo yash-2.35/tests/redir.p.out0000644000175000017500000000102312154557026016000 0ustar magicantmagicantHello, Hello, World. redirection before command 2>/dev/null 2 foo noclobber bar ===== 1 ===== complex redirection not writable not readable exec redirect exec redirect printed 1 exec in group file descriptor closed printed 2 printed 3 printed 4 ===== 2 ===== Test of here-document. <""> "'"''\-\'\" Test of here-document. <"${TERM+}"> "'"''\\-\'\" Test of here-document. <""> "'"''\-\'\" Test of here-document. <"${TERM+}"> "'"''\\-\'\" Test of here-document. 123456 Test of here-document. 123\ 456 1 2 ===== 3 ===== 10000 yash-2.35/tests/fnmatch.p.out0000644000175000017500000000106612154557026016322 0ustar magicantmagicant1 11 21 31 41 51 61 71 81 91 111 112 113 114 121 122 123 124 131 132 133 134 141 142 143 144 211 212 213 214 221 222 223 224 231 232 233 234 241 242 243 244 311 312 313 314 315 321 322 323 324 325 331 332 333 334 335 341 342 343 344 345 351 352 353 354 355 391 392 393 1011 1012 1013 1014 1021 1022 1023 1024 1031 1032 1033 1034 1041 1042 1043 1044 1099 2001 2004 2011 2012 2013 2014 2016 2022 2023 2024 2025 2026 2102 2111 2112 2121 2122 2131 2132 3001 lower 3001 alpha 3001 alnum 3001 graph 3001 print 3001 xdigit 3002 3003 3004 3007 3101 3111 3113 3121 3145 3155 yash-2.35/tests/variable.p.tst0000644000175000017500000001013112154557026016463 0ustar magicantmagicant# variable.p.tst: test of variables for any POSIX-compliant shell # vim: set ft=sh ts=8 sts=4 sw=4 noet: echo $LINENO cat </dev/null (empty=no; echo -$empty-) 2>/dev/null (unset var; echo $var) 2>/dev/null (var=no sleep 0 && echo not reached - sleep) 2>/dev/null (var=no cd && echo not reached - cd) 2>/dev/null export readonlyvar="$(readonly | grep -E '^readonly[[:blank:]]+var=')" $INVOKE $TESTEE -s <<\END eval $readonlyvar (var=no; echo $var) 2>/dev/null END export readonlyempty="$(readonly | grep -E '^readonly[[:blank:]]+empty$')" $INVOKE $TESTEE -s <<\END eval $readonlyempty (empty=no; echo -$empty-) 2>/dev/null END echo ===== function unset ===== echo () { :; } echo ng unset -f echo echo ok echo ===== set shift ===== set 1 2 3 a b c shift echo "$@" shift 2 echo "$@" shift 4 2>/dev/null || echo shift 4 loop () while [ $# -ne 0 ]; do echo "$@" shift done loop x y z echo "$@" shift 3 echo $# "$@" echo ===== getopts ===== echo $OPTIND set -- -a -b "foo bar" -c - -- -d baz while getopts ab:c opt do echo $opt "${OPTARG-unset}" done echo $opt $OPTIND echo ===== 1 OPTIND=1 while getopts a:b opt -a -- -abc -b -- -a foo do echo $opt "${OPTARG-unset}" done echo $opt $OPTIND echo ===== 2 OPTIND=1 while getopts :abcde opt -abc -de fgh do echo $opt "${OPTARG-unset}" done echo $opt $OPTIND OPTIND=1 while getopts :abcde opt -abc -de do echo $opt "${OPTARG-unset}" done echo $opt $OPTIND echo ===== 3 set -- unset opt OPTIND=1 ! getopts "" opt echo $? $opt $OPTIND "${OPTARG-unset}" echo ===== 4 set -- -a b c unset opt OPTIND=1 getopts "" opt 2>/dev/null echo $? $opt "${OPTARG-unset}" set -- -a b c unset opt OPTIND=1 getopts : opt echo $? $opt "${OPTARG-unset}" set -- -a unset opt OPTIND=1 getopts a: opt 2>/dev/null echo $? $opt "${OPTARG-unset}" set -- -a unset opt OPTIND=1 getopts :a: opt echo $? $opt "${OPTARG-unset}" echo ===== read ===== unset IFS a b c d e read a b c <&2 2>/dev/null echo ===== input.t ===== $INVOKE $TESTEE -iv +m --norcfile input.y.t 3>&2 2>/dev/null # test of '\!' is in history.t # TODO test of '\j' in PS1/PS2 yash-2.35/tests/Makefile.in0000644000175000017500000000444412154557026015763 0ustar magicantmagicant# Makefile.in for test of yash # (C) 2007-2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . .POSIX: .SUFFIXES: .c .h .d .o @MAKE_SHELL@ topdir = .. subdir = tests CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LDLIBS = @LDLIBS@ SOURCES = checkfg.c invoke.c resetsig.c TEST_SOURCES = *.tst *.out *.err *.oux *.erx *.t TARGET = @TARGET@ TESTERS = checkfg invoke resetsig TESTEE = $(topdir)/$(TARGET) BYPRODUCTS = $(SOURCES:.c=.o) $(TESTERS) test.log *.dSYM test test-all: tester testee @./resetsig $(SHELL) ./run-test.sh test-posix: @$(MAKE) TEST_ITEMS='*.p.tst' test test-yash: @$(MAKE) TEST_ITEMS='*.y.tst' test tester: $(TESTERS) $(TESTERS): $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS) testee: @+if [ x'$(TESTEE)' = x'$(topdir)/$(TARGET)' ]; then \ (cd $(topdir) && $(MAKE) $(TARGET)); \ fi .c.o: @rm -f $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< DISTFILES = $(SOURCES) $(SOURCES:.c=.d) Makefile.in run-test.sh distfiles: makedeps $(DISTFILES) copy-distfiles: distfiles mkdir -p $(topdir)/$(DISTTARGETDIR) cp $(DISTFILES) $(TEST_SOURCES) $(topdir)/$(DISTTARGETDIR) makedeps: _PHONY @(cd $(topdir) && $(MAKE) $(TARGET)) $(topdir)/$(TARGET) $(topdir)/makedeps.yash $(SOURCES) mostlyclean: rm -fr $(BYPRODUCTS) clean: mostlyclean distclean: clean rm -fr Makefile maintainer-clean: distclean rm -fr $(SOURCES:.c=.d) Makefile: Makefile.in $(topdir)/config.status @+(cd $(topdir) && $(MAKE) config.status) @(cd $(topdir) && $(SHELL) config.status $(subdir)/$@) .PHONY: test test-all test-posix test-yash tester testee distfiles copy-distfiles makedeps mostlyclean clean distclean maintainer-clean _PHONY: @MAKE_INCLUDE@ checkfg.d @MAKE_INCLUDE@ invoke.d @MAKE_INCLUDE@ resetsig.d yash-2.35/job.c0000644000175000017500000012074612154557026013476 0ustar magicantmagicant/* Yash: yet another shell */ /* job.c: job control */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "job.h" #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include #include #include "builtin.h" #include "exec.h" #include "option.h" #include "plist.h" #include "redir.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "yash.h" #if YASH_ENABLE_LINEEDIT # include "xfnmatch.h" # include "lineedit/complete.h" # ifndef FG_DONT_SAVE_TERMINAL # include "lineedit/terminfo.h" # endif #endif static inline job_T *get_job(size_t jobnumber) __attribute__((pure)); static inline void free_job(job_T *job); static void trim_joblist(void); static void set_current_jobnumber(size_t jobnumber); static size_t find_next_job(size_t numlimit); static void apply_curstop(void); static int calc_status(int status) __attribute__((const)); static wchar_t *get_job_name(const job_T *job) __attribute__((nonnull,warn_unused_result)); static char *get_process_status_string(const process_T *p, bool *needfree) __attribute__((nonnull,malloc,warn_unused_result)); static char *get_job_status_string(const job_T *job, bool *needfree) __attribute__((nonnull,malloc,warn_unused_result)); static int print_job_status( size_t jobnumber, bool changedonly, bool verbose, FILE *f) __attribute__((nonnull)); static size_t get_jobnumber_from_name(const wchar_t *name) __attribute__((nonnull,pure)); static size_t get_jobnumber_from_pid(long pid) __attribute__((pure)); static bool jobs_builtin_print_job(size_t jobnumber, bool verbose, bool changedonly, bool pgidonly, bool runningonly, bool stoppedonly); static int continue_job(size_t jobnumber, job_T *job, bool fg) __attribute__((nonnull)); static bool wait_builtin_has_job(bool jobcontrol); /* The list of jobs. * `joblist.contents[ACTIVE_JOBNO]' is a special job that is called "active * job", the job that is currently being executed. * The list length is always non-zero. */ static plist_T joblist; /* number of the current/previous jobs. 0 if none. */ static size_t current_jobnumber, previous_jobnumber; /* Initializes the job list. */ void init_job(void) { assert(joblist.contents == NULL); pl_init(&joblist); pl_add(&joblist, NULL); } /* Sets the active job. */ void set_active_job(job_T *job) { assert(ACTIVE_JOBNO < joblist.length); assert(joblist.contents[ACTIVE_JOBNO] == NULL); joblist.contents[ACTIVE_JOBNO] = job; } /* Moves the active job into the job list. * If the newly added job is stopped, it becomes the current job. * If `current' is true or there is no current job, the newly added job becomes * the current job if there is no stopped job. */ void add_job(bool current) { job_T *job = joblist.contents[ACTIVE_JOBNO]; size_t jobnumber; assert(job != NULL); joblist.contents[ACTIVE_JOBNO] = NULL; /* if there is an empty element in the list, use it */ for (jobnumber = 1; jobnumber < joblist.length; jobnumber++) { if (joblist.contents[jobnumber] == NULL) { joblist.contents[jobnumber] = job; goto set_current; } } /* if there is no empty, append at the end of the list */ pl_add(&joblist, job); set_current: assert(joblist.contents[jobnumber] == job); if (job->j_status == JS_STOPPED || current) set_current_jobnumber(jobnumber); else set_current_jobnumber(current_jobnumber); } /* Returns the job of the specified number or NULL if not found. */ job_T *get_job(size_t jobnumber) { return (jobnumber < joblist.length) ? joblist.contents[jobnumber] : NULL; } /* Removes the job of the specified number. * If the job is the current/previous job, the current/previous job is reset * (another job is assigned to it). */ void remove_job(size_t jobnumber) { free_job(get_job(jobnumber)); joblist.contents[jobnumber] = NULL; trim_joblist(); set_current_jobnumber(current_jobnumber); } /* Removes all jobs unconditionally. */ void remove_all_jobs(void) { for (size_t i = 0; i < joblist.length; i++) { free_job(joblist.contents[i]); joblist.contents[i] = NULL; } trim_joblist(); current_jobnumber = previous_jobnumber = 0; } /* Frees the specified job. */ void free_job(job_T *job) { if (job != NULL) { for (size_t i = 0; i < job->j_pcount; i++) free(job->j_procs[i].pr_name); free(job); } } /* Shrink the job list, removing unused elements. */ void trim_joblist(void) { if (joblist.maxlength > 20 && joblist.maxlength / 2 > joblist.length) { pl_setmax(&joblist, joblist.length * 2); } else { size_t tail = joblist.length; while (tail > 1 && joblist.contents[tail - 1] == NULL) tail--; assert(tail > 0); pl_remove(&joblist, tail, SIZE_MAX); } } /* Sets the `j_legacy' flags of all jobs. * All the jobs will be no longer job-controlled. */ void neglect_all_jobs(void) { for (size_t i = 0; i < joblist.length; i++) { job_T *job = joblist.contents[i]; if (job != NULL) job->j_legacy = true; } current_jobnumber = previous_jobnumber = 0; } /* Current/previous job selection discipline: * * - When there is one or more stopped jobs, the current job must be one of * them. * - When there are more than one stopped job, the previous job must be one of * them but the current one. * - The current job becomes the previous job when another job becomes the * current. * * - When a foreground job is stopped, it becomes the current job. * - When an asynchronous command is executed and the "curasync" option is set, * it becomes the current job. * - When a job is continued by the "bg" command and the "curbg" option is set, * it becomes the current job. * - When a job is stopped and the "curstop" option is set, it becomes the * current job. * * - The "wait" command doesn't change the current and previous jobs. */ /* Sets the current job number to the specified one and resets the previous job * number. If the specified job number is not used, a job is arbitrarily chosen * for the current. If there is one or more stopped jobs and the one specified * by the argument is not stopped, the current job is not changed. */ /* This function must be called whenever a job is added to or removed from the * job list or any job's status has been changed. */ void set_current_jobnumber(size_t jobnumber) { size_t stopcount = stopped_job_count(); const job_T *newcurrent = get_job(jobnumber); if (newcurrent == NULL || (stopcount > 0 && newcurrent->j_status != JS_STOPPED)) { jobnumber = current_jobnumber; newcurrent = get_job(jobnumber); if (newcurrent == NULL || (stopcount > 0 && newcurrent->j_status != JS_STOPPED)) { jobnumber = previous_jobnumber; newcurrent = get_job(jobnumber); if (newcurrent == NULL || (stopcount > 0 && newcurrent->j_status != JS_STOPPED)) jobnumber = find_next_job(ACTIVE_JOBNO); } } if (jobnumber != current_jobnumber) { size_t oldcurrentnum = current_jobnumber; current_jobnumber = jobnumber; jobnumber = oldcurrentnum; } else { jobnumber = previous_jobnumber; } const job_T *newprevious = get_job(jobnumber); if (newprevious == NULL || jobnumber == current_jobnumber || (stopcount > 1 && newprevious->j_status != JS_STOPPED)) { jobnumber = previous_jobnumber; newprevious = get_job(jobnumber); if (newprevious == NULL || jobnumber == current_jobnumber || (stopcount > 1 && newprevious->j_status != JS_STOPPED)) jobnumber = find_next_job(current_jobnumber); } previous_jobnumber = jobnumber; } /* Returns an arbitrary job number except the specified. * The returned number is suitable for the current/previous jobs. * If there is no job to pick out, 0 is returned. * Stopped jobs are preferred to running/finished jobs. * If there are more than one stopped jobs, the previous job is preferred. */ size_t find_next_job(size_t excl) { if (previous_jobnumber != excl) { job_T *job = get_job(previous_jobnumber); if (job != NULL && job->j_status == JS_STOPPED) return previous_jobnumber; } size_t jobnumber = joblist.length; while (--jobnumber > 0) { if (jobnumber != excl) { job_T *job = get_job(jobnumber); if (job != NULL && job->j_status == JS_STOPPED) return jobnumber; } } jobnumber = joblist.length; while (--jobnumber > 0) { if (jobnumber != excl) { job_T *job = get_job(jobnumber); if (job != NULL) return jobnumber; } } return 0; } /* If the "curstop" option is set and there is a job which has been stopped and * whose `j_statuschanged' flag is set, make it the current job. */ void apply_curstop(void) { if (shopt_curstop) { for (size_t i = 0; i < joblist.length; i++) { job_T *job = joblist.contents[i]; if (job != NULL) if (job->j_status == JS_STOPPED && job->j_statuschanged) set_current_jobnumber(i); } } set_current_jobnumber(current_jobnumber); } /* Counts the number of jobs in the job list. */ size_t job_count(void) { size_t count = 0; for (size_t i = 0; i < joblist.length; i++) if (joblist.contents[i] != NULL) count++; return count; } /* Counts the number of stopped jobs in the job list. */ size_t stopped_job_count(void) { size_t count = 0; for (size_t i = 0; i < joblist.length; i++) { job_T *job = joblist.contents[i]; if (job != NULL && job->j_status == JS_STOPPED) count++; } return count; } /* Updates the info about the jobs in the job list. * This function doesn't block. */ void do_wait(void) { pid_t pid; int status; #if HAVE_WCONTINUED static int waitpidoption = WUNTRACED | WCONTINUED | WNOHANG; #else const int waitpidoption = WUNTRACED | WNOHANG; #endif start: pid = waitpid(-1, &status, waitpidoption); if (pid < 0) { switch (errno) { case EINTR: goto start; /* try again */ case ECHILD: return; /* there are no child processes */ #if HAVE_WCONTINUED /* Even when the WCONTINUED flag is defined in the * header, the OS kernel may not support it. We try again without * the flag if it is rejected. */ case EINVAL: if (waitpidoption & WCONTINUED) { waitpidoption &= ~WCONTINUED; goto start; } /* falls thru! */ #endif default: xerror(errno, "waitpid"); return; } } else if (pid == 0) { /* no more jobs to be updated */ return; } size_t jobnumber, pnumber; job_T *job; process_T *pr; /* determine `jobnumber', `job' and `pr' from `pid' */ for (jobnumber = 0; jobnumber < joblist.length; jobnumber++) if ((job = joblist.contents[jobnumber]) != NULL) for (pnumber = 0; pnumber < job->j_pcount; pnumber++) if ((pr = &job->j_procs[pnumber])->pr_pid == pid) goto found; /* If `pid' was not found in the job list, we simply ignore it. This may * happen on some occasions: e.g. the job has been "disown"ed. */ goto start; found: pr->pr_statuscode = status; if (WIFEXITED(status) || WIFSIGNALED(status)) pr->pr_status = JS_DONE; if (WIFSTOPPED(status)) pr->pr_status = JS_STOPPED; #ifdef HAVE_WCONTINUED if (WIFCONTINUED(status)) pr->pr_status = JS_RUNNING; /* On FreeBSD, when WIFCONTINUED is true, WIFSIGNALED is also true. We must * be careful about the order of these checks. */ #endif /* decide the job status from the process status: * - JS_RUNNING if any of the processes is running. * - JS_STOPPED if no processes are running but some are stopped. * - JS_DONE if all the processes are finished. */ jobstatus_T oldstatus = job->j_status; bool anyrunning = false, anystopped = false; /* check if there are running/stopped processes */ for (size_t i = 0; i < job->j_pcount; i++) { switch (job->j_procs[i].pr_status) { case JS_RUNNING: anyrunning = true; goto out_of_loop; case JS_STOPPED: anystopped = true; break; default: break; } } out_of_loop: job->j_status = anyrunning ? JS_RUNNING : anystopped ? JS_STOPPED : JS_DONE; if (job->j_status != oldstatus) job->j_statuschanged = true; goto start; } /* Waits for the specified job to finish (or stop). * `jobnumber' must be a valid job number. * If `return_on_stop' is false, waits for the job to finish. * Otherwise, waits for the job to finish or stop. * If `interruptible' is true, this function can be canceled by SIGINT. * If `return_on_trap' is true, this function returns false immediately after * trap actions are performed. Otherwise, traps are not handled. * This function returns immediately if the job is already finished/stopped or * is not a child of this shell process. * Returns the signal number if interrupted, or zero if successful. */ /* In most cases, you should call `put_foreground' to bring the shell back to * foreground after calling `wait_for_job' if `doing_job_control_now' is true. */ int wait_for_job(size_t jobnumber, bool return_on_stop, bool interruptible, bool return_on_trap) { int signum = 0; job_T *job = joblist.contents[jobnumber]; if (!job->j_legacy) { bool savenonotify = job->j_nonotify; job->j_nonotify = true; for (;;) { if (job->j_status == JS_DONE) break; if (return_on_stop && job->j_status == JS_STOPPED) break; signum = wait_for_sigchld(interruptible, return_on_trap); if (signum != 0) break; } job->j_nonotify = savenonotify; } return signum; } /* Waits for the specified child process to finish (or stop). * `cpid' is the process ID of the child process to wait for. This must not be * in the job list. * `cpgid' is the process group ID of the child. If the child's PGID is the same * as that of the parent, `cpgid' must be 0. * If `return_on_stop' is false, waits for the job to finish. * Otherwise, waits for the job to finish or stop. * Traps are not handled in this function. * There must be no active job when this function is called. * If `return_on_stop' is true and the child is stopped, this function returns * a pointer to a pointer to a wide string. The caller must assign a pointer to * a newly malloced wide string to the variable the return value points to. * This string is used as the name of the new stopped job. * If the child exited, this function returns NULL. * The exit status is assigned to `laststatus' in any case. */ wchar_t **wait_for_child(pid_t cpid, pid_t cpgid, bool return_on_stop) { job_T *job = xmalloc(sizeof *job + sizeof *job->j_procs); job->j_pgid = cpgid; job->j_status = JS_RUNNING; job->j_statuschanged = false; job->j_legacy = false; job->j_nonotify = false; job->j_pcount = 1; job->j_procs[0].pr_pid = cpid; job->j_procs[0].pr_status = JS_RUNNING; job->j_procs[0].pr_statuscode = 0; job->j_procs[0].pr_name = NULL; set_active_job(job); wait_for_job(ACTIVE_JOBNO, return_on_stop, false, false); if (doing_job_control_now) put_foreground(shell_pgid); laststatus = calc_status_of_job(job); if (job->j_status == JS_DONE) { notify_signaled_job(ACTIVE_JOBNO); remove_job(ACTIVE_JOBNO); return NULL; } else { add_job(true); return &job->j_procs[0].pr_name; } } /* Returns the process group ID of the specified job. * If no valid job is found, an error message is printed and -1 is returned. * `jobname' may have a preceding '%' sign. */ pid_t get_job_pgid(const wchar_t *jobname) { size_t jobnumber = get_jobnumber_from_name( (jobname[0] == L'%') ? &jobname[1] : jobname); const job_T *job; if (jobnumber >= joblist.length) { xerror(0, Ngt("job specification `%ls' is ambiguous"), jobname); return -1; } else if (jobnumber == 0 || (job = joblist.contents[jobnumber]) == NULL || job->j_legacy) { xerror(0, Ngt("no such job `%ls'"), jobname); return -1; } else if (job->j_pgid == 0) { xerror(0, Ngt("`%ls' is not a job-controlled job"), jobname); return -1; } else { return job->j_pgid; } } /* Puts the specified process group in the foreground. * `pgrp' must be a valid process group ID and `doing_job_control_now' must be * true. */ void put_foreground(pid_t pgrp) { sigset_t blockss, savess; assert(doing_job_control_now); assert(pgrp > 0); sigemptyset(&blockss); sigaddset(&blockss, SIGTTOU); sigemptyset(&savess); sigprocmask(SIG_BLOCK, &blockss, &savess); tcsetpgrp(ttyfd, pgrp); sigprocmask(SIG_SETMASK, &savess, NULL); } /* Ensures the current shell process is in the foreground. * The shell process is stopped by SIGTTOU until it is put in the foreground. * This function requires `doing_job_control_now' to be true. */ /* This function prevents the job-control shell from mangling the terminal while * another shell is using it. */ void ensure_foreground(void) { /* This function calls `tcsetpgrp' with the default SIGTTOU handler. If the * shell is in the background, it will receive SIGTTOU and get stopped until * it is continued in the foreground. */ struct sigaction dflsa, savesa; sigset_t blockss, savess; assert(doing_job_control_now); assert(shell_pgid > 0); dflsa.sa_handler = SIG_DFL; dflsa.sa_flags = 0; sigemptyset(&dflsa.sa_mask); sigemptyset(&savesa.sa_mask); sigaction(SIGTTOU, &dflsa, &savesa); sigemptyset(&blockss); sigaddset(&blockss, SIGTTOU); sigemptyset(&savess); sigprocmask(SIG_UNBLOCK, &blockss, &savess); tcsetpgrp(ttyfd, shell_pgid); sigprocmask(SIG_SETMASK, &savess, NULL); sigaction(SIGTTOU, &savesa, NULL); } /* Computes the exit status from the status code returned by `waitpid'. */ int calc_status(int status) { if (WIFEXITED(status)) return WEXITSTATUS(status); #ifdef WIFCONTINUED if (WIFCONTINUED(status)) return Exit_SUCCESS; /* On FreeBSD, when WIFCONTINUED is true, WIFSIGNALED is also true. We must * be careful about the order of these checks. */ #endif if (WIFSIGNALED(status)) return WTERMSIG(status) + TERMSIGOFFSET; if (WIFSTOPPED(status)) return WSTOPSIG(status) + TERMSIGOFFSET; assert(false); } /* Computes the exit status of the specified job. * The job state must be JS_DONE or JS_STOPPED. */ int calc_status_of_job(const job_T *job) { switch (job->j_status) { case JS_DONE: if (job->j_procs[job->j_pcount - 1].pr_pid != 0) return calc_status(job->j_procs[job->j_pcount - 1].pr_statuscode); else return job->j_procs[job->j_pcount - 1].pr_statuscode; case JS_STOPPED: for (int i = job->j_pcount; --i >= 0; ) { if (job->j_procs[i].pr_status == JS_STOPPED) return calc_status(job->j_procs[i].pr_statuscode); } /* falls thru! */ default: assert(false); } } /* Returns the name of the specified job. * If the job has only one process, `job->j_procs[0].pr_name' is returned. * Otherwise, the names of all the process are concatenated and returned, which * must be freed by the caller. */ wchar_t *get_job_name(const job_T *job) { if (job->j_pcount == 1) return job->j_procs[0].pr_name; xwcsbuf_T buf; wb_init(&buf); for (size_t i = 0; i < job->j_pcount; i++) { if (i > 0) wb_cat(&buf, L" | "); wb_cat(&buf, job->j_procs[i].pr_name); } return wb_towcs(&buf); } /* Returns a string that describes the status of the specified process * such as "Running" and "Stopped(SIGTSTP)". * The returned string must be freed by the caller iff `*needfree' is assigned * true, otherwise it must not be modified or freed. */ char *get_process_status_string(const process_T *p, bool *needfree) { int status, sig; switch (p->pr_status) { case JS_RUNNING: *needfree = false; return (char *) gt("Running"); case JS_STOPPED: *needfree = true; return malloc_printf(gt("Stopped(SIG%ls)"), get_signal_name(WSTOPSIG(p->pr_statuscode))); case JS_DONE: status = p->pr_statuscode; if (p->pr_pid == 0) goto exitstatus; if (WIFEXITED(status)) { status = WEXITSTATUS(status); exitstatus: if (status == Exit_SUCCESS) { *needfree = false; return (char *) gt("Done"); } else { *needfree = true; return malloc_printf(gt("Done(%d)"), status); } } else { assert(WIFSIGNALED(status)); *needfree = true; sig = WTERMSIG(status); #ifdef WCOREDUMP if (WCOREDUMP(sig)) return malloc_printf(gt("Killed (SIG%ls: core dumped)"), get_signal_name(sig)); #endif return malloc_printf(gt("Killed (SIG%ls)"), get_signal_name(sig)); } } assert(false); } /* Returns a string that describes the status of the specified job * such as "Running" and "Stopped(SIGTSTP)". * The returned string must be freed by the caller iff `*needfree' is assigned * true, otherwise it must not be modified or freed. */ char *get_job_status_string(const job_T *job, bool *needfree) { switch (job->j_status) { case JS_RUNNING: *needfree = false; return (char *) gt("Running"); case JS_STOPPED: /* find a stopped process */ for (size_t i = job->j_pcount; ; ) if (job->j_procs[--i].pr_status == JS_STOPPED) return get_process_status_string(&job->j_procs[i], needfree); assert(false); case JS_DONE: return get_process_status_string( &job->j_procs[job->j_pcount - 1], needfree); } assert(false); } /* Prints the status of the specified job. * Finished jobs are removed from the job list after the status is printed. * If the specified job doesn't exist, nothing is printed (it isn't an error). * If `changedonly' is true, the job is printed only if the `j_statuschanged' * flag is true. * If `verbose' is true, the status is printed in the process-wise format rather * than the usual job-wise format. * Returns zero if successful. Returns errno if `fprintf' failed. */ int print_job_status(size_t jobnumber, bool changedonly, bool verbose, FILE *f) { int result = 0; job_T *job = get_job(jobnumber); if (job == NULL || (changedonly && !job->j_statuschanged) || job->j_nonotify) return result; char current; if (jobnumber == current_jobnumber) current = '+'; else if (jobnumber == previous_jobnumber) current = '-'; else current = ' '; if (!verbose) { bool needfree; char *status = get_job_status_string(job, &needfree); wchar_t *jobname = get_job_name(job); /* TRANSLATORS: the translated format string can be different * from the original only in the number of spaces. This is required * for POSIX compliance. */ result = fprintf(f, gt("[%zu] %c %-20s %ls\n"), jobnumber, current, status, jobname); result = (result >= 0) ? 0 : errno; if (needfree) free(status); if (jobname != job->j_procs[0].pr_name) free(jobname); } else { bool needfree; pid_t pid = job->j_procs[0].pr_pid; char *status = get_process_status_string( &job->j_procs[posixly_correct ? job->j_pcount - 1 : 0], &needfree); wchar_t *jobname = job->j_procs[0].pr_name; /* TRANSLATORS: the translated format string can be different * from the original only in the number of spaces. This is required * for POSIX compliance. */ result = fprintf(f, gt("[%zu] %c %5jd %-20s %ls\n"), jobnumber, current, (intmax_t) pid, status, jobname); result = (result >= 0) ? 0 : errno; if (needfree) free(status); for (size_t i = 1; result == 0 && i < job->j_pcount; i++) { pid = job->j_procs[i].pr_pid; status = get_process_status_string(&job->j_procs[i], &needfree); jobname = job->j_procs[i].pr_name; /* TRANSLATORS: the translated format string can be different * from the original only in the number of spaces. This is required * for POSIX compliance. */ result = fprintf(f, gt(" %5jd %-20s | %ls\n"), (intmax_t) pid, (posixly_correct ? "" : status), jobname); result = (result >= 0) ? 0 : errno; if (needfree) free(status); } } job->j_statuschanged = false; if (job->j_status == JS_DONE) remove_job(jobnumber); return result; } /* Prints the status of jobs which have been changed but not reported. */ void print_job_status_all(void) { apply_curstop(); for (size_t i = 1; i < joblist.length; i++) print_job_status(i, true, false, stderr); } /* If the shell is interactive and the specified job has been killed by a * signal other than SIGPIPE, prints a notification to the standard error. * If the signal is SIGINT, only a single newline is printed to the standard * error and the shell is flagged as interrupted. */ void notify_signaled_job(size_t jobnumber) { if (!is_interactive_now) return; job_T *job = get_job(jobnumber); if (job == NULL || job->j_status != JS_DONE) return; process_T *p = &job->j_procs[job->j_pcount - 1]; assert(p->pr_status == JS_DONE); if (p->pr_pid == 0 || !WIFSIGNALED(p->pr_statuscode)) return; int sig = WTERMSIG(p->pr_statuscode); switch (sig) { case SIGINT: fputc('\n', stderr); set_interrupted(); break; case SIGPIPE: break; default: #if HAVE_STRSIGNAL fprintf(stderr, gt("The process was killed by SIG%ls: %s\n"), get_signal_name(sig), strsignal(sig)); #else fprintf(stderr, gt("The process was killed by SIG%ls\n"), get_signal_name(sig)); #endif break; } } /* Returns the job number from the specified job ID string. * If no applicable job is found, zero is returned. * If more than one jobs are found, `joblist.length' is returned. * When `name' is a number, the number is returned if it is a valid job number. * The string must not have the preceding '%'. */ /* "", "%", "+" -> the current job * "-" -> the previous job * "n" (integer) -> the job #n * "xxx" -> the job whose name starts with "xxx" * "?xxx" -> the job whose name contains "xxx" */ size_t get_jobnumber_from_name(const wchar_t *name) { if (name[0] == L'\0' || wcscmp(name, L"%") == 0 || wcscmp(name, L"+") == 0) return current_jobnumber; if (wcscmp(name, L"-") == 0) return previous_jobnumber; if (iswdigit(name[0])) { unsigned long num; if (xwcstoul(name, 10, &num)) return (num <= SIZE_MAX && get_job(num) != NULL) ? num : 0; } bool contain; size_t n = 0; if (name[0] == L'?') { contain = true; name++; } else { contain = false; } for (size_t i = 1; i < joblist.length; i++) { job_T *job = joblist.contents[i]; if (job != NULL) { wchar_t *jobname = get_job_name(job); bool match = contain ? wcsstr(jobname, name) != NULL : matchwcsprefix(jobname, name) != NULL; if (jobname != job->j_procs[0].pr_name) free(jobname); if (match) { if (n != 0) return joblist.length; /* more than one found */ else n = i; } } } return n; } /* Returns the number of job that contains a process whose process ID is `pid'. * If not found, 0 is returned. */ size_t get_jobnumber_from_pid(long pid) { size_t jobnumber; if (pid == 0) return 0; for (jobnumber = joblist.length; --jobnumber > 0; ) { job_T *job = joblist.contents[jobnumber]; if (job != NULL) { for (size_t i = 0; i < job->j_pcount; i++) if (job->j_procs[i].pr_pid == pid) goto found; } } found: return jobnumber; } #if YASH_ENABLE_LINEEDIT /* Generates completion candidates for job names matching the pattern. */ /* The prototype of this function is declared in "lineedit/complete.h". */ void generate_job_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_JOB)) return; le_compdebug("adding job candidates"); if (!le_compile_cpatterns(compopt)) return; for (size_t i = 1; i < joblist.length; i++) { const job_T *job = joblist.contents[i]; if (job == NULL) continue; switch (job->j_status) { case JS_RUNNING: if (!(compopt->type & CGT_RUNNING)) continue; break; case JS_STOPPED: if (!(compopt->type & CGT_STOPPED)) continue; break; case JS_DONE: if (!(compopt->type & CGT_DONE)) continue; break; } wchar_t *jobname = get_job_name(job); if (le_wmatch_comppatterns(compopt, jobname)) le_new_candidate(CT_JOB, xwcsdup(jobname), malloc_wprintf(L"%%%zu", i), compopt); if (jobname != job->j_procs[0].pr_name) free(jobname); } } #endif /* YASH_ENABLE_LINEEDIT */ /********** Built-ins **********/ /* Options for the "jobs" built-in. */ const struct xgetopt_T jobs_options[] = { { L'l', L"verbose", OPTARG_NONE, true, NULL, }, { L'n', L"new", OPTARG_NONE, false, NULL, }, { L'p', L"pgid-only", OPTARG_NONE, true, NULL, }, { L'r', L"running-only", OPTARG_NONE, false, NULL, }, { L's', L"stopped-only", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "jobs" built-in, which accepts the following options: * -l: be verbose * -n: print the jobs only whose status have changed * -p: print the process ID only * -r: print running jobs only * -s: print stopped jobs only * In the POSIXly correct mode, only -l and -p are available. */ int jobs_builtin(int argc, void **argv) { bool verbose = false, changedonly = false, pgidonly = false; bool runningonly = false, stoppedonly = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, jobs_options, 0)) != NULL) { switch (opt->shortopt) { case L'l': verbose = true; break; case L'n': changedonly = true; break; case L'p': pgidonly = true; break; case L'r': runningonly = true; break; case L's': stoppedonly = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } nextforceexit = true; apply_curstop(); if (xoptind < argc) { /* print the specified jobs */ do { const wchar_t *jobspec = ARGV(xoptind); if (jobspec[0] == L'%') { jobspec++; } else if (posixly_correct) { xerror(0, Ngt("`%ls' is not a valid job specification"), ARGV(xoptind)); continue; } size_t jobnumber = get_jobnumber_from_name(jobspec); if (jobnumber >= joblist.length) { xerror(0, Ngt("job specification `%ls' is ambiguous"), ARGV(xoptind)); } else if (jobnumber == 0 || joblist.contents[jobnumber] == NULL) { xerror(0, Ngt("no such job `%ls'"), ARGV(xoptind)); } else { if (!jobs_builtin_print_job(jobnumber, verbose, changedonly, pgidonly, runningonly, stoppedonly)) return Exit_FAILURE; } } while (++xoptind < argc); } else { /* print all jobs */ for (size_t i = 1; i < joblist.length; i++) { if (!jobs_builtin_print_job(i, verbose, changedonly, pgidonly, runningonly, stoppedonly)) return Exit_FAILURE; } } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Prints the job status. * On an I/O error, an error message is printed to the standard error and false * is returned. */ bool jobs_builtin_print_job(size_t jobnumber, bool verbose, bool changedonly, bool pgidonly, bool runningonly, bool stoppedonly) { job_T *job = get_job(jobnumber); if (job == NULL) return true; if (runningonly && job->j_status != JS_RUNNING) return true; if (stoppedonly && job->j_status != JS_STOPPED) return true; int err; if (pgidonly) { if (changedonly && !job->j_statuschanged) return true; int result = printf("%jd\n", (intmax_t) job->j_pgid); err = (result >= 0) ? 0 : errno; } else { err = print_job_status(jobnumber, changedonly, verbose, stdout); } if (err != 0) { xerror(err, Ngt("cannot print to the standard output")); return false; } else { return true; } } #if YASH_ENABLE_HELP const char jobs_help[] = Ngt( "print info about jobs" ); const char jobs_syntax[] = Ngt( "\tjobs [-lnprs] [job...]\n" ); #endif /* The "fg"/"bg" built-in */ int fg_builtin(int argc, void **argv) { bool fg = (wcscmp(argv[0], L"fg") == 0); const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, 0)) != NULL) { switch (opt->shortopt) { #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (fg && posixly_correct && !validate_operand_count(argc - xoptind, 0, 1)) return Exit_ERROR; if (!doing_job_control_now) { xerror(0, Ngt("job control is disabled")); return Exit_FAILURE; } int status = Exit_SUCCESS; job_T *job; if (xoptind < argc) { do { const wchar_t *jobspec = ARGV(xoptind); if (jobspec[0] == L'%') { jobspec++; } else if (posixly_correct) { xerror(0, Ngt("`%ls' is not a valid job specification"), ARGV(xoptind)); continue; } size_t jobnumber = get_jobnumber_from_name(jobspec); if (jobnumber >= joblist.length) { xerror(0, Ngt("job specification `%ls' is ambiguous"), ARGV(xoptind)); } else if (jobnumber == 0 || (job = joblist.contents[jobnumber]) == NULL || job->j_legacy) { xerror(0, Ngt("no such job `%ls'"), ARGV(xoptind)); } else if (job->j_pgid == 0) { xerror(0, Ngt("`%ls' is not a job-controlled job"), ARGV(xoptind)); } else { status = continue_job(jobnumber, job, fg); } } while (++xoptind < argc); } else { if (current_jobnumber == 0 || (job = joblist.contents[current_jobnumber])->j_legacy) { xerror(0, Ngt("there is no current job")); } else { status = continue_job(current_jobnumber, job, fg); } } if (status != 0) return status; if (yash_error_message_count != 0) return Exit_FAILURE; return Exit_SUCCESS; } /* Continues execution of the specified job. * Returns the exit code of the continued job or 0 if it is still running. */ int continue_job(size_t jobnumber, job_T *job, bool fg) { assert(job->j_pgid > 0); assert(!job->j_legacy); wchar_t *name = get_job_name(job); if (fg && posixly_correct) printf("%ls\n", name); else printf("[%zu] %ls\n", jobnumber, name); if (name != job->j_procs[0].pr_name) free(name); #if YASH_ENABLE_LINEEDIT && !defined(FG_DONT_SAVE_TERMINAL) bool termsave = fg && le_save_terminal(); /* see below */ #endif if (job->j_status != JS_DONE) { if (fg) put_foreground(job->j_pgid); if (kill(-job->j_pgid, SIGCONT) >= 0) job->j_status = JS_RUNNING; } else { if (!fg) xerror(0, Ngt("job %%%zu has already terminated"), jobnumber); } int status; if (fg) { wait_for_job(jobnumber, true, false, false); put_foreground(shell_pgid); #if YASH_ENABLE_LINEEDIT && !defined(FG_DONT_SAVE_TERMINAL) if (termsave) le_restore_terminal(); #endif switch (job->j_status) { case JS_STOPPED: status = calc_status_of_job(job); set_current_jobnumber(jobnumber); break; case JS_DONE: status = calc_status_of_job(job); notify_signaled_job(jobnumber); remove_job(jobnumber); break; default: assert(false); } } else { set_current_jobnumber(shopt_curbg ? jobnumber : current_jobnumber); status = (job->j_status == JS_RUNNING) ? Exit_SUCCESS : Exit_FAILURE; } return status; /* We save the terminal state before continuing a job in the foreground and * restore the state after the job has finished. This is because some * programs leave the terminal in the wrong state if they were at first * invoked in the background. * Programs that change the terminal state generally save the state before * changing it and restore it when they are finished. But, if they are * invoked in the background, they may save the state that is being used by * another program (typically the shell's line-editing), so the state that * they restore is not the normal state. * We try to work around this problem by saving and restoring the terminal * state for the continued programs. */ } #if YASH_ENABLE_HELP const char fg_help[] = Ngt( "run jobs in the foreground" ); const char fg_syntax[] = Ngt( "\tfg [job...]\n" ); const char bg_help[] = Ngt( "run jobs in the background" ); const char bg_syntax[] = Ngt( "\tbg [job...]\n" ); #endif /* YASH_ENABLE_HELP */ /* The "wait" built-in */ int wait_builtin(int argc, void **argv) { bool jobcontrol = doing_job_control_now; int status = Exit_SUCCESS; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, 0)) != NULL) { switch (opt->shortopt) { #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } job_T *job; if (xoptind < argc) { /* wait for the specified jobs */ do { const wchar_t *jobspec = ARGV(xoptind); size_t jobnumber; if (jobspec[0] == L'%') { jobnumber = get_jobnumber_from_name(&jobspec[1]); } else { long pid; if (!xwcstol(jobspec, 10, &pid) || pid < 0) { xerror(0, Ngt("`%ls' is not a valid job specification"), jobspec); continue; } jobnumber = get_jobnumber_from_pid(pid); } if (jobnumber >= joblist.length) { xerror(0, Ngt("job specification `%ls' is ambiguous"), ARGV(xoptind)); } else if (jobnumber == 0 || (job = joblist.contents[jobnumber]) == NULL || job->j_legacy) { status = Exit_NOTFOUND; } else { status = wait_for_job(jobnumber, jobcontrol, jobcontrol, true); if (status == 0) { status = calc_status_of_job(job); } else { assert(TERMSIGOFFSET >= 128); status += TERMSIGOFFSET; break; } if (job->j_status != JS_RUNNING) { if (jobcontrol && is_interactive_now && !posixly_correct) print_job_status(jobnumber, false, false, stdout); else if (job->j_status == JS_DONE) remove_job(jobnumber); } } } while (++xoptind < argc); } else { /* wait for all jobs */ while (wait_builtin_has_job(jobcontrol)) { status = wait_for_sigchld(jobcontrol, true); if (status) { assert(TERMSIGOFFSET >= 128); status += TERMSIGOFFSET; break; } } } if (status != 0) return status; if (yash_error_message_count != 0) return Exit_FAILURE; return Exit_SUCCESS; } /* Checks if the shell has any job to wait for. */ bool wait_builtin_has_job(bool jobcontrol) { /* print/remove already-finished jobs */ if (jobcontrol && is_interactive_now && !posixly_correct) { for (size_t i = 1; i < joblist.length; i++) print_job_status(i, true, false, stdout); } else { for (size_t i = 1; i < joblist.length; i++) { job_T *job = joblist.contents[i]; if (job != NULL && (job->j_legacy || job->j_status == JS_DONE)) remove_job(i); } } for (size_t i = 1; i < joblist.length; i++) { job_T *job = joblist.contents[i]; if (job != NULL && (!jobcontrol || job->j_status == JS_RUNNING)) return true; } return false; } #if YASH_ENABLE_HELP const char wait_help[] = Ngt( "wait for jobs to terminate" ); const char wait_syntax[] = Ngt( "\twait [job or process_id...]\n" ); #endif /* The "disown" built-in, which accepts the following option: * -a: disown all jobs */ int disown_builtin(int argc, void **argv) { bool all = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, all_help_options, 0)) != NULL) { switch (opt->shortopt) { case L'a': all = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (all) { remove_all_jobs(); } else if (xoptind < argc) { do { const wchar_t *jobspec = ARGV(xoptind); if (jobspec[0] == L'%') { jobspec++; } else if (posixly_correct) { xerror(0, Ngt("`%ls' is not a valid job specification"), ARGV(xoptind)); continue; } size_t jobnumber = get_jobnumber_from_name(jobspec); if (jobnumber >= joblist.length) { xerror(0, Ngt("job specification `%ls' is ambiguous"), ARGV(xoptind)); } else if (jobnumber == 0 || joblist.contents[jobnumber] == NULL) { xerror(0, Ngt("no such job `%ls'"), ARGV(xoptind)); } else { remove_job(jobnumber); } } while (++xoptind < argc); } else { if (current_jobnumber == 0 || get_job(current_jobnumber) == NULL) xerror(0, Ngt("there is no current job")); else remove_job(current_jobnumber); } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } #if YASH_ENABLE_HELP const char disown_help[] = Ngt( "disown jobs" ); const char disown_syntax[] = Ngt( "\tdisown [job...]\n" "\tdisown -a\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/strbuf.h0000644000175000017500000003571412154557026014236 0ustar magicantmagicant/* Yash: yet another shell */ /* strbuf.h: modifiable string buffer */ /* (C) 2007-2011 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_STRBUF_H #define YASH_STRBUF_H #include #include #include #define Size_max ((size_t) -1) // = SIZE_MAX typedef struct xstrbuf_T { char *contents; size_t length, maxlength; } xstrbuf_T; typedef struct xwcsbuf_T { wchar_t *contents; size_t length, maxlength; } xwcsbuf_T; extern xstrbuf_T *sb_init(xstrbuf_T *buf) __attribute__((nonnull)); extern xstrbuf_T *sb_initwith(xstrbuf_T *restrict buf, char *restrict s) __attribute__((nonnull)); static inline void sb_destroy(xstrbuf_T *buf) __attribute__((nonnull)); static inline char *sb_tostr(xstrbuf_T *buf) __attribute__((nonnull)); extern xstrbuf_T *sb_setmax(xstrbuf_T *buf, size_t newmax) __attribute__((nonnull)); extern xstrbuf_T *sb_ensuremax(xstrbuf_T *buf, size_t max) __attribute__((nonnull)); static inline xstrbuf_T *sb_truncate(xstrbuf_T *buf, size_t newlength) __attribute__((nonnull)); static inline xstrbuf_T *sb_clear(xstrbuf_T *buf) __attribute__((nonnull)); extern xstrbuf_T *sb_replace_force( xstrbuf_T *restrict buf, size_t i, size_t bn, const char *restrict s, size_t sn) __attribute__((nonnull)); extern xstrbuf_T *sb_replace( xstrbuf_T *restrict buf, size_t i, size_t bn, const char *restrict s, size_t sn) __attribute__((nonnull)); static inline xstrbuf_T *sb_ninsert_force( xstrbuf_T *restrict buf, size_t i, const char *restrict s, size_t n) __attribute__((nonnull)); static inline xstrbuf_T *sb_ninsert( xstrbuf_T *restrict buf, size_t i, const char *restrict s, size_t n) __attribute__((nonnull)); static inline xstrbuf_T *sb_insert( xstrbuf_T *restrict buf, size_t i, const char *restrict s) __attribute__((nonnull)); static inline xstrbuf_T *sb_ncat_force( xstrbuf_T *restrict buf, const char *restrict s, size_t n) __attribute__((nonnull)); static inline xstrbuf_T *sb_ncat( xstrbuf_T *restrict buf, const char *restrict s, size_t n) __attribute__((nonnull)); static inline xstrbuf_T *sb_cat( xstrbuf_T *restrict buf, const char *restrict s) __attribute__((nonnull)); static inline xstrbuf_T *sb_catfree( xstrbuf_T *restrict buf, char *restrict s) __attribute__((nonnull)); static inline xstrbuf_T *sb_remove(xstrbuf_T *buf, size_t i, size_t n) __attribute__((nonnull)); extern xstrbuf_T *sb_ccat(xstrbuf_T *buf, char c) __attribute__((nonnull)); extern xstrbuf_T *sb_ccat_repeat(xstrbuf_T *buf, char c, size_t n) __attribute__((nonnull)); extern _Bool sb_wccat( xstrbuf_T *restrict buf, wchar_t c, mbstate_t *restrict ps) __attribute__((nonnull)); extern wchar_t *sb_wcsncat(xstrbuf_T *restrict buf, const wchar_t *restrict s, size_t n, mbstate_t *restrict ps) __attribute__((nonnull)); #if HAVE_WCSNRTOMBS static inline #else extern #endif wchar_t *sb_wcscat(xstrbuf_T *restrict buf, const wchar_t *restrict s, mbstate_t *restrict ps) __attribute__((nonnull)); extern int sb_vprintf( xstrbuf_T *restrict buf, const char *restrict format, va_list ap) __attribute__((nonnull(1,2),format(printf,2,0))); extern int sb_printf( xstrbuf_T *restrict buf, const char *restrict format, ...) __attribute__((nonnull(1,2),format(printf,2,3))); extern xwcsbuf_T *wb_init(xwcsbuf_T *buf) __attribute__((nonnull)); extern xwcsbuf_T *wb_initwith(xwcsbuf_T *restrict buf, wchar_t *restrict s) __attribute__((nonnull)); static inline void wb_destroy(xwcsbuf_T *buf) __attribute__((nonnull)); static inline wchar_t *wb_towcs(xwcsbuf_T *buf) __attribute__((nonnull)); extern xwcsbuf_T *wb_setmax(xwcsbuf_T *buf, size_t newmax) __attribute__((nonnull)); extern xwcsbuf_T *wb_ensuremax(xwcsbuf_T *buf, size_t max) __attribute__((nonnull)); static inline xwcsbuf_T *wb_truncate(xwcsbuf_T *buf, size_t newlength) __attribute__((nonnull)); static inline xwcsbuf_T *wb_clear(xwcsbuf_T *buf) __attribute__((nonnull)); extern xwcsbuf_T *wb_replace_force( xwcsbuf_T *restrict buf, size_t i, size_t bn, const wchar_t *restrict s, size_t sn) __attribute__((nonnull)); extern xwcsbuf_T *wb_replace( xwcsbuf_T *restrict buf, size_t i, size_t bn, const wchar_t *restrict s, size_t sn) __attribute__((nonnull)); static inline xwcsbuf_T *wb_ninsert_force( xwcsbuf_T *restrict buf, size_t i, const wchar_t *restrict s, size_t n) __attribute__((nonnull)); static inline xwcsbuf_T *wb_ninsert( xwcsbuf_T *restrict buf, size_t i, const wchar_t *restrict s, size_t n) __attribute__((nonnull)); static inline xwcsbuf_T *wb_insert( xwcsbuf_T *restrict buf, size_t i, const wchar_t *restrict s) __attribute__((nonnull)); static inline xwcsbuf_T *wb_ncat_force( xwcsbuf_T *restrict buf, const wchar_t *restrict s, size_t n) __attribute__((nonnull)); static inline xwcsbuf_T *wb_ncat( xwcsbuf_T *restrict buf, const wchar_t *restrict s, size_t n) __attribute__((nonnull)); static inline xwcsbuf_T *wb_cat( xwcsbuf_T *restrict buf, const wchar_t *restrict s) __attribute__((nonnull)); static inline xwcsbuf_T *wb_catfree( xwcsbuf_T *restrict buf, wchar_t *restrict s) __attribute__((nonnull)); static inline xwcsbuf_T *wb_remove(xwcsbuf_T *buf, size_t i, size_t n) __attribute__((nonnull)); extern xwcsbuf_T *wb_wccat(xwcsbuf_T *buf, wchar_t c) __attribute__((nonnull)); extern char *wb_mbscat(xwcsbuf_T *restrict buf, const char *restrict s) __attribute__((nonnull)); extern int wb_vwprintf( xwcsbuf_T *restrict buf, const wchar_t *restrict format, va_list ap) __attribute__((nonnull(1,2))); extern int wb_wprintf( xwcsbuf_T *restrict buf, const wchar_t *restrict format, ...) __attribute__((nonnull(1,2))); extern char *malloc_wcsntombs(const wchar_t *s, size_t n) __attribute__((nonnull,malloc,warn_unused_result)); #if HAVE_WCSNRTOMBS static inline #else extern #endif char *malloc_wcstombs(const wchar_t *s) __attribute__((nonnull,malloc,warn_unused_result)); static inline char *realloc_wcstombs(wchar_t *s) __attribute__((nonnull,malloc,warn_unused_result)); extern wchar_t *malloc_mbstowcs(const char *s) __attribute__((nonnull,malloc,warn_unused_result)); static inline wchar_t *realloc_mbstowcs(char *s) __attribute__((nonnull,malloc,warn_unused_result)); extern char *malloc_vprintf(const char *format, va_list ap) __attribute__((nonnull(1),malloc,warn_unused_result,format(printf,1,0))); extern char *malloc_printf(const char *format, ...) __attribute__((nonnull(1),malloc,warn_unused_result,format(printf,1,2))); extern wchar_t *malloc_vwprintf(const wchar_t *format, va_list ap) __attribute__((nonnull(1),malloc,warn_unused_result)); extern wchar_t *malloc_wprintf(const wchar_t *format, ...) __attribute__((nonnull(1),malloc,warn_unused_result)); extern wchar_t *joinwcsarray(void *const *array, const wchar_t *padding) __attribute__((malloc,warn_unused_result,nonnull)); /* Frees the specified multibyte string buffer. The contents are lost. */ void sb_destroy(xstrbuf_T *buf) { free(buf->contents); } /* Frees the specified multibyte string buffer and returns the contents. * The caller must `free' the return value. */ char *sb_tostr(xstrbuf_T *buf) { return buf->contents; } /* Shrinks the length of the buffer to `newlength'. * `newlength' must not be larger than the current length. * Characters beyond the new length are lost. * `maxlength' of the buffer is not changed. */ xstrbuf_T *sb_truncate(xstrbuf_T *buf, size_t newlength) { #ifdef assert assert(newlength <= buf->length); #endif buf->contents[buf->length = newlength] = '\0'; return buf; } /* Clears the contents of the specified string buffer. * `maxlength' of the buffer is not changed. */ xstrbuf_T *sb_clear(xstrbuf_T *buf) { return sb_truncate(buf, 0); } /* Inserts the first `n' bytes of multibyte string `s' at offset `i' in buffer * `buf'. * No boundary checks are done and null characters are not considered special. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_ninsert_force( xstrbuf_T *restrict buf, size_t i, const char *restrict s, size_t n) { return sb_replace_force(buf, i, 0, s, n); } /* Inserts the first `n' bytes of multibyte string `s' at offset `i' in buffer * `buf'. * If (strlen(s) <= n), the whole of `s' is inserted. * If (buf->length <= i), `s' is appended to the end of the buffer. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_ninsert( xstrbuf_T *restrict buf, size_t i, const char *restrict s, size_t n) { return sb_replace(buf, i, 0, s, n); } /* Inserts multibyte string `s' at offset `i' in buffer `buf'. * If (buf->length <= i), `s' is appended to the end of the buffer. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_insert(xstrbuf_T *restrict buf, size_t i, const char *restrict s) { return sb_replace(buf, i, 0, s, Size_max); } /* Appends the first `n' bytes of multibyte string `s' to buffer `buf'. * No boundary checks are done and null characters are not considered special. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_ncat_force( xstrbuf_T *restrict buf, const char *restrict s, size_t n) { return sb_replace_force(buf, buf->length, 0, s, n); } /* Appends the first `n' bytes of multibyte string `s' to buffer `buf'. * If (strlen(s) <= n), the whole of `s' is appended. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_ncat(xstrbuf_T *restrict buf, const char *restrict s, size_t n) { return sb_replace(buf, Size_max, 0, s, n); } /* Appends multibyte string `s' to buffer `buf'. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_cat(xstrbuf_T *restrict buf, const char *restrict s) { return sb_replace(buf, Size_max, 0, s, Size_max); } /* Appends multibyte string `s' to buffer `buf' and free the string. * `s' must not be part of `buf->contents'. */ xstrbuf_T *sb_catfree(xstrbuf_T *restrict buf, char *restrict s) { sb_cat(buf, s); free(s); return buf; } /* Removes `n' bytes at offset `i' in buffer `buf'. * If (buf->length <= i), `buf' is unchanged. * If (buf->length <= i + n), `buf' is truncated to `i' bytes. */ xstrbuf_T *sb_remove(xstrbuf_T *buf, size_t i, size_t n) { return sb_replace(buf, i, n, "", 0); } #if HAVE_WCSNRTOMBS wchar_t *sb_wcscat(xstrbuf_T *restrict buf, const wchar_t *restrict s, mbstate_t *restrict ps) { return sb_wcsncat(buf, s, Size_max, ps); } #endif /* Frees the specified wide string buffer. The contents are lost. */ void wb_destroy(xwcsbuf_T *buf) { free(buf->contents); } /* Frees the specified wide string buffer and returns the contents. * The caller must `free' the return value. */ wchar_t *wb_towcs(xwcsbuf_T *buf) { return buf->contents; } /* Shrinks the length of the specified buffer to `newlength'. * `newlength' must not be larger than the current length. * Characters beyond the new length are lost. * `maxlength' of the buffer is not changed. */ xwcsbuf_T *wb_truncate(xwcsbuf_T *buf, size_t newlength) { #ifdef assert assert(newlength <= buf->length); #endif buf->contents[buf->length = newlength] = L'\0'; return buf; } /* Clears the contents of the specified string buffer. * `maxlength' of the buffer is not changed. */ xwcsbuf_T *wb_clear(xwcsbuf_T *buf) { return wb_truncate(buf, 0); } /* Inserts the first `n' characters of wide string `s' at offset `i' in buffer * `buf'. * No boundary checks are done and null characters are not considered special. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_ninsert_force( xwcsbuf_T *restrict buf, size_t i, const wchar_t *restrict s, size_t n) { return wb_replace_force(buf, i, 0, s, n); } /* Inserts the first `n' characters of wide string `s` at offset `i' in buffer * `buf'. * If (wcslen(s) <= n), the whole of `s' is inserted. * If (buf->length <= i), `s' is appended to the end of the buffer. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_ninsert( xwcsbuf_T *restrict buf, size_t i, const wchar_t *restrict s, size_t n) { return wb_replace(buf, i, 0, s, n); } /* Inserts wide string `s' at offset `i' in buffer `buf'. * If (buf->length <= i), `s' is appended to the end of the buffer. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_insert( xwcsbuf_T *restrict buf, size_t i, const wchar_t *restrict s) { return wb_replace(buf, i, 0, s, Size_max); } /* Appends the first `n' characters of wide string `s' to buffer `buf'. * No boundary checks are done and null characters are not considered special. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_ncat_force( xwcsbuf_T *restrict buf, const wchar_t *restrict s, size_t n) { return wb_replace_force(buf, buf->length, 0, s, n); } /* Appends the first `n' characters of wide string `s' to buffer `buf'. * If (wcslen(s) <= n), the whole of `s' is appended. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_ncat(xwcsbuf_T *restrict buf, const wchar_t *restrict s, size_t n) { return wb_replace(buf, Size_max, 0, s, n); } /* Appends wide string `s' to buffer `buf'. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_cat(xwcsbuf_T *restrict buf, const wchar_t *restrict s) { return wb_replace(buf, Size_max, 0, s, Size_max); } /* Appends wide string `s' to buffer and frees the string. * `s' must not be part of `buf->contents'. */ xwcsbuf_T *wb_catfree(xwcsbuf_T *restrict buf, wchar_t *restrict s) { wb_cat(buf, s); free(s); return buf; } /* Removes `n' characters at offset `i' in buffer `buf'. * If (buf->length <= i), `buf' is unchanged. * If (buf->length <= i + n), `buf' is truncated to `i' characters. */ xwcsbuf_T *wb_remove(xwcsbuf_T *buf, size_t i, size_t n) { return wb_replace(buf, i, n, L"", 0); } #if HAVE_WCSNRTOMBS char *malloc_wcstombs(const wchar_t *s) { return malloc_wcsntombs(s, Size_max); } #endif /* Converts the specified wide string into a newly malloced multibyte string and * frees the original wide string. * Returns NULL on error. The wide string is freed anyway. * The resulting string starts and ends in the initial shift state.*/ char *realloc_wcstombs(wchar_t *s) { char *result = malloc_wcstombs(s); free(s); return result; } /* Converts the specified multibyte string into a newly malloced wide string and * frees the multibyte string. * Returns NULL on error. The multibyte string is freed anyway. */ wchar_t *realloc_mbstowcs(char *s) { wchar_t *result = malloc_mbstowcs(s); free(s); return result; } #undef Size_max #endif /* YASH_STRBUF_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtin.d0000644000175000017500000000054112154557026014361 0ustar magicantmagicantbuiltin.o: builtin.c common.h config.h builtin.h alias.h xgetopt.h exec.h \ hashtable.h history.h job.h option.h path.h sig.h strbuf.h util.h \ variable.h xfnmatch.h yash.h builtins/printf.h builtins/test.h \ builtins/ulimit.h builtins/../xgetopt.h lineedit/complete.h \ lineedit/../plist.h lineedit/../xgetopt.h lineedit/keymap.h \ lineedit/key.h yash-2.35/INSTALL0000644000175000017500000003307212154557026013604 0ustar magicantmagicant====================================================================== Yash Build and Installation Guide ====================================================================== A one-liner for experts: ./configure && make && sudo make install ---------------------------------------------------------------------- Contents: 1. What you need to build yash 2. Configuration 3. Building and testing 4. Installation and uninstallation 5. More configuration options ---------------------------------------------------------------------- 1. What You Need to Build Yash Yash is a program written in C99 (ISO/IEC 9899:1999), an extended version of the C programming language, so you need a C99 compiler to build it. If you do not have a C99 compiler installed on your system, install one first. If you have a C99 compiler installed as the `c99' command, it will suffice. Or if you have a recent version of the `gcc' command installed from the GNU Compiler Collection, it will also do. If you have a C99 compiler other than the `c99' or `gcc' command and want to use that, you have to specify the compiler in configuration. The build process of yash is automated using the `make' command, so you need the `make' command installed in addition to the compiler. It is recommended to use a version of `make' that conforms to POSIX. GNU Make is confirmed to work, and most of other versions will also do. Yash is based on API specified in the POSIX standard (IEEE Std 1003.1, 2008 Edition). If your system does not support the POSIX API, yash may not be able to be built or work as expected. Yash uses the `gettext' function to support localized messages. On recent versions of GNU/Linux and Solaris, the `gettext' function is provided in the standard C library, so you do not need any extra library. On some other systems, the `gettext' function is provided in an extra library called `libintl'. If you do not have the `libintl' library installed on your system, first install the library or disable the internationalization support in configuration to build yash without it. Yash uses the `curses' library to support powerful command line editing. If you do not have the `curses' library installed on your system, first install it or disable command line editing in configuration to build yash without it. ---------------------------------------------------------------------- 2. Configuration The configuration process produces some files that are used in the main build process. There files contain specific information about which features are supported on your system, where yash will be installed, etc. The configuration is done by the shell script named `configure'. To start the configuration, change the working directory of your shell to the directory containing the `configure' script using the `cd' command and invoke `sh configure'. You can specify some options and/or variables when invoking the `configure' script in order to specify: * the compiler, the archiver, etc. that are used in the build * features that will be supported by the resultant executable * directories where executable and other files are installed. For example, to configure with the command line editing feature disabled, invoke the script as `sh configure --disable-lineedit'. To use the `cc' command as the compiler during the build, `sh configure CC=cc' The rest of this section describes the options and variables that can be specified. The following options can be specified to enable or disable specific features of yash. By default, yash is built with all features enabled. --enable-alias --disable-alias If disabled, you cannot use aliases in the shell and the `alias' and `unalias' built-in commands are not available. --enable-array --disable-array If disabled, the `array' built-in command is not available. Note that array variables are available regardless of this option. --enable-dirstack --disable-dirstack If disabled, the `dirs', `pushd', and `popd' built-in commands are not available. --enable-help --disable-help If disabled, the `help' built-in command is not available. --enable-history --disable-history If disabled, the `fc' and `history' built-in commands are not available. --enable-lineedit --disable-lineedit If disabled, command line editing for the interactive shell is not available. When this feature is enabled, the history feature must also be enabled. --enable-printf --disable-printf If disabled, the `printf' and `echo' built-in commands are not available. --enable-socket --disable-socket If disabled, socket redirection is not available. To enable this feature, your system have to support sockets. --enable-test --disable-test If disabled, the `test' and `[' built-in commands are not available. --enable-ulimit --disable-ulimit If disabled, the `ulimit' built-in command is not available. To enable this feature, your system must support the `getrlimit' and `setrlimit' functions in the standard C library. The following option specifies the behavior of yash: --default-loadpath=... When yash is invoked, the $YASH_LOADPATH variable is initialized to this value. (default: /yash) The following options specify where files are installed: --prefix=... The basic installation path prefix. (default: /usr/local) --exec-prefix=... The basic installation path prefix for binaries. (default: ) --bindir=... The directory where the main executable binary is installed. (default: /bin) --datarootdir=... The basic installation path prefix for files other than the main executable binary. (default: /share) --datadir=... The directory where auxiliary script files are installed. (default: ) --localedir=... The directory where localized message data are installed. (default: /locale) --mandir=... The directory where roff-format manual pages are installed. (default: /man) --docdir=... The directory where non-roff-format manual pages are installed. (default: /doc/yash) --htmldir=... The directory where HTML manual pages are installed. (default: ) The following variables can be used to specify commands and their options used during the build: CC=... This specifies the compiler/linker command used during the build. CFLAGS=... This specifies the compiler option used in compiling (but not in linking). This overrides the options used in the default configuration. CADDS=... This specifies the compiler option used in compiling (but not in linking) in addition to the CFLAGS variable above. You can use CADDS to add compiler options to the default ones. LDFLAGS=... This specifies the linker option used in linking (but not in compiling). This overrides the options used in the default configuration. This variable does not include options that specify linked libraries (see LDLIBS below). LDADDS=... This specifies the linker option used in linking (but not in compiling) in addition to the LDFLAGS variable above. You can use LDADDS to add linker options to the default ones. LDLIBS=... This specifies the linker option that specify libraries linked to the executable binary. This overrides the options automatically detected by the configuration process. AR=... This specifies the archiver command used during the build. ARFLAGS=... This specifies the archiver option used in making a binary archive. This overrides the options used in the default configuration. LINGUAS=... This specifies the names of locales for which localized message data are installed. To specify more than one locale, separate names by spaces. (All space-separated names must be given at once in one variable value. The whole variable value should be properly quoted when invoking the `configure' script.) INSTALL=... This specifies the installer command used in installation. ---------------------------------------------------------------------- 3. Building and Testing Once the configuration is done, to build yash, invoke the `make' command from your shell. The `make' command will automatically invoke the compiler and linker in a proper order to produce the executable binary of yash. After yash is built, you can test the functionality of it by invoking `make test'. (Actually, you can directly invoke `make test' before `make' because the test process automatically builds yash if it is not yet built.) ---------------------------------------------------------------------- 4. Installation and Uninstallation After yash is built, to install yash in your system, invoke `make install'. This will install the main executable binary of yash and all auxiliary files used by yash. If the installation directories are not specified in the configuration, the files are installed into the following directories by default: Main executable binary: /usr/local/bin Auxiliary shell scripts: /usr/local/share/yash Localization data: /usr/local/share/locale Roff-format manual: /usr/local/share/man HTML-format manual: /usr/local/share/doc/yash In most systems, a special permission is required to install files into these directories. Use the `sudo' or other proper command to obtain the permission or you may want to install into other directories by specifying the directories in the configuration. Instead of `make install', you can use `make install-binary' to install the main binary only or `make install-data' to install the other data files only. Instead of `make install' or `make install-binary', you can use `make install-strip' or `make install-binary-strip', respectively, to remove debugging information from the binary during installation. This makes the installed binary size smaller. To uninstall yash, invoke `make uninstall'. You can instead use `make uninstall-binary' or `make uninstall-data' to uninstall the main binary or the other data files only, respectively. ---------------------------------------------------------------------- 5. More Configuration Options After invoking the `configure' script, you can manually edit the `config.h' file to customize yash more. These options cannot be configured by the `configure' script because they are not so interesting for most people to customize. The options can be set by defining macros in the `config.h' file as described below. Some of the options are Boolean options. To enable a Boolean option, define the corresponding macro as a non-zero integer value. To disable a Boolean option, define the macro as zero or leave it undefined. For non-Boolean options, the default value is shown to the right of the macro name. #define ALIAS_LIST_MAX 30 This macro must be defined as a positive integer. This macro specifies the maximum number of aliases that can be expanded recursively. #define DOUBLE_DIVISION_BY_ZERO_ERROR 1 /* Boolean option */ If this macro is set to a non-zero, division by zero in floating-point arithmetic is treated as an error. Otherwise, division by zero is assumed to return a valid result (like infinity). #define FG_DONT_SAVE_TERMINAL 1 /* Boolean option */ When a program that changes the terminal settings is invoked in the background and later continued in the foreground by the `fg' built-in command, it may leave the terminal in the wrong settings. By default, the `fg' command works around this problem by saving the terminal settings before continuing the program and restoring the settings after the program has finished. Defining this macro as a non-zero disables this workaround. #define FIXED_SIGNAL_AS_ERROR 1 /* Boolean option */ As specified in the POSIX standard, if signal handlers that ignore signals are inherited from the invoker process to a shell process, the signal handlers cannot be removed by the `trap' built-in command if the shell is non-interactive. This macro specifies the behavior of the `trap' command in such a case. If this macro is set to a non-zero, the command results in an error. Otherwise, the command returns the exit status of success without any error message. Note that the signal handlers are not removed regardless of this macro. #define FORMAT_INDENT_WIDTH 3 This macro must be defined as a non-negative integer. This macro specifies the number of spaces used to indent commands that are formated and printed by the shell. #define MAX_HISTSIZE 1000000 This macro specifies the maximum size of history. The value must not over (INT_MAX / 10). #define HISTORY_MIN_MAX_NUMBER 100000 This macro specifies the number of history entry at which the number wraps back to 1. (If there are very many history entries, the entry number may wrap at a number larger than this value.) The value must be a power of 10 that is not less than 32768. #define DEFAULT_HISTSIZE 500 This macro specifies the default history size. The value must be 128 or larger. #define LIST_AMBIGUOUS_OPTIONS 1 /* Boolean option */ When an option specified in invocation of the shell or a built-in command is ambiguous, a list of option names that match the specified ambiguous name is printed if this macro is defined as a non-zero. #define SHELLFDMINMAX 100 This macro must be defined as an integer that is not less than 10. When the shell opens a file that is not directly used by user commands, the file descriptor for the file is chosen from integers that is not less than the value of this macro. #define YASH_DISABLE_SUPERUSER 1 /* Boolean option */ If this macro is set to a non-zero, the user whose user ID is zero is not treated as a superuser, who is considered to have special privilege about file access. yash-2.35/option.d0000644000175000017500000000020312154557026014216 0ustar magicantmagicantoption.o: option.c common.h config.h option.h xgetopt.h builtin.h exec.h \ job.h plist.h redir.h sig.h strbuf.h util.h variable.h yash-2.35/job.h0000644000175000017500000001023012154557026013465 0ustar magicantmagicant/* Yash: yet another shell */ /* job.h: job control */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_JOB_H #define YASH_JOB_H #include #include #include "xgetopt.h" /* status of job/process */ typedef enum jobstatus_T { JS_RUNNING, JS_STOPPED, JS_DONE, } jobstatus_T; /* info about a process in a job */ typedef struct process_T { pid_t pr_pid; /* process ID */ jobstatus_T pr_status; int pr_statuscode; wchar_t *pr_name; /* process name made from command line */ } process_T; /* If `pr_pid' is 0, the process was finished without `fork'ing from the shell. * In this case, `pr_status' is JS_DONE and `pr_statuscode' is the exit status. * If `pr_pid' is a positive number, it's the process ID. In this case, * `pr_statuscode' is the status code returned by `waitpid'. */ /* info about a job */ typedef struct job_T { pid_t j_pgid; /* process group ID */ jobstatus_T j_status; _Bool j_statuschanged; /* job's status not yet reported? */ _Bool j_legacy; /* not a true child of the shell? */ _Bool j_nonotify; /* suppress printing job status? */ size_t j_pcount; /* # of processes in `j_procs' */ process_T j_procs[]; /* info about processes */ } job_T; /* When job control is off, `j_pgid' is 0 since the job shares the process group * ID with the shell. * In subshells, the `j_legacy' flag is set to indicate that the job is not * a direct child of the current shell process. */ /* job number of the active job */ #define ACTIVE_JOBNO 0 /* When a process is stopped/terminated by a signal, this value is added to the * signal number to make the value of the exit status. * 128 in bash/zsh/dash/pdksh/mksh/posh, 256 in ksh. */ #ifndef TERMSIGOFFSET #define TERMSIGOFFSET 384 #endif extern void init_job(void); extern void set_active_job(job_T *job) __attribute__((nonnull)); extern void add_job(_Bool current); extern void remove_job(size_t jobnumber); extern void remove_job_nofitying_signal(size_t jobnumber); extern void remove_all_jobs(void); extern void neglect_all_jobs(void); extern size_t job_count(void) __attribute__((pure)); extern size_t stopped_job_count(void) __attribute__((pure)); extern void do_wait(void); extern int wait_for_job(size_t jobnumber, _Bool return_on_stop, _Bool interruptible, _Bool return_on_trap); extern wchar_t **wait_for_child(pid_t cpid, pid_t cpgid, _Bool return_on_stop); extern pid_t get_job_pgid(const wchar_t *jobname) __attribute__((pure)); extern void put_foreground(pid_t pgrp); extern void ensure_foreground(void); extern int calc_status_of_job(const job_T *job) __attribute__((pure,nonnull)); extern void print_job_status_all(void); extern void notify_signaled_job(size_t jobnumber); extern int jobs_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char jobs_help[], jobs_syntax[]; #endif extern const struct xgetopt_T jobs_options[]; extern int fg_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char fg_help[], fg_syntax[], bg_help[], bg_syntax[]; #endif extern int wait_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char wait_help[], wait_syntax[]; #endif extern int disown_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char disown_help[], disown_syntax[]; #endif #endif /* YASH_JOB_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/po/0000755000175000017500000000000012154557026013164 5ustar magicantmagicantyash-2.35/po/quot.sed0000644000175000017500000000023112154557026014645 0ustar magicantmagicants/"\([^"]*\)"/“\1â€/g s/`\([^`']*\)'/‘\1’/g s/ '\([^`']*\)' / ‘\1’ /g s/ '\([^`']*\)'$/ ‘\1’/g s/^'\([^`']*\)' /‘\1’ /g s/“â€/""/g yash-2.35/po/en@boldquot.ih0000644000175000017500000000007112154557026015760 0ustar magicantmagicant/^msgid /{ x s/m/m/ ta r en@boldquot.hd g N bb :a x :b } yash-2.35/po/yash.pot0000644000175000017500000007304212154557026014662 0ustar magicantmagicant# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Magicant # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: yash 2.35\n" "Report-Msgid-Bugs-To: http://sourceforge.jp/projects/yash/forums/\n" "POT-Creation-Date: 2013-06-08 16:31+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" #: alias.c:396 #, c-format msgid "%ls: an alias for `%ls'\n" msgstr "" #: alias.c:493 alias.c:544 #, c-format msgid "no such alias `%ls'" msgstr "" #: alias.c:496 #, c-format msgid "`%ls' is not a valid alias name" msgstr "" #: alias.c:505 msgid "define or print aliases" msgstr "" #: alias.c:508 msgid "\talias [-gp] [name[=value]...]\n" msgstr "" #: alias.c:552 msgid "undefine aliases" msgstr "" #: alias.c:555 msgid "" "\tunalias name...\n" "\tunalias -a\n" msgstr "" #: arith.c:175 arith.c:217 msgid "arithmetic: invalid syntax" msgstr "" #: arith.c:212 msgid "the index is not an integer" msgstr "" #. TRANSLATORS: This error message is shown when the target #. * of an assignment is not a variable. #: arith.c:280 msgid "arithmetic: cannot assign to a number" msgstr "" #: arith.c:446 arith.c:964 #, c-format msgid "arithmetic: `%ls' is missing" msgstr "" #: arith.c:780 arith.c:791 msgid "arithmetic: division by zero" msgstr "" #: arith.c:827 arith.c:903 #, c-format msgid "arithmetic: operator `%ls' is not supported" msgstr "" #. TRANSLATORS: This error message is shown when the operand of #. * the "++" or "--" operator is not a variable. #: arith.c:840 arith.c:917 #, c-format msgid "arithmetic: operator `%ls' requires a variable" msgstr "" #: arith.c:979 msgid "arithmetic: a value is missing" msgstr "" #: arith.c:1016 arith.c:1060 #, c-format msgid "arithmetic: `%ls' is not a valid number" msgstr "" #: arith.c:1330 #, c-format msgid "arithmetic: `%lc' is not a valid number or operator" msgstr "" #: builtin.c:251 #, c-format msgid "the -%lc option cannot be used with the -%lc option" msgstr "" #: builtin.c:277 #, c-format msgid "this command requires an operand" msgid_plural "this command requires %zu operands" msgstr[0] "" msgstr[1] "" #. TRANSLATORS: This message is printed when a command that takes no #. * operand was invoked with some operands. #: builtin.c:290 msgid "no operand is expected" msgstr "" #. TRANSLATORS: This message is printed when a command was invoked with #. * the wrong number of operands. #: builtin.c:294 msgid "too many operands are specified" msgstr "" #: builtin.c:346 yash.c:363 msgid "Try `man yash' for details.\n" msgstr "" #: builtin.c:361 #, c-format msgid "no such built-in `%ls'" msgstr "" #. TRANSLATORS: This is printed before syntax info of a built-in. #: builtin.c:369 #, c-format msgid "" "Syntax:\n" "%s\n" msgstr "" #. TRANSLATORS: This text is printed before a list of options. #: builtin.c:388 builtin.c:408 msgid "Options:\n" msgstr "" #: builtin.c:547 msgid "do nothing" msgstr "" #: builtin.c:550 msgid "\t: [...]\n" msgstr "" #: builtin.c:554 msgid "do nothing successfully" msgstr "" #: builtin.c:557 msgid "\ttrue\n" msgstr "" #: builtin.c:561 msgid "do nothing unsuccessfully" msgstr "" #: builtin.c:564 msgid "\tfalse\n" msgstr "" #: builtin.c:589 msgid "print usage of built-in commands" msgstr "" #: builtin.c:592 msgid "\thelp [built-in...]\n" msgstr "" #: builtins/printf.c:206 builtins/printf.c:332 history.c:1458 job.c:1062 #: path.c:1370 util.c:301 msgid "cannot print to the standard output" msgstr "" #: builtins/printf.c:267 msgid "print arguments" msgstr "" #: builtins/printf.c:270 msgid "\techo [string...]\n" msgstr "" #: builtins/printf.c:411 msgid "cannot parse the format" msgstr "" #: builtins/printf.c:520 msgid "the conversion specifier is missing" msgstr "" #: builtins/printf.c:524 #, c-format msgid "`%lc' is not a valid conversion specifier" msgstr "" #: builtins/printf.c:529 #, c-format msgid "invalid flag for conversion specifier `%lc'" msgstr "" #: builtins/printf.c:659 #, c-format msgid "`%ls' is not a valid number" msgstr "" #: builtins/printf.c:693 builtins/test.c:556 builtins/test.c:562 #: builtins/ulimit.c:229 exec.c:1684 exec.c:1757 history.c:1714 sig.c:1333 #: variable.c:2063 variable.c:2123 variable.c:2162 variable.c:2334 yash.c:611 #, c-format msgid "`%ls' is not a valid integer" msgstr "" #: builtins/printf.c:758 msgid "print a formatted string" msgstr "" #: builtins/printf.c:761 msgid "\tprintf format [value...]\n" msgstr "" #: builtins/test.c:82 builtins/test.c:425 parser.c:1256 parser.c:1704 #: parser.c:1784 parser.c:1812 parser.c:2199 parser.c:2271 parser.c:2358 #: parser.c:2730 #, c-format msgid "`%ls' is missing" msgstr "" #: builtins/test.c:113 #, c-format msgid "`%ls' is not a valid operator" msgstr "" #: builtins/test.c:138 #, c-format msgid "`%ls' is not a unary operator" msgstr "" #: builtins/test.c:159 builtins/test.c:627 builtins/test.c:635 exec.c:1893 #: exec.c:2027 exec.c:2036 history.c:1492 lineedit/keymap.c:476 path.c:1175 #: path.c:1247 strbuf.c:545 strbuf.c:568 msgid "unexpected error" msgstr "" #: builtins/test.c:364 #, c-format msgid "`%ls' is not a binary operator" msgstr "" #: builtins/test.c:416 #, c-format msgid "an expression is missing after `%ls'" msgstr "" #: builtins/test.c:682 msgid "evaluate a conditional expression" msgstr "" #: builtins/test.c:685 msgid "" "\ttest expression\n" "\t[ expression ]\n" msgstr "" #: builtins/ulimit.c:65 msgid "file size (blocks)" msgstr "" #: builtins/ulimit.c:73 msgid "core file size (blocks)" msgstr "" #: builtins/ulimit.c:75 msgid "data segment size (kbytes)" msgstr "" #: builtins/ulimit.c:78 msgid "max nice" msgstr "" #: builtins/ulimit.c:83 msgid "pending signals" msgstr "" #: builtins/ulimit.c:87 msgid "locked memory (kbytes)" msgstr "" #: builtins/ulimit.c:91 msgid "resident set size (kbytes)" msgstr "" #: builtins/ulimit.c:94 msgid "open files" msgstr "" #: builtins/ulimit.c:97 msgid "message queue size (bytes)" msgstr "" #: builtins/ulimit.c:101 msgid "real-time priority" msgstr "" #: builtins/ulimit.c:104 msgid "stack size (kbytes)" msgstr "" #: builtins/ulimit.c:106 msgid "CPU time (seconds)" msgstr "" #: builtins/ulimit.c:109 msgid "user processes" msgstr "" #: builtins/ulimit.c:113 msgid "memory (kbytes)" msgstr "" #: builtins/ulimit.c:117 msgid "file locks" msgstr "" #: builtins/ulimit.c:170 builtins/ulimit.c:245 #, c-format msgid "cannot get the current limit for the resource type of `%s'" msgstr "" #: builtins/ulimit.c:217 msgid "the soft limit cannot exceed the hard limit" msgstr "" #: builtins/ulimit.c:222 msgid "failed to set the limit" msgstr "" #: builtins/ulimit.c:251 #, c-format msgid "-%lc: %-30s " msgstr "" #: builtins/ulimit.c:263 msgid "unlimited" msgstr "" #: builtins/ulimit.c:270 msgid "set or print a resource limitation" msgstr "" #: builtins/ulimit.c:273 msgid "" "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [limit]\n" msgstr "" #: exec.c:736 msgid "cannot open a pipe" msgstr "" #: exec.c:960 msgid "cannot make a child process" msgstr "" #: exec.c:1185 exec.c:2051 exec.c:2282 #, c-format msgid "no such command `%s'" msgstr "" #: exec.c:1239 #, c-format msgid "cannot execute command `%s'" msgstr "" #: exec.c:1240 #, c-format msgid "cannot execute command `%s' (%s)" msgstr "" #: exec.c:1340 #, c-format msgid "cannot invoke a new shell to execute script `%s'" msgstr "" #: exec.c:1396 exec.c:1418 msgid "cannot open a pipe for the command substitution" msgstr "" #: exec.c:1455 msgid "command substitution" msgstr "" #: exec.c:1694 msgid "cannot be used in the interactive mode" msgstr "" #: exec.c:1704 msgid "return from a function or script" msgstr "" #: exec.c:1707 msgid "\treturn [-n] [exit_status]\n" msgstr "" #: exec.c:1739 msgid "not in an iteration" msgstr "" #: exec.c:1760 #, c-format msgid "%u is not a positive integer" msgstr "" #: exec.c:1770 msgid "not in a loop" msgstr "" #: exec.c:1789 msgid "exit a loop" msgstr "" #: exec.c:1792 msgid "" "\tbreak [count]\n" "\tbreak -i\n" msgstr "" #: exec.c:1797 msgid "continue a loop" msgstr "" #: exec.c:1800 msgid "" "\tcontinue [count]\n" "\tcontinue -i\n" msgstr "" #: exec.c:1840 msgid "evaluate arguments as a command" msgstr "" #: exec.c:1843 msgid "\teval [-i] [argument...]\n" msgstr "" #: exec.c:1902 #, c-format msgid "file `%s' was not found in $YASH_LOADPATH" msgstr "" #: exec.c:1912 #, c-format msgid "file `%s' was not found in $PATH" msgstr "" #: exec.c:1929 redir.c:279 yash.c:207 #, c-format msgid "cannot open file `%s'" msgstr "" #: exec.c:1953 msgid "read a file and execute commands" msgstr "" #: exec.c:1956 msgid "\t. [-AL] file [argument...]\n" msgstr "" #: exec.c:2004 yash.c:598 #, c-format msgid "You have a stopped job!" msgid_plural "You have %zu stopped jobs!" msgstr[0] "" msgstr[1] "" #: exec.c:2008 msgid " Use the -f option to exec anyway.\n" msgstr "" #: exec.c:2098 msgid "replace the shell process with an external command" msgstr "" #: exec.c:2101 msgid "\texec [-cf] [-a name] [command [argument...]]\n" msgstr "" #: exec.c:2161 msgid "the -a or -k option must be used with the -v option" msgstr "" #: exec.c:2255 #, c-format msgid "%ls: a shell keyword\n" msgstr "" #: exec.c:2288 #, c-format msgid "%s: a special built-in\n" msgstr "" #: exec.c:2292 #, c-format msgid "%s: a semi-special built-in\n" msgstr "" #: exec.c:2304 #, c-format msgid "%s: a regular built-in (not found in $PATH)\n" msgstr "" #: exec.c:2305 #, c-format msgid "%s: a regular built-in at %s\n" msgstr "" #: exec.c:2312 #, c-format msgid "%s: a function\n" msgstr "" #: exec.c:2328 #, c-format msgid "%s: an external command at %s\n" msgstr "" #: exec.c:2350 #, c-format msgid "%s: an external command at %s/%s\n" msgstr "" #: exec.c:2359 msgid "execute or identify a command" msgstr "" #: exec.c:2362 msgid "" "\tcommand [-befp] command [argument...]\n" "\tcommand -v|-V [-abefkp] command...\n" msgstr "" #: exec.c:2367 msgid "identify a command" msgstr "" #: exec.c:2370 msgid "\ttype command...\n" msgstr "" #: exec.c:2408 msgid "cannot get the time data" msgstr "" #: exec.c:2424 msgid "print CPU time usage" msgstr "" #: exec.c:2427 msgid "\ttimes\n" msgstr "" #: expand.c:288 expand.c:294 expand.c:312 redir.c:455 msgid "redirection" msgstr "" #: expand.c:302 #, c-format msgid "filename `%ls' matches more than one file" msgstr "" #: expand.c:630 msgid "the parameter index is invalid" msgstr "" #: expand.c:784 msgid "a nested parameter expansion cannot be assigned" msgstr "" #: expand.c:787 #, c-format msgid "cannot assign to parameter `%ls' in parameter expansion" msgstr "" #: expand.c:793 #, c-format msgid "the specified index does not support assignment in the parameter expansion of array `%ls'" msgstr "" #: expand.c:833 expand.c:1052 #, c-format msgid "parameter `%ls' is not set" msgstr "" #: expand.c:1048 msgid "the parameter value is empty" msgstr "" #: expand.c:1051 #, c-format msgid "parameter `%ls' is not set or has an empty value" msgstr "" #: history.c:1262 msgid "the -n or -v option must be used with the -l option" msgstr "" #: history.c:1268 history.c:1659 msgid "cannot be used during line-editing" msgstr "" #: history.c:1284 msgid "the command history is empty" msgstr "" #: history.c:1319 history.c:1774 #, c-format msgid "no such history entry `%ls'" msgstr "" #: history.c:1421 #, c-format msgid "no such history entry beginning with `%ls'" msgstr "" #: history.c:1529 lineedit/editing.c:2671 msgid "cannot create a temporary file to edit history" msgstr "" #: history.c:1534 lineedit/editing.c:2676 #, c-format msgid "cannot open temporary file `%s'" msgstr "" #: history.c:1542 lineedit/editing.c:2684 msgid "cannot invoke the editor to edit history" msgstr "" #: history.c:1545 history.c:1571 lineedit/editing.c:2687 redir.c:793 #, c-format msgid "failed to remove temporary file `%s'" msgstr "" #: history.c:1563 msgid "the editor returned a non-zero exit status" msgstr "" #: history.c:1568 #, c-format msgid "cannot read commands from file `%s'" msgstr "" #: history.c:1626 msgid "list or re-execute command history" msgstr "" #: history.c:1629 msgid "" "\tfc [-qr] [-e editor] [first [last]]\n" "\tfc -s [-q] [old=new] [first]\n" "\tfc -l [-nrv] [first [last]]\n" msgstr "" #: history.c:1820 #, c-format msgid "cannot read history from file `%ls'" msgstr "" #: history.c:1854 #, c-format msgid "cannot write history to file `%ls'" msgstr "" #: history.c:1875 msgid "manage command history" msgstr "" #: history.c:1878 msgid "\thistory [-cF] [-d entry] [-s command] [-r file] [-w file] [count]\n" msgstr "" #: input.c:153 lineedit/lineedit.c:218 msgid "cannot read input" msgstr "" #: input.c:254 input.c:272 input.c:281 msgid "prompt" msgstr "" #: job.c:518 job.c:1014 job.c:1120 job.c:1273 job.c:1383 #, c-format msgid "job specification `%ls' is ambiguous" msgstr "" #: job.c:523 job.c:1017 job.c:1125 job.c:1386 #, c-format msgid "no such job `%ls'" msgstr "" #: job.c:526 job.c:1127 #, c-format msgid "`%ls' is not a job-controlled job" msgstr "" #: job.c:656 job.c:699 msgid "Running" msgstr "" #: job.c:659 #, c-format msgid "Stopped(SIG%ls)" msgstr "" #: job.c:670 msgid "Done" msgstr "" #: job.c:673 #, c-format msgid "Done(%d)" msgstr "" #: job.c:681 #, c-format msgid "Killed (SIG%ls: core dumped)" msgstr "" #: job.c:684 #, c-format msgid "Killed (SIG%ls)" msgstr "" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:744 #, c-format msgid "[%zu] %c %-20s %ls\n" msgstr "" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:763 #, c-format msgid "[%zu] %c %5jd %-20s %ls\n" msgstr "" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:777 #, c-format msgid " %5jd %-20s | %ls\n" msgstr "" #: job.c:827 #, c-format msgid "The process was killed by SIG%ls: %s\n" msgstr "" #: job.c:830 #, c-format msgid "The process was killed by SIG%ls\n" msgstr "" #: job.c:1007 job.c:1113 job.c:1266 job.c:1377 #, c-format msgid "`%ls' is not a valid job specification" msgstr "" #: job.c:1071 msgid "print info about jobs" msgstr "" #: job.c:1074 msgid "\tjobs [-lnprs] [job...]\n" msgstr "" #: job.c:1100 msgid "job control is disabled" msgstr "" #: job.c:1136 job.c:1393 msgid "there is no current job" msgstr "" #: job.c:1175 #, c-format msgid "job %%%zu has already terminated" msgstr "" #: job.c:1221 msgid "run jobs in the foreground" msgstr "" #: job.c:1224 msgid "\tfg [job...]\n" msgstr "" #: job.c:1228 msgid "run jobs in the background" msgstr "" #: job.c:1231 msgid "\tbg [job...]\n" msgstr "" #: job.c:1340 msgid "wait for jobs to terminate" msgstr "" #: job.c:1343 msgid "\twait [job or process_id...]\n" msgstr "" #: job.c:1403 msgid "disown jobs" msgstr "" #: job.c:1406 msgid "" "\tdisown [job...]\n" "\tdisown -a\n" msgstr "" #: lineedit/complete.c:1514 #, c-format msgid "more than one -%lc option is specified" msgstr "" #: lineedit/complete.c:1526 msgid "the complete built-in can be used during command line completion only" msgstr "" #: lineedit/complete.c:1539 #, c-format msgid "the specified prefix `%ls' does not match the target word `%ls'" msgstr "" #: lineedit/complete.c:1587 msgid "generate completion candidates" msgstr "" #: lineedit/complete.c:1590 msgid "" "\tcomplete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \\\n" "\t [-abcdfghjkuv] [[-O] [-D description] words...]\n" msgstr "" #: lineedit/display.c:1346 #, c-format msgid "Candidate %zu of %zu; Page %zu of %zu" msgstr "" #: lineedit/display.c:1362 msgid "No candidates" msgstr "" #: lineedit/editing.c:2741 msgid "lineedit" msgstr "" #: lineedit/keymap.c:422 msgid "option combination is invalid" msgstr "" #: lineedit/keymap.c:429 msgid "no option is specified" msgstr "" #: lineedit/keymap.c:463 msgid "cannot bind an empty key sequence" msgstr "" #: lineedit/keymap.c:487 #, c-format msgid "no such editing command `%ls'" msgstr "" #: lineedit/keymap.c:521 #, c-format msgid "key sequence `%ls' is not bound" msgstr "" #: lineedit/keymap.c:567 msgid "set or print key bindings for line-editing" msgstr "" #: lineedit/keymap.c:570 msgid "" "\tbindkey -aev [key_sequence [command]]\n" "\tbindkey -l\n" msgstr "" #: mail.c:164 mail.c:237 msgid "You have new mail." msgstr "" #: option.c:394 xgetopt.c:414 #, c-format msgid "the -%lc option requires an argument" msgstr "" #: option.c:441 option.c:560 sig.c:1277 xgetopt.c:382 #, c-format msgid "`%ls' is not a valid option" msgstr "" #: option.c:583 xgetopt.c:417 #, c-format msgid "the --%ls option requires an argument" msgstr "" #: option.c:597 xgetopt.c:431 #, c-format msgid "%ls: the --%ls option does not take an argument" msgstr "" #: option.c:606 xgetopt.c:392 #, c-format msgid "option `%ls' is ambiguous" msgstr "" #: option.c:630 #, c-format msgid "the %ls option cannot be changed once the shell has been initialized" msgstr "" #: option.c:889 msgid "on" msgstr "" #: option.c:890 msgid "off" msgstr "" #: option.c:914 msgid "set shell options and positional parameters" msgstr "" #: option.c:917 msgid "" "\tset [option...] [--] [new_positional_parameter...]\n" "\tset -o|+o # print current settings\n" msgstr "" #: parser.c:589 msgid "syntax error: " msgstr "" #: parser.c:869 msgid "`;' or `&' is missing" msgstr "" #: parser.c:1087 msgid "a command is missing at the end of input" msgstr "" #: parser.c:1089 #, c-format msgid "a command is missing before `%lc'" msgstr "" #: parser.c:1124 #, c-format msgid "invalid use of `%lc'" msgstr "" #: parser.c:1380 msgid "the redirection target is missing" msgstr "" #: parser.c:1387 msgid "the end-of-here-document indicator is missing" msgstr "" #: parser.c:1513 msgid "the double quotation is not closed" msgstr "" #: parser.c:1530 msgid "the single quotation is not closed" msgstr "" #: parser.c:1682 msgid "the parameter name is missing or invalid" msgstr "" #: parser.c:1694 parser.c:1699 msgid "the index is missing" msgstr "" #: parser.c:1728 parser.c:1742 parser.c:1786 #, c-format msgid "invalid use of `%lc' in parameter expansion" msgstr "" #: parser.c:1732 #, c-format msgid "invalid character `%lc' in parameter expansion" msgstr "" #: parser.c:1889 msgid "the backquoted command substitution is not closed" msgstr "" #: parser.c:2077 parser.c:2110 parser.c:2203 parser.c:2239 #, c-format msgid "commands are missing between `%ls' and `%ls'" msgstr "" #: parser.c:2123 parser.c:2230 #, c-format msgid "commands are missing after `%ls'" msgstr "" #: parser.c:2166 msgid "an identifier is required after `for'" msgstr "" #: parser.c:2168 #, c-format msgid "`%ls' is not a valid identifier" msgstr "" #: parser.c:2180 msgid "redirections are not allowed after `in'" msgstr "" #: parser.c:2190 msgid "`;' is not allowed just after the identifier in a for loop" msgstr "" #: parser.c:2264 parser.c:2339 parser.c:2384 #, c-format msgid "a word is required after `%ls'" msgstr "" #: parser.c:2330 msgid "an unquoted `esac' cannot be the first case pattern" msgstr "" #: parser.c:2342 #, c-format msgid "encountered an invalid character `%lc' in the case pattern" msgstr "" #: parser.c:2370 parser.c:2688 parser.c:2691 #, c-format msgid "`%ls' cannot be used as a command name" msgstr "" #: parser.c:2402 parser.c:2443 msgid "a function body must be a compound command" msgstr "" #: parser.c:2434 msgid "`(' must be followed by `)' in a function definition" msgstr "" #: parser.c:2471 msgid "the end-of-here-document indicator contains a newline" msgstr "" #: parser.c:2679 #, c-format msgid "encountered `%ls' without a matching `('" msgstr "" #: parser.c:2682 #, c-format msgid "encountered `%ls' without a matching `{'" msgstr "" #: parser.c:2685 #, c-format msgid "`%ls' is used outside `case'" msgstr "" #: parser.c:2694 parser.c:2715 #, c-format msgid "encountered `%ls' without a matching `if' and/or `then'" msgstr "" #: parser.c:2698 #, c-format msgid "encountered `%ls' without a matching `if' or `elif'" msgstr "" #: parser.c:2703 #, c-format msgid "encountered `%ls' without a matching `for', `while', or `until'" msgstr "" #: parser.c:2707 #, c-format msgid "encountered `%ls' without a matching `do'" msgstr "" #: parser.c:2712 #, c-format msgid "encountered `%ls' without a matching `case'" msgstr "" #: parser.c:2728 #, c-format msgid "(maybe you missed `%ls'?)" msgstr "" #: path.c:1090 msgid "$HOME is not set" msgstr "" #: path.c:1099 variable.c:2864 msgid "$OLDPWD is not set" msgstr "" #: path.c:1129 msgid "$PWD has an invalid value" msgstr "" #: path.c:1138 path.c:1149 path.c:1365 msgid "cannot determine the current directory" msgstr "" #: path.c:1221 #, c-format msgid "`%ls'" msgstr "" #: path.c:1252 #, c-format msgid "`%s'" msgstr "" #: path.c:1316 msgid "change the working directory" msgstr "" #: path.c:1319 msgid "\tcd [-L|-P] [directory]\n" msgstr "" #: path.c:1377 msgid "print the working directory" msgstr "" #: path.c:1380 msgid "\tpwd [-L|-P]\n" msgstr "" #: path.c:1435 #, c-format msgid "no such user `%ls'" msgstr "" #: path.c:1457 #, c-format msgid "`%ls': a command name must not contain `/'" msgstr "" #: path.c:1465 #, c-format msgid "command `%s' was not found in $PATH" msgstr "" #: path.c:1511 msgid "remember, forget, or report command locations" msgstr "" #: path.c:1514 msgid "" "\thash command...\n" "\thash -r [command...]\n" "\thash [-a] # print remembered paths\n" "\thash -d user...\n" "\thash -d -r [user...]\n" "\thash -d # print remembered paths\n" msgstr "" #: path.c:1621 path.c:1704 #, c-format msgid "`%ls' is not a valid mask specification" msgstr "" #: path.c:1731 msgid "print or set the file creation mask" msgstr "" #: path.c:1734 msgid "" "\tumask mode\n" "\tumask [-S]\n" msgstr "" #: redir.c:70 #, c-format msgid "error in closing file descriptor %d" msgstr "" #: redir.c:91 #, c-format msgid "cannot copy file descriptor %d to %d" msgstr "" #: redir.c:280 msgid "disabling job control" msgstr "" #: redir.c:328 msgid "redirection: invalid file descriptor" msgstr "" #: redir.c:331 redir.c:607 redir.c:679 #, c-format msgid "redirection: file descriptor %d is unavailable" msgstr "" #: redir.c:379 #, c-format msgid "redirection: cannot open file `%s'" msgstr "" #: redir.c:467 #, c-format msgid "cannot save file descriptor %d" msgstr "" #: redir.c:557 #, c-format msgid "socket redirection: cannot resolve the address of `%s': %s" msgstr "" #: redir.c:601 redir.c:616 redir.c:671 #, c-format msgid "redirection: %s" msgstr "" #: redir.c:624 #, c-format msgid "redirection: file descriptor %d is not readable" msgstr "" #: redir.c:636 #, c-format msgid "redirection: file descriptor %d is not writable" msgstr "" #: redir.c:674 #, c-format msgid "redirection: %d>>|%d: the input and output file descriptors are same" msgstr "" #: redir.c:718 #, c-format msgid "redirection: %d>>|%d" msgstr "" #: redir.c:735 redir.c:775 redir.c:796 msgid "cannot write the here-document contents to the temporary file" msgstr "" #: redir.c:788 msgid "cannot create a temporary file for the here-document" msgstr "" #: redir.c:801 msgid "cannot seek the temporary file for the here-document" msgstr "" #: redir.c:815 msgid "redirection: cannot open a pipe for the command redirection" msgstr "" #: redir.c:854 msgid "command redirection" msgstr "" #: sig.c:481 msgid "cannot send SIGSTOP signal" msgstr "" #: sig.c:581 msgid "too many files are opened for yash to handle" msgstr "" #: sig.c:780 #, c-format msgid "SIG%ls cannot be trapped" msgstr "" #: sig.c:795 #, c-format msgid "real-time signal SIG%ls is not supported" msgstr "" #: sig.c:811 #, c-format msgid "SIG%ls cannot be reset" msgstr "" #: sig.c:1128 sig.c:1169 sig.c:1247 sig.c:1312 #, c-format msgid "no such signal `%ls'" msgstr "" #: sig.c:1198 msgid "set or print signal handlers" msgstr "" #: sig.c:1201 msgid "" "\ttrap [action signal...]\n" "\ttrap signal_number [signal...]\n" "\ttrap -p [signal...]\n" msgstr "" #: sig.c:1235 msgid "the signal name is not specified" msgstr "" #: sig.c:1241 #, c-format msgid "%ls: the signal name must be specified without `SIG'" msgstr "" #: sig.c:1381 msgid "send a signal to processes" msgstr "" #: sig.c:1384 msgid "" "\tkill [-signal|-s signal|-n number] process...\n" "\tkill -l [-v] [number...]\n" msgstr "" #: util.c:269 msgid "unknown error" msgstr "" #: variable.c:367 variable.c:372 msgid "failed to set $PWD" msgstr "" #: variable.c:396 #, c-format msgid "no such array $%ls" msgstr "" #: variable.c:399 variable.c:601 variable.c:1688 variable.c:2293 #: variable.c:2910 #, c-format msgid "$%ls is read-only" msgstr "" #: variable.c:416 #, c-format msgid "failed to unset environment variable $%s" msgstr "" #: variable.c:420 #, c-format msgid "failed to set environment variable $%s" msgstr "" #: variable.c:695 #, c-format msgid "index %zu is out of range (the actual size of array $%ls is %zu)" msgstr "" #: variable.c:1238 #, c-format msgid "function `%ls' cannot be redefined because it is read-only" msgstr "" #: variable.c:1418 variable.c:2996 msgid "the directory stack is empty" msgstr "" #: variable.c:1456 variable.c:2848 variable.c:3092 msgid "$PWD is not set" msgstr "" #: variable.c:1468 #, c-format msgid "index %ls is out of range" msgstr "" #: variable.c:1712 #, c-format msgid "no such variable $%ls" msgstr "" #: variable.c:1724 #, c-format msgid "no such function `%ls'" msgstr "" #: variable.c:1912 msgid "set or print variables" msgstr "" #: variable.c:1915 msgid "\ttypeset [-fgprxX] [name[=value]...]\n" msgstr "" #: variable.c:1918 msgid "export variables as environment variables" msgstr "" #: variable.c:1921 msgid "\texport [-prX] [name[=value]...]\n" msgstr "" #: variable.c:1924 msgid "make variables read-only" msgstr "" #: variable.c:1927 msgid "\treadonly [-fpxX] [name[=value]...]\n" msgstr "" #: variable.c:1975 msgid "more than one option cannot be used at once" msgstr "" #: variable.c:1994 #, c-format msgid "`%ls' is not a valid array name" msgstr "" #: variable.c:2186 #, c-format msgid "index %ls is out of range (the actual size of array $%ls is %zu)" msgstr "" #: variable.c:2193 msgid "manipulate an array" msgstr "" #: variable.c:2196 msgid "" "\tarray # print arrays\n" "\tarray name [value...] # set array values\n" "\tarray -d name [index...]\n" "\tarray -i name index [value...]\n" "\tarray -s name index value\n" msgstr "" #: variable.c:2247 variable.c:2411 variable.c:2619 #, c-format msgid "`%ls' is not a valid variable name" msgstr "" #: variable.c:2268 #, c-format msgid "function `%ls' is read-only" msgstr "" #: variable.c:2304 msgid "remove variables or functions" msgstr "" #: variable.c:2307 msgid "\tunset [-fv] [name...]\n" msgstr "" #: variable.c:2337 #, c-format msgid "%ls: the operand value must not be negative" msgstr "" #: variable.c:2355 #, c-format msgid "%zu: cannot shift so many (there is only one positional parameter)" msgid_plural "%zu: cannot shift so many (there are only %zu positional parameters)" msgstr[0] "" msgstr[1] "" #: variable.c:2377 msgid "remove some positional parameters" msgstr "" #: variable.c:2380 msgid "\tshift [count]\n" msgstr "" #: variable.c:2414 #, c-format msgid "`%ls' is not a valid option specification" msgstr "" #: variable.c:2472 #, c-format msgid "%ls: `-%lc' is not a valid option\n" msgstr "" #: variable.c:2495 #, c-format msgid "%ls: the -%lc option's argument is missing\n" msgstr "" #: variable.c:2518 msgid "$OPTIND has an invalid value" msgstr "" #: variable.c:2573 msgid "parse command options" msgstr "" #: variable.c:2576 msgid "\tgetopts options variable [argument...]\n" msgstr "" #: variable.c:2779 msgid "read a line from the standard input" msgstr "" #: variable.c:2782 msgid "\tread [-Ar] variable...\n" msgstr "" #: variable.c:2907 msgid "$DIRSTACK is not an array" msgstr "" #: variable.c:2962 msgid "push a directory into the directory stack" msgstr "" #: variable.c:2965 msgid "\tpushd [-L|-P] [directory]\n" msgstr "" #: variable.c:3005 variable.c:3081 #, c-format msgid "`%ls' is not a valid index" msgstr "" #: variable.c:3028 msgid "pop a directory from the directory stack" msgstr "" #: variable.c:3031 msgid "\tpopd [index]\n" msgstr "" #: variable.c:3119 msgid "print the directory stack" msgstr "" #: variable.c:3122 msgid "\tdirs [-cv] [index...]\n" msgstr "" #: yash.c:111 #, c-format msgid "%s: cannot convert the argument `%s' into a wide character string" msgstr "" #: yash.c:115 #, c-format msgid "%s: the argument is replaced with an empty string\n" msgstr "" #: yash.c:180 msgid "the -c option is specified but no command is given" msgstr "" #: yash.c:353 #, c-format msgid "" "Syntax:\n" "\t%s [option...] [filename [argument...]]\n" "\t%s [option...] -c command [command_name [argument...]]\n" "\t%s [option...] -s [argument...]\n" msgstr "" #: yash.c:370 #, c-format msgid "Yet another shell, version %s\n" msgstr "" #: yash.c:372 msgid "" "This is free software licensed under GNU GPL version 2.\n" "You can modify and redistribute it, but there is NO WARRANTY.\n" msgstr "" #: yash.c:376 msgid "" "\n" "Enabled features:\n" msgstr "" #: yash.c:525 msgid "Use `exit' to leave the shell.\n" msgstr "" #: yash.c:602 msgid " Use `exit' again to exit anyway.\n" msgstr "" #: yash.c:624 msgid "exit the shell" msgstr "" #: yash.c:627 msgid "\texit [-f] [exit_status]\n" msgstr "" #: yash.c:657 msgid "" "refusing to suspend because of a possible deadlock.\n" "Use the -f option to suspend anyway." msgstr "" #: yash.c:671 msgid "suspend the shell" msgstr "" #: yash.c:674 msgid "\tsuspend [-f]\n" msgstr "" yash-2.35/po/en@boldquot.po0000644000175000017500000012756212154557026016015 0ustar magicantmagicant# English translations for yash package. # Copyright (C) 2013 Magicant # This file is distributed under the same license as the yash package. # Automatically generated, 2013. # # All this catalog "translates" are quotation characters. # The msgids must be ASCII and therefore cannot contain real quotation # characters, only substitutes like grave accent (0x60), apostrophe (0x27) # and double quote (0x22). These substitutes look strange; see # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html # # This catalog translates grave accent (0x60) and apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019). # It also translates pairs of apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019) # and pairs of quotation mark (0x22) to # left double quotation mark (U+201C) and right double quotation mark (U+201D). # # When output to an UTF-8 terminal, the quotation characters appear perfectly. # When output to an ISO-8859-1 terminal, the single quotation marks are # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to # grave/acute accent (by libiconv), and the double quotation marks are # transliterated to 0x22. # When output to an ASCII terminal, the single quotation marks are # transliterated to apostrophes, and the double quotation marks are # transliterated to 0x22. # # This catalog furthermore displays the text between the quotation marks in # bold face, assuming the VT100/XTerm escape sequences. # msgid "" msgstr "" "Project-Id-Version: yash 2.35\n" "Report-Msgid-Bugs-To: http://sourceforge.jp/projects/yash/forums/\n" "POT-Creation-Date: 2013-06-08 16:31+0900\n" "PO-Revision-Date: 2013-06-08 16:31+0900\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: en@boldquot\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: alias.c:396 #, c-format msgid "%ls: an alias for `%ls'\n" msgstr "%ls: an alias for ‘%ls’\n" #: alias.c:493 alias.c:544 #, c-format msgid "no such alias `%ls'" msgstr "no such alias ‘%ls’" #: alias.c:496 #, c-format msgid "`%ls' is not a valid alias name" msgstr "‘%ls’ is not a valid alias name" #: alias.c:505 msgid "define or print aliases" msgstr "define or print aliases" #: alias.c:508 msgid "\talias [-gp] [name[=value]...]\n" msgstr "\talias [-gp] [name[=value]...]\n" #: alias.c:552 msgid "undefine aliases" msgstr "undefine aliases" #: alias.c:555 msgid "" "\tunalias name...\n" "\tunalias -a\n" msgstr "" "\tunalias name...\n" "\tunalias -a\n" #: arith.c:175 arith.c:217 msgid "arithmetic: invalid syntax" msgstr "arithmetic: invalid syntax" #: arith.c:212 msgid "the index is not an integer" msgstr "the index is not an integer" #. TRANSLATORS: This error message is shown when the target #. * of an assignment is not a variable. #: arith.c:280 msgid "arithmetic: cannot assign to a number" msgstr "arithmetic: cannot assign to a number" #: arith.c:446 arith.c:964 #, c-format msgid "arithmetic: `%ls' is missing" msgstr "arithmetic: ‘%ls’ is missing" #: arith.c:780 arith.c:791 msgid "arithmetic: division by zero" msgstr "arithmetic: division by zero" #: arith.c:827 arith.c:903 #, c-format msgid "arithmetic: operator `%ls' is not supported" msgstr "arithmetic: operator ‘%ls’ is not supported" #. TRANSLATORS: This error message is shown when the operand of #. * the "++" or "--" operator is not a variable. #: arith.c:840 arith.c:917 #, c-format msgid "arithmetic: operator `%ls' requires a variable" msgstr "arithmetic: operator ‘%ls’ requires a variable" #: arith.c:979 msgid "arithmetic: a value is missing" msgstr "arithmetic: a value is missing" #: arith.c:1016 arith.c:1060 #, c-format msgid "arithmetic: `%ls' is not a valid number" msgstr "arithmetic: ‘%ls’ is not a valid number" #: arith.c:1330 #, c-format msgid "arithmetic: `%lc' is not a valid number or operator" msgstr "arithmetic: ‘%lc’ is not a valid number or operator" #: builtin.c:251 #, c-format msgid "the -%lc option cannot be used with the -%lc option" msgstr "the -%lc option cannot be used with the -%lc option" #: builtin.c:277 #, c-format msgid "this command requires an operand" msgid_plural "this command requires %zu operands" msgstr[0] "this command requires an operand" msgstr[1] "this command requires %zu operands" #. TRANSLATORS: This message is printed when a command that takes no #. * operand was invoked with some operands. #: builtin.c:290 msgid "no operand is expected" msgstr "no operand is expected" #. TRANSLATORS: This message is printed when a command was invoked with #. * the wrong number of operands. #: builtin.c:294 msgid "too many operands are specified" msgstr "too many operands are specified" #: builtin.c:346 yash.c:363 msgid "Try `man yash' for details.\n" msgstr "Try ‘man yash’ for details.\n" #: builtin.c:361 #, c-format msgid "no such built-in `%ls'" msgstr "no such built-in ‘%ls’" #. TRANSLATORS: This is printed before syntax info of a built-in. #: builtin.c:369 #, c-format msgid "" "Syntax:\n" "%s\n" msgstr "" "Syntax:\n" "%s\n" #. TRANSLATORS: This text is printed before a list of options. #: builtin.c:388 builtin.c:408 msgid "Options:\n" msgstr "Options:\n" #: builtin.c:547 msgid "do nothing" msgstr "do nothing" #: builtin.c:550 msgid "\t: [...]\n" msgstr "\t: [...]\n" #: builtin.c:554 msgid "do nothing successfully" msgstr "do nothing successfully" #: builtin.c:557 msgid "\ttrue\n" msgstr "\ttrue\n" #: builtin.c:561 msgid "do nothing unsuccessfully" msgstr "do nothing unsuccessfully" #: builtin.c:564 msgid "\tfalse\n" msgstr "\tfalse\n" #: builtin.c:589 msgid "print usage of built-in commands" msgstr "print usage of built-in commands" #: builtin.c:592 msgid "\thelp [built-in...]\n" msgstr "\thelp [built-in...]\n" #: builtins/printf.c:206 builtins/printf.c:332 history.c:1458 job.c:1062 #: path.c:1370 util.c:301 msgid "cannot print to the standard output" msgstr "cannot print to the standard output" #: builtins/printf.c:267 msgid "print arguments" msgstr "print arguments" #: builtins/printf.c:270 msgid "\techo [string...]\n" msgstr "\techo [string...]\n" #: builtins/printf.c:411 msgid "cannot parse the format" msgstr "cannot parse the format" #: builtins/printf.c:520 msgid "the conversion specifier is missing" msgstr "the conversion specifier is missing" #: builtins/printf.c:524 #, c-format msgid "`%lc' is not a valid conversion specifier" msgstr "‘%lc’ is not a valid conversion specifier" #: builtins/printf.c:529 #, c-format msgid "invalid flag for conversion specifier `%lc'" msgstr "invalid flag for conversion specifier ‘%lc’" #: builtins/printf.c:659 #, c-format msgid "`%ls' is not a valid number" msgstr "‘%ls’ is not a valid number" #: builtins/printf.c:693 builtins/test.c:556 builtins/test.c:562 #: builtins/ulimit.c:229 exec.c:1684 exec.c:1757 history.c:1714 sig.c:1333 #: variable.c:2063 variable.c:2123 variable.c:2162 variable.c:2334 yash.c:611 #, c-format msgid "`%ls' is not a valid integer" msgstr "‘%ls’ is not a valid integer" #: builtins/printf.c:758 msgid "print a formatted string" msgstr "print a formatted string" #: builtins/printf.c:761 msgid "\tprintf format [value...]\n" msgstr "\tprintf format [value...]\n" #: builtins/test.c:82 builtins/test.c:425 parser.c:1256 parser.c:1704 #: parser.c:1784 parser.c:1812 parser.c:2199 parser.c:2271 parser.c:2358 #: parser.c:2730 #, c-format msgid "`%ls' is missing" msgstr "‘%ls’ is missing" #: builtins/test.c:113 #, c-format msgid "`%ls' is not a valid operator" msgstr "‘%ls’ is not a valid operator" #: builtins/test.c:138 #, c-format msgid "`%ls' is not a unary operator" msgstr "‘%ls’ is not a unary operator" #: builtins/test.c:159 builtins/test.c:627 builtins/test.c:635 exec.c:1893 #: exec.c:2027 exec.c:2036 history.c:1492 lineedit/keymap.c:476 path.c:1175 #: path.c:1247 strbuf.c:545 strbuf.c:568 msgid "unexpected error" msgstr "unexpected error" #: builtins/test.c:364 #, c-format msgid "`%ls' is not a binary operator" msgstr "‘%ls’ is not a binary operator" #: builtins/test.c:416 #, c-format msgid "an expression is missing after `%ls'" msgstr "an expression is missing after ‘%ls’" #: builtins/test.c:682 msgid "evaluate a conditional expression" msgstr "evaluate a conditional expression" #: builtins/test.c:685 msgid "" "\ttest expression\n" "\t[ expression ]\n" msgstr "" "\ttest expression\n" "\t[ expression ]\n" #: builtins/ulimit.c:65 msgid "file size (blocks)" msgstr "file size (blocks)" #: builtins/ulimit.c:73 msgid "core file size (blocks)" msgstr "core file size (blocks)" #: builtins/ulimit.c:75 msgid "data segment size (kbytes)" msgstr "data segment size (kbytes)" #: builtins/ulimit.c:78 msgid "max nice" msgstr "max nice" #: builtins/ulimit.c:83 msgid "pending signals" msgstr "pending signals" #: builtins/ulimit.c:87 msgid "locked memory (kbytes)" msgstr "locked memory (kbytes)" #: builtins/ulimit.c:91 msgid "resident set size (kbytes)" msgstr "resident set size (kbytes)" #: builtins/ulimit.c:94 msgid "open files" msgstr "open files" #: builtins/ulimit.c:97 msgid "message queue size (bytes)" msgstr "message queue size (bytes)" #: builtins/ulimit.c:101 msgid "real-time priority" msgstr "real-time priority" #: builtins/ulimit.c:104 msgid "stack size (kbytes)" msgstr "stack size (kbytes)" #: builtins/ulimit.c:106 msgid "CPU time (seconds)" msgstr "CPU time (seconds)" #: builtins/ulimit.c:109 msgid "user processes" msgstr "user processes" #: builtins/ulimit.c:113 msgid "memory (kbytes)" msgstr "memory (kbytes)" #: builtins/ulimit.c:117 msgid "file locks" msgstr "file locks" #: builtins/ulimit.c:170 builtins/ulimit.c:245 #, c-format msgid "cannot get the current limit for the resource type of `%s'" msgstr "cannot get the current limit for the resource type of ‘%s’" #: builtins/ulimit.c:217 msgid "the soft limit cannot exceed the hard limit" msgstr "the soft limit cannot exceed the hard limit" #: builtins/ulimit.c:222 msgid "failed to set the limit" msgstr "failed to set the limit" #: builtins/ulimit.c:251 #, c-format msgid "-%lc: %-30s " msgstr "-%lc: %-30s " #: builtins/ulimit.c:263 msgid "unlimited" msgstr "unlimited" #: builtins/ulimit.c:270 msgid "set or print a resource limitation" msgstr "set or print a resource limitation" #: builtins/ulimit.c:273 msgid "" "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [limit]\n" msgstr "" "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [limit]\n" #: exec.c:736 msgid "cannot open a pipe" msgstr "cannot open a pipe" #: exec.c:960 msgid "cannot make a child process" msgstr "cannot make a child process" #: exec.c:1185 exec.c:2051 exec.c:2282 #, c-format msgid "no such command `%s'" msgstr "no such command ‘%s’" #: exec.c:1239 #, c-format msgid "cannot execute command `%s'" msgstr "cannot execute command ‘%s’" #: exec.c:1240 #, c-format msgid "cannot execute command `%s' (%s)" msgstr "cannot execute command ‘%s’ (%s)" #: exec.c:1340 #, c-format msgid "cannot invoke a new shell to execute script `%s'" msgstr "cannot invoke a new shell to execute script ‘%s’" #: exec.c:1396 exec.c:1418 msgid "cannot open a pipe for the command substitution" msgstr "cannot open a pipe for the command substitution" #: exec.c:1455 msgid "command substitution" msgstr "command substitution" #: exec.c:1694 msgid "cannot be used in the interactive mode" msgstr "cannot be used in the interactive mode" #: exec.c:1704 msgid "return from a function or script" msgstr "return from a function or script" #: exec.c:1707 msgid "\treturn [-n] [exit_status]\n" msgstr "\treturn [-n] [exit_status]\n" #: exec.c:1739 msgid "not in an iteration" msgstr "not in an iteration" #: exec.c:1760 #, c-format msgid "%u is not a positive integer" msgstr "%u is not a positive integer" #: exec.c:1770 msgid "not in a loop" msgstr "not in a loop" #: exec.c:1789 msgid "exit a loop" msgstr "exit a loop" #: exec.c:1792 msgid "" "\tbreak [count]\n" "\tbreak -i\n" msgstr "" "\tbreak [count]\n" "\tbreak -i\n" #: exec.c:1797 msgid "continue a loop" msgstr "continue a loop" #: exec.c:1800 msgid "" "\tcontinue [count]\n" "\tcontinue -i\n" msgstr "" "\tcontinue [count]\n" "\tcontinue -i\n" #: exec.c:1840 msgid "evaluate arguments as a command" msgstr "evaluate arguments as a command" #: exec.c:1843 msgid "\teval [-i] [argument...]\n" msgstr "\teval [-i] [argument...]\n" #: exec.c:1902 #, c-format msgid "file `%s' was not found in $YASH_LOADPATH" msgstr "file ‘%s’ was not found in $YASH_LOADPATH" #: exec.c:1912 #, c-format msgid "file `%s' was not found in $PATH" msgstr "file ‘%s’ was not found in $PATH" #: exec.c:1929 redir.c:279 yash.c:207 #, c-format msgid "cannot open file `%s'" msgstr "cannot open file ‘%s’" #: exec.c:1953 msgid "read a file and execute commands" msgstr "read a file and execute commands" #: exec.c:1956 msgid "\t. [-AL] file [argument...]\n" msgstr "\t. [-AL] file [argument...]\n" #: exec.c:2004 yash.c:598 #, c-format msgid "You have a stopped job!" msgid_plural "You have %zu stopped jobs!" msgstr[0] "You have a stopped job!" msgstr[1] "You have %zu stopped jobs!" #: exec.c:2008 msgid " Use the -f option to exec anyway.\n" msgstr " Use the -f option to exec anyway.\n" #: exec.c:2098 msgid "replace the shell process with an external command" msgstr "replace the shell process with an external command" #: exec.c:2101 msgid "\texec [-cf] [-a name] [command [argument...]]\n" msgstr "\texec [-cf] [-a name] [command [argument...]]\n" #: exec.c:2161 msgid "the -a or -k option must be used with the -v option" msgstr "the -a or -k option must be used with the -v option" #: exec.c:2255 #, c-format msgid "%ls: a shell keyword\n" msgstr "%ls: a shell keyword\n" #: exec.c:2288 #, c-format msgid "%s: a special built-in\n" msgstr "%s: a special built-in\n" #: exec.c:2292 #, c-format msgid "%s: a semi-special built-in\n" msgstr "%s: a semi-special built-in\n" #: exec.c:2304 #, c-format msgid "%s: a regular built-in (not found in $PATH)\n" msgstr "%s: a regular built-in (not found in $PATH)\n" #: exec.c:2305 #, c-format msgid "%s: a regular built-in at %s\n" msgstr "%s: a regular built-in at %s\n" #: exec.c:2312 #, c-format msgid "%s: a function\n" msgstr "%s: a function\n" #: exec.c:2328 #, c-format msgid "%s: an external command at %s\n" msgstr "%s: an external command at %s\n" #: exec.c:2350 #, c-format msgid "%s: an external command at %s/%s\n" msgstr "%s: an external command at %s/%s\n" #: exec.c:2359 msgid "execute or identify a command" msgstr "execute or identify a command" #: exec.c:2362 msgid "" "\tcommand [-befp] command [argument...]\n" "\tcommand -v|-V [-abefkp] command...\n" msgstr "" "\tcommand [-befp] command [argument...]\n" "\tcommand -v|-V [-abefkp] command...\n" #: exec.c:2367 msgid "identify a command" msgstr "identify a command" #: exec.c:2370 msgid "\ttype command...\n" msgstr "\ttype command...\n" #: exec.c:2408 msgid "cannot get the time data" msgstr "cannot get the time data" #: exec.c:2424 msgid "print CPU time usage" msgstr "print CPU time usage" #: exec.c:2427 msgid "\ttimes\n" msgstr "\ttimes\n" #: expand.c:288 expand.c:294 expand.c:312 redir.c:455 msgid "redirection" msgstr "redirection" #: expand.c:302 #, c-format msgid "filename `%ls' matches more than one file" msgstr "filename ‘%ls’ matches more than one file" #: expand.c:630 msgid "the parameter index is invalid" msgstr "the parameter index is invalid" #: expand.c:784 msgid "a nested parameter expansion cannot be assigned" msgstr "a nested parameter expansion cannot be assigned" #: expand.c:787 #, c-format msgid "cannot assign to parameter `%ls' in parameter expansion" msgstr "cannot assign to parameter ‘%ls’ in parameter expansion" #: expand.c:793 #, c-format msgid "" "the specified index does not support assignment in the parameter expansion " "of array `%ls'" msgstr "" "the specified index does not support assignment in the parameter expansion " "of array ‘%ls’" #: expand.c:833 expand.c:1052 #, c-format msgid "parameter `%ls' is not set" msgstr "parameter ‘%ls’ is not set" #: expand.c:1048 msgid "the parameter value is empty" msgstr "the parameter value is empty" #: expand.c:1051 #, c-format msgid "parameter `%ls' is not set or has an empty value" msgstr "parameter ‘%ls’ is not set or has an empty value" #: history.c:1262 msgid "the -n or -v option must be used with the -l option" msgstr "the -n or -v option must be used with the -l option" #: history.c:1268 history.c:1659 msgid "cannot be used during line-editing" msgstr "cannot be used during line-editing" #: history.c:1284 msgid "the command history is empty" msgstr "the command history is empty" #: history.c:1319 history.c:1774 #, c-format msgid "no such history entry `%ls'" msgstr "no such history entry ‘%ls’" #: history.c:1421 #, c-format msgid "no such history entry beginning with `%ls'" msgstr "no such history entry beginning with ‘%ls’" #: history.c:1529 lineedit/editing.c:2671 msgid "cannot create a temporary file to edit history" msgstr "cannot create a temporary file to edit history" #: history.c:1534 lineedit/editing.c:2676 #, c-format msgid "cannot open temporary file `%s'" msgstr "cannot open temporary file ‘%s’" #: history.c:1542 lineedit/editing.c:2684 msgid "cannot invoke the editor to edit history" msgstr "cannot invoke the editor to edit history" #: history.c:1545 history.c:1571 lineedit/editing.c:2687 redir.c:793 #, c-format msgid "failed to remove temporary file `%s'" msgstr "failed to remove temporary file ‘%s’" #: history.c:1563 msgid "the editor returned a non-zero exit status" msgstr "the editor returned a non-zero exit status" #: history.c:1568 #, c-format msgid "cannot read commands from file `%s'" msgstr "cannot read commands from file ‘%s’" #: history.c:1626 msgid "list or re-execute command history" msgstr "list or re-execute command history" #: history.c:1629 msgid "" "\tfc [-qr] [-e editor] [first [last]]\n" "\tfc -s [-q] [old=new] [first]\n" "\tfc -l [-nrv] [first [last]]\n" msgstr "" "\tfc [-qr] [-e editor] [first [last]]\n" "\tfc -s [-q] [old=new] [first]\n" "\tfc -l [-nrv] [first [last]]\n" #: history.c:1820 #, c-format msgid "cannot read history from file `%ls'" msgstr "cannot read history from file ‘%ls’" #: history.c:1854 #, c-format msgid "cannot write history to file `%ls'" msgstr "cannot write history to file ‘%ls’" #: history.c:1875 msgid "manage command history" msgstr "manage command history" #: history.c:1878 msgid "\thistory [-cF] [-d entry] [-s command] [-r file] [-w file] [count]\n" msgstr "\thistory [-cF] [-d entry] [-s command] [-r file] [-w file] [count]\n" #: input.c:153 lineedit/lineedit.c:218 msgid "cannot read input" msgstr "cannot read input" #: input.c:254 input.c:272 input.c:281 msgid "prompt" msgstr "prompt" #: job.c:518 job.c:1014 job.c:1120 job.c:1273 job.c:1383 #, c-format msgid "job specification `%ls' is ambiguous" msgstr "job specification ‘%ls’ is ambiguous" #: job.c:523 job.c:1017 job.c:1125 job.c:1386 #, c-format msgid "no such job `%ls'" msgstr "no such job ‘%ls’" #: job.c:526 job.c:1127 #, c-format msgid "`%ls' is not a job-controlled job" msgstr "‘%ls’ is not a job-controlled job" #: job.c:656 job.c:699 msgid "Running" msgstr "Running" #: job.c:659 #, c-format msgid "Stopped(SIG%ls)" msgstr "Stopped(SIG%ls)" #: job.c:670 msgid "Done" msgstr "Done" #: job.c:673 #, c-format msgid "Done(%d)" msgstr "Done(%d)" #: job.c:681 #, c-format msgid "Killed (SIG%ls: core dumped)" msgstr "Killed (SIG%ls: core dumped)" #: job.c:684 #, c-format msgid "Killed (SIG%ls)" msgstr "Killed (SIG%ls)" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:744 #, c-format msgid "[%zu] %c %-20s %ls\n" msgstr "[%zu] %c %-20s %ls\n" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:763 #, c-format msgid "[%zu] %c %5jd %-20s %ls\n" msgstr "[%zu] %c %5jd %-20s %ls\n" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:777 #, c-format msgid " %5jd %-20s | %ls\n" msgstr " %5jd %-20s | %ls\n" #: job.c:827 #, c-format msgid "The process was killed by SIG%ls: %s\n" msgstr "The process was killed by SIG%ls: %s\n" #: job.c:830 #, c-format msgid "The process was killed by SIG%ls\n" msgstr "The process was killed by SIG%ls\n" #: job.c:1007 job.c:1113 job.c:1266 job.c:1377 #, c-format msgid "`%ls' is not a valid job specification" msgstr "‘%ls’ is not a valid job specification" #: job.c:1071 msgid "print info about jobs" msgstr "print info about jobs" #: job.c:1074 msgid "\tjobs [-lnprs] [job...]\n" msgstr "\tjobs [-lnprs] [job...]\n" #: job.c:1100 msgid "job control is disabled" msgstr "job control is disabled" #: job.c:1136 job.c:1393 msgid "there is no current job" msgstr "there is no current job" #: job.c:1175 #, c-format msgid "job %%%zu has already terminated" msgstr "job %%%zu has already terminated" #: job.c:1221 msgid "run jobs in the foreground" msgstr "run jobs in the foreground" #: job.c:1224 msgid "\tfg [job...]\n" msgstr "\tfg [job...]\n" #: job.c:1228 msgid "run jobs in the background" msgstr "run jobs in the background" #: job.c:1231 msgid "\tbg [job...]\n" msgstr "\tbg [job...]\n" #: job.c:1340 msgid "wait for jobs to terminate" msgstr "wait for jobs to terminate" #: job.c:1343 msgid "\twait [job or process_id...]\n" msgstr "\twait [job or process_id...]\n" #: job.c:1403 msgid "disown jobs" msgstr "disown jobs" #: job.c:1406 msgid "" "\tdisown [job...]\n" "\tdisown -a\n" msgstr "" "\tdisown [job...]\n" "\tdisown -a\n" #: lineedit/complete.c:1514 #, c-format msgid "more than one -%lc option is specified" msgstr "more than one -%lc option is specified" #: lineedit/complete.c:1526 msgid "the complete built-in can be used during command line completion only" msgstr "the complete built-in can be used during command line completion only" #: lineedit/complete.c:1539 #, c-format msgid "the specified prefix `%ls' does not match the target word `%ls'" msgstr "" "the specified prefix ‘%ls’ does not match the target word ‘%ls’" #: lineedit/complete.c:1587 msgid "generate completion candidates" msgstr "generate completion candidates" #: lineedit/complete.c:1590 msgid "" "\tcomplete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \\\n" "\t [-abcdfghjkuv] [[-O] [-D description] words...]\n" msgstr "" "\tcomplete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \\\n" "\t [-abcdfghjkuv] [[-O] [-D description] words...]\n" #: lineedit/display.c:1346 #, c-format msgid "Candidate %zu of %zu; Page %zu of %zu" msgstr "Candidate %zu of %zu; Page %zu of %zu" #: lineedit/display.c:1362 msgid "No candidates" msgstr "No candidates" #: lineedit/editing.c:2741 msgid "lineedit" msgstr "lineedit" #: lineedit/keymap.c:422 msgid "option combination is invalid" msgstr "option combination is invalid" #: lineedit/keymap.c:429 msgid "no option is specified" msgstr "no option is specified" #: lineedit/keymap.c:463 msgid "cannot bind an empty key sequence" msgstr "cannot bind an empty key sequence" #: lineedit/keymap.c:487 #, c-format msgid "no such editing command `%ls'" msgstr "no such editing command ‘%ls’" #: lineedit/keymap.c:521 #, c-format msgid "key sequence `%ls' is not bound" msgstr "key sequence ‘%ls’ is not bound" #: lineedit/keymap.c:567 msgid "set or print key bindings for line-editing" msgstr "set or print key bindings for line-editing" #: lineedit/keymap.c:570 msgid "" "\tbindkey -aev [key_sequence [command]]\n" "\tbindkey -l\n" msgstr "" "\tbindkey -aev [key_sequence [command]]\n" "\tbindkey -l\n" #: mail.c:164 mail.c:237 msgid "You have new mail." msgstr "You have new mail." #: option.c:394 xgetopt.c:414 #, c-format msgid "the -%lc option requires an argument" msgstr "the -%lc option requires an argument" #: option.c:441 option.c:560 sig.c:1277 xgetopt.c:382 #, c-format msgid "`%ls' is not a valid option" msgstr "‘%ls’ is not a valid option" #: option.c:583 xgetopt.c:417 #, c-format msgid "the --%ls option requires an argument" msgstr "the --%ls option requires an argument" #: option.c:597 xgetopt.c:431 #, c-format msgid "%ls: the --%ls option does not take an argument" msgstr "%ls: the --%ls option does not take an argument" #: option.c:606 xgetopt.c:392 #, c-format msgid "option `%ls' is ambiguous" msgstr "option ‘%ls’ is ambiguous" #: option.c:630 #, c-format msgid "the %ls option cannot be changed once the shell has been initialized" msgstr "the %ls option cannot be changed once the shell has been initialized" #: option.c:889 msgid "on" msgstr "on" #: option.c:890 msgid "off" msgstr "off" #: option.c:914 msgid "set shell options and positional parameters" msgstr "set shell options and positional parameters" #: option.c:917 msgid "" "\tset [option...] [--] [new_positional_parameter...]\n" "\tset -o|+o # print current settings\n" msgstr "" "\tset [option...] [--] [new_positional_parameter...]\n" "\tset -o|+o # print current settings\n" #: parser.c:589 msgid "syntax error: " msgstr "syntax error: " #: parser.c:869 msgid "`;' or `&' is missing" msgstr "‘;’ or ‘&’ is missing" #: parser.c:1087 msgid "a command is missing at the end of input" msgstr "a command is missing at the end of input" #: parser.c:1089 #, c-format msgid "a command is missing before `%lc'" msgstr "a command is missing before ‘%lc’" #: parser.c:1124 #, c-format msgid "invalid use of `%lc'" msgstr "invalid use of ‘%lc’" #: parser.c:1380 msgid "the redirection target is missing" msgstr "the redirection target is missing" #: parser.c:1387 msgid "the end-of-here-document indicator is missing" msgstr "the end-of-here-document indicator is missing" #: parser.c:1513 msgid "the double quotation is not closed" msgstr "the double quotation is not closed" #: parser.c:1530 msgid "the single quotation is not closed" msgstr "the single quotation is not closed" #: parser.c:1682 msgid "the parameter name is missing or invalid" msgstr "the parameter name is missing or invalid" #: parser.c:1694 parser.c:1699 msgid "the index is missing" msgstr "the index is missing" #: parser.c:1728 parser.c:1742 parser.c:1786 #, c-format msgid "invalid use of `%lc' in parameter expansion" msgstr "invalid use of ‘%lc’ in parameter expansion" #: parser.c:1732 #, c-format msgid "invalid character `%lc' in parameter expansion" msgstr "invalid character ‘%lc’ in parameter expansion" #: parser.c:1889 msgid "the backquoted command substitution is not closed" msgstr "the backquoted command substitution is not closed" #: parser.c:2077 parser.c:2110 parser.c:2203 parser.c:2239 #, c-format msgid "commands are missing between `%ls' and `%ls'" msgstr "commands are missing between ‘%ls’ and ‘%ls’" #: parser.c:2123 parser.c:2230 #, c-format msgid "commands are missing after `%ls'" msgstr "commands are missing after ‘%ls’" #: parser.c:2166 msgid "an identifier is required after `for'" msgstr "an identifier is required after ‘for’" #: parser.c:2168 #, c-format msgid "`%ls' is not a valid identifier" msgstr "‘%ls’ is not a valid identifier" #: parser.c:2180 msgid "redirections are not allowed after `in'" msgstr "redirections are not allowed after ‘in’" #: parser.c:2190 msgid "`;' is not allowed just after the identifier in a for loop" msgstr "‘;’ is not allowed just after the identifier in a for loop" #: parser.c:2264 parser.c:2339 parser.c:2384 #, c-format msgid "a word is required after `%ls'" msgstr "a word is required after ‘%ls’" #: parser.c:2330 msgid "an unquoted `esac' cannot be the first case pattern" msgstr "an unquoted ‘esac’ cannot be the first case pattern" #: parser.c:2342 #, c-format msgid "encountered an invalid character `%lc' in the case pattern" msgstr "encountered an invalid character ‘%lc’ in the case pattern" #: parser.c:2370 parser.c:2688 parser.c:2691 #, c-format msgid "`%ls' cannot be used as a command name" msgstr "‘%ls’ cannot be used as a command name" #: parser.c:2402 parser.c:2443 msgid "a function body must be a compound command" msgstr "a function body must be a compound command" #: parser.c:2434 msgid "`(' must be followed by `)' in a function definition" msgstr "‘(’ must be followed by ‘)’ in a function definition" #: parser.c:2471 msgid "the end-of-here-document indicator contains a newline" msgstr "the end-of-here-document indicator contains a newline" #: parser.c:2679 #, c-format msgid "encountered `%ls' without a matching `('" msgstr "encountered ‘%ls’ without a matching ‘(’" #: parser.c:2682 #, c-format msgid "encountered `%ls' without a matching `{'" msgstr "encountered ‘%ls’ without a matching ‘{’" #: parser.c:2685 #, c-format msgid "`%ls' is used outside `case'" msgstr "‘%ls’ is used outside ‘case’" #: parser.c:2694 parser.c:2715 #, c-format msgid "encountered `%ls' without a matching `if' and/or `then'" msgstr "" "encountered ‘%ls’ without a matching ‘if’ and/or ‘then’" #: parser.c:2698 #, c-format msgid "encountered `%ls' without a matching `if' or `elif'" msgstr "encountered ‘%ls’ without a matching ‘if’ or ‘elif’" #: parser.c:2703 #, c-format msgid "encountered `%ls' without a matching `for', `while', or `until'" msgstr "" "encountered ‘%ls’ without a matching ‘for’, ‘while’, or " "‘until’" #: parser.c:2707 #, c-format msgid "encountered `%ls' without a matching `do'" msgstr "encountered ‘%ls’ without a matching ‘do’" #: parser.c:2712 #, c-format msgid "encountered `%ls' without a matching `case'" msgstr "encountered ‘%ls’ without a matching ‘case’" #: parser.c:2728 #, c-format msgid "(maybe you missed `%ls'?)" msgstr "(maybe you missed ‘%ls’?)" #: path.c:1090 msgid "$HOME is not set" msgstr "$HOME is not set" #: path.c:1099 variable.c:2864 msgid "$OLDPWD is not set" msgstr "$OLDPWD is not set" #: path.c:1129 msgid "$PWD has an invalid value" msgstr "$PWD has an invalid value" #: path.c:1138 path.c:1149 path.c:1365 msgid "cannot determine the current directory" msgstr "cannot determine the current directory" #: path.c:1221 #, c-format msgid "`%ls'" msgstr "‘%ls’" #: path.c:1252 #, c-format msgid "`%s'" msgstr "‘%s’" #: path.c:1316 msgid "change the working directory" msgstr "change the working directory" #: path.c:1319 msgid "\tcd [-L|-P] [directory]\n" msgstr "\tcd [-L|-P] [directory]\n" #: path.c:1377 msgid "print the working directory" msgstr "print the working directory" #: path.c:1380 msgid "\tpwd [-L|-P]\n" msgstr "\tpwd [-L|-P]\n" #: path.c:1435 #, c-format msgid "no such user `%ls'" msgstr "no such user ‘%ls’" #: path.c:1457 #, c-format msgid "`%ls': a command name must not contain `/'" msgstr "‘%ls’: a command name must not contain ‘/’" #: path.c:1465 #, c-format msgid "command `%s' was not found in $PATH" msgstr "command ‘%s’ was not found in $PATH" #: path.c:1511 msgid "remember, forget, or report command locations" msgstr "remember, forget, or report command locations" #: path.c:1514 msgid "" "\thash command...\n" "\thash -r [command...]\n" "\thash [-a] # print remembered paths\n" "\thash -d user...\n" "\thash -d -r [user...]\n" "\thash -d # print remembered paths\n" msgstr "" "\thash command...\n" "\thash -r [command...]\n" "\thash [-a] # print remembered paths\n" "\thash -d user...\n" "\thash -d -r [user...]\n" "\thash -d # print remembered paths\n" #: path.c:1621 path.c:1704 #, c-format msgid "`%ls' is not a valid mask specification" msgstr "‘%ls’ is not a valid mask specification" #: path.c:1731 msgid "print or set the file creation mask" msgstr "print or set the file creation mask" #: path.c:1734 msgid "" "\tumask mode\n" "\tumask [-S]\n" msgstr "" "\tumask mode\n" "\tumask [-S]\n" #: redir.c:70 #, c-format msgid "error in closing file descriptor %d" msgstr "error in closing file descriptor %d" #: redir.c:91 #, c-format msgid "cannot copy file descriptor %d to %d" msgstr "cannot copy file descriptor %d to %d" #: redir.c:280 msgid "disabling job control" msgstr "disabling job control" #: redir.c:328 msgid "redirection: invalid file descriptor" msgstr "redirection: invalid file descriptor" #: redir.c:331 redir.c:607 redir.c:679 #, c-format msgid "redirection: file descriptor %d is unavailable" msgstr "redirection: file descriptor %d is unavailable" #: redir.c:379 #, c-format msgid "redirection: cannot open file `%s'" msgstr "redirection: cannot open file ‘%s’" #: redir.c:467 #, c-format msgid "cannot save file descriptor %d" msgstr "cannot save file descriptor %d" #: redir.c:557 #, c-format msgid "socket redirection: cannot resolve the address of `%s': %s" msgstr "socket redirection: cannot resolve the address of ‘%s’: %s" #: redir.c:601 redir.c:616 redir.c:671 #, c-format msgid "redirection: %s" msgstr "redirection: %s" #: redir.c:624 #, c-format msgid "redirection: file descriptor %d is not readable" msgstr "redirection: file descriptor %d is not readable" #: redir.c:636 #, c-format msgid "redirection: file descriptor %d is not writable" msgstr "redirection: file descriptor %d is not writable" #: redir.c:674 #, c-format msgid "redirection: %d>>|%d: the input and output file descriptors are same" msgstr "redirection: %d>>|%d: the input and output file descriptors are same" #: redir.c:718 #, c-format msgid "redirection: %d>>|%d" msgstr "redirection: %d>>|%d" #: redir.c:735 redir.c:775 redir.c:796 msgid "cannot write the here-document contents to the temporary file" msgstr "cannot write the here-document contents to the temporary file" #: redir.c:788 msgid "cannot create a temporary file for the here-document" msgstr "cannot create a temporary file for the here-document" #: redir.c:801 msgid "cannot seek the temporary file for the here-document" msgstr "cannot seek the temporary file for the here-document" #: redir.c:815 msgid "redirection: cannot open a pipe for the command redirection" msgstr "redirection: cannot open a pipe for the command redirection" #: redir.c:854 msgid "command redirection" msgstr "command redirection" #: sig.c:481 msgid "cannot send SIGSTOP signal" msgstr "cannot send SIGSTOP signal" #: sig.c:581 msgid "too many files are opened for yash to handle" msgstr "too many files are opened for yash to handle" #: sig.c:780 #, c-format msgid "SIG%ls cannot be trapped" msgstr "SIG%ls cannot be trapped" #: sig.c:795 #, c-format msgid "real-time signal SIG%ls is not supported" msgstr "real-time signal SIG%ls is not supported" #: sig.c:811 #, c-format msgid "SIG%ls cannot be reset" msgstr "SIG%ls cannot be reset" #: sig.c:1128 sig.c:1169 sig.c:1247 sig.c:1312 #, c-format msgid "no such signal `%ls'" msgstr "no such signal ‘%ls’" #: sig.c:1198 msgid "set or print signal handlers" msgstr "set or print signal handlers" #: sig.c:1201 msgid "" "\ttrap [action signal...]\n" "\ttrap signal_number [signal...]\n" "\ttrap -p [signal...]\n" msgstr "" "\ttrap [action signal...]\n" "\ttrap signal_number [signal...]\n" "\ttrap -p [signal...]\n" #: sig.c:1235 msgid "the signal name is not specified" msgstr "the signal name is not specified" #: sig.c:1241 #, c-format msgid "%ls: the signal name must be specified without `SIG'" msgstr "%ls: the signal name must be specified without ‘SIG’" #: sig.c:1381 msgid "send a signal to processes" msgstr "send a signal to processes" #: sig.c:1384 msgid "" "\tkill [-signal|-s signal|-n number] process...\n" "\tkill -l [-v] [number...]\n" msgstr "" "\tkill [-signal|-s signal|-n number] process...\n" "\tkill -l [-v] [number...]\n" #: util.c:269 msgid "unknown error" msgstr "unknown error" #: variable.c:367 variable.c:372 msgid "failed to set $PWD" msgstr "failed to set $PWD" #: variable.c:396 #, c-format msgid "no such array $%ls" msgstr "no such array $%ls" #: variable.c:399 variable.c:601 variable.c:1688 variable.c:2293 #: variable.c:2910 #, c-format msgid "$%ls is read-only" msgstr "$%ls is read-only" #: variable.c:416 #, c-format msgid "failed to unset environment variable $%s" msgstr "failed to unset environment variable $%s" #: variable.c:420 #, c-format msgid "failed to set environment variable $%s" msgstr "failed to set environment variable $%s" #: variable.c:695 #, c-format msgid "index %zu is out of range (the actual size of array $%ls is %zu)" msgstr "index %zu is out of range (the actual size of array $%ls is %zu)" #: variable.c:1238 #, c-format msgid "function `%ls' cannot be redefined because it is read-only" msgstr "function ‘%ls’ cannot be redefined because it is read-only" #: variable.c:1418 variable.c:2996 msgid "the directory stack is empty" msgstr "the directory stack is empty" #: variable.c:1456 variable.c:2848 variable.c:3092 msgid "$PWD is not set" msgstr "$PWD is not set" #: variable.c:1468 #, c-format msgid "index %ls is out of range" msgstr "index %ls is out of range" #: variable.c:1712 #, c-format msgid "no such variable $%ls" msgstr "no such variable $%ls" #: variable.c:1724 #, c-format msgid "no such function `%ls'" msgstr "no such function ‘%ls’" #: variable.c:1912 msgid "set or print variables" msgstr "set or print variables" #: variable.c:1915 msgid "\ttypeset [-fgprxX] [name[=value]...]\n" msgstr "\ttypeset [-fgprxX] [name[=value]...]\n" #: variable.c:1918 msgid "export variables as environment variables" msgstr "export variables as environment variables" #: variable.c:1921 msgid "\texport [-prX] [name[=value]...]\n" msgstr "\texport [-prX] [name[=value]...]\n" #: variable.c:1924 msgid "make variables read-only" msgstr "make variables read-only" #: variable.c:1927 msgid "\treadonly [-fpxX] [name[=value]...]\n" msgstr "\treadonly [-fpxX] [name[=value]...]\n" #: variable.c:1975 msgid "more than one option cannot be used at once" msgstr "more than one option cannot be used at once" #: variable.c:1994 #, c-format msgid "`%ls' is not a valid array name" msgstr "‘%ls’ is not a valid array name" #: variable.c:2186 #, c-format msgid "index %ls is out of range (the actual size of array $%ls is %zu)" msgstr "index %ls is out of range (the actual size of array $%ls is %zu)" #: variable.c:2193 msgid "manipulate an array" msgstr "manipulate an array" #: variable.c:2196 msgid "" "\tarray # print arrays\n" "\tarray name [value...] # set array values\n" "\tarray -d name [index...]\n" "\tarray -i name index [value...]\n" "\tarray -s name index value\n" msgstr "" "\tarray # print arrays\n" "\tarray name [value...] # set array values\n" "\tarray -d name [index...]\n" "\tarray -i name index [value...]\n" "\tarray -s name index value\n" #: variable.c:2247 variable.c:2411 variable.c:2619 #, c-format msgid "`%ls' is not a valid variable name" msgstr "‘%ls’ is not a valid variable name" #: variable.c:2268 #, c-format msgid "function `%ls' is read-only" msgstr "function ‘%ls’ is read-only" #: variable.c:2304 msgid "remove variables or functions" msgstr "remove variables or functions" #: variable.c:2307 msgid "\tunset [-fv] [name...]\n" msgstr "\tunset [-fv] [name...]\n" #: variable.c:2337 #, c-format msgid "%ls: the operand value must not be negative" msgstr "%ls: the operand value must not be negative" #: variable.c:2355 #, c-format msgid "%zu: cannot shift so many (there is only one positional parameter)" msgid_plural "" "%zu: cannot shift so many (there are only %zu positional parameters)" msgstr[0] "%zu: cannot shift so many (there is only one positional parameter)" msgstr[1] "" "%zu: cannot shift so many (there are only %zu positional parameters)" #: variable.c:2377 msgid "remove some positional parameters" msgstr "remove some positional parameters" #: variable.c:2380 msgid "\tshift [count]\n" msgstr "\tshift [count]\n" #: variable.c:2414 #, c-format msgid "`%ls' is not a valid option specification" msgstr "‘%ls’ is not a valid option specification" #: variable.c:2472 #, c-format msgid "%ls: `-%lc' is not a valid option\n" msgstr "%ls: ‘-%lc’ is not a valid option\n" #: variable.c:2495 #, c-format msgid "%ls: the -%lc option's argument is missing\n" msgstr "%ls: the -%lc option's argument is missing\n" #: variable.c:2518 msgid "$OPTIND has an invalid value" msgstr "$OPTIND has an invalid value" #: variable.c:2573 msgid "parse command options" msgstr "parse command options" #: variable.c:2576 msgid "\tgetopts options variable [argument...]\n" msgstr "\tgetopts options variable [argument...]\n" #: variable.c:2779 msgid "read a line from the standard input" msgstr "read a line from the standard input" #: variable.c:2782 msgid "\tread [-Ar] variable...\n" msgstr "\tread [-Ar] variable...\n" #: variable.c:2907 msgid "$DIRSTACK is not an array" msgstr "$DIRSTACK is not an array" #: variable.c:2962 msgid "push a directory into the directory stack" msgstr "push a directory into the directory stack" #: variable.c:2965 msgid "\tpushd [-L|-P] [directory]\n" msgstr "\tpushd [-L|-P] [directory]\n" #: variable.c:3005 variable.c:3081 #, c-format msgid "`%ls' is not a valid index" msgstr "‘%ls’ is not a valid index" #: variable.c:3028 msgid "pop a directory from the directory stack" msgstr "pop a directory from the directory stack" #: variable.c:3031 msgid "\tpopd [index]\n" msgstr "\tpopd [index]\n" #: variable.c:3119 msgid "print the directory stack" msgstr "print the directory stack" #: variable.c:3122 msgid "\tdirs [-cv] [index...]\n" msgstr "\tdirs [-cv] [index...]\n" #: yash.c:111 #, c-format msgid "%s: cannot convert the argument `%s' into a wide character string" msgstr "" "%s: cannot convert the argument ‘%s’ into a wide character string" #: yash.c:115 #, c-format msgid "%s: the argument is replaced with an empty string\n" msgstr "%s: the argument is replaced with an empty string\n" #: yash.c:180 msgid "the -c option is specified but no command is given" msgstr "the -c option is specified but no command is given" #: yash.c:353 #, c-format msgid "" "Syntax:\n" "\t%s [option...] [filename [argument...]]\n" "\t%s [option...] -c command [command_name [argument...]]\n" "\t%s [option...] -s [argument...]\n" msgstr "" "Syntax:\n" "\t%s [option...] [filename [argument...]]\n" "\t%s [option...] -c command [command_name [argument...]]\n" "\t%s [option...] -s [argument...]\n" #: yash.c:370 #, c-format msgid "Yet another shell, version %s\n" msgstr "Yet another shell, version %s\n" #: yash.c:372 msgid "" "This is free software licensed under GNU GPL version 2.\n" "You can modify and redistribute it, but there is NO WARRANTY.\n" msgstr "" "This is free software licensed under GNU GPL version 2.\n" "You can modify and redistribute it, but there is NO WARRANTY.\n" #: yash.c:376 msgid "" "\n" "Enabled features:\n" msgstr "" "\n" "Enabled features:\n" #: yash.c:525 msgid "Use `exit' to leave the shell.\n" msgstr "Use ‘exit’ to leave the shell.\n" #: yash.c:602 msgid " Use `exit' again to exit anyway.\n" msgstr " Use ‘exit’ again to exit anyway.\n" #: yash.c:624 msgid "exit the shell" msgstr "exit the shell" #: yash.c:627 msgid "\texit [-f] [exit_status]\n" msgstr "\texit [-f] [exit_status]\n" #: yash.c:657 msgid "" "refusing to suspend because of a possible deadlock.\n" "Use the -f option to suspend anyway." msgstr "" "refusing to suspend because of a possible deadlock.\n" "Use the -f option to suspend anyway." #: yash.c:671 msgid "suspend the shell" msgstr "suspend the shell" #: yash.c:674 msgid "\tsuspend [-f]\n" msgstr "\tsuspend [-f]\n" yash-2.35/po/en@quot.hd0000644000175000017500000000226312154557026015117 0ustar magicantmagicant# All this catalog "translates" are quotation characters. # The msgids must be ASCII and therefore cannot contain real quotation # characters, only substitutes like grave accent (0x60), apostrophe (0x27) # and double quote (0x22). These substitutes look strange; see # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html # # This catalog translates grave accent (0x60) and apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019). # It also translates pairs of apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019) # and pairs of quotation mark (0x22) to # left double quotation mark (U+201C) and right double quotation mark (U+201D). # # When output to an UTF-8 terminal, the quotation characters appear perfectly. # When output to an ISO-8859-1 terminal, the single quotation marks are # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to # grave/acute accent (by libiconv), and the double quotation marks are # transliterated to 0x22. # When output to an ASCII terminal, the single quotation marks are # transliterated to apostrophes, and the double quotation marks are # transliterated to 0x22. # yash-2.35/po/insert-hd.sin0000644000175000017500000000124012154557026015571 0ustar magicantmagicant# Sed script that inserts the file called HEADER before the header entry. # # At each occurrence of a line starting with "msgid ", we execute the following # commands. At the first occurrence, insert the file. At the following # occurrences, do nothing. The distinction between the first and the following # occurrences is achieved by looking at the hold space. /^msgid /{ x # Test if the hold space is empty. s/m/m/ ta # Yes it was empty. First occurrence. Read the file. r HEADER # Output the file's contents by reading the next line. But don't lose the # current line while doing this. g N bb :a # The hold space was nonempty. Following occurrences. Do nothing. x :b } yash-2.35/po/en@quot.mo0000644000175000017500000007704312154557026015147 0ustar magicantmagicantÞ•\ü ÓÜ() FP§p 3&ZtK}ÙWw¬¿.Ù !" D `L ­ (» –ä {!C!Ô!Ií!7"F"a" }"‹"$¤"É"Yå"?#O#!^#€#Nˆ#×#Þ#%ð#;$R$k$‰$¡$¿$Ó$#ë$$%4%F%`%q%„%¡%»%"Ë%î%&+&/I&+y&4¥&Ú&,ê&'5'R'j'!‰'A«'2í' (‡=(Å( ß(ì(%ÿ(%)*)3)C) `) n)x)€)—)°)ŠÀ) K*!W*%y*vŸ*+3+S+2r+¥+¸+Ì+)ç+,&,>,O,!n,,®,Î,î,-)-&F-'m-•-±-Ï-)ë-".8.*U.€.4….:º.õ.( /!4/*V///±/$Ð/%õ/303O0ƒ0' 0È0%ç0 1*1+E1.q17 1"Ø1&û1!"2$D24i2.ž2&Í2ô2 3:13l30…3(¶3ß3û3/4>4T4t4#Œ4#°4#Ô4ø4 54)5^5"y5=œ5Ú5#÷56/6 D6,e6’6¢6º6Õ6í6 7 7727(L7+u7)¡7?Ë77 83C8(w8: 8#Û8!ÿ8!9A9 _9k9)z9$¤9É9&Ü9:(: D:)e: :š:)­::×:;.;M;`;@z;@»;.ü;++<W<+l< ˜<¹<$Ñ<ö<="=B=Y=r=‰==¦=¶=&Ñ=+ø=$>;>R>f>y>>¥>Ã>Ú>*ö>!?3?H?[? q??“?—? š?¥?¿?Ý?0ø?)@?@(O@x@@¦@¶@#Ì@ð@ A &AGA)NA xA#™A½A(ÐA ùABDB_B;oB"«B/ÎB/þB..C$]C'‚CXªC-D!1DSD2qD¤D ¿DàDûDE"1E*TEEœE+³E:ßEF.F@FDOF3”F$ÈF%íF3G2GG3zG1®GàGEýG#CHgH"„H*§H5ÒH-I6IKIgI(†I¯I!ÌI îI"J+2JY^J?¸JøJCK,TKK¡K²K ÃK ÑKÛKêK…L‹M ¨M²M§ÒM zN3ˆN¼NÖNKïN};O¹OÙOñOP!P.;PjP!„P¦P`®P Q(Q–FQÝQCòQ6RIOR™R¨RÃR ßRíR$S+SYGS¡S±S!ÀSâSNêS9T@T%RT;xT´TÍTëTU!U5U'MU$uUšU¬UÆU×UêUV!V&1VXVnV+‹V/·V+çV8WLW,\W‰W§WÄWÜW!ûWEX2cX–X‡³X;Y YYfY%yYŸY¤Y­Y½Y ÚY èYòYúYZ*ZŠ:Z ÅZ!ÑZ%óZv[ [#±[Õ[2ô['\:\N\-i\ —\*¡\Ì\"á\%]!*]#L]#p]#”]¸] ×]*ø]+#^O^!o^‘^-±^&ß^$_2+_^_<g_>¤_ã_(`%*`*P`/{`"«`(Î`)÷`7!a7Ya ‘a+²aÞa%ýa#b@b/[b2‹b;¾b"úb&c!Dc$fc4‹c.Àc&ïcd$6d>[dšd4³d(ède-e/@epe#Še®e#Æe'êe'f:fLf4kf f&»f=âf g'=gegyg$Žg4³gègøgh+hCh Yh ehphˆh0¢h3Óh1iO9iC‰i?Íi0 j>>j#}j!¡jÃjãj k k)k(Fkok&‚k©k(Ák$êk-l =lHl-[l>‰lÈlèlmm@4m@um2¶m/émn/2n bnƒn(›n#Änèn"ñno+oDo[oooxoˆo&£o+Êoöo p$pqUq kqyqq‘q ”qŸq½qÛq4úq/rEr(Ur~r“r¬r¼r#Òrörs ,sMs)Ts ~s#ŸsÃs(Ös ÿs tD tet;ut&±t/Øt/u.8u$gu+ŒuX¸u-v!?vav2v²v Ívîv w$w"?w*bwwªw+Áw>íw,x@xRxDax3¦x$Úx%ÿx3%y2Yy3Œy1ÀyòyEz#Uzyz"–z*¹z5äz-{H{]{y{(˜{Á{!Þ{ |"!|+D|]p|GÎ|}C.},r}Ÿ}¿}Ð} á} ï}ù}~GèаªE!ßÈ 15qPÃJ8Sæ úå8î5XBëÎ.D$g1¯OJ=Õ¹”Ù:á,¥XÄ&Š(·­M¶–&§âÁ‚H4`lØtyTÇÞiWH ÊPRÓ®2<jS‰Aó2•¡Œ¿ÉCíäañ×~ü çNÿWLRo7™*3Zê> û¤ºN?4I'"#_9;9ýwÀ>eŲ¬þ’-/Í»C fx=飄¢›-U˜%‡0h³Æ7;Úd'Mp!vŸLËFƒ3“YÛõ†.ïœV6{Â|÷ $TÏA€?%r+Ž Üö\ ½«¼@*¨:"ã©‘D<b[E,QøÒàì(sUðˆz)K ^ÖVBOI¾ùYš ´¸cG/ ž6[òÔ±µ]KÌô—F)¦u‹… \n0Ñ#Q+@Z}Ýkm . [-AL] file [argument...] : [...] alias [-gp] [name[=value]...] array # print arrays array name [value...] # set array values array -d name [index...] array -i name index [value...] array -s name index value bg [job...] bindkey -aev [key_sequence [command]] bindkey -l break [count] break -i cd [-L|-P] [directory] command [-befp] command [argument...] command -v|-V [-abefkp] command... complete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \ [-abcdfghjkuv] [[-O] [-D description] words...] continue [count] continue -i dirs [-cv] [index...] disown [job...] disown -a echo [string...] eval [-i] [argument...] exec [-cf] [-a name] [command [argument...]] exit [-f] [exit_status] export [-prX] [name[=value]...] false fc [-qr] [-e editor] [first [last]] fc -s [-q] [old=new] [first] fc -l [-nrv] [first [last]] fg [job...] getopts options variable [argument...] hash command... hash -r [command...] hash [-a] # print remembered paths hash -d user... hash -d -r [user...] hash -d # print remembered paths help [built-in...] history [-cF] [-d entry] [-s command] [-r file] [-w file] [count] jobs [-lnprs] [job...] kill [-signal|-s signal|-n number] process... kill -l [-v] [number...] popd [index] printf format [value...] pushd [-L|-P] [directory] pwd [-L|-P] read [-Ar] variable... readonly [-fpxX] [name[=value]...] return [-n] [exit_status] set [option...] [--] [new_positional_parameter...] set -o|+o # print current settings shift [count] suspend [-f] test expression [ expression ] times trap [action signal...] trap signal_number [signal...] trap -p [signal...] true type command... typeset [-fgprxX] [name[=value]...] ulimit -a [-H|-S] ulimit [-H|-S] [-efilnqrstuvx] [limit] umask mode umask [-S] unalias name... unalias -a unset [-fv] [name...] wait [job or process_id...] Enabled features: %5jd %-20s | %ls Use `exit' again to exit anyway. Use the -f option to exec anyway. $%ls is read-only$DIRSTACK is not an array$HOME is not set$OLDPWD is not set$OPTIND has an invalid value$PWD has an invalid value$PWD is not set%ls: `-%lc' is not a valid option %ls: a shell keyword %ls: an alias for `%ls' %ls: the -%lc option's argument is missing %ls: the --%ls option does not take an argument%ls: the operand value must not be negative%ls: the signal name must be specified without `SIG'%s: a function %s: a regular built-in (not found in $PATH) %s: a regular built-in at %s %s: a semi-special built-in %s: a special built-in %s: an external command at %s %s: an external command at %s/%s %s: cannot convert the argument `%s' into a wide character string%s: the argument is replaced with an empty string %u is not a positive integer%zu: cannot shift so many (there is only one positional parameter)%zu: cannot shift so many (there are only %zu positional parameters)(maybe you missed `%ls'?)-%lc: %-30s CPU time (seconds)Candidate %zu of %zu; Page %zu of %zuDoneDone(%d)Killed (SIG%ls)Killed (SIG%ls: core dumped)No candidatesOptions: RunningSIG%ls cannot be resetSIG%ls cannot be trappedStopped(SIG%ls)Syntax: %s [option...] [filename [argument...]] %s [option...] -c command [command_name [argument...]] %s [option...] -s [argument...] Syntax: %s The process was killed by SIG%ls The process was killed by SIG%ls: %s This is free software licensed under GNU GPL version 2. You can modify and redistribute it, but there is NO WARRANTY. Try `man yash' for details. Use `exit' to leave the shell. Yet another shell, version %s You have a stopped job!You have %zu stopped jobs!You have new mail.[%zu] %c %-20s %ls [%zu] %c %5jd %-20s %ls `%lc' is not a valid conversion specifier`%ls'`%ls' cannot be used as a command name`%ls' is missing`%ls' is not a binary operator`%ls' is not a job-controlled job`%ls' is not a unary operator`%ls' is not a valid alias name`%ls' is not a valid array name`%ls' is not a valid identifier`%ls' is not a valid index`%ls' is not a valid integer`%ls' is not a valid job specification`%ls' is not a valid mask specification`%ls' is not a valid number`%ls' is not a valid operator`%ls' is not a valid option`%ls' is not a valid option specification`%ls' is not a valid variable name`%ls' is used outside `case'`%ls': a command name must not contain `/'`%s'`(' must be followed by `)' in a function definition`;' is not allowed just after the identifier in a for loop`;' or `&' is missinga command is missing at the end of inputa command is missing before `%lc'a function body must be a compound commanda nested parameter expansion cannot be assigneda word is required after `%ls'an expression is missing after `%ls'an identifier is required after `for'an unquoted `esac' cannot be the first case patternarithmetic: `%lc' is not a valid number or operatorarithmetic: `%ls' is missingarithmetic: `%ls' is not a valid numberarithmetic: a value is missingarithmetic: cannot assign to a numberarithmetic: division by zeroarithmetic: invalid syntaxarithmetic: operator `%ls' is not supportedarithmetic: operator `%ls' requires a variablecannot assign to parameter `%ls' in parameter expansioncannot be used during line-editingcannot be used in the interactive modecannot bind an empty key sequencecannot copy file descriptor %d to %dcannot create a temporary file for the here-documentcannot create a temporary file to edit historycannot determine the current directorycannot execute command `%s'cannot execute command `%s' (%s)cannot get the current limit for the resource type of `%s'cannot get the time datacannot invoke a new shell to execute script `%s'cannot invoke the editor to edit historycannot make a child processcannot open a pipecannot open a pipe for the command substitutioncannot open file `%s'cannot open temporary file `%s'cannot parse the formatcannot print to the standard outputcannot read commands from file `%s'cannot read history from file `%ls'cannot read inputcannot save file descriptor %dcannot seek the temporary file for the here-documentcannot send SIGSTOP signalcannot write history to file `%ls'cannot write the here-document contents to the temporary filechange the working directorycommand `%s' was not found in $PATHcommand redirectioncommand substitutioncommands are missing after `%ls'commands are missing between `%ls' and `%ls'continue a loopcore file size (blocks)data segment size (kbytes)define or print aliasesdisabling job controldisown jobsdo nothingdo nothing successfullydo nothing unsuccessfullyencountered `%ls' without a matching `('encountered `%ls' without a matching `case'encountered `%ls' without a matching `do'encountered `%ls' without a matching `for', `while', or `until'encountered `%ls' without a matching `if' and/or `then'encountered `%ls' without a matching `if' or `elif'encountered `%ls' without a matching `{'encountered an invalid character `%lc' in the case patternerror in closing file descriptor %devaluate a conditional expressionevaluate arguments as a commandexecute or identify a commandexit a loopexit the shellexport variables as environment variablesfailed to remove temporary file `%s'failed to set $PWDfailed to set environment variable $%sfailed to set the limitfailed to unset environment variable $%sfile `%s' was not found in $PATHfile `%s' was not found in $YASH_LOADPATHfile locksfile size (blocks)filename `%ls' matches more than one filefunction `%ls' cannot be redefined because it is read-onlyfunction `%ls' is read-onlygenerate completion candidatesidentify a commandindex %ls is out of rangeindex %ls is out of range (the actual size of array $%ls is %zu)index %zu is out of range (the actual size of array $%ls is %zu)invalid character `%lc' in parameter expansioninvalid flag for conversion specifier `%lc'invalid use of `%lc'invalid use of `%lc' in parameter expansionjob %%%zu has already terminatedjob control is disabledjob specification `%ls' is ambiguouskey sequence `%ls' is not boundlineeditlist or re-execute command historylocked memory (kbytes)make variables read-onlymanage command historymanipulate an arraymax nicememory (kbytes)message queue size (bytes)more than one -%lc option is specifiedmore than one option cannot be used at onceno operand is expectedno option is specifiedno such alias `%ls'no such array $%lsno such built-in `%ls'no such command `%s'no such editing command `%ls'no such function `%ls'no such history entry `%ls'no such history entry beginning with `%ls'no such job `%ls'no such signal `%ls'no such user `%ls'no such variable $%lsnot in a loopnot in an iterationoffonopen filesoption `%ls' is ambiguousoption combination is invalidparameter `%ls' is not setparameter `%ls' is not set or has an empty valueparse command optionspending signalspop a directory from the directory stackprint CPU time usageprint a formatted stringprint argumentsprint info about jobsprint or set the file creation maskprint the directory stackprint the working directoryprint usage of built-in commandspromptpush a directory into the directory stackread a file and execute commandsread a line from the standard inputreal-time priorityreal-time signal SIG%ls is not supportedredirectionredirection: %d>>|%dredirection: %d>>|%d: the input and output file descriptors are sameredirection: %sredirection: cannot open a pipe for the command redirectionredirection: cannot open file `%s'redirection: file descriptor %d is not readableredirection: file descriptor %d is not writableredirection: file descriptor %d is unavailableredirection: invalid file descriptorredirections are not allowed after `in'refusing to suspend because of a possible deadlock. Use the -f option to suspend anyway.remember, forget, or report command locationsremove some positional parametersremove variables or functionsreplace the shell process with an external commandresident set size (kbytes)return from a function or scriptrun jobs in the backgroundrun jobs in the foregroundsend a signal to processesset or print a resource limitationset or print key bindings for line-editingset or print signal handlersset or print variablesset shell options and positional parameterssocket redirection: cannot resolve the address of `%s': %sstack size (kbytes)suspend the shellsyntax error: the %ls option cannot be changed once the shell has been initializedthe -%lc option cannot be used with the -%lc optionthe -%lc option requires an argumentthe --%ls option requires an argumentthe -a or -k option must be used with the -v optionthe -c option is specified but no command is giventhe -n or -v option must be used with the -l optionthe backquoted command substitution is not closedthe command history is emptythe complete built-in can be used during command line completion onlythe conversion specifier is missingthe directory stack is emptythe double quotation is not closedthe editor returned a non-zero exit statusthe end-of-here-document indicator contains a newlinethe end-of-here-document indicator is missingthe index is missingthe index is not an integerthe parameter index is invalidthe parameter name is missing or invalidthe parameter value is emptythe redirection target is missingthe signal name is not specifiedthe single quotation is not closedthe soft limit cannot exceed the hard limitthe specified index does not support assignment in the parameter expansion of array `%ls'the specified prefix `%ls' does not match the target word `%ls'there is no current jobthis command requires an operandthis command requires %zu operandstoo many files are opened for yash to handletoo many operands are specifiedundefine aliasesunexpected errorunknown errorunlimiteduser processeswait for jobs to terminateProject-Id-Version: yash 2.35 Report-Msgid-Bugs-To: http://sourceforge.jp/projects/yash/forums/ POT-Creation-Date: 2013-06-08 16:31+0900 PO-Revision-Date: 2013-06-08 16:31+0900 Last-Translator: Automatically generated Language-Team: none Language: en@quot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=2; plural=(n != 1); . [-AL] file [argument...] : [...] alias [-gp] [name[=value]...] array # print arrays array name [value...] # set array values array -d name [index...] array -i name index [value...] array -s name index value bg [job...] bindkey -aev [key_sequence [command]] bindkey -l break [count] break -i cd [-L|-P] [directory] command [-befp] command [argument...] command -v|-V [-abefkp] command... complete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \ [-abcdfghjkuv] [[-O] [-D description] words...] continue [count] continue -i dirs [-cv] [index...] disown [job...] disown -a echo [string...] eval [-i] [argument...] exec [-cf] [-a name] [command [argument...]] exit [-f] [exit_status] export [-prX] [name[=value]...] false fc [-qr] [-e editor] [first [last]] fc -s [-q] [old=new] [first] fc -l [-nrv] [first [last]] fg [job...] getopts options variable [argument...] hash command... hash -r [command...] hash [-a] # print remembered paths hash -d user... hash -d -r [user...] hash -d # print remembered paths help [built-in...] history [-cF] [-d entry] [-s command] [-r file] [-w file] [count] jobs [-lnprs] [job...] kill [-signal|-s signal|-n number] process... kill -l [-v] [number...] popd [index] printf format [value...] pushd [-L|-P] [directory] pwd [-L|-P] read [-Ar] variable... readonly [-fpxX] [name[=value]...] return [-n] [exit_status] set [option...] [--] [new_positional_parameter...] set -o|+o # print current settings shift [count] suspend [-f] test expression [ expression ] times trap [action signal...] trap signal_number [signal...] trap -p [signal...] true type command... typeset [-fgprxX] [name[=value]...] ulimit -a [-H|-S] ulimit [-H|-S] [-efilnqrstuvx] [limit] umask mode umask [-S] unalias name... unalias -a unset [-fv] [name...] wait [job or process_id...] Enabled features: %5jd %-20s | %ls Use ‘exit’ again to exit anyway. Use the -f option to exec anyway. $%ls is read-only$DIRSTACK is not an array$HOME is not set$OLDPWD is not set$OPTIND has an invalid value$PWD has an invalid value$PWD is not set%ls: ‘-%lc’ is not a valid option %ls: a shell keyword %ls: an alias for ‘%ls’ %ls: the -%lc option's argument is missing %ls: the --%ls option does not take an argument%ls: the operand value must not be negative%ls: the signal name must be specified without ‘SIG’%s: a function %s: a regular built-in (not found in $PATH) %s: a regular built-in at %s %s: a semi-special built-in %s: a special built-in %s: an external command at %s %s: an external command at %s/%s %s: cannot convert the argument ‘%s’ into a wide character string%s: the argument is replaced with an empty string %u is not a positive integer%zu: cannot shift so many (there is only one positional parameter)%zu: cannot shift so many (there are only %zu positional parameters)(maybe you missed ‘%ls’?)-%lc: %-30s CPU time (seconds)Candidate %zu of %zu; Page %zu of %zuDoneDone(%d)Killed (SIG%ls)Killed (SIG%ls: core dumped)No candidatesOptions: RunningSIG%ls cannot be resetSIG%ls cannot be trappedStopped(SIG%ls)Syntax: %s [option...] [filename [argument...]] %s [option...] -c command [command_name [argument...]] %s [option...] -s [argument...] Syntax: %s The process was killed by SIG%ls The process was killed by SIG%ls: %s This is free software licensed under GNU GPL version 2. You can modify and redistribute it, but there is NO WARRANTY. Try ‘man yash’ for details. Use ‘exit’ to leave the shell. Yet another shell, version %s You have a stopped job!You have %zu stopped jobs!You have new mail.[%zu] %c %-20s %ls [%zu] %c %5jd %-20s %ls ‘%lc’ is not a valid conversion specifier‘%ls’‘%ls’ cannot be used as a command name‘%ls’ is missing‘%ls’ is not a binary operator‘%ls’ is not a job-controlled job‘%ls’ is not a unary operator‘%ls’ is not a valid alias name‘%ls’ is not a valid array name‘%ls’ is not a valid identifier‘%ls’ is not a valid index‘%ls’ is not a valid integer‘%ls’ is not a valid job specification‘%ls’ is not a valid mask specification‘%ls’ is not a valid number‘%ls’ is not a valid operator‘%ls’ is not a valid option‘%ls’ is not a valid option specification‘%ls’ is not a valid variable name‘%ls’ is used outside ‘case’‘%ls’: a command name must not contain ‘/’‘%s’‘(’ must be followed by ‘)’ in a function definition‘;’ is not allowed just after the identifier in a for loop‘;’ or ‘&’ is missinga command is missing at the end of inputa command is missing before ‘%lc’a function body must be a compound commanda nested parameter expansion cannot be assigneda word is required after ‘%ls’an expression is missing after ‘%ls’an identifier is required after ‘for’an unquoted ‘esac’ cannot be the first case patternarithmetic: ‘%lc’ is not a valid number or operatorarithmetic: ‘%ls’ is missingarithmetic: ‘%ls’ is not a valid numberarithmetic: a value is missingarithmetic: cannot assign to a numberarithmetic: division by zeroarithmetic: invalid syntaxarithmetic: operator ‘%ls’ is not supportedarithmetic: operator ‘%ls’ requires a variablecannot assign to parameter ‘%ls’ in parameter expansioncannot be used during line-editingcannot be used in the interactive modecannot bind an empty key sequencecannot copy file descriptor %d to %dcannot create a temporary file for the here-documentcannot create a temporary file to edit historycannot determine the current directorycannot execute command ‘%s’cannot execute command ‘%s’ (%s)cannot get the current limit for the resource type of ‘%s’cannot get the time datacannot invoke a new shell to execute script ‘%s’cannot invoke the editor to edit historycannot make a child processcannot open a pipecannot open a pipe for the command substitutioncannot open file ‘%s’cannot open temporary file ‘%s’cannot parse the formatcannot print to the standard outputcannot read commands from file ‘%s’cannot read history from file ‘%ls’cannot read inputcannot save file descriptor %dcannot seek the temporary file for the here-documentcannot send SIGSTOP signalcannot write history to file ‘%ls’cannot write the here-document contents to the temporary filechange the working directorycommand ‘%s’ was not found in $PATHcommand redirectioncommand substitutioncommands are missing after ‘%ls’commands are missing between ‘%ls’ and ‘%ls’continue a loopcore file size (blocks)data segment size (kbytes)define or print aliasesdisabling job controldisown jobsdo nothingdo nothing successfullydo nothing unsuccessfullyencountered ‘%ls’ without a matching ‘(’encountered ‘%ls’ without a matching ‘case’encountered ‘%ls’ without a matching ‘do’encountered ‘%ls’ without a matching ‘for’, ‘while’, or ‘until’encountered ‘%ls’ without a matching ‘if’ and/or ‘then’encountered ‘%ls’ without a matching ‘if’ or ‘elif’encountered ‘%ls’ without a matching ‘{’encountered an invalid character ‘%lc’ in the case patternerror in closing file descriptor %devaluate a conditional expressionevaluate arguments as a commandexecute or identify a commandexit a loopexit the shellexport variables as environment variablesfailed to remove temporary file ‘%s’failed to set $PWDfailed to set environment variable $%sfailed to set the limitfailed to unset environment variable $%sfile ‘%s’ was not found in $PATHfile ‘%s’ was not found in $YASH_LOADPATHfile locksfile size (blocks)filename ‘%ls’ matches more than one filefunction ‘%ls’ cannot be redefined because it is read-onlyfunction ‘%ls’ is read-onlygenerate completion candidatesidentify a commandindex %ls is out of rangeindex %ls is out of range (the actual size of array $%ls is %zu)index %zu is out of range (the actual size of array $%ls is %zu)invalid character ‘%lc’ in parameter expansioninvalid flag for conversion specifier ‘%lc’invalid use of ‘%lc’invalid use of ‘%lc’ in parameter expansionjob %%%zu has already terminatedjob control is disabledjob specification ‘%ls’ is ambiguouskey sequence ‘%ls’ is not boundlineeditlist or re-execute command historylocked memory (kbytes)make variables read-onlymanage command historymanipulate an arraymax nicememory (kbytes)message queue size (bytes)more than one -%lc option is specifiedmore than one option cannot be used at onceno operand is expectedno option is specifiedno such alias ‘%ls’no such array $%lsno such built-in ‘%ls’no such command ‘%s’no such editing command ‘%ls’no such function ‘%ls’no such history entry ‘%ls’no such history entry beginning with ‘%ls’no such job ‘%ls’no such signal ‘%ls’no such user ‘%ls’no such variable $%lsnot in a loopnot in an iterationoffonopen filesoption ‘%ls’ is ambiguousoption combination is invalidparameter ‘%ls’ is not setparameter ‘%ls’ is not set or has an empty valueparse command optionspending signalspop a directory from the directory stackprint CPU time usageprint a formatted stringprint argumentsprint info about jobsprint or set the file creation maskprint the directory stackprint the working directoryprint usage of built-in commandspromptpush a directory into the directory stackread a file and execute commandsread a line from the standard inputreal-time priorityreal-time signal SIG%ls is not supportedredirectionredirection: %d>>|%dredirection: %d>>|%d: the input and output file descriptors are sameredirection: %sredirection: cannot open a pipe for the command redirectionredirection: cannot open file ‘%s’redirection: file descriptor %d is not readableredirection: file descriptor %d is not writableredirection: file descriptor %d is unavailableredirection: invalid file descriptorredirections are not allowed after ‘in’refusing to suspend because of a possible deadlock. Use the -f option to suspend anyway.remember, forget, or report command locationsremove some positional parametersremove variables or functionsreplace the shell process with an external commandresident set size (kbytes)return from a function or scriptrun jobs in the backgroundrun jobs in the foregroundsend a signal to processesset or print a resource limitationset or print key bindings for line-editingset or print signal handlersset or print variablesset shell options and positional parameterssocket redirection: cannot resolve the address of ‘%s’: %sstack size (kbytes)suspend the shellsyntax error: the %ls option cannot be changed once the shell has been initializedthe -%lc option cannot be used with the -%lc optionthe -%lc option requires an argumentthe --%ls option requires an argumentthe -a or -k option must be used with the -v optionthe -c option is specified but no command is giventhe -n or -v option must be used with the -l optionthe backquoted command substitution is not closedthe command history is emptythe complete built-in can be used during command line completion onlythe conversion specifier is missingthe directory stack is emptythe double quotation is not closedthe editor returned a non-zero exit statusthe end-of-here-document indicator contains a newlinethe end-of-here-document indicator is missingthe index is missingthe index is not an integerthe parameter index is invalidthe parameter name is missing or invalidthe parameter value is emptythe redirection target is missingthe signal name is not specifiedthe single quotation is not closedthe soft limit cannot exceed the hard limitthe specified index does not support assignment in the parameter expansion of array ‘%ls’the specified prefix ‘%ls’ does not match the target word ‘%ls’there is no current jobthis command requires an operandthis command requires %zu operandstoo many files are opened for yash to handletoo many operands are specifiedundefine aliasesunexpected errorunknown errorunlimiteduser processeswait for jobs to terminateyash-2.35/po/stamp-po0000644000175000017500000000000012154557026014635 0ustar magicantmagicantyash-2.35/po/en@quot.ih0000644000175000017500000000006512154557026015122 0ustar magicantmagicant/^msgid /{ x s/m/m/ ta r en@quot.hd g N bb :a x :b } yash-2.35/po/en@quot.po0000644000175000017500000012554112154557026015147 0ustar magicantmagicant# English translations for yash package. # Copyright (C) 2013 Magicant # This file is distributed under the same license as the yash package. # Automatically generated, 2013. # # All this catalog "translates" are quotation characters. # The msgids must be ASCII and therefore cannot contain real quotation # characters, only substitutes like grave accent (0x60), apostrophe (0x27) # and double quote (0x22). These substitutes look strange; see # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html # # This catalog translates grave accent (0x60) and apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019). # It also translates pairs of apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019) # and pairs of quotation mark (0x22) to # left double quotation mark (U+201C) and right double quotation mark (U+201D). # # When output to an UTF-8 terminal, the quotation characters appear perfectly. # When output to an ISO-8859-1 terminal, the single quotation marks are # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to # grave/acute accent (by libiconv), and the double quotation marks are # transliterated to 0x22. # When output to an ASCII terminal, the single quotation marks are # transliterated to apostrophes, and the double quotation marks are # transliterated to 0x22. # msgid "" msgstr "" "Project-Id-Version: yash 2.35\n" "Report-Msgid-Bugs-To: http://sourceforge.jp/projects/yash/forums/\n" "POT-Creation-Date: 2013-06-08 16:31+0900\n" "PO-Revision-Date: 2013-06-08 16:31+0900\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: en@quot\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: alias.c:396 #, c-format msgid "%ls: an alias for `%ls'\n" msgstr "%ls: an alias for ‘%ls’\n" #: alias.c:493 alias.c:544 #, c-format msgid "no such alias `%ls'" msgstr "no such alias ‘%ls’" #: alias.c:496 #, c-format msgid "`%ls' is not a valid alias name" msgstr "‘%ls’ is not a valid alias name" #: alias.c:505 msgid "define or print aliases" msgstr "define or print aliases" #: alias.c:508 msgid "\talias [-gp] [name[=value]...]\n" msgstr "\talias [-gp] [name[=value]...]\n" #: alias.c:552 msgid "undefine aliases" msgstr "undefine aliases" #: alias.c:555 msgid "" "\tunalias name...\n" "\tunalias -a\n" msgstr "" "\tunalias name...\n" "\tunalias -a\n" #: arith.c:175 arith.c:217 msgid "arithmetic: invalid syntax" msgstr "arithmetic: invalid syntax" #: arith.c:212 msgid "the index is not an integer" msgstr "the index is not an integer" #. TRANSLATORS: This error message is shown when the target #. * of an assignment is not a variable. #: arith.c:280 msgid "arithmetic: cannot assign to a number" msgstr "arithmetic: cannot assign to a number" #: arith.c:446 arith.c:964 #, c-format msgid "arithmetic: `%ls' is missing" msgstr "arithmetic: ‘%ls’ is missing" #: arith.c:780 arith.c:791 msgid "arithmetic: division by zero" msgstr "arithmetic: division by zero" #: arith.c:827 arith.c:903 #, c-format msgid "arithmetic: operator `%ls' is not supported" msgstr "arithmetic: operator ‘%ls’ is not supported" #. TRANSLATORS: This error message is shown when the operand of #. * the "++" or "--" operator is not a variable. #: arith.c:840 arith.c:917 #, c-format msgid "arithmetic: operator `%ls' requires a variable" msgstr "arithmetic: operator ‘%ls’ requires a variable" #: arith.c:979 msgid "arithmetic: a value is missing" msgstr "arithmetic: a value is missing" #: arith.c:1016 arith.c:1060 #, c-format msgid "arithmetic: `%ls' is not a valid number" msgstr "arithmetic: ‘%ls’ is not a valid number" #: arith.c:1330 #, c-format msgid "arithmetic: `%lc' is not a valid number or operator" msgstr "arithmetic: ‘%lc’ is not a valid number or operator" #: builtin.c:251 #, c-format msgid "the -%lc option cannot be used with the -%lc option" msgstr "the -%lc option cannot be used with the -%lc option" #: builtin.c:277 #, c-format msgid "this command requires an operand" msgid_plural "this command requires %zu operands" msgstr[0] "this command requires an operand" msgstr[1] "this command requires %zu operands" #. TRANSLATORS: This message is printed when a command that takes no #. * operand was invoked with some operands. #: builtin.c:290 msgid "no operand is expected" msgstr "no operand is expected" #. TRANSLATORS: This message is printed when a command was invoked with #. * the wrong number of operands. #: builtin.c:294 msgid "too many operands are specified" msgstr "too many operands are specified" #: builtin.c:346 yash.c:363 msgid "Try `man yash' for details.\n" msgstr "Try ‘man yash’ for details.\n" #: builtin.c:361 #, c-format msgid "no such built-in `%ls'" msgstr "no such built-in ‘%ls’" #. TRANSLATORS: This is printed before syntax info of a built-in. #: builtin.c:369 #, c-format msgid "" "Syntax:\n" "%s\n" msgstr "" "Syntax:\n" "%s\n" #. TRANSLATORS: This text is printed before a list of options. #: builtin.c:388 builtin.c:408 msgid "Options:\n" msgstr "Options:\n" #: builtin.c:547 msgid "do nothing" msgstr "do nothing" #: builtin.c:550 msgid "\t: [...]\n" msgstr "\t: [...]\n" #: builtin.c:554 msgid "do nothing successfully" msgstr "do nothing successfully" #: builtin.c:557 msgid "\ttrue\n" msgstr "\ttrue\n" #: builtin.c:561 msgid "do nothing unsuccessfully" msgstr "do nothing unsuccessfully" #: builtin.c:564 msgid "\tfalse\n" msgstr "\tfalse\n" #: builtin.c:589 msgid "print usage of built-in commands" msgstr "print usage of built-in commands" #: builtin.c:592 msgid "\thelp [built-in...]\n" msgstr "\thelp [built-in...]\n" #: builtins/printf.c:206 builtins/printf.c:332 history.c:1458 job.c:1062 #: path.c:1370 util.c:301 msgid "cannot print to the standard output" msgstr "cannot print to the standard output" #: builtins/printf.c:267 msgid "print arguments" msgstr "print arguments" #: builtins/printf.c:270 msgid "\techo [string...]\n" msgstr "\techo [string...]\n" #: builtins/printf.c:411 msgid "cannot parse the format" msgstr "cannot parse the format" #: builtins/printf.c:520 msgid "the conversion specifier is missing" msgstr "the conversion specifier is missing" #: builtins/printf.c:524 #, c-format msgid "`%lc' is not a valid conversion specifier" msgstr "‘%lc’ is not a valid conversion specifier" #: builtins/printf.c:529 #, c-format msgid "invalid flag for conversion specifier `%lc'" msgstr "invalid flag for conversion specifier ‘%lc’" #: builtins/printf.c:659 #, c-format msgid "`%ls' is not a valid number" msgstr "‘%ls’ is not a valid number" #: builtins/printf.c:693 builtins/test.c:556 builtins/test.c:562 #: builtins/ulimit.c:229 exec.c:1684 exec.c:1757 history.c:1714 sig.c:1333 #: variable.c:2063 variable.c:2123 variable.c:2162 variable.c:2334 yash.c:611 #, c-format msgid "`%ls' is not a valid integer" msgstr "‘%ls’ is not a valid integer" #: builtins/printf.c:758 msgid "print a formatted string" msgstr "print a formatted string" #: builtins/printf.c:761 msgid "\tprintf format [value...]\n" msgstr "\tprintf format [value...]\n" #: builtins/test.c:82 builtins/test.c:425 parser.c:1256 parser.c:1704 #: parser.c:1784 parser.c:1812 parser.c:2199 parser.c:2271 parser.c:2358 #: parser.c:2730 #, c-format msgid "`%ls' is missing" msgstr "‘%ls’ is missing" #: builtins/test.c:113 #, c-format msgid "`%ls' is not a valid operator" msgstr "‘%ls’ is not a valid operator" #: builtins/test.c:138 #, c-format msgid "`%ls' is not a unary operator" msgstr "‘%ls’ is not a unary operator" #: builtins/test.c:159 builtins/test.c:627 builtins/test.c:635 exec.c:1893 #: exec.c:2027 exec.c:2036 history.c:1492 lineedit/keymap.c:476 path.c:1175 #: path.c:1247 strbuf.c:545 strbuf.c:568 msgid "unexpected error" msgstr "unexpected error" #: builtins/test.c:364 #, c-format msgid "`%ls' is not a binary operator" msgstr "‘%ls’ is not a binary operator" #: builtins/test.c:416 #, c-format msgid "an expression is missing after `%ls'" msgstr "an expression is missing after ‘%ls’" #: builtins/test.c:682 msgid "evaluate a conditional expression" msgstr "evaluate a conditional expression" #: builtins/test.c:685 msgid "" "\ttest expression\n" "\t[ expression ]\n" msgstr "" "\ttest expression\n" "\t[ expression ]\n" #: builtins/ulimit.c:65 msgid "file size (blocks)" msgstr "file size (blocks)" #: builtins/ulimit.c:73 msgid "core file size (blocks)" msgstr "core file size (blocks)" #: builtins/ulimit.c:75 msgid "data segment size (kbytes)" msgstr "data segment size (kbytes)" #: builtins/ulimit.c:78 msgid "max nice" msgstr "max nice" #: builtins/ulimit.c:83 msgid "pending signals" msgstr "pending signals" #: builtins/ulimit.c:87 msgid "locked memory (kbytes)" msgstr "locked memory (kbytes)" #: builtins/ulimit.c:91 msgid "resident set size (kbytes)" msgstr "resident set size (kbytes)" #: builtins/ulimit.c:94 msgid "open files" msgstr "open files" #: builtins/ulimit.c:97 msgid "message queue size (bytes)" msgstr "message queue size (bytes)" #: builtins/ulimit.c:101 msgid "real-time priority" msgstr "real-time priority" #: builtins/ulimit.c:104 msgid "stack size (kbytes)" msgstr "stack size (kbytes)" #: builtins/ulimit.c:106 msgid "CPU time (seconds)" msgstr "CPU time (seconds)" #: builtins/ulimit.c:109 msgid "user processes" msgstr "user processes" #: builtins/ulimit.c:113 msgid "memory (kbytes)" msgstr "memory (kbytes)" #: builtins/ulimit.c:117 msgid "file locks" msgstr "file locks" #: builtins/ulimit.c:170 builtins/ulimit.c:245 #, c-format msgid "cannot get the current limit for the resource type of `%s'" msgstr "cannot get the current limit for the resource type of ‘%s’" #: builtins/ulimit.c:217 msgid "the soft limit cannot exceed the hard limit" msgstr "the soft limit cannot exceed the hard limit" #: builtins/ulimit.c:222 msgid "failed to set the limit" msgstr "failed to set the limit" #: builtins/ulimit.c:251 #, c-format msgid "-%lc: %-30s " msgstr "-%lc: %-30s " #: builtins/ulimit.c:263 msgid "unlimited" msgstr "unlimited" #: builtins/ulimit.c:270 msgid "set or print a resource limitation" msgstr "set or print a resource limitation" #: builtins/ulimit.c:273 msgid "" "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [limit]\n" msgstr "" "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [limit]\n" #: exec.c:736 msgid "cannot open a pipe" msgstr "cannot open a pipe" #: exec.c:960 msgid "cannot make a child process" msgstr "cannot make a child process" #: exec.c:1185 exec.c:2051 exec.c:2282 #, c-format msgid "no such command `%s'" msgstr "no such command ‘%s’" #: exec.c:1239 #, c-format msgid "cannot execute command `%s'" msgstr "cannot execute command ‘%s’" #: exec.c:1240 #, c-format msgid "cannot execute command `%s' (%s)" msgstr "cannot execute command ‘%s’ (%s)" #: exec.c:1340 #, c-format msgid "cannot invoke a new shell to execute script `%s'" msgstr "cannot invoke a new shell to execute script ‘%s’" #: exec.c:1396 exec.c:1418 msgid "cannot open a pipe for the command substitution" msgstr "cannot open a pipe for the command substitution" #: exec.c:1455 msgid "command substitution" msgstr "command substitution" #: exec.c:1694 msgid "cannot be used in the interactive mode" msgstr "cannot be used in the interactive mode" #: exec.c:1704 msgid "return from a function or script" msgstr "return from a function or script" #: exec.c:1707 msgid "\treturn [-n] [exit_status]\n" msgstr "\treturn [-n] [exit_status]\n" #: exec.c:1739 msgid "not in an iteration" msgstr "not in an iteration" #: exec.c:1760 #, c-format msgid "%u is not a positive integer" msgstr "%u is not a positive integer" #: exec.c:1770 msgid "not in a loop" msgstr "not in a loop" #: exec.c:1789 msgid "exit a loop" msgstr "exit a loop" #: exec.c:1792 msgid "" "\tbreak [count]\n" "\tbreak -i\n" msgstr "" "\tbreak [count]\n" "\tbreak -i\n" #: exec.c:1797 msgid "continue a loop" msgstr "continue a loop" #: exec.c:1800 msgid "" "\tcontinue [count]\n" "\tcontinue -i\n" msgstr "" "\tcontinue [count]\n" "\tcontinue -i\n" #: exec.c:1840 msgid "evaluate arguments as a command" msgstr "evaluate arguments as a command" #: exec.c:1843 msgid "\teval [-i] [argument...]\n" msgstr "\teval [-i] [argument...]\n" #: exec.c:1902 #, c-format msgid "file `%s' was not found in $YASH_LOADPATH" msgstr "file ‘%s’ was not found in $YASH_LOADPATH" #: exec.c:1912 #, c-format msgid "file `%s' was not found in $PATH" msgstr "file ‘%s’ was not found in $PATH" #: exec.c:1929 redir.c:279 yash.c:207 #, c-format msgid "cannot open file `%s'" msgstr "cannot open file ‘%s’" #: exec.c:1953 msgid "read a file and execute commands" msgstr "read a file and execute commands" #: exec.c:1956 msgid "\t. [-AL] file [argument...]\n" msgstr "\t. [-AL] file [argument...]\n" #: exec.c:2004 yash.c:598 #, c-format msgid "You have a stopped job!" msgid_plural "You have %zu stopped jobs!" msgstr[0] "You have a stopped job!" msgstr[1] "You have %zu stopped jobs!" #: exec.c:2008 msgid " Use the -f option to exec anyway.\n" msgstr " Use the -f option to exec anyway.\n" #: exec.c:2098 msgid "replace the shell process with an external command" msgstr "replace the shell process with an external command" #: exec.c:2101 msgid "\texec [-cf] [-a name] [command [argument...]]\n" msgstr "\texec [-cf] [-a name] [command [argument...]]\n" #: exec.c:2161 msgid "the -a or -k option must be used with the -v option" msgstr "the -a or -k option must be used with the -v option" #: exec.c:2255 #, c-format msgid "%ls: a shell keyword\n" msgstr "%ls: a shell keyword\n" #: exec.c:2288 #, c-format msgid "%s: a special built-in\n" msgstr "%s: a special built-in\n" #: exec.c:2292 #, c-format msgid "%s: a semi-special built-in\n" msgstr "%s: a semi-special built-in\n" #: exec.c:2304 #, c-format msgid "%s: a regular built-in (not found in $PATH)\n" msgstr "%s: a regular built-in (not found in $PATH)\n" #: exec.c:2305 #, c-format msgid "%s: a regular built-in at %s\n" msgstr "%s: a regular built-in at %s\n" #: exec.c:2312 #, c-format msgid "%s: a function\n" msgstr "%s: a function\n" #: exec.c:2328 #, c-format msgid "%s: an external command at %s\n" msgstr "%s: an external command at %s\n" #: exec.c:2350 #, c-format msgid "%s: an external command at %s/%s\n" msgstr "%s: an external command at %s/%s\n" #: exec.c:2359 msgid "execute or identify a command" msgstr "execute or identify a command" #: exec.c:2362 msgid "" "\tcommand [-befp] command [argument...]\n" "\tcommand -v|-V [-abefkp] command...\n" msgstr "" "\tcommand [-befp] command [argument...]\n" "\tcommand -v|-V [-abefkp] command...\n" #: exec.c:2367 msgid "identify a command" msgstr "identify a command" #: exec.c:2370 msgid "\ttype command...\n" msgstr "\ttype command...\n" #: exec.c:2408 msgid "cannot get the time data" msgstr "cannot get the time data" #: exec.c:2424 msgid "print CPU time usage" msgstr "print CPU time usage" #: exec.c:2427 msgid "\ttimes\n" msgstr "\ttimes\n" #: expand.c:288 expand.c:294 expand.c:312 redir.c:455 msgid "redirection" msgstr "redirection" #: expand.c:302 #, c-format msgid "filename `%ls' matches more than one file" msgstr "filename ‘%ls’ matches more than one file" #: expand.c:630 msgid "the parameter index is invalid" msgstr "the parameter index is invalid" #: expand.c:784 msgid "a nested parameter expansion cannot be assigned" msgstr "a nested parameter expansion cannot be assigned" #: expand.c:787 #, c-format msgid "cannot assign to parameter `%ls' in parameter expansion" msgstr "cannot assign to parameter ‘%ls’ in parameter expansion" #: expand.c:793 #, c-format msgid "" "the specified index does not support assignment in the parameter expansion " "of array `%ls'" msgstr "" "the specified index does not support assignment in the parameter expansion " "of array ‘%ls’" #: expand.c:833 expand.c:1052 #, c-format msgid "parameter `%ls' is not set" msgstr "parameter ‘%ls’ is not set" #: expand.c:1048 msgid "the parameter value is empty" msgstr "the parameter value is empty" #: expand.c:1051 #, c-format msgid "parameter `%ls' is not set or has an empty value" msgstr "parameter ‘%ls’ is not set or has an empty value" #: history.c:1262 msgid "the -n or -v option must be used with the -l option" msgstr "the -n or -v option must be used with the -l option" #: history.c:1268 history.c:1659 msgid "cannot be used during line-editing" msgstr "cannot be used during line-editing" #: history.c:1284 msgid "the command history is empty" msgstr "the command history is empty" #: history.c:1319 history.c:1774 #, c-format msgid "no such history entry `%ls'" msgstr "no such history entry ‘%ls’" #: history.c:1421 #, c-format msgid "no such history entry beginning with `%ls'" msgstr "no such history entry beginning with ‘%ls’" #: history.c:1529 lineedit/editing.c:2671 msgid "cannot create a temporary file to edit history" msgstr "cannot create a temporary file to edit history" #: history.c:1534 lineedit/editing.c:2676 #, c-format msgid "cannot open temporary file `%s'" msgstr "cannot open temporary file ‘%s’" #: history.c:1542 lineedit/editing.c:2684 msgid "cannot invoke the editor to edit history" msgstr "cannot invoke the editor to edit history" #: history.c:1545 history.c:1571 lineedit/editing.c:2687 redir.c:793 #, c-format msgid "failed to remove temporary file `%s'" msgstr "failed to remove temporary file ‘%s’" #: history.c:1563 msgid "the editor returned a non-zero exit status" msgstr "the editor returned a non-zero exit status" #: history.c:1568 #, c-format msgid "cannot read commands from file `%s'" msgstr "cannot read commands from file ‘%s’" #: history.c:1626 msgid "list or re-execute command history" msgstr "list or re-execute command history" #: history.c:1629 msgid "" "\tfc [-qr] [-e editor] [first [last]]\n" "\tfc -s [-q] [old=new] [first]\n" "\tfc -l [-nrv] [first [last]]\n" msgstr "" "\tfc [-qr] [-e editor] [first [last]]\n" "\tfc -s [-q] [old=new] [first]\n" "\tfc -l [-nrv] [first [last]]\n" #: history.c:1820 #, c-format msgid "cannot read history from file `%ls'" msgstr "cannot read history from file ‘%ls’" #: history.c:1854 #, c-format msgid "cannot write history to file `%ls'" msgstr "cannot write history to file ‘%ls’" #: history.c:1875 msgid "manage command history" msgstr "manage command history" #: history.c:1878 msgid "\thistory [-cF] [-d entry] [-s command] [-r file] [-w file] [count]\n" msgstr "\thistory [-cF] [-d entry] [-s command] [-r file] [-w file] [count]\n" #: input.c:153 lineedit/lineedit.c:218 msgid "cannot read input" msgstr "cannot read input" #: input.c:254 input.c:272 input.c:281 msgid "prompt" msgstr "prompt" #: job.c:518 job.c:1014 job.c:1120 job.c:1273 job.c:1383 #, c-format msgid "job specification `%ls' is ambiguous" msgstr "job specification ‘%ls’ is ambiguous" #: job.c:523 job.c:1017 job.c:1125 job.c:1386 #, c-format msgid "no such job `%ls'" msgstr "no such job ‘%ls’" #: job.c:526 job.c:1127 #, c-format msgid "`%ls' is not a job-controlled job" msgstr "‘%ls’ is not a job-controlled job" #: job.c:656 job.c:699 msgid "Running" msgstr "Running" #: job.c:659 #, c-format msgid "Stopped(SIG%ls)" msgstr "Stopped(SIG%ls)" #: job.c:670 msgid "Done" msgstr "Done" #: job.c:673 #, c-format msgid "Done(%d)" msgstr "Done(%d)" #: job.c:681 #, c-format msgid "Killed (SIG%ls: core dumped)" msgstr "Killed (SIG%ls: core dumped)" #: job.c:684 #, c-format msgid "Killed (SIG%ls)" msgstr "Killed (SIG%ls)" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:744 #, c-format msgid "[%zu] %c %-20s %ls\n" msgstr "[%zu] %c %-20s %ls\n" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:763 #, c-format msgid "[%zu] %c %5jd %-20s %ls\n" msgstr "[%zu] %c %5jd %-20s %ls\n" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:777 #, c-format msgid " %5jd %-20s | %ls\n" msgstr " %5jd %-20s | %ls\n" #: job.c:827 #, c-format msgid "The process was killed by SIG%ls: %s\n" msgstr "The process was killed by SIG%ls: %s\n" #: job.c:830 #, c-format msgid "The process was killed by SIG%ls\n" msgstr "The process was killed by SIG%ls\n" #: job.c:1007 job.c:1113 job.c:1266 job.c:1377 #, c-format msgid "`%ls' is not a valid job specification" msgstr "‘%ls’ is not a valid job specification" #: job.c:1071 msgid "print info about jobs" msgstr "print info about jobs" #: job.c:1074 msgid "\tjobs [-lnprs] [job...]\n" msgstr "\tjobs [-lnprs] [job...]\n" #: job.c:1100 msgid "job control is disabled" msgstr "job control is disabled" #: job.c:1136 job.c:1393 msgid "there is no current job" msgstr "there is no current job" #: job.c:1175 #, c-format msgid "job %%%zu has already terminated" msgstr "job %%%zu has already terminated" #: job.c:1221 msgid "run jobs in the foreground" msgstr "run jobs in the foreground" #: job.c:1224 msgid "\tfg [job...]\n" msgstr "\tfg [job...]\n" #: job.c:1228 msgid "run jobs in the background" msgstr "run jobs in the background" #: job.c:1231 msgid "\tbg [job...]\n" msgstr "\tbg [job...]\n" #: job.c:1340 msgid "wait for jobs to terminate" msgstr "wait for jobs to terminate" #: job.c:1343 msgid "\twait [job or process_id...]\n" msgstr "\twait [job or process_id...]\n" #: job.c:1403 msgid "disown jobs" msgstr "disown jobs" #: job.c:1406 msgid "" "\tdisown [job...]\n" "\tdisown -a\n" msgstr "" "\tdisown [job...]\n" "\tdisown -a\n" #: lineedit/complete.c:1514 #, c-format msgid "more than one -%lc option is specified" msgstr "more than one -%lc option is specified" #: lineedit/complete.c:1526 msgid "the complete built-in can be used during command line completion only" msgstr "the complete built-in can be used during command line completion only" #: lineedit/complete.c:1539 #, c-format msgid "the specified prefix `%ls' does not match the target word `%ls'" msgstr "the specified prefix ‘%ls’ does not match the target word ‘%ls’" #: lineedit/complete.c:1587 msgid "generate completion candidates" msgstr "generate completion candidates" #: lineedit/complete.c:1590 msgid "" "\tcomplete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \\\n" "\t [-abcdfghjkuv] [[-O] [-D description] words...]\n" msgstr "" "\tcomplete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \\\n" "\t [-abcdfghjkuv] [[-O] [-D description] words...]\n" #: lineedit/display.c:1346 #, c-format msgid "Candidate %zu of %zu; Page %zu of %zu" msgstr "Candidate %zu of %zu; Page %zu of %zu" #: lineedit/display.c:1362 msgid "No candidates" msgstr "No candidates" #: lineedit/editing.c:2741 msgid "lineedit" msgstr "lineedit" #: lineedit/keymap.c:422 msgid "option combination is invalid" msgstr "option combination is invalid" #: lineedit/keymap.c:429 msgid "no option is specified" msgstr "no option is specified" #: lineedit/keymap.c:463 msgid "cannot bind an empty key sequence" msgstr "cannot bind an empty key sequence" #: lineedit/keymap.c:487 #, c-format msgid "no such editing command `%ls'" msgstr "no such editing command ‘%ls’" #: lineedit/keymap.c:521 #, c-format msgid "key sequence `%ls' is not bound" msgstr "key sequence ‘%ls’ is not bound" #: lineedit/keymap.c:567 msgid "set or print key bindings for line-editing" msgstr "set or print key bindings for line-editing" #: lineedit/keymap.c:570 msgid "" "\tbindkey -aev [key_sequence [command]]\n" "\tbindkey -l\n" msgstr "" "\tbindkey -aev [key_sequence [command]]\n" "\tbindkey -l\n" #: mail.c:164 mail.c:237 msgid "You have new mail." msgstr "You have new mail." #: option.c:394 xgetopt.c:414 #, c-format msgid "the -%lc option requires an argument" msgstr "the -%lc option requires an argument" #: option.c:441 option.c:560 sig.c:1277 xgetopt.c:382 #, c-format msgid "`%ls' is not a valid option" msgstr "‘%ls’ is not a valid option" #: option.c:583 xgetopt.c:417 #, c-format msgid "the --%ls option requires an argument" msgstr "the --%ls option requires an argument" #: option.c:597 xgetopt.c:431 #, c-format msgid "%ls: the --%ls option does not take an argument" msgstr "%ls: the --%ls option does not take an argument" #: option.c:606 xgetopt.c:392 #, c-format msgid "option `%ls' is ambiguous" msgstr "option ‘%ls’ is ambiguous" #: option.c:630 #, c-format msgid "the %ls option cannot be changed once the shell has been initialized" msgstr "the %ls option cannot be changed once the shell has been initialized" #: option.c:889 msgid "on" msgstr "on" #: option.c:890 msgid "off" msgstr "off" #: option.c:914 msgid "set shell options and positional parameters" msgstr "set shell options and positional parameters" #: option.c:917 msgid "" "\tset [option...] [--] [new_positional_parameter...]\n" "\tset -o|+o # print current settings\n" msgstr "" "\tset [option...] [--] [new_positional_parameter...]\n" "\tset -o|+o # print current settings\n" #: parser.c:589 msgid "syntax error: " msgstr "syntax error: " #: parser.c:869 msgid "`;' or `&' is missing" msgstr "‘;’ or ‘&’ is missing" #: parser.c:1087 msgid "a command is missing at the end of input" msgstr "a command is missing at the end of input" #: parser.c:1089 #, c-format msgid "a command is missing before `%lc'" msgstr "a command is missing before ‘%lc’" #: parser.c:1124 #, c-format msgid "invalid use of `%lc'" msgstr "invalid use of ‘%lc’" #: parser.c:1380 msgid "the redirection target is missing" msgstr "the redirection target is missing" #: parser.c:1387 msgid "the end-of-here-document indicator is missing" msgstr "the end-of-here-document indicator is missing" #: parser.c:1513 msgid "the double quotation is not closed" msgstr "the double quotation is not closed" #: parser.c:1530 msgid "the single quotation is not closed" msgstr "the single quotation is not closed" #: parser.c:1682 msgid "the parameter name is missing or invalid" msgstr "the parameter name is missing or invalid" #: parser.c:1694 parser.c:1699 msgid "the index is missing" msgstr "the index is missing" #: parser.c:1728 parser.c:1742 parser.c:1786 #, c-format msgid "invalid use of `%lc' in parameter expansion" msgstr "invalid use of ‘%lc’ in parameter expansion" #: parser.c:1732 #, c-format msgid "invalid character `%lc' in parameter expansion" msgstr "invalid character ‘%lc’ in parameter expansion" #: parser.c:1889 msgid "the backquoted command substitution is not closed" msgstr "the backquoted command substitution is not closed" #: parser.c:2077 parser.c:2110 parser.c:2203 parser.c:2239 #, c-format msgid "commands are missing between `%ls' and `%ls'" msgstr "commands are missing between ‘%ls’ and ‘%ls’" #: parser.c:2123 parser.c:2230 #, c-format msgid "commands are missing after `%ls'" msgstr "commands are missing after ‘%ls’" #: parser.c:2166 msgid "an identifier is required after `for'" msgstr "an identifier is required after ‘for’" #: parser.c:2168 #, c-format msgid "`%ls' is not a valid identifier" msgstr "‘%ls’ is not a valid identifier" #: parser.c:2180 msgid "redirections are not allowed after `in'" msgstr "redirections are not allowed after ‘in’" #: parser.c:2190 msgid "`;' is not allowed just after the identifier in a for loop" msgstr "‘;’ is not allowed just after the identifier in a for loop" #: parser.c:2264 parser.c:2339 parser.c:2384 #, c-format msgid "a word is required after `%ls'" msgstr "a word is required after ‘%ls’" #: parser.c:2330 msgid "an unquoted `esac' cannot be the first case pattern" msgstr "an unquoted ‘esac’ cannot be the first case pattern" #: parser.c:2342 #, c-format msgid "encountered an invalid character `%lc' in the case pattern" msgstr "encountered an invalid character ‘%lc’ in the case pattern" #: parser.c:2370 parser.c:2688 parser.c:2691 #, c-format msgid "`%ls' cannot be used as a command name" msgstr "‘%ls’ cannot be used as a command name" #: parser.c:2402 parser.c:2443 msgid "a function body must be a compound command" msgstr "a function body must be a compound command" #: parser.c:2434 msgid "`(' must be followed by `)' in a function definition" msgstr "‘(’ must be followed by ‘)’ in a function definition" #: parser.c:2471 msgid "the end-of-here-document indicator contains a newline" msgstr "the end-of-here-document indicator contains a newline" #: parser.c:2679 #, c-format msgid "encountered `%ls' without a matching `('" msgstr "encountered ‘%ls’ without a matching ‘(’" #: parser.c:2682 #, c-format msgid "encountered `%ls' without a matching `{'" msgstr "encountered ‘%ls’ without a matching ‘{’" #: parser.c:2685 #, c-format msgid "`%ls' is used outside `case'" msgstr "‘%ls’ is used outside ‘case’" #: parser.c:2694 parser.c:2715 #, c-format msgid "encountered `%ls' without a matching `if' and/or `then'" msgstr "encountered ‘%ls’ without a matching ‘if’ and/or ‘then’" #: parser.c:2698 #, c-format msgid "encountered `%ls' without a matching `if' or `elif'" msgstr "encountered ‘%ls’ without a matching ‘if’ or ‘elif’" #: parser.c:2703 #, c-format msgid "encountered `%ls' without a matching `for', `while', or `until'" msgstr "encountered ‘%ls’ without a matching ‘for’, ‘while’, or ‘until’" #: parser.c:2707 #, c-format msgid "encountered `%ls' without a matching `do'" msgstr "encountered ‘%ls’ without a matching ‘do’" #: parser.c:2712 #, c-format msgid "encountered `%ls' without a matching `case'" msgstr "encountered ‘%ls’ without a matching ‘case’" #: parser.c:2728 #, c-format msgid "(maybe you missed `%ls'?)" msgstr "(maybe you missed ‘%ls’?)" #: path.c:1090 msgid "$HOME is not set" msgstr "$HOME is not set" #: path.c:1099 variable.c:2864 msgid "$OLDPWD is not set" msgstr "$OLDPWD is not set" #: path.c:1129 msgid "$PWD has an invalid value" msgstr "$PWD has an invalid value" #: path.c:1138 path.c:1149 path.c:1365 msgid "cannot determine the current directory" msgstr "cannot determine the current directory" #: path.c:1221 #, c-format msgid "`%ls'" msgstr "‘%ls’" #: path.c:1252 #, c-format msgid "`%s'" msgstr "‘%s’" #: path.c:1316 msgid "change the working directory" msgstr "change the working directory" #: path.c:1319 msgid "\tcd [-L|-P] [directory]\n" msgstr "\tcd [-L|-P] [directory]\n" #: path.c:1377 msgid "print the working directory" msgstr "print the working directory" #: path.c:1380 msgid "\tpwd [-L|-P]\n" msgstr "\tpwd [-L|-P]\n" #: path.c:1435 #, c-format msgid "no such user `%ls'" msgstr "no such user ‘%ls’" #: path.c:1457 #, c-format msgid "`%ls': a command name must not contain `/'" msgstr "‘%ls’: a command name must not contain ‘/’" #: path.c:1465 #, c-format msgid "command `%s' was not found in $PATH" msgstr "command ‘%s’ was not found in $PATH" #: path.c:1511 msgid "remember, forget, or report command locations" msgstr "remember, forget, or report command locations" #: path.c:1514 msgid "" "\thash command...\n" "\thash -r [command...]\n" "\thash [-a] # print remembered paths\n" "\thash -d user...\n" "\thash -d -r [user...]\n" "\thash -d # print remembered paths\n" msgstr "" "\thash command...\n" "\thash -r [command...]\n" "\thash [-a] # print remembered paths\n" "\thash -d user...\n" "\thash -d -r [user...]\n" "\thash -d # print remembered paths\n" #: path.c:1621 path.c:1704 #, c-format msgid "`%ls' is not a valid mask specification" msgstr "‘%ls’ is not a valid mask specification" #: path.c:1731 msgid "print or set the file creation mask" msgstr "print or set the file creation mask" #: path.c:1734 msgid "" "\tumask mode\n" "\tumask [-S]\n" msgstr "" "\tumask mode\n" "\tumask [-S]\n" #: redir.c:70 #, c-format msgid "error in closing file descriptor %d" msgstr "error in closing file descriptor %d" #: redir.c:91 #, c-format msgid "cannot copy file descriptor %d to %d" msgstr "cannot copy file descriptor %d to %d" #: redir.c:280 msgid "disabling job control" msgstr "disabling job control" #: redir.c:328 msgid "redirection: invalid file descriptor" msgstr "redirection: invalid file descriptor" #: redir.c:331 redir.c:607 redir.c:679 #, c-format msgid "redirection: file descriptor %d is unavailable" msgstr "redirection: file descriptor %d is unavailable" #: redir.c:379 #, c-format msgid "redirection: cannot open file `%s'" msgstr "redirection: cannot open file ‘%s’" #: redir.c:467 #, c-format msgid "cannot save file descriptor %d" msgstr "cannot save file descriptor %d" #: redir.c:557 #, c-format msgid "socket redirection: cannot resolve the address of `%s': %s" msgstr "socket redirection: cannot resolve the address of ‘%s’: %s" #: redir.c:601 redir.c:616 redir.c:671 #, c-format msgid "redirection: %s" msgstr "redirection: %s" #: redir.c:624 #, c-format msgid "redirection: file descriptor %d is not readable" msgstr "redirection: file descriptor %d is not readable" #: redir.c:636 #, c-format msgid "redirection: file descriptor %d is not writable" msgstr "redirection: file descriptor %d is not writable" #: redir.c:674 #, c-format msgid "redirection: %d>>|%d: the input and output file descriptors are same" msgstr "redirection: %d>>|%d: the input and output file descriptors are same" #: redir.c:718 #, c-format msgid "redirection: %d>>|%d" msgstr "redirection: %d>>|%d" #: redir.c:735 redir.c:775 redir.c:796 msgid "cannot write the here-document contents to the temporary file" msgstr "cannot write the here-document contents to the temporary file" #: redir.c:788 msgid "cannot create a temporary file for the here-document" msgstr "cannot create a temporary file for the here-document" #: redir.c:801 msgid "cannot seek the temporary file for the here-document" msgstr "cannot seek the temporary file for the here-document" #: redir.c:815 msgid "redirection: cannot open a pipe for the command redirection" msgstr "redirection: cannot open a pipe for the command redirection" #: redir.c:854 msgid "command redirection" msgstr "command redirection" #: sig.c:481 msgid "cannot send SIGSTOP signal" msgstr "cannot send SIGSTOP signal" #: sig.c:581 msgid "too many files are opened for yash to handle" msgstr "too many files are opened for yash to handle" #: sig.c:780 #, c-format msgid "SIG%ls cannot be trapped" msgstr "SIG%ls cannot be trapped" #: sig.c:795 #, c-format msgid "real-time signal SIG%ls is not supported" msgstr "real-time signal SIG%ls is not supported" #: sig.c:811 #, c-format msgid "SIG%ls cannot be reset" msgstr "SIG%ls cannot be reset" #: sig.c:1128 sig.c:1169 sig.c:1247 sig.c:1312 #, c-format msgid "no such signal `%ls'" msgstr "no such signal ‘%ls’" #: sig.c:1198 msgid "set or print signal handlers" msgstr "set or print signal handlers" #: sig.c:1201 msgid "" "\ttrap [action signal...]\n" "\ttrap signal_number [signal...]\n" "\ttrap -p [signal...]\n" msgstr "" "\ttrap [action signal...]\n" "\ttrap signal_number [signal...]\n" "\ttrap -p [signal...]\n" #: sig.c:1235 msgid "the signal name is not specified" msgstr "the signal name is not specified" #: sig.c:1241 #, c-format msgid "%ls: the signal name must be specified without `SIG'" msgstr "%ls: the signal name must be specified without ‘SIG’" #: sig.c:1381 msgid "send a signal to processes" msgstr "send a signal to processes" #: sig.c:1384 msgid "" "\tkill [-signal|-s signal|-n number] process...\n" "\tkill -l [-v] [number...]\n" msgstr "" "\tkill [-signal|-s signal|-n number] process...\n" "\tkill -l [-v] [number...]\n" #: util.c:269 msgid "unknown error" msgstr "unknown error" #: variable.c:367 variable.c:372 msgid "failed to set $PWD" msgstr "failed to set $PWD" #: variable.c:396 #, c-format msgid "no such array $%ls" msgstr "no such array $%ls" #: variable.c:399 variable.c:601 variable.c:1688 variable.c:2293 #: variable.c:2910 #, c-format msgid "$%ls is read-only" msgstr "$%ls is read-only" #: variable.c:416 #, c-format msgid "failed to unset environment variable $%s" msgstr "failed to unset environment variable $%s" #: variable.c:420 #, c-format msgid "failed to set environment variable $%s" msgstr "failed to set environment variable $%s" #: variable.c:695 #, c-format msgid "index %zu is out of range (the actual size of array $%ls is %zu)" msgstr "index %zu is out of range (the actual size of array $%ls is %zu)" #: variable.c:1238 #, c-format msgid "function `%ls' cannot be redefined because it is read-only" msgstr "function ‘%ls’ cannot be redefined because it is read-only" #: variable.c:1418 variable.c:2996 msgid "the directory stack is empty" msgstr "the directory stack is empty" #: variable.c:1456 variable.c:2848 variable.c:3092 msgid "$PWD is not set" msgstr "$PWD is not set" #: variable.c:1468 #, c-format msgid "index %ls is out of range" msgstr "index %ls is out of range" #: variable.c:1712 #, c-format msgid "no such variable $%ls" msgstr "no such variable $%ls" #: variable.c:1724 #, c-format msgid "no such function `%ls'" msgstr "no such function ‘%ls’" #: variable.c:1912 msgid "set or print variables" msgstr "set or print variables" #: variable.c:1915 msgid "\ttypeset [-fgprxX] [name[=value]...]\n" msgstr "\ttypeset [-fgprxX] [name[=value]...]\n" #: variable.c:1918 msgid "export variables as environment variables" msgstr "export variables as environment variables" #: variable.c:1921 msgid "\texport [-prX] [name[=value]...]\n" msgstr "\texport [-prX] [name[=value]...]\n" #: variable.c:1924 msgid "make variables read-only" msgstr "make variables read-only" #: variable.c:1927 msgid "\treadonly [-fpxX] [name[=value]...]\n" msgstr "\treadonly [-fpxX] [name[=value]...]\n" #: variable.c:1975 msgid "more than one option cannot be used at once" msgstr "more than one option cannot be used at once" #: variable.c:1994 #, c-format msgid "`%ls' is not a valid array name" msgstr "‘%ls’ is not a valid array name" #: variable.c:2186 #, c-format msgid "index %ls is out of range (the actual size of array $%ls is %zu)" msgstr "index %ls is out of range (the actual size of array $%ls is %zu)" #: variable.c:2193 msgid "manipulate an array" msgstr "manipulate an array" #: variable.c:2196 msgid "" "\tarray # print arrays\n" "\tarray name [value...] # set array values\n" "\tarray -d name [index...]\n" "\tarray -i name index [value...]\n" "\tarray -s name index value\n" msgstr "" "\tarray # print arrays\n" "\tarray name [value...] # set array values\n" "\tarray -d name [index...]\n" "\tarray -i name index [value...]\n" "\tarray -s name index value\n" #: variable.c:2247 variable.c:2411 variable.c:2619 #, c-format msgid "`%ls' is not a valid variable name" msgstr "‘%ls’ is not a valid variable name" #: variable.c:2268 #, c-format msgid "function `%ls' is read-only" msgstr "function ‘%ls’ is read-only" #: variable.c:2304 msgid "remove variables or functions" msgstr "remove variables or functions" #: variable.c:2307 msgid "\tunset [-fv] [name...]\n" msgstr "\tunset [-fv] [name...]\n" #: variable.c:2337 #, c-format msgid "%ls: the operand value must not be negative" msgstr "%ls: the operand value must not be negative" #: variable.c:2355 #, c-format msgid "%zu: cannot shift so many (there is only one positional parameter)" msgid_plural "" "%zu: cannot shift so many (there are only %zu positional parameters)" msgstr[0] "%zu: cannot shift so many (there is only one positional parameter)" msgstr[1] "" "%zu: cannot shift so many (there are only %zu positional parameters)" #: variable.c:2377 msgid "remove some positional parameters" msgstr "remove some positional parameters" #: variable.c:2380 msgid "\tshift [count]\n" msgstr "\tshift [count]\n" #: variable.c:2414 #, c-format msgid "`%ls' is not a valid option specification" msgstr "‘%ls’ is not a valid option specification" #: variable.c:2472 #, c-format msgid "%ls: `-%lc' is not a valid option\n" msgstr "%ls: ‘-%lc’ is not a valid option\n" #: variable.c:2495 #, c-format msgid "%ls: the -%lc option's argument is missing\n" msgstr "%ls: the -%lc option's argument is missing\n" #: variable.c:2518 msgid "$OPTIND has an invalid value" msgstr "$OPTIND has an invalid value" #: variable.c:2573 msgid "parse command options" msgstr "parse command options" #: variable.c:2576 msgid "\tgetopts options variable [argument...]\n" msgstr "\tgetopts options variable [argument...]\n" #: variable.c:2779 msgid "read a line from the standard input" msgstr "read a line from the standard input" #: variable.c:2782 msgid "\tread [-Ar] variable...\n" msgstr "\tread [-Ar] variable...\n" #: variable.c:2907 msgid "$DIRSTACK is not an array" msgstr "$DIRSTACK is not an array" #: variable.c:2962 msgid "push a directory into the directory stack" msgstr "push a directory into the directory stack" #: variable.c:2965 msgid "\tpushd [-L|-P] [directory]\n" msgstr "\tpushd [-L|-P] [directory]\n" #: variable.c:3005 variable.c:3081 #, c-format msgid "`%ls' is not a valid index" msgstr "‘%ls’ is not a valid index" #: variable.c:3028 msgid "pop a directory from the directory stack" msgstr "pop a directory from the directory stack" #: variable.c:3031 msgid "\tpopd [index]\n" msgstr "\tpopd [index]\n" #: variable.c:3119 msgid "print the directory stack" msgstr "print the directory stack" #: variable.c:3122 msgid "\tdirs [-cv] [index...]\n" msgstr "\tdirs [-cv] [index...]\n" #: yash.c:111 #, c-format msgid "%s: cannot convert the argument `%s' into a wide character string" msgstr "%s: cannot convert the argument ‘%s’ into a wide character string" #: yash.c:115 #, c-format msgid "%s: the argument is replaced with an empty string\n" msgstr "%s: the argument is replaced with an empty string\n" #: yash.c:180 msgid "the -c option is specified but no command is given" msgstr "the -c option is specified but no command is given" #: yash.c:353 #, c-format msgid "" "Syntax:\n" "\t%s [option...] [filename [argument...]]\n" "\t%s [option...] -c command [command_name [argument...]]\n" "\t%s [option...] -s [argument...]\n" msgstr "" "Syntax:\n" "\t%s [option...] [filename [argument...]]\n" "\t%s [option...] -c command [command_name [argument...]]\n" "\t%s [option...] -s [argument...]\n" #: yash.c:370 #, c-format msgid "Yet another shell, version %s\n" msgstr "Yet another shell, version %s\n" #: yash.c:372 msgid "" "This is free software licensed under GNU GPL version 2.\n" "You can modify and redistribute it, but there is NO WARRANTY.\n" msgstr "" "This is free software licensed under GNU GPL version 2.\n" "You can modify and redistribute it, but there is NO WARRANTY.\n" #: yash.c:376 msgid "" "\n" "Enabled features:\n" msgstr "" "\n" "Enabled features:\n" #: yash.c:525 msgid "Use `exit' to leave the shell.\n" msgstr "Use ‘exit’ to leave the shell.\n" #: yash.c:602 msgid " Use `exit' again to exit anyway.\n" msgstr " Use ‘exit’ again to exit anyway.\n" #: yash.c:624 msgid "exit the shell" msgstr "exit the shell" #: yash.c:627 msgid "\texit [-f] [exit_status]\n" msgstr "\texit [-f] [exit_status]\n" #: yash.c:657 msgid "" "refusing to suspend because of a possible deadlock.\n" "Use the -f option to suspend anyway." msgstr "" "refusing to suspend because of a possible deadlock.\n" "Use the -f option to suspend anyway." #: yash.c:671 msgid "suspend the shell" msgstr "suspend the shell" #: yash.c:674 msgid "\tsuspend [-f]\n" msgstr "\tsuspend [-f]\n" yash-2.35/po/boldquot.sed0000644000175000017500000000033112154557026015507 0ustar magicantmagicants/"\([^"]*\)"/“\1â€/g s/`\([^`']*\)'/‘\1’/g s/ '\([^`']*\)' / ‘\1’ /g s/ '\([^`']*\)'$/ ‘\1’/g s/^'\([^`']*\)' /‘\1’ /g s/“â€/""/g s/“/“/g s/â€/â€/g s/‘/‘/g s/’/’/g yash-2.35/po/ja.po0000644000175000017500000013546012154557026014127 0ustar magicantmagicant# Japanese translations for yash package # yash パッケージã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã®å’Œè¨³ # Copyright (C) 2010-2012 Magicant # This file is distributed under the same license as the yash package. # WATANABE Yuki , 2010-2012. # msgid "" msgstr "" "Project-Id-Version: yash 2.35\n" "Report-Msgid-Bugs-To: http://sourceforge.jp/projects/yash/forums/\n" "POT-Creation-Date: 2013-06-08 16:19+0900\n" "PO-Revision-Date: 2013-06-08 16:30+0900\n" "Last-Translator: WATANABE Yuki \n" "Language-Team: Japanese\n" "Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" #: alias.c:396 #, c-format msgid "%ls: an alias for `%ls'\n" msgstr "%ls: 「%lsã€ã¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹\n" #: alias.c:493 alias.c:544 #, c-format msgid "no such alias `%ls'" msgstr "「%lsã€ã¨ã„ã†ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ã‚りã¾ã›ã‚“" #: alias.c:496 #, c-format msgid "`%ls' is not a valid alias name" msgstr "「%lsã€ã¯æœ‰åйãªã‚¨ã‚¤ãƒªã‚¢ã‚¹åã§ã¯ã‚りã¾ã›ã‚“" #: alias.c:505 msgid "define or print aliases" msgstr "エイリアスを定義ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹" #: alias.c:508 msgid "\talias [-gp] [name[=value]...]\n" msgstr "\talias [-gp] [åå‰[=値]...]\n" #: alias.c:552 msgid "undefine aliases" msgstr "エイリアスã®å®šç¾©ã‚’削除ã™ã‚‹" #: alias.c:555 msgid "" "\tunalias name...\n" "\tunalias -a\n" msgstr "" "\tunalias åå‰...\n" "\tunalias -a\n" #: arith.c:175 arith.c:217 msgid "arithmetic: invalid syntax" msgstr "æ•°å¼å±•é–‹: æ§‹æ–‡ãŒæ­£ã—ãã‚りã¾ã›ã‚“" #: arith.c:212 msgid "the index is not an integer" msgstr "ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæ•´æ•°ã§ã¯ã‚りã¾ã›ã‚“" #. TRANSLATORS: This error message is shown when the target #. * of an assignment is not a variable. #: arith.c:280 msgid "arithmetic: cannot assign to a number" msgstr "æ•°å¼å±•é–‹: 代入先ã¯å¤‰æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“" #: arith.c:446 arith.c:964 #, c-format msgid "arithmetic: `%ls' is missing" msgstr "æ•°å¼å±•é–‹: 「%lsã€ãŒæŠœã‘ã¦ã„ã¾ã™" #: arith.c:780 arith.c:791 msgid "arithmetic: division by zero" msgstr "æ•°å¼å±•é–‹: 0 ã«ã‚ˆã‚‹é™¤ç®—" #: arith.c:827 arith.c:903 #, c-format msgid "arithmetic: operator `%ls' is not supported" msgstr "æ•°å¼å±•é–‹: 演算å­ã€Œ%lsã€ã¯ä½¿ãˆã¾ã›ã‚“" #. TRANSLATORS: This error message is shown when the operand of #. * the "++" or "--" operator is not a variable. #: arith.c:840 arith.c:917 #, c-format msgid "arithmetic: operator `%ls' requires a variable" msgstr "æ•°å¼å±•é–‹: 演算å­ã€Œ%lsã€ã®å¯¾è±¡ã¯å¤‰æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“" #: arith.c:979 msgid "arithmetic: a value is missing" msgstr "æ•°å¼å±•é–‹: å€¤ãŒæŠœã‘ã¦ã„ã¾ã™" #: arith.c:1016 arith.c:1060 #, c-format msgid "arithmetic: `%ls' is not a valid number" msgstr "æ•°å¼å±•é–‹:「%lsã€ã¯æœ‰åŠ¹ãªæ•°å€¤ã§ã¯ã‚りã¾ã›ã‚“" #: arith.c:1330 #, c-format msgid "arithmetic: `%lc' is not a valid number or operator" msgstr "æ•°å¼å±•é–‹:「%lcã€ã¯æœ‰åŠ¹ãªæ•°å€¤ã‚„演算å­ã§ã¯ã‚りã¾ã›ã‚“" #: builtin.c:251 #, c-format msgid "the -%lc option cannot be used with the -%lc option" msgstr "-%lc オプション㯠-%lc オプションã¨ã¯ä¸€ç·’ã«ä½¿ãˆã¾ã›ã‚“" #: builtin.c:277 #, c-format msgid "this command requires an operand" msgid_plural "this command requires %zu operands" msgstr[0] "オペランドãŒè¶³ã‚Šã¾ã›ã‚“ (%zu 個必è¦)" #. TRANSLATORS: This message is printed when a command that takes no #. * operand was invoked with some operands. #: builtin.c:290 msgid "no operand is expected" msgstr "ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’å—ã‘付ã‘ã¾ã›ã‚“" #. TRANSLATORS: This message is printed when a command was invoked with #. * the wrong number of operands. #: builtin.c:294 msgid "too many operands are specified" msgstr "ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®æ•°ãŒå¤šã™ãŽã¾ã™" #: builtin.c:346 yash.c:363 msgid "Try `man yash' for details.\n" msgstr "詳ã—ãã¯: man yash\n" #: builtin.c:361 #, c-format msgid "no such built-in `%ls'" msgstr "「%lsã€ã¨ã„ã†ã‚ˆã†ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚りã¾ã›ã‚“" #. TRANSLATORS: This is printed before syntax info of a built-in. #: builtin.c:369 #, c-format msgid "" "Syntax:\n" "%s\n" msgstr "" "æ§‹æ–‡:\n" "%s\n" #. TRANSLATORS: This text is printed before a list of options. #: builtin.c:388 builtin.c:408 msgid "Options:\n" msgstr "オプション:\n" #: builtin.c:547 msgid "do nothing" msgstr "何もã—ãªã„" #: builtin.c:550 msgid "\t: [...]\n" msgstr "\t: [...]\n" #: builtin.c:554 msgid "do nothing successfully" msgstr "何もã›ãšæˆåŠŸã‚’è¿”ã™" #: builtin.c:557 msgid "\ttrue\n" msgstr "\ttrue\n" #: builtin.c:561 msgid "do nothing unsuccessfully" msgstr "何もã›ãšå¤±æ•—ã‚’è¿”ã™" #: builtin.c:564 msgid "\tfalse\n" msgstr "\tfalse\n" #: builtin.c:589 msgid "print usage of built-in commands" msgstr "組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ä½¿ã„方を表示ã™ã‚‹" #: builtin.c:592 msgid "\thelp [built-in...]\n" msgstr "\thelp [組込ã¿ã‚³ãƒžãƒ³ãƒ‰...]\n" #: builtins/printf.c:206 builtins/printf.c:332 history.c:1458 job.c:1062 #: path.c:1370 util.c:301 msgid "cannot print to the standard output" msgstr "標準出力ã«å‡ºåŠ›ã§ãã¾ã›ã‚“" #: builtins/printf.c:267 msgid "print arguments" msgstr "引数を出力ã™ã‚‹" #: builtins/printf.c:270 msgid "\techo [string...]\n" msgstr "\techo [文字列...]\n" #: builtins/printf.c:411 msgid "cannot parse the format" msgstr "書å¼ã‚’è§£æžã§ãã¾ã›ã‚“" #: builtins/printf.c:520 msgid "the conversion specifier is missing" msgstr "å¤‰æ›æŒ‡å®šå­ãŒæŠœã‘ã¦ã„ã¾ã™" #: builtins/printf.c:524 #, c-format msgid "`%lc' is not a valid conversion specifier" msgstr "「%lcã€ã¯æœ‰åйãªå¤‰æ›æŒ‡å®šå­ã§ã¯ã‚りã¾ã›ã‚“" #: builtins/printf.c:529 #, c-format msgid "invalid flag for conversion specifier `%lc'" msgstr "å¤‰æ›æŒ‡å®šå­ã€Œ%lcã€ã«å¯¾ã™ã‚‹ãƒ•ラグãŒä¸æ­£ã§ã™" #: builtins/printf.c:659 #, c-format msgid "`%ls' is not a valid number" msgstr "「%lsã€ã¯æœ‰åŠ¹ãªæ•°å€¤ã§ã¯ã‚りã¾ã›ã‚“" #: builtins/printf.c:693 builtins/test.c:556 builtins/test.c:562 #: builtins/ulimit.c:229 exec.c:1684 exec.c:1757 history.c:1714 sig.c:1333 #: variable.c:2063 variable.c:2123 variable.c:2162 variable.c:2334 yash.c:611 #, c-format msgid "`%ls' is not a valid integer" msgstr "「%lsã€ã¯æœ‰åŠ¹ãªæ•´æ•°ã§ã¯ã‚りã¾ã›ã‚“" #: builtins/printf.c:758 msgid "print a formatted string" msgstr "文字列を整形ã—ã¦å‡ºåŠ›ã™ã‚‹" #: builtins/printf.c:761 msgid "\tprintf format [value...]\n" msgstr "\tprintf æ›¸å¼ [値...]\n" #: builtins/test.c:82 builtins/test.c:425 parser.c:1256 parser.c:1704 #: parser.c:1784 parser.c:1812 parser.c:2199 parser.c:2271 parser.c:2358 #: parser.c:2730 #, c-format msgid "`%ls' is missing" msgstr "「%lsã€ãŒæŠœã‘ã¦ã„ã¾ã™" #: builtins/test.c:113 #, c-format msgid "`%ls' is not a valid operator" msgstr "「%lsã€ã¯æœ‰åŠ¹ãªæ¼”ç®—å­ã§ã¯ã‚りã¾ã›ã‚“" #: builtins/test.c:138 #, c-format msgid "`%ls' is not a unary operator" msgstr "「%lsã€ã¯å˜é …演算å­ã§ã¯ã‚りã¾ã›ã‚“" #: builtins/test.c:159 builtins/test.c:627 builtins/test.c:635 exec.c:1893 #: exec.c:2027 exec.c:2036 history.c:1492 lineedit/keymap.c:476 path.c:1175 #: path.c:1247 strbuf.c:545 strbuf.c:568 msgid "unexpected error" msgstr "想定外ã®ã‚¨ãƒ©ãƒ¼ã§ã™" #: builtins/test.c:364 #, c-format msgid "`%ls' is not a binary operator" msgstr "「%lsã€ã¯äºŒé …演算å­ã§ã¯ã‚りã¾ã›ã‚“" #: builtins/test.c:416 #, c-format msgid "an expression is missing after `%ls'" msgstr "「%lsã€ã®å¾Œã§å¼ãŒæŠœã‘ã¦ã„ã¾ã™" #: builtins/test.c:682 msgid "evaluate a conditional expression" msgstr "æ¡ä»¶å¼ã‚’評価ã™ã‚‹" #: builtins/test.c:685 msgid "" "\ttest expression\n" "\t[ expression ]\n" msgstr "" "\ttest å¼\n" "\t[ å¼ ]\n" #: builtins/ulimit.c:65 msgid "file size (blocks)" msgstr "ファイルサイズ (ブロック数)    " #: builtins/ulimit.c:73 msgid "core file size (blocks)" msgstr "コアファイルサイズ (ブロック数)  " #: builtins/ulimit.c:75 msgid "data segment size (kbytes)" msgstr "データセグメントサイズ (キロãƒã‚¤ãƒˆ)" #: builtins/ulimit.c:78 msgid "max nice" msgstr "最大 nice             " #: builtins/ulimit.c:83 msgid "pending signals" msgstr "処ç†å¾…ã¡ã‚·ã‚°ãƒŠãƒ«ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ " #: builtins/ulimit.c:87 msgid "locked memory (kbytes)" msgstr "ロックã—ãŸãƒ¡ãƒ¢ãƒª (キロãƒã‚¤ãƒˆ)   " #: builtins/ulimit.c:91 msgid "resident set size (kbytes)" msgstr "レジデントセットサイズ (キロãƒã‚¤ãƒˆ)" #: builtins/ulimit.c:94 msgid "open files" msgstr "é–‹ã‘るファイル数         " #: builtins/ulimit.c:97 msgid "message queue size (bytes)" msgstr "メッセージキューサイズ (ãƒã‚¤ãƒˆ)  " #: builtins/ulimit.c:101 msgid "real-time priority" msgstr "リアルタイム優先度        " #: builtins/ulimit.c:104 msgid "stack size (kbytes)" msgstr "スタックサイズ (キロãƒã‚¤ãƒˆ)    " #: builtins/ulimit.c:106 msgid "CPU time (seconds)" msgstr "CPU 時間 (ç§’)           " #: builtins/ulimit.c:109 msgid "user processes" msgstr "ユーザプロセス数         " #: builtins/ulimit.c:113 msgid "memory (kbytes)" msgstr "メモリ (キロãƒã‚¤ãƒˆ)        " #: builtins/ulimit.c:117 msgid "file locks" msgstr "ファイルã®ãƒ­ãƒƒã‚¯ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ " #: builtins/ulimit.c:170 builtins/ulimit.c:245 #, c-format msgid "cannot get the current limit for the resource type of `%s'" msgstr "リソース「%sã€ã®ç¾åœ¨ã®åˆ¶é™å€¤ã‚’å–å¾—ã§ãã¾ã›ã‚“" #: builtins/ulimit.c:217 msgid "the soft limit cannot exceed the hard limit" msgstr "ソフトリミットã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚ˆã‚Šå¤§ããã§ãã¾ã›ã‚“" #: builtins/ulimit.c:222 msgid "failed to set the limit" msgstr "リミットã®è¨­å®šã«å¤±æ•—ã—ã¾ã—ãŸ" #: builtins/ulimit.c:251 #, c-format msgid "-%lc: %-30s " msgstr "-%lc: %-52s " #: builtins/ulimit.c:263 msgid "unlimited" msgstr "無制é™" #: builtins/ulimit.c:270 msgid "set or print a resource limitation" msgstr "リソースã®åˆ¶é™ã‚’設定ã¾ãŸã¯è¨­å®šã™ã‚‹" #: builtins/ulimit.c:273 msgid "" "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [limit]\n" msgstr "" "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [制é™]\n" #: exec.c:736 msgid "cannot open a pipe" msgstr "パイプを開ã‘ã¾ã›ã‚“" #: exec.c:960 msgid "cannot make a child process" msgstr "å­ãƒ—ロセスを生æˆã§ãã¾ã›ã‚“" #: exec.c:1185 exec.c:2051 exec.c:2282 #, c-format msgid "no such command `%s'" msgstr "「%sã€ã¨ã„ã†ã‚ˆã†ãªã‚³ãƒžãƒ³ãƒ‰ã¯ã‚りã¾ã›ã‚“" #: exec.c:1239 #, c-format msgid "cannot execute command `%s'" msgstr "コマンド「%sã€ã‚’実行ã§ãã¾ã›ã‚“" #: exec.c:1240 #, c-format msgid "cannot execute command `%s' (%s)" msgstr "コマンド「%sã€(%s) を実行ã§ãã¾ã›ã‚“" #: exec.c:1340 #, c-format msgid "cannot invoke a new shell to execute script `%s'" msgstr "スクリプト「%sã€ã‚’実行ã™ã‚‹ãŸã‚ã®æ–°ã—ã„シェルを起動ã§ãã¾ã›ã‚“" #: exec.c:1396 exec.c:1418 msgid "cannot open a pipe for the command substitution" msgstr "コマンド置æ›ã®ãŸã‚ã®ãƒ‘イプを開ã‘ã¾ã›ã‚“" #: exec.c:1455 msgid "command substitution" msgstr "コマンド置æ›" #: exec.c:1694 msgid "cannot be used in the interactive mode" msgstr "対話モードã§ã¯ä½¿ãˆã¾ã›ã‚“" #: exec.c:1704 msgid "return from a function or script" msgstr "関数やスクリプトã‹ã‚‰æŠœã‘ã‚‹" #: exec.c:1707 msgid "\treturn [-n] [exit_status]\n" msgstr "\treturn [-n] [終了ステータス]\n" #: exec.c:1739 msgid "not in an iteration" msgstr "å復実行ã®é€”中ã§ã¯ã‚りã¾ã›ã‚“" #: exec.c:1760 #, c-format msgid "%u is not a positive integer" msgstr "%u ã¯æ­£ã®æ•´æ•°ã§ã¯ã‚りã¾ã›ã‚“" #: exec.c:1770 msgid "not in a loop" msgstr "ループã®é€”中ã§ã¯ã‚りã¾ã›ã‚“" #: exec.c:1789 msgid "exit a loop" msgstr "ループを抜ã‘ã‚‹" #: exec.c:1792 msgid "" "\tbreak [count]\n" "\tbreak -i\n" msgstr "" "\tbreak [æ·±ã•]\n" "\tbreak -i\n" #: exec.c:1797 msgid "continue a loop" msgstr "ループã®å…ˆé ­ã«æˆ»ã‚‹" #: exec.c:1800 msgid "" "\tcontinue [count]\n" "\tcontinue -i\n" msgstr "" "\tcontinue [æ·±ã•]\n" "\tcontinue -i\n" #: exec.c:1840 msgid "evaluate arguments as a command" msgstr "引数をコマンドã¨ã—ã¦å®Ÿè¡Œã™ã‚‹" #: exec.c:1843 msgid "\teval [-i] [argument...]\n" msgstr "\teval [-i] [引数...]\n" #: exec.c:1902 #, c-format msgid "file `%s' was not found in $YASH_LOADPATH" msgstr "ファイル「%sã€ã¯ $YASH_LOADPATH 内ã«è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸ" #: exec.c:1912 #, c-format msgid "file `%s' was not found in $PATH" msgstr "ファイル「%sã€ã¯ $PATH 内ã«è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸ" #: exec.c:1929 redir.c:279 yash.c:207 #, c-format msgid "cannot open file `%s'" msgstr "ファイル「%sã€ã‚’é–‹ã‘ã¾ã›ã‚“" #: exec.c:1953 msgid "read a file and execute commands" msgstr "ファイルをスクリプトã¨ã—ã¦å®Ÿè¡Œã™ã‚‹" #: exec.c:1956 msgid "\t. [-AL] file [argument...]\n" msgstr "\t. [-AL] ファイル [引数...]\n" #: exec.c:2004 yash.c:598 #, c-format msgid "You have a stopped job!" msgid_plural "You have %zu stopped jobs!" msgstr[0] "åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–㌠%zu 個ã‚りã¾ã™!" #: exec.c:2008 msgid " Use the -f option to exec anyway.\n" msgstr " ãれã§ã‚‚ exec ã™ã‚‹ã«ã¯ -f オプションを付ã‘ã¦ãã ã•ã„。\n" #: exec.c:2098 msgid "replace the shell process with an external command" msgstr "シェルã®ãƒ—ロセスを外部コマンドã«å¤‰ãˆã‚‹" #: exec.c:2101 msgid "\texec [-cf] [-a name] [command [argument...]]\n" msgstr "\texec [-cf] [-a åå‰] [コマンド [引数...]]\n" #: exec.c:2161 msgid "the -a or -k option must be used with the -v option" msgstr "-a ãŠã‚ˆã³ -k オプション㯠-v オプションã¨ä¸€ç·’ã«ã—ã‹ä½¿ãˆã¾ã›ã‚“" #: exec.c:2255 #, c-format msgid "%ls: a shell keyword\n" msgstr "%ls: シェルã®äºˆç´„語\n" #: exec.c:2288 #, c-format msgid "%s: a special built-in\n" msgstr "%s: 特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰\n" #: exec.c:2292 #, c-format msgid "%s: a semi-special built-in\n" msgstr "%s: 準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰\n" #: exec.c:2304 #, c-format msgid "%s: a regular built-in (not found in $PATH)\n" msgstr "%s: 通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ ($PATH 内ã«å­˜åœ¨ã›ãš)\n" #: exec.c:2305 #, c-format msgid "%s: a regular built-in at %s\n" msgstr "%s: 通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ (%s)\n" #: exec.c:2312 #, c-format msgid "%s: a function\n" msgstr "%s: 関数\n" #: exec.c:2328 #, c-format msgid "%s: an external command at %s\n" msgstr "%s: 外部コマンド (%s)\n" #: exec.c:2350 #, c-format msgid "%s: an external command at %s/%s\n" msgstr "%s: 外部コマンド (%s/%s)\n" #: exec.c:2359 msgid "execute or identify a command" msgstr "コマンドを実行ã¾ãŸã¯ç‰¹å®šã™ã‚‹" #: exec.c:2362 msgid "" "\tcommand [-befp] command [argument...]\n" "\tcommand -v|-V [-abefkp] command...\n" msgstr "" "\tcommand [-befp] コマンド [引数...]\n" "\tcommand -v|-V [-abefkp] コマンド...\n" #: exec.c:2367 msgid "identify a command" msgstr "コマンドを特定ã™ã‚‹" #: exec.c:2370 msgid "\ttype command...\n" msgstr "\ttype コマンド...\n" #: exec.c:2408 msgid "cannot get the time data" msgstr "時間情報をå–å¾—ã§ãã¾ã›ã‚“" #: exec.c:2424 msgid "print CPU time usage" msgstr "消費 CPU 時間を表示ã™ã‚‹" #: exec.c:2427 msgid "\ttimes\n" msgstr "\ttimes\n" #: expand.c:288 expand.c:294 expand.c:312 redir.c:455 msgid "redirection" msgstr "リダイレクト" #: expand.c:302 #, c-format msgid "filename `%ls' matches more than one file" msgstr "ファイルå「%lsã€ã«å½“ã¦ã¯ã¾ã‚‹ãƒ•ァイルãŒè¤‡æ•°ã‚りã¾ã™" #: expand.c:630 msgid "the parameter index is invalid" msgstr "パラメータã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæ­£ã—ãã‚りã¾ã›ã‚“" #: expand.c:784 msgid "a nested parameter expansion cannot be assigned" msgstr "入れå­ã®ãƒ‘ラメータ展開ã¯ä»£å…¥ã§ãã¾ã›ã‚“" #: expand.c:787 #, c-format msgid "cannot assign to parameter `%ls' in parameter expansion" msgstr "パラメータ展開ã§ã¯ãƒ‘ラメータ「%lsã€ã«ä»£å…¥ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" #: expand.c:793 #, c-format msgid "" "the specified index does not support assignment in the parameter expansion " "of array `%ls'" msgstr "" "é…列「%lsã€ã®ãƒ‘ラメータ展開ã«ãŠã„ã¦æŒ‡å®šã•れã¦ã„るインデックスã¯ä»£å…¥ã§ãã¾ã›ã‚“" #: expand.c:833 expand.c:1052 #, c-format msgid "parameter `%ls' is not set" msgstr "パラメータ「%lsã€ã¯å­˜åœ¨ã—ã¾ã›ã‚“" #: expand.c:1048 msgid "the parameter value is empty" msgstr "パラメータã®å€¤ãŒç©ºã§ã™" #: expand.c:1051 #, c-format msgid "parameter `%ls' is not set or has an empty value" msgstr "パラメータ「%lsã€ã¯å­˜åœ¨ã—ãªã„ã‹å€¤ãŒç©ºã§ã™" #: history.c:1262 msgid "the -n or -v option must be used with the -l option" msgstr "-n ãŠã‚ˆã³ -v オプション㯠-l オプションã¨ä¸€ç·’ã«ã—ã‹ä½¿ãˆã¾ã›ã‚“" #: history.c:1268 history.c:1659 msgid "cannot be used during line-editing" msgstr "行編集中ã«ã¯ä½¿ãˆã¾ã›ã‚“" #: history.c:1284 msgid "the command history is empty" msgstr "コマンド履歴ã¯ç©ºã§ã™" #: history.c:1319 history.c:1774 #, c-format msgid "no such history entry `%ls'" msgstr "「%lsã€ã¨ã„ã†ã‚ˆã†ãªå±¥æ­´é …ç›®ã¯ã‚りã¾ã›ã‚“" #: history.c:1421 #, c-format msgid "no such history entry beginning with `%ls'" msgstr "「%lsã€ã§å§‹ã¾ã‚‹ã‚ˆã†ãªå±¥æ­´é …ç›®ã¯ã‚りã¾ã›ã‚“" #: history.c:1529 lineedit/editing.c:2671 msgid "cannot create a temporary file to edit history" msgstr "履歴を編集ã™ã‚‹ãŸã‚ã®ä¸€æ™‚ファイルを作æˆã§ãã¾ã›ã‚“" #: history.c:1534 lineedit/editing.c:2676 #, c-format msgid "cannot open temporary file `%s'" msgstr "一時ファイル「%sã€ãŒé–‹ã‘ã¾ã›ã‚“" #: history.c:1542 lineedit/editing.c:2684 msgid "cannot invoke the editor to edit history" msgstr "履歴を編集ã™ã‚‹ãŸã‚ã®ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã§ãã¾ã›ã‚“" #: history.c:1545 history.c:1571 lineedit/editing.c:2687 redir.c:793 #, c-format msgid "failed to remove temporary file `%s'" msgstr "一時ファイル「%sã€ã‚’削除ã§ãã¾ã›ã‚“ã§ã—ãŸ" #: history.c:1563 msgid "the editor returned a non-zero exit status" msgstr "エディタ㌠0 以外ã®çµ‚了ステータスを返ã—ã¾ã—ãŸ" #: history.c:1568 #, c-format msgid "cannot read commands from file `%s'" msgstr "ファイル「%sã€ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚ã¾ã›ã‚“" #: history.c:1626 msgid "list or re-execute command history" msgstr "コマンド履歴を表示ã—ãŸã‚Šã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ãŸã‚Šã™ã‚‹" #: history.c:1629 msgid "" "\tfc [-qr] [-e editor] [first [last]]\n" "\tfc -s [-q] [old=new] [first]\n" "\tfc -l [-nrv] [first [last]]\n" msgstr "" "\tfc [-qr] [-e エディタ] [始点 [終点]]\n" "\tfc -s [-q] [å…ƒ=å…ˆ] [始点]\n" "\tfc -l [-nrv] [始点 [終点]]\n" #: history.c:1820 #, c-format msgid "cannot read history from file `%ls'" msgstr "ファイル「%lsã€ã‹ã‚‰å±¥æ­´ã‚’読ã¿è¾¼ã‚ã¾ã›ã‚“" #: history.c:1854 #, c-format msgid "cannot write history to file `%ls'" msgstr "ファイル「%lsã€ã«å±¥æ­´ã‚’書ãè¾¼ã‚ã¾ã›ã‚“" #: history.c:1875 msgid "manage command history" msgstr "コマンド履歴を管ç†ã™ã‚‹" #: history.c:1878 msgid "\thistory [-cF] [-d entry] [-s command] [-r file] [-w file] [count]\n" msgstr "" "\thistory [-cF] [-d é …ç›®] [-s コマンド] [-r ファイル] [-w ファイル] [個数]\n" #: input.c:153 lineedit/lineedit.c:218 msgid "cannot read input" msgstr "入力を読ã¿è¾¼ã‚ã¾ã›ã‚“" #: input.c:254 input.c:272 input.c:281 msgid "prompt" msgstr "プロンプト" #: job.c:518 job.c:1014 job.c:1120 job.c:1273 job.c:1383 #, c-format msgid "job specification `%ls' is ambiguous" msgstr "ジョブ指定「%lsã€ã¯æ›–昧ã§ã™" #: job.c:523 job.c:1017 job.c:1125 job.c:1386 #, c-format msgid "no such job `%ls'" msgstr "「%lsã€ã«è©²å½“ã™ã‚‹ã‚¸ãƒ§ãƒ–ã¯ã‚りã¾ã›ã‚“" #: job.c:526 job.c:1127 #, c-format msgid "`%ls' is not a job-controlled job" msgstr "「%lsã€ã¯ã‚¸ãƒ§ãƒ–制御ã®å¯¾è±¡ã¨ãªã£ã¦ã„るジョブã§ã¯ã‚りã¾ã›ã‚“" #: job.c:656 job.c:699 msgid "Running" msgstr "実行中" #: job.c:659 #, c-format msgid "Stopped(SIG%ls)" msgstr "åœæ­¢ä¸­(SIG%ls)" #: job.c:670 msgid "Done" msgstr "完了 " #: job.c:673 #, c-format msgid "Done(%d)" msgstr "完了(%d) " #: job.c:681 #, c-format msgid "Killed (SIG%ls: core dumped)" msgstr "中止 (SIG%ls: コアダンプ)" #: job.c:684 #, c-format msgid "Killed (SIG%ls)" msgstr "中止 (SIG%ls)" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:744 #, c-format msgid "[%zu] %c %-20s %ls\n" msgstr "[%zu] %c %-25s %ls\n" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:763 #, c-format msgid "[%zu] %c %5jd %-20s %ls\n" msgstr "[%zu] %c %5jd %-25s %ls\n" #. TRANSLATORS: the translated format string can be different #. * from the original only in the number of spaces. This is required #. * for POSIX compliance. #: job.c:777 #, c-format msgid " %5jd %-20s | %ls\n" msgstr " %5jd %-25s | %ls\n" #: job.c:827 #, c-format msgid "The process was killed by SIG%ls: %s\n" msgstr "プロセス㯠SIG%ls ã«ã‚ˆã‚Šå¼·åˆ¶çµ‚了ã—ã¾ã—㟠(%s)\n" #: job.c:830 #, c-format msgid "The process was killed by SIG%ls\n" msgstr "プロセス㯠SIG%ls ã«ã‚ˆã‚Šå¼·åˆ¶çµ‚了ã—ã¾ã—ãŸ\n" #: job.c:1007 job.c:1113 job.c:1266 job.c:1377 #, c-format msgid "`%ls' is not a valid job specification" msgstr "「%lsã€ã¯æœ‰åйãªã‚¸ãƒ§ãƒ– ID ã§ã¯ã‚りã¾ã›ã‚“" #: job.c:1071 msgid "print info about jobs" msgstr "ã‚¸ãƒ§ãƒ–ã®æƒ…報を表示ã™ã‚‹" #: job.c:1074 msgid "\tjobs [-lnprs] [job...]\n" msgstr "\tjobs [-lnprs] [ジョブ...]\n" #: job.c:1100 msgid "job control is disabled" msgstr "ジョブコントロールã¯ç„¡åйã§ã™" #: job.c:1136 job.c:1393 msgid "there is no current job" msgstr "ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯ã‚りã¾ã›ã‚“" #: job.c:1175 #, c-format msgid "job %%%zu has already terminated" msgstr "ジョブ %%%zu ã¯æ—¢ã«çµ‚了ã—ã¦ã„ã¾ã™" #: job.c:1221 msgid "run jobs in the foreground" msgstr "ジョブをフォアグラウンドã§å®Ÿè¡Œã™ã‚‹" #: job.c:1224 msgid "\tfg [job...]\n" msgstr "\tfg [ジョブ...]\n" #: job.c:1228 msgid "run jobs in the background" msgstr "ジョブをãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã™ã‚‹" #: job.c:1231 msgid "\tbg [job...]\n" msgstr "\tbg [ジョブ...]\n" #: job.c:1340 msgid "wait for jobs to terminate" msgstr "ジョブã®çµ‚了を待ã¤" #: job.c:1343 msgid "\twait [job or process_id...]\n" msgstr "\twait [ジョブã¾ãŸã¯ãƒ—ロセス番å·...]\n" #: job.c:1403 msgid "disown jobs" msgstr "ジョブを放棄ã™ã‚‹" #: job.c:1406 msgid "" "\tdisown [job...]\n" "\tdisown -a\n" msgstr "" "\tdisown [ジョブ...]\n" "\tdisown -a\n" #: lineedit/complete.c:1514 #, c-format msgid "more than one -%lc option is specified" msgstr "-%lc ãŒäºŒå›žä»¥ä¸ŠæŒ‡å®šã•れã¦ã„ã¾ã™" #: lineedit/complete.c:1526 msgid "the complete built-in can be used during command line completion only" msgstr "complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³è£œå®Œã®æœ€ä¸­ã«ã—ã‹ä½¿ãˆã¾ã›ã‚“" #: lineedit/complete.c:1539 #, c-format msgid "the specified prefix `%ls' does not match the target word `%ls'" msgstr "指定ã•ã‚ŒãŸæŽ¥é ­è¾žã€Œ%lsã€ã¯è£œå®Œå¯¾è±¡ã€Œ%lsã€ã«é©åˆã—ã¾ã›ã‚“" #: lineedit/complete.c:1587 msgid "generate completion candidates" msgstr "補完候補を生æˆã™ã‚‹" #: lineedit/complete.c:1590 msgid "" "\tcomplete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \\\n" "\t [-abcdfghjkuv] [[-O] [-D description] words...]\n" msgstr "" "\tcomplete [-A パターン] [-R パターン] [-T] [-P 接頭辞] [-S 接尾辞] \\\n" "\t [-abcdfghjkuv] [[-O] [-D 説明] å˜èªž...]\n" #: lineedit/display.c:1346 #, c-format msgid "Candidate %zu of %zu; Page %zu of %zu" msgstr "候補 %zu/%zuã€ãƒšãƒ¼ã‚¸ %zu/%zu" #: lineedit/display.c:1362 msgid "No candidates" msgstr "候補ãªã—" #: lineedit/editing.c:2741 msgid "lineedit" msgstr "行編集" #: lineedit/keymap.c:422 msgid "option combination is invalid" msgstr "オプションã®çµ„ã¿åˆã‚ã›ãŒæ­£ã—ãã‚りã¾ã›ã‚“" #: lineedit/keymap.c:429 msgid "no option is specified" msgstr "ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã¾ã›ã‚“" #: lineedit/keymap.c:463 msgid "cannot bind an empty key sequence" msgstr "空ã®ã‚­ãƒ¼ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’割り当ã¦ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" #: lineedit/keymap.c:487 #, c-format msgid "no such editing command `%ls'" msgstr "「%lsã€ã¨ã„ã†ã‚ˆã†ãªç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚りã¾ã›ã‚“" #: lineedit/keymap.c:521 #, c-format msgid "key sequence `%ls' is not bound" msgstr "キーシーケンス「%lsã€ã«ã‚³ãƒžãƒ³ãƒ‰ã¯å‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“" #: lineedit/keymap.c:567 msgid "set or print key bindings for line-editing" msgstr "行編集ã®ã‚­ãƒ¼å‰²ã‚Šå½“ã¦ã‚’設定ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹" #: lineedit/keymap.c:570 msgid "" "\tbindkey -aev [key_sequence [command]]\n" "\tbindkey -l\n" msgstr "" "\tbindkey -aev [キーシーケンス [コマンド]]\n" "\tbindkey -l\n" #: mail.c:164 mail.c:237 msgid "You have new mail." msgstr "æ–°ç€ãƒ¡ãƒ¼ãƒ«ãŒã‚りã¾ã™ã€‚" #: option.c:394 xgetopt.c:414 #, c-format msgid "the -%lc option requires an argument" msgstr "-%lc オプションã®å¼•æ•°ãŒæŠœã‘ã¦ã„ã¾ã™" #: option.c:441 option.c:560 sig.c:1277 xgetopt.c:382 #, c-format msgid "`%ls' is not a valid option" msgstr "「%lsã€ã¯æœ‰åйãªã‚ªãƒ—ションã§ã¯ã‚りã¾ã›ã‚“" #: option.c:583 xgetopt.c:417 #, c-format msgid "the --%ls option requires an argument" msgstr "--%ls オプションã¯å¼•æ•°ã‚’å–りã¾ã›ã‚“" #: option.c:597 xgetopt.c:431 #, c-format msgid "%ls: the --%ls option does not take an argument" msgstr "%ls: --%ls オプションã¯å¼•æ•°ã‚’å–りã¾ã›ã‚“" #: option.c:606 xgetopt.c:392 #, c-format msgid "option `%ls' is ambiguous" msgstr "オプション「%lsã€ã¯æ›–昧ã§ã™" #: option.c:630 #, c-format msgid "the %ls option cannot be changed once the shell has been initialized" msgstr "シェルãŒåˆæœŸåŒ–ã•れãŸå¾Œã¯ %ls オプションを変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" #: option.c:889 msgid "on" msgstr "å…¥" #: option.c:890 msgid "off" msgstr "切" #: option.c:914 msgid "set shell options and positional parameters" msgstr "シェルオプションã¨ä½ç½®ãƒ‘ラメータを設定ã™ã‚‹" #: option.c:917 msgid "" "\tset [option...] [--] [new_positional_parameter...]\n" "\tset -o|+o # print current settings\n" msgstr "" "\tset [オプション...] [--] [æ–°ã—ã„ä½ç½®ãƒ‘ラメータ...]\n" "\tset -o|+o # ç¾åœ¨ã®è¨­å®šã‚’表示ã™ã‚‹\n" #: parser.c:589 msgid "syntax error: " msgstr "構文エラー: " #: parser.c:869 msgid "`;' or `&' is missing" msgstr "「;ã€ã¾ãŸã¯ã€Œ&ã€ãŒæŠœã‘ã¦ã„ã¾ã™" #: parser.c:1087 msgid "a command is missing at the end of input" msgstr "å…¥åŠ›ã®æœ€å¾Œã§ã‚³ãƒžãƒ³ãƒ‰ãŒæŠœã‘ã¦ã„ã¾ã™" #: parser.c:1089 #, c-format msgid "a command is missing before `%lc'" msgstr "「%lcã€ã®å‰ã«ã‚³ãƒžãƒ³ãƒ‰ãŒã‚りã¾ã›ã‚“" #: parser.c:1124 #, c-format msgid "invalid use of `%lc'" msgstr "「%lcã€ã®ä½¿ã„æ–¹ãŒæ­£ã—ãã‚りã¾ã›ã‚“" #: parser.c:1380 msgid "the redirection target is missing" msgstr "リダイレクトã®å¯¾è±¡ãŒæŠœã‘ã¦ã„ã¾ã™" #: parser.c:1387 msgid "the end-of-here-document indicator is missing" msgstr "ヒアドキュメントã®çµ‚端å­ãŒæŠœã‘ã¦ã„ã¾ã™" #: parser.c:1513 msgid "the double quotation is not closed" msgstr "二é‡å¼•用符ãŒé–‰ã˜ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“" #: parser.c:1530 msgid "the single quotation is not closed" msgstr "å˜ä¸€å¼•用符ãŒé–‰ã˜ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“" #: parser.c:1682 msgid "the parameter name is missing or invalid" msgstr "パラメータåãŒæŠœã‘ã¦ã„ã‚‹ã‹ä¸æ­£ã§ã™" #: parser.c:1694 parser.c:1699 msgid "the index is missing" msgstr "ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæŠœã‘ã¦ã„ã¾ã™" #: parser.c:1728 parser.c:1742 parser.c:1786 #, c-format msgid "invalid use of `%lc' in parameter expansion" msgstr "パラメータ展開ã«ãŠã„ã¦ã€Œ%lcã€ã®ä½¿ã„æ–¹ãŒæ­£ã—ãã‚りã¾ã›ã‚“" #: parser.c:1732 #, c-format msgid "invalid character `%lc' in parameter expansion" msgstr "パラメータ展開ã«ç„¡åŠ¹ãªæ–‡å­—「%lcã€ãŒæ··ã˜ã£ã¦ã„ã¾ã™" #: parser.c:1889 msgid "the backquoted command substitution is not closed" msgstr "「`ã€ã«ã‚ˆã‚‹ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒé–‰ã˜ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“" #: parser.c:2077 parser.c:2110 parser.c:2203 parser.c:2239 #, c-format msgid "commands are missing between `%ls' and `%ls'" msgstr "「%lsã€ã¨ã€Œ%lsã€ã®é–“ã«ã‚³ãƒžãƒ³ãƒ‰ãŒã‚りã¾ã›ã‚“" #: parser.c:2123 parser.c:2230 #, c-format msgid "commands are missing after `%ls'" msgstr "「%lsã€ã®å¾Œã«ã‚³ãƒžãƒ³ãƒ‰ãŒã‚りã¾ã›ã‚“" #: parser.c:2166 msgid "an identifier is required after `for'" msgstr "「forã€ã®å¾Œã«ã¯è­˜åˆ¥å­ãŒå¿…è¦ã§ã™" #: parser.c:2168 #, c-format msgid "`%ls' is not a valid identifier" msgstr "「%lsã€ã¯æœ‰åйãªè­˜åˆ¥å­ã§ã¯ã‚りã¾ã›ã‚“" #: parser.c:2180 msgid "redirections are not allowed after `in'" msgstr "「inã€ã®å¾Œã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯æ›¸ã‘ã¾ã›ã‚“" #: parser.c:2190 msgid "`;' is not allowed just after the identifier in a for loop" msgstr "for ループã®è­˜åˆ¥å­ã®ç›´å¾Œã«ã€Œ;ã€ã‚’ç½®ã„ã¦ã¯ã„ã‘ã¾ã›ã‚“" #: parser.c:2264 parser.c:2339 parser.c:2384 #, c-format msgid "a word is required after `%ls'" msgstr "「%lsã€ã®å¾Œã«ã¯å˜èªžãŒå¿…è¦ã§ã™" #: parser.c:2330 msgid "an unquoted `esac' cannot be the first case pattern" msgstr "クォートã—ã¦ã„ãªã„「esacã€ã‚’最åˆã®ãƒ‘ターンã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" #: parser.c:2342 #, c-format msgid "encountered an invalid character `%lc' in the case pattern" msgstr "case ã®ãƒ‘ターン内ã«ä¸æ­£ãªæ–‡å­—「%lcã€ãŒã‚りã¾ã™" #: parser.c:2370 parser.c:2688 parser.c:2691 #, c-format msgid "`%ls' cannot be used as a command name" msgstr "「%lsã€ã¯ã‚³ãƒžãƒ³ãƒ‰åã¨ã—ã¦ä½¿ãˆã¾ã›ã‚“" #: parser.c:2402 parser.c:2443 msgid "a function body must be a compound command" msgstr "é–¢æ•°ã®æœ¬ä½“ã¯è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“" #: parser.c:2434 msgid "`(' must be followed by `)' in a function definition" msgstr "関数定義ã§ã¯ã€Œ(ã€ã®ç›´å¾Œã«ã€Œ)ã€ãŒå¿…è¦ã§ã™" #: parser.c:2471 msgid "the end-of-here-document indicator contains a newline" msgstr "ヒアドキュメントã®çµ‚端å­ã«æ”¹è¡ŒãŒå…¥ã£ã¦ã„ã¾ã™" #: parser.c:2679 #, c-format msgid "encountered `%ls' without a matching `('" msgstr "「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œ(ã€ãŒã‚りã¾ã›ã‚“" #: parser.c:2682 #, c-format msgid "encountered `%ls' without a matching `{'" msgstr "「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œ{ã€ãŒã‚りã¾ã›ã‚“" #: parser.c:2685 #, c-format msgid "`%ls' is used outside `case'" msgstr "「%lsã€ãŒ case コマンドã®å¤–ã§ä½¿ã‚れã¦ã„ã¾ã™" #: parser.c:2694 parser.c:2715 #, c-format msgid "encountered `%ls' without a matching `if' and/or `then'" msgstr "「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œifã€ã¾ãŸã¯ã€Œthenã€ãŒã‚りã¾ã›ã‚“" #: parser.c:2698 #, c-format msgid "encountered `%ls' without a matching `if' or `elif'" msgstr "「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œifã€ã¾ãŸã¯ã€Œelifã€ãŒã‚りã¾ã›ã‚“" #: parser.c:2703 #, c-format msgid "encountered `%ls' without a matching `for', `while', or `until'" msgstr "「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œforã€ã€Œwhileã€ã¾ãŸã¯ã€Œuntilã€ãŒã‚りã¾ã›ã‚“" #: parser.c:2707 #, c-format msgid "encountered `%ls' without a matching `do'" msgstr "「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œdoã€ãŒã‚りã¾ã›ã‚“" #: parser.c:2712 #, c-format msgid "encountered `%ls' without a matching `case'" msgstr "「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œcaseã€ãŒã‚りã¾ã›ã‚“" #: parser.c:2728 #, c-format msgid "(maybe you missed `%ls'?)" msgstr "(「%lsã€ã‚’忘れã¦ã„ã¾ã›ã‚“ã‹?)" #: path.c:1090 msgid "$HOME is not set" msgstr "$HOME ãŒè¨­å®šã•れã¦ã„ã¾ã›ã‚“" #: path.c:1099 variable.c:2864 msgid "$OLDPWD is not set" msgstr "$OLDPWD ãŒè¨­å®šã•れã¦ã„ã¾ã›ã‚“" #: path.c:1129 msgid "$PWD has an invalid value" msgstr "$PWD ã®å€¤ãŒæ­£ã—ãã‚りã¾ã›ã‚“" #: path.c:1138 path.c:1149 path.c:1365 msgid "cannot determine the current directory" msgstr "ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒåˆ†ã‹ã‚Šã¾ã›ã‚“" #: path.c:1221 #, c-format msgid "`%ls'" msgstr "「%lsã€" #: path.c:1252 #, c-format msgid "`%s'" msgstr "「%sã€" #: path.c:1316 msgid "change the working directory" msgstr "作業ディレクトリを変更ã™ã‚‹" #: path.c:1319 msgid "\tcd [-L|-P] [directory]\n" msgstr "\tcd [-L|-P] [ディレクトリ]\n" #: path.c:1377 msgid "print the working directory" msgstr "作業ディレクトリを表示ã™ã‚‹" #: path.c:1380 msgid "\tpwd [-L|-P]\n" msgstr "\tpwd [-L|-P]\n" #: path.c:1435 #, c-format msgid "no such user `%ls'" msgstr "「%lsã€ã¨ã„ã†ãƒ¦ãƒ¼ã‚¶ã¯å­˜åœ¨ã—ã¾ã›ã‚“" #: path.c:1457 #, c-format msgid "`%ls': a command name must not contain `/'" msgstr "「%lsã€: コマンドåã« / ã‚’å«ã‚ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" #: path.c:1465 #, c-format msgid "command `%s' was not found in $PATH" msgstr "コマンド「%sã€ã¯ $PATH ã®ä¸­ã«è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸ" #: path.c:1511 msgid "remember, forget, or report command locations" msgstr "コマンドã®ãƒ‘スã®ã‚­ãƒ£ãƒƒã‚·ãƒ¥ãƒ‡ãƒ¼ã‚¿ã‚’登録・消去・表示ã™ã‚‹" #: path.c:1514 msgid "" "\thash command...\n" "\thash -r [command...]\n" "\thash [-a] # print remembered paths\n" "\thash -d user...\n" "\thash -d -r [user...]\n" "\thash -d # print remembered paths\n" msgstr "" "\thash コマンド...\n" "\thash -r [コマンド...]\n" "\thash [-a] # 記憶ã—ãŸãƒ‘スを表示ã™ã‚‹\n" "\thash -d ユーザ...\n" "\thash -d -r [ユーザ...]\n" "\thash -d # 記憶ã—ãŸãƒ‘スを表示ã™ã‚‹\n" #: path.c:1621 path.c:1704 #, c-format msgid "`%ls' is not a valid mask specification" msgstr "「%lsã€ã¯æœ‰åйãªãƒžã‚¹ã‚¯è¨­å®šã§ã¯ã‚りã¾ã›ã‚“" #: path.c:1731 msgid "print or set the file creation mask" msgstr "ファイル作æˆãƒžã‚¹ã‚¯ã‚’表示ã¾ãŸã¯è¨­å®šã™ã‚‹" #: path.c:1734 msgid "" "\tumask mode\n" "\tumask [-S]\n" msgstr "" "\tumask モード\n" "\tumask [-S]\n" #: redir.c:70 #, c-format msgid "error in closing file descriptor %d" msgstr "ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã‚’é–‰ã˜ã‚‹éš›ã«ã‚¨ãƒ©ãƒ¼" #: redir.c:91 #, c-format msgid "cannot copy file descriptor %d to %d" msgstr "ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã‚’ %d ã«ã‚³ãƒ”ーã§ãã¾ã›ã‚“" #: redir.c:280 msgid "disabling job control" msgstr "ジョブ制御ã¯ç„¡åйã«ãªã‚Šã¾ã™" #: redir.c:328 msgid "redirection: invalid file descriptor" msgstr "リダイレクト: 無効ãªãƒ•ァイル記述å­ã§ã™" #: redir.c:331 redir.c:607 redir.c:679 #, c-format msgid "redirection: file descriptor %d is unavailable" msgstr "リダイレクト: ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã¯ä½¿ãˆã¾ã›ã‚“" #: redir.c:379 #, c-format msgid "redirection: cannot open file `%s'" msgstr "リダイレクト: ファイル「%sã€ã‚’é–‹ã‘ã¾ã›ã‚“" #: redir.c:467 #, c-format msgid "cannot save file descriptor %d" msgstr "ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã‚’ä¿å­˜ã§ãã¾ã›ã‚“" #: redir.c:557 #, c-format msgid "socket redirection: cannot resolve the address of `%s': %s" msgstr "ソケットリダイレクト:「%sã€ã®ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’解決ã§ãã¾ã›ã‚“: %s" #: redir.c:601 redir.c:616 redir.c:671 #, c-format msgid "redirection: %s" msgstr "リダイレクト: %s" #: redir.c:624 #, c-format msgid "redirection: file descriptor %d is not readable" msgstr "リダイレクト: ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ã¯ã‚りã¾ã›ã‚“" #: redir.c:636 #, c-format msgid "redirection: file descriptor %d is not writable" msgstr "リダイレクト: ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã¯æ›¸ãè¾¼ã¿å¯èƒ½ã§ã¯ã‚りã¾ã›ã‚“" #: redir.c:674 #, c-format msgid "redirection: %d>>|%d: the input and output file descriptors are same" msgstr "リダイレクト: %d>>|%d: 入力å´ã¨å‡ºåŠ›å´ã®ãƒ•ァイル記述å­ãŒåŒã˜ã§ã™" #: redir.c:718 #, c-format msgid "redirection: %d>>|%d" msgstr "リダイレクト: %d>>|%d" #: redir.c:735 redir.c:775 redir.c:796 msgid "cannot write the here-document contents to the temporary file" msgstr "ヒアドキュメントã®å†…å®¹ã‚’ä¸€æ™‚ãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ã出ã›ã¾ã›ã‚“" #: redir.c:788 msgid "cannot create a temporary file for the here-document" msgstr "ヒアドキュメント用ã®ä¸€æ™‚ファイルを作æˆã§ãã¾ã›ã‚“" #: redir.c:801 msgid "cannot seek the temporary file for the here-document" msgstr "ヒアドキュメント用ã®ä¸€æ™‚ファイルã®ã‚·ãƒ¼ã‚¯ãŒã§ãã¾ã›ã‚“" #: redir.c:815 msgid "redirection: cannot open a pipe for the command redirection" msgstr "リダイレクト: コマンド置æ›ç”¨ã®ãƒ‘イプを開ã‘ã¾ã›ã‚“" #: redir.c:854 msgid "command redirection" msgstr "コマンド置æ›" #: sig.c:481 msgid "cannot send SIGSTOP signal" msgstr "SIGSTOP シグナルをé€ä¿¡ã§ãã¾ã›ã‚“" #: sig.c:581 msgid "too many files are opened for yash to handle" msgstr "é–‹ã„ãŸãƒ•ã‚¡ã‚¤ãƒ«ã®æ•°ãŒå¤šã™ãŽã¦å‡¦ç†ã—ãれã¾ã›ã‚“" #: sig.c:780 #, c-format msgid "SIG%ls cannot be trapped" msgstr "SIG%ls ã¯ãƒˆãƒ©ãƒƒãƒ—ã§ãã¾ã›ã‚“" #: sig.c:795 #, c-format msgid "real-time signal SIG%ls is not supported" msgstr "リアルタイムシグナル SIG%ls ã«ã¯å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“" #: sig.c:811 #, c-format msgid "SIG%ls cannot be reset" msgstr "SIG%ls ã¯ãƒªã‚»ãƒƒãƒˆã§ãã¾ã›ã‚“" #: sig.c:1128 sig.c:1169 sig.c:1247 sig.c:1312 #, c-format msgid "no such signal `%ls'" msgstr "「%lsã€ã¨ã„ã†ã‚ˆã†ãªã‚·ã‚°ãƒŠãƒ«ã¯ã‚りã¾ã›ã‚“" #: sig.c:1198 msgid "set or print signal handlers" msgstr "シグナルãƒãƒ³ãƒ‰ãƒ©ã‚’設定ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹" #: sig.c:1201 msgid "" "\ttrap [action signal...]\n" "\ttrap signal_number [signal...]\n" "\ttrap -p [signal...]\n" msgstr "" "\ttrap [動作 シグナル...]\n" "\ttrap ã‚·ã‚°ãƒŠãƒ«ç•ªå· [シグナル...]\n" "\ttrap -p [シグナル...]\n" #: sig.c:1235 msgid "the signal name is not specified" msgstr "シグナルåãŒæŒ‡å®šã•れã¦ã„ã¾ã›ã‚“" #: sig.c:1241 #, c-format msgid "%ls: the signal name must be specified without `SIG'" msgstr "%ls: シグナルåã¯ã€ŒSIGã€ã‚’付ã‘ãšã«æŒ‡å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™" #: sig.c:1381 msgid "send a signal to processes" msgstr "プロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹" #: sig.c:1384 msgid "" "\tkill [-signal|-s signal|-n number] process...\n" "\tkill -l [-v] [number...]\n" msgstr "" "\tkill [-シグナル|-s シグナル|-n シグナル番å·] プロセス...\n" "\tkill -l [-v] [æ•°...]\n" #: util.c:269 msgid "unknown error" msgstr "䏿˜Žãªã‚¨ãƒ©ãƒ¼" #: variable.c:367 variable.c:372 msgid "failed to set $PWD" msgstr "$PWD ã®è¨­å®šã«å¤±æ•—ã—ã¾ã—ãŸ" #: variable.c:396 #, c-format msgid "no such array $%ls" msgstr "$%ls ã¨ã„ã†ã‚ˆã†ãªé…列ã¯ã‚りã¾ã›ã‚“" #: variable.c:399 variable.c:601 variable.c:1688 variable.c:2293 #: variable.c:2910 #, c-format msgid "$%ls is read-only" msgstr "$%ls ã¯èª­ã¿è¾¼ã¿å°‚用ã§ã™" #: variable.c:416 #, c-format msgid "failed to unset environment variable $%s" msgstr "環境変数 $%s ã®å‰Šé™¤ã«å¤±æ•—ã—ã¾ã—ãŸ" #: variable.c:420 #, c-format msgid "failed to set environment variable $%s" msgstr "環境変数 $%s ã®è¨­å®šã«å¤±æ•—ã—ã¾ã—ãŸ" #: variable.c:695 #, c-format msgid "index %zu is out of range (the actual size of array $%ls is %zu)" msgstr "インデックス %zu ã¯ç¯„囲外ã§ã™ (é…列 $%ls ã®ã‚µã‚¤ã‚ºã¯ %zu ã§ã™)" #: variable.c:1238 #, c-format msgid "function `%ls' cannot be redefined because it is read-only" msgstr "関数「%lsã€ã¯èª­ã¿è¾¼ã¿å°‚用ãªã®ã§å†å®šç¾©ã§ãã¾ã›ã‚“" #: variable.c:1418 variable.c:2996 msgid "the directory stack is empty" msgstr "ディレクトリスタックã¯ç©ºã§ã™" #: variable.c:1456 variable.c:2848 variable.c:3092 msgid "$PWD is not set" msgstr "$PWD ãŒè¨­å®šã•れã¦ã„ã¾ã›ã‚“" #: variable.c:1468 #, c-format msgid "index %ls is out of range" msgstr "インデックス %ls ã¯ç¯„囲外ã§ã™" #: variable.c:1712 #, c-format msgid "no such variable $%ls" msgstr "$%ls ã¨ã„ã†ã‚ˆã†ãªå¤‰æ•°ã¯ã‚りã¾ã›ã‚“" #: variable.c:1724 #, c-format msgid "no such function `%ls'" msgstr "「%lsã€ã¨ã„ã†ã‚ˆã†ãªé–¢æ•°ã¯ã‚りã¾ã›ã‚“" #: variable.c:1912 msgid "set or print variables" msgstr "変数を設定ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹" #: variable.c:1915 msgid "\ttypeset [-fgprxX] [name[=value]...]\n" msgstr "\ttypeset [-fgprxX] [åå‰[=値]...]\n" #: variable.c:1918 msgid "export variables as environment variables" msgstr "変数を環境変数ã¨ã—ã¦ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã™ã‚‹" #: variable.c:1921 msgid "\texport [-prX] [name[=value]...]\n" msgstr "\texport [-prX] [åå‰[=値]...]\n" #: variable.c:1924 msgid "make variables read-only" msgstr "変数を読ã¿è¾¼ã¿å°‚用ã«ã™ã‚‹" #: variable.c:1927 msgid "\treadonly [-fpxX] [name[=value]...]\n" msgstr "\treadonly [-fpxX] [åå‰[=値]...]\n" #: variable.c:1975 msgid "more than one option cannot be used at once" msgstr "二ã¤ä»¥ä¸Šã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«ä½¿ã†ã“ã¨ã¯ã§ãã¾ã›ã‚“" #: variable.c:1994 #, c-format msgid "`%ls' is not a valid array name" msgstr "「%lsã€ã¯æœ‰åйãªé…列åã§ã¯ã‚りã¾ã›ã‚“" #: variable.c:2186 #, c-format msgid "index %ls is out of range (the actual size of array $%ls is %zu)" msgstr "インデックス %ls ã¯ç¯„囲外ã§ã™ (é…列 $%ls ã®ã‚µã‚¤ã‚ºã¯ %zu ã§ã™)" #: variable.c:2193 msgid "manipulate an array" msgstr "é…列をæ“作ã™ã‚‹" #: variable.c:2196 msgid "" "\tarray # print arrays\n" "\tarray name [value...] # set array values\n" "\tarray -d name [index...]\n" "\tarray -i name index [value...]\n" "\tarray -s name index value\n" msgstr "" "\tarray # é…列ã®ä¸€è¦§ã‚’表示ã™ã‚‹\n" "\tarray åå‰ [値...] # é…列ã«å€¤ã‚’設定ã™ã‚‹\n" "\tarray -d åå‰ [インデックス...]\n" "\tarray -i åå‰ ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ [値...]\n" "\tarray -s åå‰ ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ 値\n" #: variable.c:2247 variable.c:2411 variable.c:2619 #, c-format msgid "`%ls' is not a valid variable name" msgstr "「%lsã€ã¯æœ‰åйãªå¤‰æ•°åã§ã¯ã‚りã¾ã›ã‚“" #: variable.c:2268 #, c-format msgid "function `%ls' is read-only" msgstr "関数「%lsã€ã¯èª­ã¿è¾¼ã¿å°‚用ã§ã™" #: variable.c:2304 msgid "remove variables or functions" msgstr "変数ã¾ãŸã¯é–¢æ•°ã‚’削除ã™ã‚‹" #: variable.c:2307 msgid "\tunset [-fv] [name...]\n" msgstr "\tunset [-fv] åå‰...\n" #: variable.c:2337 #, c-format msgid "%ls: the operand value must not be negative" msgstr "%ls: è² ã§ãªã„オペランドã®å€¤ã‚’指定ã—ã¦ãã ã•ã„" #: variable.c:2355 #, c-format msgid "%zu: cannot shift so many (there is only one positional parameter)" msgid_plural "" "%zu: cannot shift so many (there are only %zu positional parameters)" msgstr[0] "" "%zu: シフトã™ã‚‹æ•°ãŒå¤šã™ãŽã¾ã™ (ä½ç½®ãƒ‘ラメータ㯠%zu 個ã—ã‹ã‚りã¾ã›ã‚“)" #: variable.c:2377 msgid "remove some positional parameters" msgstr "ä½ç½®ãƒ‘ラメータã®ä¸€éƒ¨ã‚’削除ã™ã‚‹" #: variable.c:2380 msgid "\tshift [count]\n" msgstr "\tshift [個数]\n" #: variable.c:2414 #, c-format msgid "`%ls' is not a valid option specification" msgstr "「%lsã€ã¯æœ‰åйãªã‚ªãƒ—ション指定文字列ã§ã¯ã‚りã¾ã›ã‚“" #: variable.c:2472 #, c-format msgid "%ls: `-%lc' is not a valid option\n" msgstr "%ls: 「%lcã€ã¯æœ‰åйãªã‚ªãƒ—ションã§ã¯ã‚りã¾ã›ã‚“\n" #: variable.c:2495 #, c-format msgid "%ls: the -%lc option's argument is missing\n" msgstr "%ls: -%lc オプションã®å¼•æ•°ãŒæŠœã‘ã¦ã„ã¾ã™\n" #: variable.c:2518 msgid "$OPTIND has an invalid value" msgstr "$OPTIND ã®å€¤ãŒæ­£ã—ãã‚りã¾ã›ã‚“" #: variable.c:2573 msgid "parse command options" msgstr "コマンドã®ã‚ªãƒ—ションを解æžã™ã‚‹" #: variable.c:2576 msgid "\tgetopts options variable [argument...]\n" msgstr "\tgetopts オプション 変数å [引数...]\n" #: variable.c:2779 msgid "read a line from the standard input" msgstr "標準入力ã‹ã‚‰è¡Œã‚’読ã¿è¾¼ã‚€" #: variable.c:2782 msgid "\tread [-Ar] variable...\n" msgstr "\tread [-Ar] 変数å...\n" #: variable.c:2907 msgid "$DIRSTACK is not an array" msgstr "$DIRSTACK ã¯é…列ã§ã¯ã‚りã¾ã›ã‚“" #: variable.c:2962 msgid "push a directory into the directory stack" msgstr "ディレクトリスタックã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’追加ã™ã‚‹" #: variable.c:2965 msgid "\tpushd [-L|-P] [directory]\n" msgstr "\tpushd [-L|-P] [ディレクトリ]\n" #: variable.c:3005 variable.c:3081 #, c-format msgid "`%ls' is not a valid index" msgstr "「%lsã€ã¯æœ‰åйãªã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã¯ã‚りã¾ã›ã‚“" #: variable.c:3028 msgid "pop a directory from the directory stack" msgstr "ディレクトリスタックã‹ã‚‰ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’削除ã™ã‚‹" #: variable.c:3031 msgid "\tpopd [index]\n" msgstr "\tpopd [インデックス]\n" #: variable.c:3119 msgid "print the directory stack" msgstr "ディレクトリスタックを表示ã™ã‚‹" #: variable.c:3122 msgid "\tdirs [-cv] [index...]\n" msgstr "\tdirs [-cv] [インデックス...]\n" #: yash.c:111 #, c-format msgid "%s: cannot convert the argument `%s' into a wide character string" msgstr "%s: 引数「%sã€ã‚’ワイド文字列ã«å¤‰æ›ã§ãã¾ã›ã‚“" #: yash.c:115 #, c-format msgid "%s: the argument is replaced with an empty string\n" msgstr "%s: 引数ã¯ç©ºæ–‡å­—列ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™\n" #: yash.c:180 msgid "the -c option is specified but no command is given" msgstr "-c ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã¾ã™ãŒã‚³ãƒžãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã¾ã›ã‚“" #: yash.c:353 #, c-format msgid "" "Syntax:\n" "\t%s [option...] [filename [argument...]]\n" "\t%s [option...] -c command [command_name [argument...]]\n" "\t%s [option...] -s [argument...]\n" msgstr "" "æ§‹æ–‡:\n" "\t%s [オプション...] [ファイルå [引数...]]\n" "\t%s [オプション...] -c コマンド [コマンドå [引数...]]\n" "\t%s [オプション...] -s [引数...]\n" #: yash.c:370 #, c-format msgid "Yet another shell, version %s\n" msgstr "Yet another shell ãƒãƒ¼ã‚¸ãƒ§ãƒ³ %s\n" #: yash.c:372 msgid "" "This is free software licensed under GNU GPL version 2.\n" "You can modify and redistribute it, but there is NO WARRANTY.\n" msgstr "" "ã“ã®ã‚½ãƒ•ト㯠GNU GPL ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 2 ã§ãƒ©ã‚¤ã‚»ãƒ³ã‚¹ã•れãŸãƒ•リーソフトウェアã§" "ã™ã€‚\n" "自由ã«å¤‰æ›´ãƒ»å†é ’布ãŒã§ãã¾ã™ãŒã€ã‚½ãƒ•トã®å‹•作ã«ä¿è¨¼ã¯ã‚りã¾ã›ã‚“。\n" #: yash.c:376 msgid "" "\n" "Enabled features:\n" msgstr "" "\n" "æœ‰åŠ¹ãªæ©Ÿèƒ½:\n" #: yash.c:525 msgid "Use `exit' to leave the shell.\n" msgstr "シェルを終了ã™ã‚‹ã«ã¯ã€Œexitã€ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ãã ã•ã„。\n" #: yash.c:602 msgid " Use `exit' again to exit anyway.\n" msgstr " ãれã§ã‚‚終了ã™ã‚‹ã«ã¯ã‚‚ã†ä¸€åº¦ã€Œexitã€ã—ã¦ãã ã•ã„。\n" #: yash.c:624 msgid "exit the shell" msgstr "シェルを終了ã™ã‚‹" #: yash.c:627 msgid "\texit [-f] [exit_status]\n" msgstr "\texit [-f] [終了ステータス]\n" #: yash.c:657 msgid "" "refusing to suspend because of a possible deadlock.\n" "Use the -f option to suspend anyway." msgstr "" "ãƒ‡ãƒƒãƒ‰ãƒ­ãƒƒã‚¯ã®æã‚ŒãŒã‚ã‚‹ãŸã‚サスペンドã—ã¾ã›ã‚“ã§ã—ãŸã€‚\n" "本当ã«ã‚µã‚¹ãƒšãƒ³ãƒ‰ã™ã‚‹ã«ã¯ -f オプションを付ã‘ã¦ãã ã•ã„。" #: yash.c:671 msgid "suspend the shell" msgstr "ã‚·ã‚§ãƒ«ã‚’åœæ­¢ã™ã‚‹" #: yash.c:674 msgid "\tsuspend [-f]\n" msgstr "\tsuspend [-f]\n" yash-2.35/po/ja.mo0000644000175000017500000011116412154557026014117 0ustar magicantmagicantÞ•\ü ÓÜ() FP§p 3&ZtK}ÙWw¬¿.Ù !" D `L ­ (» –ä {!C!Ô!Ií!7"F"a" }"‹"$¤"É"Yå"?#O#!^#€#Nˆ#×#Þ#%ð#;$R$k$‰$¡$¿$Ó$#ë$$%4%F%`%q%„%¡%»%"Ë%î%&+&/I&+y&4¥&Ú&,ê&'5'R'j'!‰'A«'2í' (‡=(Å( ß(ì(%ÿ(%)*)3)C) `) n)x)€)—)°)ŠÀ) K*!W*%y*vŸ*+3+S+2r+¥+¸+Ì+)ç+,&,>,O,!n,,®,Î,î,-)-&F-'m-•-±-Ï-)ë-".8.*U.€.4….:º.õ.( /!4/*V///±/$Ð/%õ/303O0ƒ0' 0È0%ç0 1*1+E1.q17 1"Ø1&û1!"2$D24i2.ž2&Í2ô2 3:13l30…3(¶3ß3û3/4>4T4t4#Œ4#°4#Ô4ø4 54)5^5"y5=œ5Ú5#÷56/6 D6,e6’6¢6º6Õ6í6 7 7727(L7+u7)¡7?Ë77 83C8(w8: 8#Û8!ÿ8!9A9 _9k9)z9$¤9É9&Ü9:(: D:)e: :š:)­::×:;.;M;`;@z;@»;.ü;++<W<+l< ˜<¹<$Ñ<ö<="=B=Y=r=‰==¦=¶=&Ñ=+ø=$>;>R>f>y>>¥>Ã>Ú>*ö>!?3?H?[? q??“?—? š?¥?¿?Ý?0ø?)@?@(O@x@@¦@¶@#Ì@ð@ A &AGA)NA xA#™A½A(ÐA ùABDB_B;oB"«B/ÎB/þB..C$]C'‚CXªC-D!1DSD2qD¤D ¿DàDûDE"1E*TEEœE+³E:ßEF.F@FDOF3”F$ÈF%íF3G2GG3zG1®GàGEýG#CHgH"„H*§H5ÒH-I6IKIgI(†I¯I!ÌI îI"J+2JY^J?¸JøJCK,TKK¡K²K ÃK ÑKÛKêK“L"™M ¼MÆMêæMÑNAåN'O!BOSdO‰¸O BP$cP"ˆP«PÁP3ÙP# Q!1QSQm[QÉQ/ÝQÀ R!ÎRZðRKScjSÎSêS$T (T6T$PT%uTp›T UU,U@UeHU®UµU%ÌU<òU/VMVmV0…V¶VÉVKáVO-W }W(žW$ÇW&ìW)X&=X#dX?ˆXÈX$äX8 Y5BYAxYPºY Z>Z(VZ#Z £ZÄZáZ?[5A['w[aŸ['\ )\16\"h\ ‹\ •\£\"µ\ Ø\å\ ÷\%]%']M]®_] ^9^>T^Γ^b_Sz_%Î_-ô_!"`D`X`9s` ­`3·`ë`0 aT;a0a<Áa3þa32b<fb0£b7Ôb9 c0Fc3wc9«cHåc3.d<bdDŸdäd;ídJ)e,te3¡e0ÕeBf9If*ƒf*®f-Ùf^gIfg,°g=Ýg&h>Bhh/¡h2ÑhPiZUi!°i$ÒiT÷i;LjHˆjHÑj6k,Qk1~kA°k$òkYlBql'´lÜl9øl&2m,Ym†m$¥m>Êm9 nCn1bnN”n,ãn6oNGo'–oE¾opp0*p<[p˜p3´p3èp-q'Jqrq‹q›q·q1Óq4r2:rRmrEÀrEs1LsA~s4Àsõs*t*9tdtzt6“t;Êt#u/*u*Zu/…uBµuKøu3Dv3xvK¬vEøv*>wiw…w)¡wRËwRxHqx<ºx0÷xQ(y.zy*©y'ÔyQüy NzKXz3¤z$Øz!ýz{15{3g{3›{,Ï{Hü{<E|-‚|3°|/ä|B}8W}?}3Ð}9~<>~3{~9¯~0é~/'J*r¡3¥'Ù<€->€<l€-©€3×€E Q$r—!­9Ï- ‚'7‚0_‚‚B ‚3ã‚$ƒ3<ƒDpƒµƒȃYäƒ>„GU„:„WØ„W0…?ˆ…8È…5†¤7†Q܆-.‡$\‡9‡3»‡'ï‡3ˆ3Kˆ$ˆ3¤ˆ<؈6‰$L‰?q‰R±‰3Š8ŠQŠ_cŠJÊ2‹0A‹Vr‹ZÉ‹V$Œ@{Œ¼Œ]ÛŒ$9*^-‰B·Bú9=Ž'wŽ0ŸŽ?ÐŽ3!D0f-—-ÅKór?N²$‘1&‘BX‘'›‘'Ñë‘’ ’3$’X’GèаªE!ßÈ 15qPÃJ8Sæ úå8î5XBëÎ.D$g1¯OJ=Õ¹”Ù:á,¥XÄ&Š(·­M¶–&§âÁ‚H4`lØtyTÇÞiWH ÊPRÓ®2<jS‰Aó2•¡Œ¿ÉCíäañ×~ü çNÿWLRo7™*3Zê> û¤ºN?4I'"#_9;9ýwÀ>eŲ¬þ’-/Í»C fx=飄¢›-U˜%‡0h³Æ7;Úd'Mp!vŸLËFƒ3“YÛõ†.ïœV6{Â|÷ $TÏA€?%r+Ž Üö\ ½«¼@*¨:"ã©‘D<b[E,QøÒàì(sUðˆz)K ^ÖVBOI¾ùYš ´¸cG/ ž6[òÔ±µ]KÌô—F)¦u‹… \n0Ñ#Q+@Z}Ýkm . [-AL] file [argument...] : [...] alias [-gp] [name[=value]...] array # print arrays array name [value...] # set array values array -d name [index...] array -i name index [value...] array -s name index value bg [job...] bindkey -aev [key_sequence [command]] bindkey -l break [count] break -i cd [-L|-P] [directory] command [-befp] command [argument...] command -v|-V [-abefkp] command... complete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \ [-abcdfghjkuv] [[-O] [-D description] words...] continue [count] continue -i dirs [-cv] [index...] disown [job...] disown -a echo [string...] eval [-i] [argument...] exec [-cf] [-a name] [command [argument...]] exit [-f] [exit_status] export [-prX] [name[=value]...] false fc [-qr] [-e editor] [first [last]] fc -s [-q] [old=new] [first] fc -l [-nrv] [first [last]] fg [job...] getopts options variable [argument...] hash command... hash -r [command...] hash [-a] # print remembered paths hash -d user... hash -d -r [user...] hash -d # print remembered paths help [built-in...] history [-cF] [-d entry] [-s command] [-r file] [-w file] [count] jobs [-lnprs] [job...] kill [-signal|-s signal|-n number] process... kill -l [-v] [number...] popd [index] printf format [value...] pushd [-L|-P] [directory] pwd [-L|-P] read [-Ar] variable... readonly [-fpxX] [name[=value]...] return [-n] [exit_status] set [option...] [--] [new_positional_parameter...] set -o|+o # print current settings shift [count] suspend [-f] test expression [ expression ] times trap [action signal...] trap signal_number [signal...] trap -p [signal...] true type command... typeset [-fgprxX] [name[=value]...] ulimit -a [-H|-S] ulimit [-H|-S] [-efilnqrstuvx] [limit] umask mode umask [-S] unalias name... unalias -a unset [-fv] [name...] wait [job or process_id...] Enabled features: %5jd %-20s | %ls Use `exit' again to exit anyway. Use the -f option to exec anyway. $%ls is read-only$DIRSTACK is not an array$HOME is not set$OLDPWD is not set$OPTIND has an invalid value$PWD has an invalid value$PWD is not set%ls: `-%lc' is not a valid option %ls: a shell keyword %ls: an alias for `%ls' %ls: the -%lc option's argument is missing %ls: the --%ls option does not take an argument%ls: the operand value must not be negative%ls: the signal name must be specified without `SIG'%s: a function %s: a regular built-in (not found in $PATH) %s: a regular built-in at %s %s: a semi-special built-in %s: a special built-in %s: an external command at %s %s: an external command at %s/%s %s: cannot convert the argument `%s' into a wide character string%s: the argument is replaced with an empty string %u is not a positive integer%zu: cannot shift so many (there is only one positional parameter)%zu: cannot shift so many (there are only %zu positional parameters)(maybe you missed `%ls'?)-%lc: %-30s CPU time (seconds)Candidate %zu of %zu; Page %zu of %zuDoneDone(%d)Killed (SIG%ls)Killed (SIG%ls: core dumped)No candidatesOptions: RunningSIG%ls cannot be resetSIG%ls cannot be trappedStopped(SIG%ls)Syntax: %s [option...] [filename [argument...]] %s [option...] -c command [command_name [argument...]] %s [option...] -s [argument...] Syntax: %s The process was killed by SIG%ls The process was killed by SIG%ls: %s This is free software licensed under GNU GPL version 2. You can modify and redistribute it, but there is NO WARRANTY. Try `man yash' for details. Use `exit' to leave the shell. Yet another shell, version %s You have a stopped job!You have %zu stopped jobs!You have new mail.[%zu] %c %-20s %ls [%zu] %c %5jd %-20s %ls `%lc' is not a valid conversion specifier`%ls'`%ls' cannot be used as a command name`%ls' is missing`%ls' is not a binary operator`%ls' is not a job-controlled job`%ls' is not a unary operator`%ls' is not a valid alias name`%ls' is not a valid array name`%ls' is not a valid identifier`%ls' is not a valid index`%ls' is not a valid integer`%ls' is not a valid job specification`%ls' is not a valid mask specification`%ls' is not a valid number`%ls' is not a valid operator`%ls' is not a valid option`%ls' is not a valid option specification`%ls' is not a valid variable name`%ls' is used outside `case'`%ls': a command name must not contain `/'`%s'`(' must be followed by `)' in a function definition`;' is not allowed just after the identifier in a for loop`;' or `&' is missinga command is missing at the end of inputa command is missing before `%lc'a function body must be a compound commanda nested parameter expansion cannot be assigneda word is required after `%ls'an expression is missing after `%ls'an identifier is required after `for'an unquoted `esac' cannot be the first case patternarithmetic: `%lc' is not a valid number or operatorarithmetic: `%ls' is missingarithmetic: `%ls' is not a valid numberarithmetic: a value is missingarithmetic: cannot assign to a numberarithmetic: division by zeroarithmetic: invalid syntaxarithmetic: operator `%ls' is not supportedarithmetic: operator `%ls' requires a variablecannot assign to parameter `%ls' in parameter expansioncannot be used during line-editingcannot be used in the interactive modecannot bind an empty key sequencecannot copy file descriptor %d to %dcannot create a temporary file for the here-documentcannot create a temporary file to edit historycannot determine the current directorycannot execute command `%s'cannot execute command `%s' (%s)cannot get the current limit for the resource type of `%s'cannot get the time datacannot invoke a new shell to execute script `%s'cannot invoke the editor to edit historycannot make a child processcannot open a pipecannot open a pipe for the command substitutioncannot open file `%s'cannot open temporary file `%s'cannot parse the formatcannot print to the standard outputcannot read commands from file `%s'cannot read history from file `%ls'cannot read inputcannot save file descriptor %dcannot seek the temporary file for the here-documentcannot send SIGSTOP signalcannot write history to file `%ls'cannot write the here-document contents to the temporary filechange the working directorycommand `%s' was not found in $PATHcommand redirectioncommand substitutioncommands are missing after `%ls'commands are missing between `%ls' and `%ls'continue a loopcore file size (blocks)data segment size (kbytes)define or print aliasesdisabling job controldisown jobsdo nothingdo nothing successfullydo nothing unsuccessfullyencountered `%ls' without a matching `('encountered `%ls' without a matching `case'encountered `%ls' without a matching `do'encountered `%ls' without a matching `for', `while', or `until'encountered `%ls' without a matching `if' and/or `then'encountered `%ls' without a matching `if' or `elif'encountered `%ls' without a matching `{'encountered an invalid character `%lc' in the case patternerror in closing file descriptor %devaluate a conditional expressionevaluate arguments as a commandexecute or identify a commandexit a loopexit the shellexport variables as environment variablesfailed to remove temporary file `%s'failed to set $PWDfailed to set environment variable $%sfailed to set the limitfailed to unset environment variable $%sfile `%s' was not found in $PATHfile `%s' was not found in $YASH_LOADPATHfile locksfile size (blocks)filename `%ls' matches more than one filefunction `%ls' cannot be redefined because it is read-onlyfunction `%ls' is read-onlygenerate completion candidatesidentify a commandindex %ls is out of rangeindex %ls is out of range (the actual size of array $%ls is %zu)index %zu is out of range (the actual size of array $%ls is %zu)invalid character `%lc' in parameter expansioninvalid flag for conversion specifier `%lc'invalid use of `%lc'invalid use of `%lc' in parameter expansionjob %%%zu has already terminatedjob control is disabledjob specification `%ls' is ambiguouskey sequence `%ls' is not boundlineeditlist or re-execute command historylocked memory (kbytes)make variables read-onlymanage command historymanipulate an arraymax nicememory (kbytes)message queue size (bytes)more than one -%lc option is specifiedmore than one option cannot be used at onceno operand is expectedno option is specifiedno such alias `%ls'no such array $%lsno such built-in `%ls'no such command `%s'no such editing command `%ls'no such function `%ls'no such history entry `%ls'no such history entry beginning with `%ls'no such job `%ls'no such signal `%ls'no such user `%ls'no such variable $%lsnot in a loopnot in an iterationoffonopen filesoption `%ls' is ambiguousoption combination is invalidparameter `%ls' is not setparameter `%ls' is not set or has an empty valueparse command optionspending signalspop a directory from the directory stackprint CPU time usageprint a formatted stringprint argumentsprint info about jobsprint or set the file creation maskprint the directory stackprint the working directoryprint usage of built-in commandspromptpush a directory into the directory stackread a file and execute commandsread a line from the standard inputreal-time priorityreal-time signal SIG%ls is not supportedredirectionredirection: %d>>|%dredirection: %d>>|%d: the input and output file descriptors are sameredirection: %sredirection: cannot open a pipe for the command redirectionredirection: cannot open file `%s'redirection: file descriptor %d is not readableredirection: file descriptor %d is not writableredirection: file descriptor %d is unavailableredirection: invalid file descriptorredirections are not allowed after `in'refusing to suspend because of a possible deadlock. Use the -f option to suspend anyway.remember, forget, or report command locationsremove some positional parametersremove variables or functionsreplace the shell process with an external commandresident set size (kbytes)return from a function or scriptrun jobs in the backgroundrun jobs in the foregroundsend a signal to processesset or print a resource limitationset or print key bindings for line-editingset or print signal handlersset or print variablesset shell options and positional parameterssocket redirection: cannot resolve the address of `%s': %sstack size (kbytes)suspend the shellsyntax error: the %ls option cannot be changed once the shell has been initializedthe -%lc option cannot be used with the -%lc optionthe -%lc option requires an argumentthe --%ls option requires an argumentthe -a or -k option must be used with the -v optionthe -c option is specified but no command is giventhe -n or -v option must be used with the -l optionthe backquoted command substitution is not closedthe command history is emptythe complete built-in can be used during command line completion onlythe conversion specifier is missingthe directory stack is emptythe double quotation is not closedthe editor returned a non-zero exit statusthe end-of-here-document indicator contains a newlinethe end-of-here-document indicator is missingthe index is missingthe index is not an integerthe parameter index is invalidthe parameter name is missing or invalidthe parameter value is emptythe redirection target is missingthe signal name is not specifiedthe single quotation is not closedthe soft limit cannot exceed the hard limitthe specified index does not support assignment in the parameter expansion of array `%ls'the specified prefix `%ls' does not match the target word `%ls'there is no current jobthis command requires an operandthis command requires %zu operandstoo many files are opened for yash to handletoo many operands are specifiedundefine aliasesunexpected errorunknown errorunlimiteduser processeswait for jobs to terminateProject-Id-Version: yash 2.35 Report-Msgid-Bugs-To: http://sourceforge.jp/projects/yash/forums/ POT-Creation-Date: 2013-06-08 16:19+0900 PO-Revision-Date: 2013-06-08 16:30+0900 Last-Translator: WATANABE Yuki Language-Team: Japanese Language: ja MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; . [-AL] ファイル [引数...] : [...] alias [-gp] [åå‰[=値]...] array # é…列ã®ä¸€è¦§ã‚’表示ã™ã‚‹ array åå‰ [値...] # é…列ã«å€¤ã‚’設定ã™ã‚‹ array -d åå‰ [インデックス...] array -i åå‰ ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ [値...] array -s åå‰ ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ 値 bg [ジョブ...] bindkey -aev [キーシーケンス [コマンド]] bindkey -l break [æ·±ã•] break -i cd [-L|-P] [ディレクトリ] command [-befp] コマンド [引数...] command -v|-V [-abefkp] コマンド... complete [-A パターン] [-R パターン] [-T] [-P 接頭辞] [-S 接尾辞] \ [-abcdfghjkuv] [[-O] [-D 説明] å˜èªž...] continue [æ·±ã•] continue -i dirs [-cv] [インデックス...] disown [ジョブ...] disown -a echo [文字列...] eval [-i] [引数...] exec [-cf] [-a åå‰] [コマンド [引数...]] exit [-f] [終了ステータス] export [-prX] [åå‰[=値]...] false fc [-qr] [-e エディタ] [始点 [終点]] fc -s [-q] [å…ƒ=å…ˆ] [始点] fc -l [-nrv] [始点 [終点]] fg [ジョブ...] getopts オプション 変数å [引数...] hash コマンド... hash -r [コマンド...] hash [-a] # 記憶ã—ãŸãƒ‘スを表示ã™ã‚‹ hash -d ユーザ... hash -d -r [ユーザ...] hash -d # 記憶ã—ãŸãƒ‘スを表示ã™ã‚‹ help [組込ã¿ã‚³ãƒžãƒ³ãƒ‰...] history [-cF] [-d é …ç›®] [-s コマンド] [-r ファイル] [-w ファイル] [個数] jobs [-lnprs] [ジョブ...] kill [-シグナル|-s シグナル|-n シグナル番å·] プロセス... kill -l [-v] [æ•°...] popd [インデックス] printf æ›¸å¼ [値...] pushd [-L|-P] [ディレクトリ] pwd [-L|-P] read [-Ar] 変数å... readonly [-fpxX] [åå‰[=値]...] return [-n] [終了ステータス] set [オプション...] [--] [æ–°ã—ã„ä½ç½®ãƒ‘ラメータ...] set -o|+o # ç¾åœ¨ã®è¨­å®šã‚’表示ã™ã‚‹ shift [個数] suspend [-f] test å¼ [ å¼ ] times trap [動作 シグナル...] trap ã‚·ã‚°ãƒŠãƒ«ç•ªå· [シグナル...] trap -p [シグナル...] true type コマンド... typeset [-fgprxX] [åå‰[=値]...] ulimit -a [-H|-S] ulimit [-H|-S] [-efilnqrstuvx] [制é™] umask モード umask [-S] unalias åå‰... unalias -a unset [-fv] åå‰... wait [ジョブã¾ãŸã¯ãƒ—ロセス番å·...] æœ‰åŠ¹ãªæ©Ÿèƒ½: %5jd %-25s | %ls ãれã§ã‚‚終了ã™ã‚‹ã«ã¯ã‚‚ã†ä¸€åº¦ã€Œexitã€ã—ã¦ãã ã•ã„。 ãれã§ã‚‚ exec ã™ã‚‹ã«ã¯ -f オプションを付ã‘ã¦ãã ã•ã„。 $%ls ã¯èª­ã¿è¾¼ã¿å°‚用ã§ã™$DIRSTACK ã¯é…列ã§ã¯ã‚りã¾ã›ã‚“$HOME ãŒè¨­å®šã•れã¦ã„ã¾ã›ã‚“$OLDPWD ãŒè¨­å®šã•れã¦ã„ã¾ã›ã‚“$OPTIND ã®å€¤ãŒæ­£ã—ãã‚りã¾ã›ã‚“$PWD ã®å€¤ãŒæ­£ã—ãã‚りã¾ã›ã‚“$PWD ãŒè¨­å®šã•れã¦ã„ã¾ã›ã‚“%ls: 「%lcã€ã¯æœ‰åйãªã‚ªãƒ—ションã§ã¯ã‚りã¾ã›ã‚“ %ls: シェルã®äºˆç´„語 %ls: 「%lsã€ã¸ã®ã‚¨ã‚¤ãƒªã‚¢ã‚¹ %ls: -%lc オプションã®å¼•æ•°ãŒæŠœã‘ã¦ã„ã¾ã™ %ls: --%ls オプションã¯å¼•æ•°ã‚’å–りã¾ã›ã‚“%ls: è² ã§ãªã„オペランドã®å€¤ã‚’指定ã—ã¦ãã ã•ã„%ls: シグナルåã¯ã€ŒSIGã€ã‚’付ã‘ãšã«æŒ‡å®šã™ã‚‹å¿…è¦ãŒã‚りã¾ã™%s: 関数 %s: 通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ ($PATH 内ã«å­˜åœ¨ã›ãš) %s: 通常ã®çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ (%s) %s: 準特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ %s: 特殊組込ã¿ã‚³ãƒžãƒ³ãƒ‰ %s: 外部コマンド (%s) %s: 外部コマンド (%s/%s) %s: 引数「%sã€ã‚’ワイド文字列ã«å¤‰æ›ã§ãã¾ã›ã‚“%s: 引数ã¯ç©ºæ–‡å­—列ã«ç½®ãæ›ãˆã‚‰ã‚Œã¾ã™ %u ã¯æ­£ã®æ•´æ•°ã§ã¯ã‚りã¾ã›ã‚“%zu: シフトã™ã‚‹æ•°ãŒå¤šã™ãŽã¾ã™ (ä½ç½®ãƒ‘ラメータ㯠%zu 個ã—ã‹ã‚りã¾ã›ã‚“)(「%lsã€ã‚’忘れã¦ã„ã¾ã›ã‚“ã‹?)-%lc: %-52s CPU 時間 (ç§’)           候補 %zu/%zuã€ãƒšãƒ¼ã‚¸ %zu/%zu完了 完了(%d) 中止 (SIG%ls)中止 (SIG%ls: コアダンプ)候補ãªã—オプション: 実行中SIG%ls ã¯ãƒªã‚»ãƒƒãƒˆã§ãã¾ã›ã‚“SIG%ls ã¯ãƒˆãƒ©ãƒƒãƒ—ã§ãã¾ã›ã‚“åœæ­¢ä¸­(SIG%ls)æ§‹æ–‡: %s [オプション...] [ファイルå [引数...]] %s [オプション...] -c コマンド [コマンドå [引数...]] %s [オプション...] -s [引数...] æ§‹æ–‡: %s プロセス㯠SIG%ls ã«ã‚ˆã‚Šå¼·åˆ¶çµ‚了ã—ã¾ã—㟠プロセス㯠SIG%ls ã«ã‚ˆã‚Šå¼·åˆ¶çµ‚了ã—ã¾ã—㟠(%s) ã“ã®ã‚½ãƒ•ト㯠GNU GPL ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 2 ã§ãƒ©ã‚¤ã‚»ãƒ³ã‚¹ã•れãŸãƒ•リーソフトウェアã§ã™ã€‚ 自由ã«å¤‰æ›´ãƒ»å†é ’布ãŒã§ãã¾ã™ãŒã€ã‚½ãƒ•トã®å‹•作ã«ä¿è¨¼ã¯ã‚りã¾ã›ã‚“。 詳ã—ãã¯: man yash シェルを終了ã™ã‚‹ã«ã¯ã€Œexitã€ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ãã ã•ã„。 Yet another shell ãƒãƒ¼ã‚¸ãƒ§ãƒ³ %s åœæ­¢ä¸­ã®ã‚¸ãƒ§ãƒ–㌠%zu 個ã‚りã¾ã™!æ–°ç€ãƒ¡ãƒ¼ãƒ«ãŒã‚りã¾ã™ã€‚[%zu] %c %-25s %ls [%zu] %c %5jd %-25s %ls 「%lcã€ã¯æœ‰åйãªå¤‰æ›æŒ‡å®šå­ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã€Œ%lsã€ã¯ã‚³ãƒžãƒ³ãƒ‰åã¨ã—ã¦ä½¿ãˆã¾ã›ã‚“「%lsã€ãŒæŠœã‘ã¦ã„ã¾ã™ã€Œ%lsã€ã¯äºŒé …演算å­ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯ã‚¸ãƒ§ãƒ–制御ã®å¯¾è±¡ã¨ãªã£ã¦ã„るジョブã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯å˜é …演算å­ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªã‚¨ã‚¤ãƒªã‚¢ã‚¹åã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªé…列åã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªè­˜åˆ¥å­ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åŠ¹ãªæ•´æ•°ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªã‚¸ãƒ§ãƒ– ID ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªãƒžã‚¹ã‚¯è¨­å®šã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åŠ¹ãªæ•°å€¤ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åŠ¹ãªæ¼”ç®—å­ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªã‚ªãƒ—ションã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªã‚ªãƒ—ション指定文字列ã§ã¯ã‚りã¾ã›ã‚“「%lsã€ã¯æœ‰åйãªå¤‰æ•°åã§ã¯ã‚りã¾ã›ã‚“「%lsã€ãŒ case コマンドã®å¤–ã§ä½¿ã‚れã¦ã„ã¾ã™ã€Œ%lsã€: コマンドåã« / ã‚’å«ã‚ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“「%sã€é–¢æ•°å®šç¾©ã§ã¯ã€Œ(ã€ã®ç›´å¾Œã«ã€Œ)ã€ãŒå¿…è¦ã§ã™for ループã®è­˜åˆ¥å­ã®ç›´å¾Œã«ã€Œ;ã€ã‚’ç½®ã„ã¦ã¯ã„ã‘ã¾ã›ã‚“「;ã€ã¾ãŸã¯ã€Œ&ã€ãŒæŠœã‘ã¦ã„ã¾ã™å…¥åŠ›ã®æœ€å¾Œã§ã‚³ãƒžãƒ³ãƒ‰ãŒæŠœã‘ã¦ã„ã¾ã™ã€Œ%lcã€ã®å‰ã«ã‚³ãƒžãƒ³ãƒ‰ãŒã‚りã¾ã›ã‚“é–¢æ•°ã®æœ¬ä½“ã¯è¤‡åˆã‚³ãƒžãƒ³ãƒ‰ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“入れå­ã®ãƒ‘ラメータ展開ã¯ä»£å…¥ã§ãã¾ã›ã‚“「%lsã€ã®å¾Œã«ã¯å˜èªžãŒå¿…è¦ã§ã™ã€Œ%lsã€ã®å¾Œã§å¼ãŒæŠœã‘ã¦ã„ã¾ã™ã€Œforã€ã®å¾Œã«ã¯è­˜åˆ¥å­ãŒå¿…è¦ã§ã™ã‚¯ã‚©ãƒ¼ãƒˆã—ã¦ã„ãªã„「esacã€ã‚’最åˆã®ãƒ‘ターンã«ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“æ•°å¼å±•é–‹:「%lcã€ã¯æœ‰åŠ¹ãªæ•°å€¤ã‚„演算å­ã§ã¯ã‚りã¾ã›ã‚“æ•°å¼å±•é–‹: 「%lsã€ãŒæŠœã‘ã¦ã„ã¾ã™æ•°å¼å±•é–‹:「%lsã€ã¯æœ‰åŠ¹ãªæ•°å€¤ã§ã¯ã‚りã¾ã›ã‚“æ•°å¼å±•é–‹: å€¤ãŒæŠœã‘ã¦ã„ã¾ã™æ•°å¼å±•é–‹: 代入先ã¯å¤‰æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“æ•°å¼å±•é–‹: 0 ã«ã‚ˆã‚‹é™¤ç®—æ•°å¼å±•é–‹: æ§‹æ–‡ãŒæ­£ã—ãã‚りã¾ã›ã‚“æ•°å¼å±•é–‹: 演算å­ã€Œ%lsã€ã¯ä½¿ãˆã¾ã›ã‚“æ•°å¼å±•é–‹: 演算å­ã€Œ%lsã€ã®å¯¾è±¡ã¯å¤‰æ•°ã§ãªã‘れã°ãªã‚Šã¾ã›ã‚“パラメータ展開ã§ã¯ãƒ‘ラメータ「%lsã€ã«ä»£å…¥ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“行編集中ã«ã¯ä½¿ãˆã¾ã›ã‚“対話モードã§ã¯ä½¿ãˆã¾ã›ã‚“空ã®ã‚­ãƒ¼ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã«ã‚³ãƒžãƒ³ãƒ‰ã‚’割り当ã¦ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã‚’ %d ã«ã‚³ãƒ”ーã§ãã¾ã›ã‚“ヒアドキュメント用ã®ä¸€æ™‚ファイルを作æˆã§ãã¾ã›ã‚“履歴を編集ã™ã‚‹ãŸã‚ã®ä¸€æ™‚ファイルを作æˆã§ãã¾ã›ã‚“ç¾åœ¨ã®ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãŒåˆ†ã‹ã‚Šã¾ã›ã‚“コマンド「%sã€ã‚’実行ã§ãã¾ã›ã‚“コマンド「%sã€(%s) を実行ã§ãã¾ã›ã‚“リソース「%sã€ã®ç¾åœ¨ã®åˆ¶é™å€¤ã‚’å–å¾—ã§ãã¾ã›ã‚“時間情報をå–å¾—ã§ãã¾ã›ã‚“スクリプト「%sã€ã‚’実行ã™ã‚‹ãŸã‚ã®æ–°ã—ã„シェルを起動ã§ãã¾ã›ã‚“履歴を編集ã™ã‚‹ãŸã‚ã®ã‚¨ãƒ‡ã‚£ã‚¿ã‚’èµ·å‹•ã§ãã¾ã›ã‚“å­ãƒ—ロセスを生æˆã§ãã¾ã›ã‚“パイプを開ã‘ã¾ã›ã‚“コマンド置æ›ã®ãŸã‚ã®ãƒ‘イプを開ã‘ã¾ã›ã‚“ファイル「%sã€ã‚’é–‹ã‘ã¾ã›ã‚“一時ファイル「%sã€ãŒé–‹ã‘ã¾ã›ã‚“書å¼ã‚’è§£æžã§ãã¾ã›ã‚“標準出力ã«å‡ºåŠ›ã§ãã¾ã›ã‚“ファイル「%sã€ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰ã‚’読ã¿è¾¼ã‚ã¾ã›ã‚“ファイル「%lsã€ã‹ã‚‰å±¥æ­´ã‚’読ã¿è¾¼ã‚ã¾ã›ã‚“入力を読ã¿è¾¼ã‚ã¾ã›ã‚“ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã‚’ä¿å­˜ã§ãã¾ã›ã‚“ヒアドキュメント用ã®ä¸€æ™‚ファイルã®ã‚·ãƒ¼ã‚¯ãŒã§ãã¾ã›ã‚“SIGSTOP シグナルをé€ä¿¡ã§ãã¾ã›ã‚“ファイル「%lsã€ã«å±¥æ­´ã‚’書ãè¾¼ã‚ã¾ã›ã‚“ヒアドキュメントã®å†…å®¹ã‚’ä¸€æ™‚ãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ã出ã›ã¾ã›ã‚“作業ディレクトリを変更ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã€Œ%sã€ã¯ $PATH ã®ä¸­ã«è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ã€Œ%lsã€ã®å¾Œã«ã‚³ãƒžãƒ³ãƒ‰ãŒã‚りã¾ã›ã‚“「%lsã€ã¨ã€Œ%lsã€ã®é–“ã«ã‚³ãƒžãƒ³ãƒ‰ãŒã‚りã¾ã›ã‚“ループã®å…ˆé ­ã«æˆ»ã‚‹ã‚³ã‚¢ãƒ•ァイルサイズ (ブロック数)  データセグメントサイズ (キロãƒã‚¤ãƒˆ)エイリアスを定義ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚¸ãƒ§ãƒ–制御ã¯ç„¡åйã«ãªã‚Šã¾ã™ã‚¸ãƒ§ãƒ–を放棄ã™ã‚‹ä½•ã‚‚ã—ãªã„何もã›ãšæˆåŠŸã‚’è¿”ã™ä½•ã‚‚ã›ãšå¤±æ•—ã‚’è¿”ã™ã€Œ%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œ(ã€ãŒã‚りã¾ã›ã‚“「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œcaseã€ãŒã‚りã¾ã›ã‚“「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œdoã€ãŒã‚りã¾ã›ã‚“「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œforã€ã€Œwhileã€ã¾ãŸã¯ã€Œuntilã€ãŒã‚りã¾ã›ã‚“「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œifã€ã¾ãŸã¯ã€Œthenã€ãŒã‚りã¾ã›ã‚“「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œifã€ã¾ãŸã¯ã€Œelifã€ãŒã‚りã¾ã›ã‚“「%lsã€ã«å¯¾å¿œã™ã‚‹ã€Œ{ã€ãŒã‚りã¾ã›ã‚“case ã®ãƒ‘ターン内ã«ä¸æ­£ãªæ–‡å­—「%lcã€ãŒã‚りã¾ã™ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã‚’é–‰ã˜ã‚‹éš›ã«ã‚¨ãƒ©ãƒ¼æ¡ä»¶å¼ã‚’評価ã™ã‚‹å¼•数をコマンドã¨ã—ã¦å®Ÿè¡Œã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã¾ãŸã¯ç‰¹å®šã™ã‚‹ãƒ«ãƒ¼ãƒ—を抜ã‘るシェルを終了ã™ã‚‹å¤‰æ•°ã‚’環境変数ã¨ã—ã¦ã‚¨ã‚¯ã‚¹ãƒãƒ¼ãƒˆã™ã‚‹ä¸€æ™‚ファイル「%sã€ã‚’削除ã§ãã¾ã›ã‚“ã§ã—ãŸ$PWD ã®è¨­å®šã«å¤±æ•—ã—ã¾ã—ãŸç’°å¢ƒå¤‰æ•° $%s ã®è¨­å®šã«å¤±æ•—ã—ã¾ã—ãŸãƒªãƒŸãƒƒãƒˆã®è¨­å®šã«å¤±æ•—ã—ã¾ã—ãŸç’°å¢ƒå¤‰æ•° $%s ã®å‰Šé™¤ã«å¤±æ•—ã—ã¾ã—ãŸãƒ•ァイル「%sã€ã¯ $PATH 内ã«è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸãƒ•ァイル「%sã€ã¯ $YASH_LOADPATH 内ã«è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸãƒ•ァイルã®ãƒ­ãƒƒã‚¯ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ ファイルサイズ (ブロック数)    ファイルå「%lsã€ã«å½“ã¦ã¯ã¾ã‚‹ãƒ•ァイルãŒè¤‡æ•°ã‚りã¾ã™é–¢æ•°ã€Œ%lsã€ã¯èª­ã¿è¾¼ã¿å°‚用ãªã®ã§å†å®šç¾©ã§ãã¾ã›ã‚“関数「%lsã€ã¯èª­ã¿è¾¼ã¿å°‚用ã§ã™è£œå®Œå€™è£œã‚’生æˆã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã‚’特定ã™ã‚‹ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ %ls ã¯ç¯„囲外ã§ã™ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ %ls ã¯ç¯„囲外ã§ã™ (é…列 $%ls ã®ã‚µã‚¤ã‚ºã¯ %zu ã§ã™)インデックス %zu ã¯ç¯„囲外ã§ã™ (é…列 $%ls ã®ã‚µã‚¤ã‚ºã¯ %zu ã§ã™)パラメータ展開ã«ç„¡åŠ¹ãªæ–‡å­—「%lcã€ãŒæ··ã˜ã£ã¦ã„ã¾ã™å¤‰æ›æŒ‡å®šå­ã€Œ%lcã€ã«å¯¾ã™ã‚‹ãƒ•ラグãŒä¸æ­£ã§ã™ã€Œ%lcã€ã®ä½¿ã„æ–¹ãŒæ­£ã—ãã‚りã¾ã›ã‚“パラメータ展開ã«ãŠã„ã¦ã€Œ%lcã€ã®ä½¿ã„æ–¹ãŒæ­£ã—ãã‚りã¾ã›ã‚“ジョブ %%%zu ã¯æ—¢ã«çµ‚了ã—ã¦ã„ã¾ã™ã‚¸ãƒ§ãƒ–コントロールã¯ç„¡åйã§ã™ã‚¸ãƒ§ãƒ–指定「%lsã€ã¯æ›–昧ã§ã™ã‚­ãƒ¼ã‚·ãƒ¼ã‚±ãƒ³ã‚¹ã€Œ%lsã€ã«ã‚³ãƒžãƒ³ãƒ‰ã¯å‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“行編集コマンド履歴を表示ã—ãŸã‚Šã‚³ãƒžãƒ³ãƒ‰ã‚’å†å®Ÿè¡Œã—ãŸã‚Šã™ã‚‹ãƒ­ãƒƒã‚¯ã—ãŸãƒ¡ãƒ¢ãƒª (キロãƒã‚¤ãƒˆ)   変数を読ã¿è¾¼ã¿å°‚用ã«ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰å±¥æ­´ã‚’管ç†ã™ã‚‹é…列をæ“作ã™ã‚‹æœ€å¤§ nice             メモリ (キロãƒã‚¤ãƒˆ)        メッセージキューサイズ (ãƒã‚¤ãƒˆ)  -%lc ãŒäºŒå›žä»¥ä¸ŠæŒ‡å®šã•れã¦ã„ã¾ã™äºŒã¤ä»¥ä¸Šã®ã‚ªãƒ—ã‚·ãƒ§ãƒ³ã‚’åŒæ™‚ã«ä½¿ã†ã“ã¨ã¯ã§ãã¾ã›ã‚“ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’å—ã‘付ã‘ã¾ã›ã‚“ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã¾ã›ã‚“「%lsã€ã¨ã„ã†ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã¯ã‚りã¾ã›ã‚“$%ls ã¨ã„ã†ã‚ˆã†ãªé…列ã¯ã‚りã¾ã›ã‚“「%lsã€ã¨ã„ã†ã‚ˆã†ãªçµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚りã¾ã›ã‚“「%sã€ã¨ã„ã†ã‚ˆã†ãªã‚³ãƒžãƒ³ãƒ‰ã¯ã‚りã¾ã›ã‚“「%lsã€ã¨ã„ã†ã‚ˆã†ãªç·¨é›†ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚りã¾ã›ã‚“「%lsã€ã¨ã„ã†ã‚ˆã†ãªé–¢æ•°ã¯ã‚りã¾ã›ã‚“「%lsã€ã¨ã„ã†ã‚ˆã†ãªå±¥æ­´é …ç›®ã¯ã‚りã¾ã›ã‚“「%lsã€ã§å§‹ã¾ã‚‹ã‚ˆã†ãªå±¥æ­´é …ç›®ã¯ã‚りã¾ã›ã‚“「%lsã€ã«è©²å½“ã™ã‚‹ã‚¸ãƒ§ãƒ–ã¯ã‚りã¾ã›ã‚“「%lsã€ã¨ã„ã†ã‚ˆã†ãªã‚·ã‚°ãƒŠãƒ«ã¯ã‚りã¾ã›ã‚“「%lsã€ã¨ã„ã†ãƒ¦ãƒ¼ã‚¶ã¯å­˜åœ¨ã—ã¾ã›ã‚“$%ls ã¨ã„ã†ã‚ˆã†ãªå¤‰æ•°ã¯ã‚りã¾ã›ã‚“ループã®é€”中ã§ã¯ã‚りã¾ã›ã‚“å復実行ã®é€”中ã§ã¯ã‚りã¾ã›ã‚“切入開ã‘るファイル数         オプション「%lsã€ã¯æ›–昧ã§ã™ã‚ªãƒ—ションã®çµ„ã¿åˆã‚ã›ãŒæ­£ã—ãã‚りã¾ã›ã‚“パラメータ「%lsã€ã¯å­˜åœ¨ã—ã¾ã›ã‚“パラメータ「%lsã€ã¯å­˜åœ¨ã—ãªã„ã‹å€¤ãŒç©ºã§ã™ã‚³ãƒžãƒ³ãƒ‰ã®ã‚ªãƒ—ションを解æžã™ã‚‹å‡¦ç†å¾…ã¡ã‚·ã‚°ãƒŠãƒ«ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ ディレクトリスタックã‹ã‚‰ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’削除ã™ã‚‹æ¶ˆè²» CPU 時間を表示ã™ã‚‹æ–‡å­—列を整形ã—ã¦å‡ºåŠ›ã™ã‚‹å¼•数を出力ã™ã‚‹ã‚¸ãƒ§ãƒ–ã®æƒ…報を表示ã™ã‚‹ãƒ•ァイル作æˆãƒžã‚¹ã‚¯ã‚’表示ã¾ãŸã¯è¨­å®šã™ã‚‹ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã‚’表示ã™ã‚‹ä½œæ¥­ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’表示ã™ã‚‹çµ„è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã®ä½¿ã„方を表示ã™ã‚‹ãƒ—ロンプトディレクトリスタックã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’追加ã™ã‚‹ãƒ•ァイルをスクリプトã¨ã—ã¦å®Ÿè¡Œã™ã‚‹æ¨™æº–入力ã‹ã‚‰è¡Œã‚’読ã¿è¾¼ã‚€ãƒªã‚¢ãƒ«ã‚¿ã‚¤ãƒ å„ªå…ˆåº¦ã€€ã€€ã€€ã€€ã€€ã€€ã€€ リアルタイムシグナル SIG%ls ã«ã¯å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“リダイレクトリダイレクト: %d>>|%dリダイレクト: %d>>|%d: 入力å´ã¨å‡ºåŠ›å´ã®ãƒ•ァイル記述å­ãŒåŒã˜ã§ã™ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ: %sリダイレクト: コマンド置æ›ç”¨ã®ãƒ‘イプを開ã‘ã¾ã›ã‚“リダイレクト: ファイル「%sã€ã‚’é–‹ã‘ã¾ã›ã‚“リダイレクト: ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã¯èª­ã¿è¾¼ã¿å¯èƒ½ã§ã¯ã‚りã¾ã›ã‚“リダイレクト: ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã¯æ›¸ãè¾¼ã¿å¯èƒ½ã§ã¯ã‚りã¾ã›ã‚“リダイレクト: ãƒ•ã‚¡ã‚¤ãƒ«è¨˜è¿°å­ %d ã¯ä½¿ãˆã¾ã›ã‚“リダイレクト: 無効ãªãƒ•ァイル記述å­ã§ã™ã€Œinã€ã®å¾Œã«ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã¯æ›¸ã‘ã¾ã›ã‚“ãƒ‡ãƒƒãƒ‰ãƒ­ãƒƒã‚¯ã®æã‚ŒãŒã‚ã‚‹ãŸã‚サスペンドã—ã¾ã›ã‚“ã§ã—ãŸã€‚ 本当ã«ã‚µã‚¹ãƒšãƒ³ãƒ‰ã™ã‚‹ã«ã¯ -f オプションを付ã‘ã¦ãã ã•ã„。コマンドã®ãƒ‘スã®ã‚­ãƒ£ãƒƒã‚·ãƒ¥ãƒ‡ãƒ¼ã‚¿ã‚’登録・消去・表示ã™ã‚‹ä½ç½®ãƒ‘ラメータã®ä¸€éƒ¨ã‚’削除ã™ã‚‹å¤‰æ•°ã¾ãŸã¯é–¢æ•°ã‚’削除ã™ã‚‹ã‚·ã‚§ãƒ«ã®ãƒ—ロセスを外部コマンドã«å¤‰ãˆã‚‹ãƒ¬ã‚¸ãƒ‡ãƒ³ãƒˆã‚»ãƒƒãƒˆã‚µã‚¤ã‚º (キロãƒã‚¤ãƒˆ)関数やスクリプトã‹ã‚‰æŠœã‘るジョブをãƒãƒƒã‚¯ã‚°ãƒ©ã‚¦ãƒ³ãƒ‰ã§å®Ÿè¡Œã™ã‚‹ã‚¸ãƒ§ãƒ–をフォアグラウンドã§å®Ÿè¡Œã™ã‚‹ãƒ—ロセスã«ã‚·ã‚°ãƒŠãƒ«ã‚’é€ã‚‹ãƒªã‚½ãƒ¼ã‚¹ã®åˆ¶é™ã‚’設定ã¾ãŸã¯è¨­å®šã™ã‚‹è¡Œç·¨é›†ã®ã‚­ãƒ¼å‰²ã‚Šå½“ã¦ã‚’設定ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚·ã‚°ãƒŠãƒ«ãƒãƒ³ãƒ‰ãƒ©ã‚’設定ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹å¤‰æ•°ã‚’設定ã¾ãŸã¯è¡¨ç¤ºã™ã‚‹ã‚·ã‚§ãƒ«ã‚ªãƒ—ションã¨ä½ç½®ãƒ‘ラメータを設定ã™ã‚‹ã‚½ã‚±ãƒƒãƒˆãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆ:「%sã€ã®ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’解決ã§ãã¾ã›ã‚“: %sスタックサイズ (キロãƒã‚¤ãƒˆ)ã€€ã€€ã€€ã€€ã‚·ã‚§ãƒ«ã‚’åœæ­¢ã™ã‚‹æ§‹æ–‡ã‚¨ãƒ©ãƒ¼: シェルãŒåˆæœŸåŒ–ã•れãŸå¾Œã¯ %ls オプションを変更ã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“-%lc オプション㯠-%lc オプションã¨ã¯ä¸€ç·’ã«ä½¿ãˆã¾ã›ã‚“-%lc オプションã®å¼•æ•°ãŒæŠœã‘ã¦ã„ã¾ã™--%ls オプションã¯å¼•æ•°ã‚’å–りã¾ã›ã‚“-a ãŠã‚ˆã³ -k オプション㯠-v オプションã¨ä¸€ç·’ã«ã—ã‹ä½¿ãˆã¾ã›ã‚“-c ã‚ªãƒ—ã‚·ãƒ§ãƒ³ãŒæŒ‡å®šã•れã¦ã„ã¾ã™ãŒã‚³ãƒžãƒ³ãƒ‰ãŒä¸Žãˆã‚‰ã‚Œã¦ã„ã¾ã›ã‚“-n ãŠã‚ˆã³ -v オプション㯠-l オプションã¨ä¸€ç·’ã«ã—ã‹ä½¿ãˆã¾ã›ã‚“「`ã€ã«ã‚ˆã‚‹ã‚³ãƒžãƒ³ãƒ‰ç½®æ›ãŒé–‰ã˜ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“コマンド履歴ã¯ç©ºã§ã™complete 組込ã¿ã‚³ãƒžãƒ³ãƒ‰ã¯ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³è£œå®Œã®æœ€ä¸­ã«ã—ã‹ä½¿ãˆã¾ã›ã‚“å¤‰æ›æŒ‡å®šå­ãŒæŠœã‘ã¦ã„ã¾ã™ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚¹ã‚¿ãƒƒã‚¯ã¯ç©ºã§ã™äºŒé‡å¼•用符ãŒé–‰ã˜ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“エディタ㌠0 以外ã®çµ‚了ステータスを返ã—ã¾ã—ãŸãƒ’アドキュメントã®çµ‚端å­ã«æ”¹è¡ŒãŒå…¥ã£ã¦ã„ã¾ã™ãƒ’アドキュメントã®çµ‚端å­ãŒæŠœã‘ã¦ã„ã¾ã™ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæŠœã‘ã¦ã„ã¾ã™ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæ•´æ•°ã§ã¯ã‚りã¾ã›ã‚“パラメータã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæ­£ã—ãã‚りã¾ã›ã‚“パラメータåãŒæŠœã‘ã¦ã„ã‚‹ã‹ä¸æ­£ã§ã™ãƒ‘ラメータã®å€¤ãŒç©ºã§ã™ãƒªãƒ€ã‚¤ãƒ¬ã‚¯ãƒˆã®å¯¾è±¡ãŒæŠœã‘ã¦ã„ã¾ã™ã‚·ã‚°ãƒŠãƒ«åãŒæŒ‡å®šã•れã¦ã„ã¾ã›ã‚“å˜ä¸€å¼•用符ãŒé–‰ã˜ã‚‰ã‚Œã¦ã„ã¾ã›ã‚“ソフトリミットã¯ãƒãƒ¼ãƒ‰ãƒªãƒŸãƒƒãƒˆã‚ˆã‚Šå¤§ããã§ãã¾ã›ã‚“é…列「%lsã€ã®ãƒ‘ラメータ展開ã«ãŠã„ã¦æŒ‡å®šã•れã¦ã„るインデックスã¯ä»£å…¥ã§ãã¾ã›ã‚“指定ã•ã‚ŒãŸæŽ¥é ­è¾žã€Œ%lsã€ã¯è£œå®Œå¯¾è±¡ã€Œ%lsã€ã«é©åˆã—ã¾ã›ã‚“ç¾åœ¨ã®ã‚¸ãƒ§ãƒ–ã¯ã‚りã¾ã›ã‚“オペランドãŒè¶³ã‚Šã¾ã›ã‚“ (%zu 個必è¦)é–‹ã„ãŸãƒ•ã‚¡ã‚¤ãƒ«ã®æ•°ãŒå¤šã™ãŽã¦å‡¦ç†ã—ãれã¾ã›ã‚“ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®æ•°ãŒå¤šã™ãŽã¾ã™ã‚¨ã‚¤ãƒªã‚¢ã‚¹ã®å®šç¾©ã‚’削除ã™ã‚‹æƒ³å®šå¤–ã®ã‚¨ãƒ©ãƒ¼ã§ã™ä¸æ˜Žãªã‚¨ãƒ©ãƒ¼ç„¡åˆ¶é™ãƒ¦ãƒ¼ã‚¶ãƒ—ロセス数         ジョブã®çµ‚了を待ã¤yash-2.35/po/en@boldquot.mo0000644000175000017500000010063712154557026016004 0ustar magicantmagicantÞ•\ü ÓÜ() FP§p 3&ZtK}ÙWw¬¿.Ù !" D `L ­ (» –ä {!C!Ô!Ií!7"F"a" }"‹"$¤"É"Yå"?#O#!^#€#Nˆ#×#Þ#%ð#;$R$k$‰$¡$¿$Ó$#ë$$%4%F%`%q%„%¡%»%"Ë%î%&+&/I&+y&4¥&Ú&,ê&'5'R'j'!‰'A«'2í' (‡=(Å( ß(ì(%ÿ(%)*)3)C) `) n)x)€)—)°)ŠÀ) K*!W*%y*vŸ*+3+S+2r+¥+¸+Ì+)ç+,&,>,O,!n,,®,Î,î,-)-&F-'m-•-±-Ï-)ë-".8.*U.€.4….:º.õ.( /!4/*V///±/$Ð/%õ/303O0ƒ0' 0È0%ç0 1*1+E1.q17 1"Ø1&û1!"2$D24i2.ž2&Í2ô2 3:13l30…3(¶3ß3û3/4>4T4t4#Œ4#°4#Ô4ø4 54)5^5"y5=œ5Ú5#÷56/6 D6,e6’6¢6º6Õ6í6 7 7727(L7+u7)¡7?Ë77 83C8(w8: 8#Û8!ÿ8!9A9 _9k9)z9$¤9É9&Ü9:(: D:)e: :š:)­::×:;.;M;`;@z;@»;.ü;++<W<+l< ˜<¹<$Ñ<ö<="=B=Y=r=‰==¦=¶=&Ñ=+ø=$>;>R>f>y>>¥>Ã>Ú>*ö>!?3?H?[? q??“?—? š?¥?¿?Ý?0ø?)@?@(O@x@@¦@¶@#Ì@ð@ A &AGA)NA xA#™A½A(ÐA ùABDB_B;oB"«B/ÎB/þB..C$]C'‚CXªC-D!1DSD2qD¤D ¿DàDûDE"1E*TEEœE+³E:ßEF.F@FDOF3”F$ÈF%íF3G2GG3zG1®GàGEýG#CHgH"„H*§H5ÒH-I6IKIgI(†I¯I!ÌI îI"J+2JY^J?¸JøJCK,TKK¡K²K ÃK ÑKÛKêK‰LM ¬M¶M§ÖM ~N3ŒNÀNÚNKóN}?O½OÝOõOP%P.?PnP!ˆPªP`²P Q(!Q–JQáQCöQ:RISRR¬RÇR ãRñR$ S/SYKS¥SµS!ÄSæSNîS=TDT%VT;|T¸TÑTïTU%U9U/QU$U¦U¸UÒUãUöUV-V.=VlV$‚V+§V/ÓV+W@/WpW,€W­WËWèWX!XMAX2XÂX‡ßX%gY YšY%­YÓYØYáYñY Z Z&Z.ZEZ^ZŠnZ ùZ![%'[vM[(Ä[+í[\28\k\~\’\5­\ã\2õ\(]*E]-p])ž]+È]+ô]+ ^&L^(s^2œ^3Ï^'_)+_'U_5}_.³_4â_B`Z`Lk`F¸`-ÿ`(-a-Va*„a/¯a*ßa0 b1;b?mb?­b(íb3cJc%icc¬c7Çc:ÿcC:d"~d&¡d!Èd$êd4e.De&se'še,ÂeFïe6f<Of(ŒfµfÑf/äf!g+6gbg#zg/žg/Îgþgh4/hdh.h=®hìh/ i9iMi,biDiÔiäiüij/j Ej Qj\jtj@ŽjCÏjAkoUk[ÅkW!l@ylFºl#m!%mGmgm …m‘m) m0Êmûm&n5n(Mn,vn5£n Ùnän5÷nF-o'toœo»oÎo@èo@)p:jp7¥p Ýp7þp 6qWq0oq+ qÌq"Õqøqr(r?rSr\rlr&‡r+®rÚrñrs(s";s ^s)s"©s'Ìs6ôs+t Itjt‰t Ÿt­tÁtÅt Èt%Ótùt&u<>u{u‘u(¡uÊußuøuv#vBv\v xv™v) v Êv#ëvw("w KwWwDlw±w;Áw.ýw/,x/\x.Œx$»x3àxXy-my!›y½y2Ûyz )zJzez€z"›z*¾zéz{+{FI{{¤{¶{DÅ{3 |$>|%c|3‰|2½|3ð|1$}V}Es}#¹}Ý}"ú}*~5H~-~~¬~Á~Ý~(ü~%!B d"…+¨eÔW:€’€Cª€,î€;L ] ku„GèаªE!ßÈ 15qPÃJ8Sæ úå8î5XBëÎ.D$g1¯OJ=Õ¹”Ù:á,¥XÄ&Š(·­M¶–&§âÁ‚H4`lØtyTÇÞiWH ÊPRÓ®2<jS‰Aó2•¡Œ¿ÉCíäañ×~ü çNÿWLRo7™*3Zê> û¤ºN?4I'"#_9;9ýwÀ>eŲ¬þ’-/Í»C fx=飄¢›-U˜%‡0h³Æ7;Úd'Mp!vŸLËFƒ3“YÛõ†.ïœV6{Â|÷ $TÏA€?%r+Ž Üö\ ½«¼@*¨:"ã©‘D<b[E,QøÒàì(sUðˆz)K ^ÖVBOI¾ùYš ´¸cG/ ž6[òÔ±µ]KÌô—F)¦u‹… \n0Ñ#Q+@Z}Ýkm . [-AL] file [argument...] : [...] alias [-gp] [name[=value]...] array # print arrays array name [value...] # set array values array -d name [index...] array -i name index [value...] array -s name index value bg [job...] bindkey -aev [key_sequence [command]] bindkey -l break [count] break -i cd [-L|-P] [directory] command [-befp] command [argument...] command -v|-V [-abefkp] command... complete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \ [-abcdfghjkuv] [[-O] [-D description] words...] continue [count] continue -i dirs [-cv] [index...] disown [job...] disown -a echo [string...] eval [-i] [argument...] exec [-cf] [-a name] [command [argument...]] exit [-f] [exit_status] export [-prX] [name[=value]...] false fc [-qr] [-e editor] [first [last]] fc -s [-q] [old=new] [first] fc -l [-nrv] [first [last]] fg [job...] getopts options variable [argument...] hash command... hash -r [command...] hash [-a] # print remembered paths hash -d user... hash -d -r [user...] hash -d # print remembered paths help [built-in...] history [-cF] [-d entry] [-s command] [-r file] [-w file] [count] jobs [-lnprs] [job...] kill [-signal|-s signal|-n number] process... kill -l [-v] [number...] popd [index] printf format [value...] pushd [-L|-P] [directory] pwd [-L|-P] read [-Ar] variable... readonly [-fpxX] [name[=value]...] return [-n] [exit_status] set [option...] [--] [new_positional_parameter...] set -o|+o # print current settings shift [count] suspend [-f] test expression [ expression ] times trap [action signal...] trap signal_number [signal...] trap -p [signal...] true type command... typeset [-fgprxX] [name[=value]...] ulimit -a [-H|-S] ulimit [-H|-S] [-efilnqrstuvx] [limit] umask mode umask [-S] unalias name... unalias -a unset [-fv] [name...] wait [job or process_id...] Enabled features: %5jd %-20s | %ls Use `exit' again to exit anyway. Use the -f option to exec anyway. $%ls is read-only$DIRSTACK is not an array$HOME is not set$OLDPWD is not set$OPTIND has an invalid value$PWD has an invalid value$PWD is not set%ls: `-%lc' is not a valid option %ls: a shell keyword %ls: an alias for `%ls' %ls: the -%lc option's argument is missing %ls: the --%ls option does not take an argument%ls: the operand value must not be negative%ls: the signal name must be specified without `SIG'%s: a function %s: a regular built-in (not found in $PATH) %s: a regular built-in at %s %s: a semi-special built-in %s: a special built-in %s: an external command at %s %s: an external command at %s/%s %s: cannot convert the argument `%s' into a wide character string%s: the argument is replaced with an empty string %u is not a positive integer%zu: cannot shift so many (there is only one positional parameter)%zu: cannot shift so many (there are only %zu positional parameters)(maybe you missed `%ls'?)-%lc: %-30s CPU time (seconds)Candidate %zu of %zu; Page %zu of %zuDoneDone(%d)Killed (SIG%ls)Killed (SIG%ls: core dumped)No candidatesOptions: RunningSIG%ls cannot be resetSIG%ls cannot be trappedStopped(SIG%ls)Syntax: %s [option...] [filename [argument...]] %s [option...] -c command [command_name [argument...]] %s [option...] -s [argument...] Syntax: %s The process was killed by SIG%ls The process was killed by SIG%ls: %s This is free software licensed under GNU GPL version 2. You can modify and redistribute it, but there is NO WARRANTY. Try `man yash' for details. Use `exit' to leave the shell. Yet another shell, version %s You have a stopped job!You have %zu stopped jobs!You have new mail.[%zu] %c %-20s %ls [%zu] %c %5jd %-20s %ls `%lc' is not a valid conversion specifier`%ls'`%ls' cannot be used as a command name`%ls' is missing`%ls' is not a binary operator`%ls' is not a job-controlled job`%ls' is not a unary operator`%ls' is not a valid alias name`%ls' is not a valid array name`%ls' is not a valid identifier`%ls' is not a valid index`%ls' is not a valid integer`%ls' is not a valid job specification`%ls' is not a valid mask specification`%ls' is not a valid number`%ls' is not a valid operator`%ls' is not a valid option`%ls' is not a valid option specification`%ls' is not a valid variable name`%ls' is used outside `case'`%ls': a command name must not contain `/'`%s'`(' must be followed by `)' in a function definition`;' is not allowed just after the identifier in a for loop`;' or `&' is missinga command is missing at the end of inputa command is missing before `%lc'a function body must be a compound commanda nested parameter expansion cannot be assigneda word is required after `%ls'an expression is missing after `%ls'an identifier is required after `for'an unquoted `esac' cannot be the first case patternarithmetic: `%lc' is not a valid number or operatorarithmetic: `%ls' is missingarithmetic: `%ls' is not a valid numberarithmetic: a value is missingarithmetic: cannot assign to a numberarithmetic: division by zeroarithmetic: invalid syntaxarithmetic: operator `%ls' is not supportedarithmetic: operator `%ls' requires a variablecannot assign to parameter `%ls' in parameter expansioncannot be used during line-editingcannot be used in the interactive modecannot bind an empty key sequencecannot copy file descriptor %d to %dcannot create a temporary file for the here-documentcannot create a temporary file to edit historycannot determine the current directorycannot execute command `%s'cannot execute command `%s' (%s)cannot get the current limit for the resource type of `%s'cannot get the time datacannot invoke a new shell to execute script `%s'cannot invoke the editor to edit historycannot make a child processcannot open a pipecannot open a pipe for the command substitutioncannot open file `%s'cannot open temporary file `%s'cannot parse the formatcannot print to the standard outputcannot read commands from file `%s'cannot read history from file `%ls'cannot read inputcannot save file descriptor %dcannot seek the temporary file for the here-documentcannot send SIGSTOP signalcannot write history to file `%ls'cannot write the here-document contents to the temporary filechange the working directorycommand `%s' was not found in $PATHcommand redirectioncommand substitutioncommands are missing after `%ls'commands are missing between `%ls' and `%ls'continue a loopcore file size (blocks)data segment size (kbytes)define or print aliasesdisabling job controldisown jobsdo nothingdo nothing successfullydo nothing unsuccessfullyencountered `%ls' without a matching `('encountered `%ls' without a matching `case'encountered `%ls' without a matching `do'encountered `%ls' without a matching `for', `while', or `until'encountered `%ls' without a matching `if' and/or `then'encountered `%ls' without a matching `if' or `elif'encountered `%ls' without a matching `{'encountered an invalid character `%lc' in the case patternerror in closing file descriptor %devaluate a conditional expressionevaluate arguments as a commandexecute or identify a commandexit a loopexit the shellexport variables as environment variablesfailed to remove temporary file `%s'failed to set $PWDfailed to set environment variable $%sfailed to set the limitfailed to unset environment variable $%sfile `%s' was not found in $PATHfile `%s' was not found in $YASH_LOADPATHfile locksfile size (blocks)filename `%ls' matches more than one filefunction `%ls' cannot be redefined because it is read-onlyfunction `%ls' is read-onlygenerate completion candidatesidentify a commandindex %ls is out of rangeindex %ls is out of range (the actual size of array $%ls is %zu)index %zu is out of range (the actual size of array $%ls is %zu)invalid character `%lc' in parameter expansioninvalid flag for conversion specifier `%lc'invalid use of `%lc'invalid use of `%lc' in parameter expansionjob %%%zu has already terminatedjob control is disabledjob specification `%ls' is ambiguouskey sequence `%ls' is not boundlineeditlist or re-execute command historylocked memory (kbytes)make variables read-onlymanage command historymanipulate an arraymax nicememory (kbytes)message queue size (bytes)more than one -%lc option is specifiedmore than one option cannot be used at onceno operand is expectedno option is specifiedno such alias `%ls'no such array $%lsno such built-in `%ls'no such command `%s'no such editing command `%ls'no such function `%ls'no such history entry `%ls'no such history entry beginning with `%ls'no such job `%ls'no such signal `%ls'no such user `%ls'no such variable $%lsnot in a loopnot in an iterationoffonopen filesoption `%ls' is ambiguousoption combination is invalidparameter `%ls' is not setparameter `%ls' is not set or has an empty valueparse command optionspending signalspop a directory from the directory stackprint CPU time usageprint a formatted stringprint argumentsprint info about jobsprint or set the file creation maskprint the directory stackprint the working directoryprint usage of built-in commandspromptpush a directory into the directory stackread a file and execute commandsread a line from the standard inputreal-time priorityreal-time signal SIG%ls is not supportedredirectionredirection: %d>>|%dredirection: %d>>|%d: the input and output file descriptors are sameredirection: %sredirection: cannot open a pipe for the command redirectionredirection: cannot open file `%s'redirection: file descriptor %d is not readableredirection: file descriptor %d is not writableredirection: file descriptor %d is unavailableredirection: invalid file descriptorredirections are not allowed after `in'refusing to suspend because of a possible deadlock. Use the -f option to suspend anyway.remember, forget, or report command locationsremove some positional parametersremove variables or functionsreplace the shell process with an external commandresident set size (kbytes)return from a function or scriptrun jobs in the backgroundrun jobs in the foregroundsend a signal to processesset or print a resource limitationset or print key bindings for line-editingset or print signal handlersset or print variablesset shell options and positional parameterssocket redirection: cannot resolve the address of `%s': %sstack size (kbytes)suspend the shellsyntax error: the %ls option cannot be changed once the shell has been initializedthe -%lc option cannot be used with the -%lc optionthe -%lc option requires an argumentthe --%ls option requires an argumentthe -a or -k option must be used with the -v optionthe -c option is specified but no command is giventhe -n or -v option must be used with the -l optionthe backquoted command substitution is not closedthe command history is emptythe complete built-in can be used during command line completion onlythe conversion specifier is missingthe directory stack is emptythe double quotation is not closedthe editor returned a non-zero exit statusthe end-of-here-document indicator contains a newlinethe end-of-here-document indicator is missingthe index is missingthe index is not an integerthe parameter index is invalidthe parameter name is missing or invalidthe parameter value is emptythe redirection target is missingthe signal name is not specifiedthe single quotation is not closedthe soft limit cannot exceed the hard limitthe specified index does not support assignment in the parameter expansion of array `%ls'the specified prefix `%ls' does not match the target word `%ls'there is no current jobthis command requires an operandthis command requires %zu operandstoo many files are opened for yash to handletoo many operands are specifiedundefine aliasesunexpected errorunknown errorunlimiteduser processeswait for jobs to terminateProject-Id-Version: yash 2.35 Report-Msgid-Bugs-To: http://sourceforge.jp/projects/yash/forums/ POT-Creation-Date: 2013-06-08 16:31+0900 PO-Revision-Date: 2013-06-08 16:31+0900 Last-Translator: Automatically generated Language-Team: none Language: en@boldquot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=2; plural=(n != 1); . [-AL] file [argument...] : [...] alias [-gp] [name[=value]...] array # print arrays array name [value...] # set array values array -d name [index...] array -i name index [value...] array -s name index value bg [job...] bindkey -aev [key_sequence [command]] bindkey -l break [count] break -i cd [-L|-P] [directory] command [-befp] command [argument...] command -v|-V [-abefkp] command... complete [-A pattern] [-R pattern] [-T] [-P prefix] [-S suffix] \ [-abcdfghjkuv] [[-O] [-D description] words...] continue [count] continue -i dirs [-cv] [index...] disown [job...] disown -a echo [string...] eval [-i] [argument...] exec [-cf] [-a name] [command [argument...]] exit [-f] [exit_status] export [-prX] [name[=value]...] false fc [-qr] [-e editor] [first [last]] fc -s [-q] [old=new] [first] fc -l [-nrv] [first [last]] fg [job...] getopts options variable [argument...] hash command... hash -r [command...] hash [-a] # print remembered paths hash -d user... hash -d -r [user...] hash -d # print remembered paths help [built-in...] history [-cF] [-d entry] [-s command] [-r file] [-w file] [count] jobs [-lnprs] [job...] kill [-signal|-s signal|-n number] process... kill -l [-v] [number...] popd [index] printf format [value...] pushd [-L|-P] [directory] pwd [-L|-P] read [-Ar] variable... readonly [-fpxX] [name[=value]...] return [-n] [exit_status] set [option...] [--] [new_positional_parameter...] set -o|+o # print current settings shift [count] suspend [-f] test expression [ expression ] times trap [action signal...] trap signal_number [signal...] trap -p [signal...] true type command... typeset [-fgprxX] [name[=value]...] ulimit -a [-H|-S] ulimit [-H|-S] [-efilnqrstuvx] [limit] umask mode umask [-S] unalias name... unalias -a unset [-fv] [name...] wait [job or process_id...] Enabled features: %5jd %-20s | %ls Use ‘exit’ again to exit anyway. Use the -f option to exec anyway. $%ls is read-only$DIRSTACK is not an array$HOME is not set$OLDPWD is not set$OPTIND has an invalid value$PWD has an invalid value$PWD is not set%ls: ‘-%lc’ is not a valid option %ls: a shell keyword %ls: an alias for ‘%ls’ %ls: the -%lc option's argument is missing %ls: the --%ls option does not take an argument%ls: the operand value must not be negative%ls: the signal name must be specified without ‘SIG’%s: a function %s: a regular built-in (not found in $PATH) %s: a regular built-in at %s %s: a semi-special built-in %s: a special built-in %s: an external command at %s %s: an external command at %s/%s %s: cannot convert the argument ‘%s’ into a wide character string%s: the argument is replaced with an empty string %u is not a positive integer%zu: cannot shift so many (there is only one positional parameter)%zu: cannot shift so many (there are only %zu positional parameters)(maybe you missed ‘%ls’?)-%lc: %-30s CPU time (seconds)Candidate %zu of %zu; Page %zu of %zuDoneDone(%d)Killed (SIG%ls)Killed (SIG%ls: core dumped)No candidatesOptions: RunningSIG%ls cannot be resetSIG%ls cannot be trappedStopped(SIG%ls)Syntax: %s [option...] [filename [argument...]] %s [option...] -c command [command_name [argument...]] %s [option...] -s [argument...] Syntax: %s The process was killed by SIG%ls The process was killed by SIG%ls: %s This is free software licensed under GNU GPL version 2. You can modify and redistribute it, but there is NO WARRANTY. Try ‘man yash’ for details. Use ‘exit’ to leave the shell. Yet another shell, version %s You have a stopped job!You have %zu stopped jobs!You have new mail.[%zu] %c %-20s %ls [%zu] %c %5jd %-20s %ls ‘%lc’ is not a valid conversion specifier‘%ls’‘%ls’ cannot be used as a command name‘%ls’ is missing‘%ls’ is not a binary operator‘%ls’ is not a job-controlled job‘%ls’ is not a unary operator‘%ls’ is not a valid alias name‘%ls’ is not a valid array name‘%ls’ is not a valid identifier‘%ls’ is not a valid index‘%ls’ is not a valid integer‘%ls’ is not a valid job specification‘%ls’ is not a valid mask specification‘%ls’ is not a valid number‘%ls’ is not a valid operator‘%ls’ is not a valid option‘%ls’ is not a valid option specification‘%ls’ is not a valid variable name‘%ls’ is used outside ‘case’‘%ls’: a command name must not contain ‘/’‘%s’‘(’ must be followed by ‘)’ in a function definition‘;’ is not allowed just after the identifier in a for loop‘;’ or ‘&’ is missinga command is missing at the end of inputa command is missing before ‘%lc’a function body must be a compound commanda nested parameter expansion cannot be assigneda word is required after ‘%ls’an expression is missing after ‘%ls’an identifier is required after ‘for’an unquoted ‘esac’ cannot be the first case patternarithmetic: ‘%lc’ is not a valid number or operatorarithmetic: ‘%ls’ is missingarithmetic: ‘%ls’ is not a valid numberarithmetic: a value is missingarithmetic: cannot assign to a numberarithmetic: division by zeroarithmetic: invalid syntaxarithmetic: operator ‘%ls’ is not supportedarithmetic: operator ‘%ls’ requires a variablecannot assign to parameter ‘%ls’ in parameter expansioncannot be used during line-editingcannot be used in the interactive modecannot bind an empty key sequencecannot copy file descriptor %d to %dcannot create a temporary file for the here-documentcannot create a temporary file to edit historycannot determine the current directorycannot execute command ‘%s’cannot execute command ‘%s’ (%s)cannot get the current limit for the resource type of ‘%s’cannot get the time datacannot invoke a new shell to execute script ‘%s’cannot invoke the editor to edit historycannot make a child processcannot open a pipecannot open a pipe for the command substitutioncannot open file ‘%s’cannot open temporary file ‘%s’cannot parse the formatcannot print to the standard outputcannot read commands from file ‘%s’cannot read history from file ‘%ls’cannot read inputcannot save file descriptor %dcannot seek the temporary file for the here-documentcannot send SIGSTOP signalcannot write history to file ‘%ls’cannot write the here-document contents to the temporary filechange the working directorycommand ‘%s’ was not found in $PATHcommand redirectioncommand substitutioncommands are missing after ‘%ls’commands are missing between ‘%ls’ and ‘%ls’continue a loopcore file size (blocks)data segment size (kbytes)define or print aliasesdisabling job controldisown jobsdo nothingdo nothing successfullydo nothing unsuccessfullyencountered ‘%ls’ without a matching ‘(’encountered ‘%ls’ without a matching ‘case’encountered ‘%ls’ without a matching ‘do’encountered ‘%ls’ without a matching ‘for’, ‘while’, or ‘until’encountered ‘%ls’ without a matching ‘if’ and/or ‘then’encountered ‘%ls’ without a matching ‘if’ or ‘elif’encountered ‘%ls’ without a matching ‘{’encountered an invalid character ‘%lc’ in the case patternerror in closing file descriptor %devaluate a conditional expressionevaluate arguments as a commandexecute or identify a commandexit a loopexit the shellexport variables as environment variablesfailed to remove temporary file ‘%s’failed to set $PWDfailed to set environment variable $%sfailed to set the limitfailed to unset environment variable $%sfile ‘%s’ was not found in $PATHfile ‘%s’ was not found in $YASH_LOADPATHfile locksfile size (blocks)filename ‘%ls’ matches more than one filefunction ‘%ls’ cannot be redefined because it is read-onlyfunction ‘%ls’ is read-onlygenerate completion candidatesidentify a commandindex %ls is out of rangeindex %ls is out of range (the actual size of array $%ls is %zu)index %zu is out of range (the actual size of array $%ls is %zu)invalid character ‘%lc’ in parameter expansioninvalid flag for conversion specifier ‘%lc’invalid use of ‘%lc’invalid use of ‘%lc’ in parameter expansionjob %%%zu has already terminatedjob control is disabledjob specification ‘%ls’ is ambiguouskey sequence ‘%ls’ is not boundlineeditlist or re-execute command historylocked memory (kbytes)make variables read-onlymanage command historymanipulate an arraymax nicememory (kbytes)message queue size (bytes)more than one -%lc option is specifiedmore than one option cannot be used at onceno operand is expectedno option is specifiedno such alias ‘%ls’no such array $%lsno such built-in ‘%ls’no such command ‘%s’no such editing command ‘%ls’no such function ‘%ls’no such history entry ‘%ls’no such history entry beginning with ‘%ls’no such job ‘%ls’no such signal ‘%ls’no such user ‘%ls’no such variable $%lsnot in a loopnot in an iterationoffonopen filesoption ‘%ls’ is ambiguousoption combination is invalidparameter ‘%ls’ is not setparameter ‘%ls’ is not set or has an empty valueparse command optionspending signalspop a directory from the directory stackprint CPU time usageprint a formatted stringprint argumentsprint info about jobsprint or set the file creation maskprint the directory stackprint the working directoryprint usage of built-in commandspromptpush a directory into the directory stackread a file and execute commandsread a line from the standard inputreal-time priorityreal-time signal SIG%ls is not supportedredirectionredirection: %d>>|%dredirection: %d>>|%d: the input and output file descriptors are sameredirection: %sredirection: cannot open a pipe for the command redirectionredirection: cannot open file ‘%s’redirection: file descriptor %d is not readableredirection: file descriptor %d is not writableredirection: file descriptor %d is unavailableredirection: invalid file descriptorredirections are not allowed after ‘in’refusing to suspend because of a possible deadlock. Use the -f option to suspend anyway.remember, forget, or report command locationsremove some positional parametersremove variables or functionsreplace the shell process with an external commandresident set size (kbytes)return from a function or scriptrun jobs in the backgroundrun jobs in the foregroundsend a signal to processesset or print a resource limitationset or print key bindings for line-editingset or print signal handlersset or print variablesset shell options and positional parameterssocket redirection: cannot resolve the address of ‘%s’: %sstack size (kbytes)suspend the shellsyntax error: the %ls option cannot be changed once the shell has been initializedthe -%lc option cannot be used with the -%lc optionthe -%lc option requires an argumentthe --%ls option requires an argumentthe -a or -k option must be used with the -v optionthe -c option is specified but no command is giventhe -n or -v option must be used with the -l optionthe backquoted command substitution is not closedthe command history is emptythe complete built-in can be used during command line completion onlythe conversion specifier is missingthe directory stack is emptythe double quotation is not closedthe editor returned a non-zero exit statusthe end-of-here-document indicator contains a newlinethe end-of-here-document indicator is missingthe index is missingthe index is not an integerthe parameter index is invalidthe parameter name is missing or invalidthe parameter value is emptythe redirection target is missingthe signal name is not specifiedthe single quotation is not closedthe soft limit cannot exceed the hard limitthe specified index does not support assignment in the parameter expansion of array ‘%ls’the specified prefix ‘%ls’ does not match the target word ‘%ls’there is no current jobthis command requires an operandthis command requires %zu operandstoo many files are opened for yash to handletoo many operands are specifiedundefine aliasesunexpected errorunknown errorunlimiteduser processeswait for jobs to terminateyash-2.35/po/en@boldquot.hd0000644000175000017500000000247112154557026015761 0ustar magicantmagicant# All this catalog "translates" are quotation characters. # The msgids must be ASCII and therefore cannot contain real quotation # characters, only substitutes like grave accent (0x60), apostrophe (0x27) # and double quote (0x22). These substitutes look strange; see # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html # # This catalog translates grave accent (0x60) and apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019). # It also translates pairs of apostrophe (0x27) to # left single quotation mark (U+2018) and right single quotation mark (U+2019) # and pairs of quotation mark (0x22) to # left double quotation mark (U+201C) and right double quotation mark (U+201D). # # When output to an UTF-8 terminal, the quotation characters appear perfectly. # When output to an ISO-8859-1 terminal, the single quotation marks are # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to # grave/acute accent (by libiconv), and the double quotation marks are # transliterated to 0x22. # When output to an ASCII terminal, the single quotation marks are # transliterated to apostrophes, and the double quotation marks are # transliterated to 0x22. # # This catalog furthermore displays the text between the quotation marks in # bold face, assuming the VT100/XTerm escape sequences. # yash-2.35/po/Makefile.in0000644000175000017500000001347712154557026015245 0ustar magicantmagicant# Makefile.in for PO files of yash # (C) 2007-2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # NOTE: In this Makefile it is assumed that the make implementation allows the # use of hyphens in target names. This means that there may be a strictly # POSIX-conforming implementation of make that rejects this Makefile. I have # never seen such an implementation but if you know of one please let me know. .POSIX: .SUFFIXES: .po .mo .ih @MAKE_SHELL@ topdir = .. subdir = po XGETTEXT = @XGETTEXT@ XGETTEXTFLAGS = @XGETTEXTFLAGS@ MSGINIT = @MSGINIT@ MSGFMT = @MSGFMT@ MSGFMTFLAGS = @MSGFMTFLAGS@ MSGMERGE = @MSGMERGE@ MSGMERGEFLAGS = @MSGMERGEFLAGS@ MSGCONV = @MSGCONV@ MSGFILTER = @MSGFILTER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_DIR = @INSTALL_DIR@ POFILES_MAN = ja.po POFILES_QUOT = en@quot.po en@boldquot.po POFILES = $(POFILES_MAN) $(POFILES_QUOT) MOFILES = $(POFILES:.po=.mo) CATALOGS = @CATALOGS@ DOMAIN = @TARGET@ VERSION = @VERSION@ COPYRIGHT_HOLDER = Magicant DESTDIR = prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ datarootdir = @datarootdir@ datadir = @datadir@ yashdatadir = $(datadir)/$(TARGET) localedir = @localedir@ mandir = @mandir@ docdir = @docdir@ htmldir = @htmldir@ # stamp-po is a timestamp denoting the last time at which the $(CATALOGS) have # been loosely updated. Its purpose is that when a developer or translator # checks out the package via VCS, "make" will update the $(DOMAIN).pot and the # $(CATALOGS), but subsequent invocations of "make" will do nothing. This # timestamp would not be necessary if updating the $(CATALOGS) would always # touch them; however, the rule for $(POFILES) has been designed to not touch # files that don't need to be changed. stamp-po: $(DOMAIN).pot @+[ -z "$(CATALOGS)" ] || $(MAKE) $(CATALOGS) touch $@ # This rule has no dependencies: we don't need to update $(DOMAIN).pot at # every "make" invocation, only create it when it is missing. # Only "make $(DOMAIN).pot-update", "make update-po" or "make dist" will force # an update. $(DOMAIN).pot: @+$(MAKE) $(DOMAIN).pot-update # This target rebuilds $(DOMAIN).pot; it is an expensive operation. $(DOMAIN).pot-update: (cd $(topdir) && find . -name '*.[ch]') | \ $(XGETTEXT) -d $(DOMAIN) -D $(topdir) -cTRANSLATORS: -f - -F --no-wrap \ --package-name=$(DOMAIN) --package-version=$(VERSION) \ --msgid-bugs-address=http://sourceforge.jp/projects/yash/forums/ \ --copyright-holder='$(COPYRIGHT_HOLDER)' $(XGETTEXTFLAGS) mv $(DOMAIN).po $(DOMAIN).pot # This target rebuilds a PO file if $(DOMAIN).pot has changed. # Note that a PO file is not touched if it doesn't need to be changed. $(POFILES_MAN): $(DOMAIN).pot $(MSGMERGE) -FU $(MSGMERGEFLAGS) $@ $(DOMAIN).pot # This target creates PO files that are automatically created from the # $(DOMAIN).pot file. This requires GNU sed (or a compatible one) that doesn't # automatically append a missing newline at the end of input. en@quot.po: $(DOMAIN).pot en@quot.ih en@quot.hd $(MSGINIT) -i $(DOMAIN).pot --no-translator -l en@quot -o - 2>/dev/null | \ sed -f en@quot.ih | \ $(MSGCONV) -t UTF-8 | \ $(MSGFILTER) sed -f quot.sed >$@ en@boldquot.po: $(DOMAIN).pot en@boldquot.ih en@boldquot.hd $(MSGINIT) -i $(DOMAIN).pot --no-translator -l en@boldquot -o - 2>/dev/null | \ sed -f en@boldquot.ih | \ $(MSGCONV) -t UTF-8 | \ $(MSGFILTER) sed -f boldquot.sed >$@ $(POFILES_QUOT:.po=.ih): insert-hd.sin target='$@'; lang=$${target%.*}; \ sed -e '/^#/d' -e "s/HEADER/$${lang}.hd/g" insert-hd.sin >$@ # This target updates all PO files as well as $(DOMAIN).pot. update-po: $(DOMAIN).pot-update @+$(MAKE) $(POFILES) .po.mo: $(MSGFMT) $(MSGFMTFLAGS) -o t-$@ $< mv -f t-$@ $@ install: install-data install-data: installdirs-data stamp-po @for lang in $(CATALOGS:.mo=); do \ dir=$(localedir)/$$lang/LC_MESSAGES; \ echo $(INSTALL_DATA) $$lang.mo $(DESTDIR)$$dir/$(DOMAIN).mo || true; \ $(INSTALL_DATA) $$lang.mo $(DESTDIR)$$dir/$(DOMAIN).mo; \ done installdirs: installdirs-data installdirs-data: @for lang in $(CATALOGS:.mo=); do \ dir=$(localedir)/$$lang/LC_MESSAGES; \ echo $(INSTALL_DIR) $(DESTDIR)$$dir || true; \ $(INSTALL_DIR) $(DESTDIR)$$dir; \ done uninstall: uninstall-data uninstall-data: @for lang in $(CATALOGS:.mo=); do \ dir=$(localedir)/$$lang/LC_MESSAGES; \ echo rm -f $(DESTDIR)$$dir/$(DOMAIN).mo || true; \ rm -f $(DESTDIR)$$dir/$(DOMAIN).mo; \ done DISTTARGETFILES = $(DOMAIN).pot $(POFILES) $(MOFILES) Makefile.in \ quot.sed boldquot.sed en@quot.ih en@quot.hd \ en@boldquot.ih en@boldquot.hd insert-hd.sin DISTFILES = $(DISTTARGETFILES) stamp-po distfiles: $(DISTTARGETFILES) touch stamp-po copy-distfiles: distfiles mkdir -p $(topdir)/$(DISTTARGETDIR) cp $(DISTFILES) $(TEST_SOURCES) $(topdir)/$(DISTTARGETDIR) mostlyclean: rm -fr $(DOMAIN).po clean: mostlyclean distclean: clean rm -fr Makefile maintainer-clean: distclean rm -fr $(DOMAIN).pot stamp-po $(POFILES_QUOT) $(POFILES_QUOT:.po=.ih) $(MOFILES) Makefile: Makefile.in $(topdir)/config.status @+(cd $(topdir) && $(MAKE) config.status) @(cd $(topdir) && $(SHELL) config.status $(subdir)/$@) .PHONY: $(DOMAIN).pot-update update-po install install-data installdirs installdirs-data uninstall uninstall-data distfiles copy-distfiles mostlyclean clean distclean maintainer-clean yash-2.35/variable.d0000644000175000017500000000050512154557026014500 0ustar magicantmagicantvariable.o: variable.c common.h config.h variable.h xgetopt.h builtin.h \ configm.h exec.h expand.h hashtable.h input.h option.h parser.h path.h \ plist.h sig.h strbuf.h util.h xfnmatch.h yash.h lineedit/complete.h \ lineedit/../plist.h lineedit/../xgetopt.h lineedit/lineedit.h \ lineedit/../input.h lineedit/terminfo.h yash-2.35/arith.d0000644000175000017500000000013412154557026014020 0ustar magicantmagicantarith.o: arith.c common.h config.h arith.h option.h xgetopt.h strbuf.h \ util.h variable.h yash-2.35/parser.d0000644000175000017500000000024012154557026014203 0ustar magicantmagicantparser.o: parser.c common.h config.h parser.h input.h alias.h xgetopt.h \ expand.h option.h plist.h strbuf.h util.h lineedit/lineedit.h \ lineedit/../input.h yash-2.35/configure0000755000175000017500000012447612154557026014473 0ustar magicantmagicant# Manually written configuration script for yash # (C) 2007-2013 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . makefile="Makefile" makefilein="Makefile.in" configlog="config.log" configstatus="config.status" configh="config.h" tempsrc=".temp.c" tempo=".temp.o" tempd=".temp.d" tempout="./.temp.out" temptxt="./.temp.txt" dirs=". builtins doc doc/ja lineedit po tests" target="yash" version="2.35" copyright="Copyright (C) 2007-2013 magicant" # object files to be linked as `yash' objs='$(MAIN_OBJS)' # object files compiled into builtins.a builtin_objs='' null="" help="false" nocreate="false" debug="false" enable_alias="true" enable_array="true" enable_dirstack="true" enable_nls="true" enable_help="true" enable_history="true" enable_lineedit="true" enable_printf="true" enable_socket="true" enable_test="true" enable_ulimit="true" default_loadpath='$(yashdatadir)' ctags_args="" etags_args="" intl_lib='intl' term_lib='tinfo curses ncurses ncursesw' prefix='/usr/local' exec_prefix='$(prefix)' bindir='$(exec_prefix)/bin' datarootdir='$(prefix)/share' datadir='$(datarootdir)' localedir='$(datarootdir)/locale' mandir='$(datarootdir)/man' docdir='$(datarootdir)/doc/'"$target" htmldir='$(docdir)' install_program='$(INSTALL) -c' install_data='$(INSTALL) -c -m 644' install_dir='$(INSTALL) -d' unset checkresult unset MAKEFLAGS umask u=rwx quoted0="'"$(printf '%s\n' "$0" | sed -e "s/'/'\\\\''/g")"'" quoted_args= for i do if [ x"$i" != x"--no-create" ] then quoted_args="${quoted_args} '"$(printf '%s\n' "$i" | sed -e "s/'/'\\\\''/g")"'" fi done parseenable() { case "$1" in --enable-*=yes|--enable-*=true) val=true ;; --enable-*=no|--enable-*=false) val=false ;; *=*) echo "$0: $1: invalid option" >&2; exit 2 ;; --enable-*) val=true ;; --disable-*) val=false ;; esac opt="${1#--*able-}" opt="${opt%%=*}" case "$opt" in alias) enable_alias=$val ;; array) enable_array=$val ;; dirstack) enable_dirstack=$val ;; help) enable_help=$val ;; history) enable_history=$val ;; lineedit) enable_lineedit=$val ;; nls) enable_nls=$val ;; printf) enable_printf=$val ;; socket) enable_socket=$val ;; test) enable_test=$val ;; ulimit) enable_ulimit=$val ;; *) echo "$0: $1: invalid option" >&2; exit 2 ;; esac } # parse options for i do case "$i" in -h|--help) help="true" ;; --no-create) nocreate="true" ;; -d|--debug) debug="true" ;; --prefix=*) prefix="${i#--prefix=}" ;; --exec-prefix=*) exec_prefix="${i#--exec-prefix=}" ;; --bindir=*) bindir="${i#--bindir=}" ;; --datarootdir=*) datarootdir="${i#--datarootdir=}" ;; --datadir=*) datadir="${i#--datadir=}" ;; --localedir=*) localedir="${i#--localedir=}" ;; --mandir=*) mandir="${i#--mandir=}" ;; --docdir=*) docdir="${i#--docdir=}" ;; --htmldir=*) htmldir="${i#--htmldir=}" ;; --enable-*|--disable-*) parseenable "$i" ;; --default-loadpath=*) default_loadpath="${i#--default-loadpath=}" ;; --with-intl-lib=*) intl_lib="${i#--with-intl-lib=}" ;; --with-term-lib=*) term_lib="${i#--with-term-lib=}" ;; ?*=*) # parse variable assignment if echo "$i" | grep -E "^[[:alpha:]][[:alnum:]]*=" >/dev/null then export "$i" else echo "$0: $i: unknown argument" >&2 exit 1 fi ;; *) echo "$0: $i: unknown argument" >&2 exit 1 esac done if ${help} then exec cat <"${configlog}" { printf '===== Configuration log: generated by %s\n' "${0##*/}" echo LC_TIME=C date echo printf '# Invocation command line was:\n%%' for i in "$0" "$@" do printf ' %s' "$(printf '%s\n' "$i" | sed -e '\|[^[:alnum:]./=-]| { s/'"'"'/'"'\\''"'/g s/\(.*\)/'"'"'\1'"'"'/ }')" done echo echo printf '# uname -i = %s\n' "$(uname -i 2>/dev/null || echo \?)" printf '# uname -n = %s\n' "$(uname -n 2>/dev/null || echo \?)" printf '# uname -m = %s\n' "$(uname -m 2>/dev/null || echo \?)" printf '# uname -o = %s\n' "$(uname -o 2>/dev/null || echo \?)" printf '# uname -p = %s\n' "$(uname -p 2>/dev/null || echo \?)" printf '# uname -r = %s\n' "$(uname -r 2>/dev/null || echo \?)" printf '# uname -s = %s\n' "$(uname -s 2>/dev/null || echo \?)" printf '# uname -v = %s\n' "$(uname -v 2>/dev/null || echo \?)" printf '# uname -a = %s\n' "$(uname -a 2>/dev/null || echo \?)" echo printf '# PATH=%s\n' "$PATH" echo } >&5 checking () { printf 'checking %s... ' "$1" printf '\nchecking %s...\n' "$1" >&5 } checkby () { printf '%% %s\n' "$*" >&5 "$@" >&5 2>&1 laststatus=$? if [ ${laststatus} -eq 0 ] then checkresult="yes" else printf '# exit status: %d\n' "${laststatus}" >&5 checkresult="no" return ${laststatus} fi } trymake () { checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \ ${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \ ${LDFLAGS-${ldflags}} ${LDADDS-${null}} -o "${tempout}" "${tempsrc}" \ "$@" ${LDLIBS-${ldlibs}} } trycompile () { checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \ ${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \ -c -o "${tempo}" "${tempsrc}" "$@" } trylink () { checkby ${CC-${cc}} ${LDFLAGS-${ldflags}} ${LDADDS-${null}} \ -o "${tempout}" "${tempo}" "$@" ${LDLIBS-${ldlibs}} } tryexec () { checkby "${tempout}" } checked () { if [ $# -ge 1 ] then checkresult="$1" fi printf '%s\n' "${checkresult}" printf '# result: %s\n' "${checkresult}" >&5 } defconfigh () { printf '# defining %s=%s in %s\n' "$1" "${2-1}" "${configh}" >&5 confighdefs="${confighdefs} #define ${1} ${2-1}" } fail () { echo "configuration failed" >&2 exit 1 } cc="${CC-c99}" cflags="${CFLAGS--O1 -g}" cppflags="${CPPFLAGS-${null}}" ldflags="${LDFLAGS-${null}}" ldlibs="${LDLIBS-${null}}" ar="${AR-ar}" arflags="${ARFLAGS--rc}" xgettext="${XGETTEXT-xgettext}" xgettextflags="${XGETTEXTFLAGS--kgt -kNgt -kngt:1,2 \ --flag=sb_vprintf:1:c-format --flag=sb_printf:1:c-format \ --flag=malloc_vprintf:1:c-format --flag=malloc_printf:1:c-format \ --flag=xerror:1:c-format --flag=serror:1:c-format \ --flag=le_compdebug:1:c-format}" msginit="${MSGINIT-msginit}" msgfmt="${MSGFMT-msgfmt}" msgfmtflags="${MSGFMTFLAGS--c}" msgmerge="${MSGMERGE-msgmerge}" msgmergeflags="${MSGMERGEFLAGS-${null}}" msgconv="${MSGCONV-msgconv}" msgfilter="${MSGFILTER-msgfilter}" asciidoc="${ASCIIDOC-asciidoc}" asciidocflags="${ASCIIDOCFLAGS-}" asciidocattrs="${ASCIIDOCATTRS--a docdate=\"\`date +%Y-%m-%d\`\" \ -a yashversion=\"\$(VERSION)\" -a linkcss -a disable-javascript}" a2x="${A2X-a2x}" a2xflags="${A2XFLAGS-}" ctags="${CTAGS-ctags}" etags="${ETAGS-etags}" cscope="${CSCOPE-cscope}" confighdefs='' # check OS type checking 'operating system' ostype=$(uname -s | tr "[:upper:]" "[:lower:]") checked "${ostype}" case "${ostype}" in darwin) defconfigh "_DARWIN_C_SOURCE" ;; sunos) defconfigh "__EXTENSIONS__" ;; esac # check POSIX conformance checking 'POSIX conformance' posixver=$(getconf _POSIX_VERSION 2>/dev/null) if [ -n "${posixver}" ] && [ x"${posixver}" != x"undefined" ] then checked "${posixver}" else checked "no" posixver="" fi checking 'SUS conformance' xopenver=$(getconf _XOPEN_VERSION 2>/dev/null) if [ -n "${xopenver}" ] && [ x"${xopenver}" != x"undefined" ] then checked "${xopenver}" else checked "no" xopenver="" fi case "${ostype}" in freebsd) # FreeBSD doesn't have a feature test macro to enable non-POSIX # extensions. We don't define _POSIX_C_SOURCE or _XOPEN_SOURCE so that # non-POSIX extensions are available. posix= xopen= ;; *) posix=${posixver} xopen=${xopenver} ;; esac # check if gcc is available if the debug option is enabled if ${debug} then checking 'whether GCC is available' if checkby eval "${CC-gcc -std=c99} --version | grep -i gcc" then checked "yes" cc="${CC-gcc -std=c99}" cflags="-pedantic -MMD -Wall -Wextra -O1 -fno-inline -ggdb" else checked "no" echo "--debug option specified but GCC is not available" >&2 fail fi else defconfigh "NDEBUG" fi # check if the compiler works checking 'whether the compiler works' cat >"${tempsrc}" <&2 fail fi # check if the compiler accepts the -O2 option if we are not debugging if ! ${debug} && [ x"${CFLAGS+set}" != x"set" ] then checking 'whether the compiler accepts -O2 flag' savecflags=${cflags} cflags="-O2 -g" cat >"${tempsrc}" <"${temptxt}" </dev/null END checkby eval "${MAKE-make} -f - _TEST_ <|"${tempsrc}" checkby pax -w -x ustar -f "${tempout}" "${tempsrc}" checked if [ x"${checkresult}" = x"yes" ] then archiver='pax -w -x ustar -f' else archiver='tar cf' fi fi # check if the install command is available if [ x"${INSTALL+set}" != x"set" ] then checking 'for the install command' >|"${tempsrc}" checkby install -c -m 644 "${tempsrc}" "${tempout}" checked if [ x"${checkresult}" = x"yes" ] then install='install' else install='$(topdir)/install-sh' fi fi # check if defining _POSIX_C_SOURCE and _XOPEN_SOURCE as values larger than # _POSIX_VERSION and _XOPEN_VERSION is accepted. if [ -n "${posix}" ] then checking 'what values _POSIX_C_SOURCE and _XOPEN_SOURCE should have' if cat >"${tempsrc}" < int main(void) { fork(); return 0; } END trycompile then checked "_POSIX_C_SOURCE=200809L, _XOPEN_SOURCE=700" posix=200809 xopen=700 elif cat >"${tempsrc}" < int main(void) { fork(); return 0; } END trycompile then checked "_POSIX_C_SOURCE=200112L, _XOPEN_SOURCE=600" posix=200112 xopen=600 else checked "failed" fi fi if [ -n "${posix}" ] then defconfigh "_POSIX_C_SOURCE" "${posix}L" fi if [ -n "${xopen}" ] then defconfigh "_XOPEN_SOURCE" "${xopen}" fi # check if _XOPEN_SOURCE_EXTENDED is accepted if [ -n "${posix}" ] then checking 'whether _XOPEN_SOURCE_EXTENDED should be defined' cat >"${tempsrc}" < int main(void) { fork(); return 0; } END trycompile checked if [ x"${checkresult}" = x"yes" ] then defconfigh "_XOPEN_SOURCE_EXTENDED" "1" fi fi # check if we need -lm if [ x"${LDLIBS+set}" != x"set" ] then checking 'if loader flag -lm can be omitted' cat >"${tempsrc}" < int main(int argc, char **argv) { return fmod(argc, 1.1) == trunc(argc) || argv == 0; } END trymake checked if [ x"${checkresult}" = x"no" ] then ldlibs="${ldlibs} -lm" fi fi # enable/disable socket redirection if ${enable_socket} then checking 'for socket library' cat >"${tempsrc}" < #include int main(void) { struct addrinfo ai = { .ai_flags = 0, .ai_family = AF_UNSPEC, .ai_protocol = 0, .ai_socktype = 1 ? SOCK_STREAM : SOCK_DGRAM, .ai_addrlen = 0, .ai_addr = (void*)0, .ai_canonname = (void*)0, .ai_next = (void*)0 }; gai_strerror(getaddrinfo("", "", &ai, (void*)0)); connect(socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol), ai.ai_addr, ai.ai_addrlen); freeaddrinfo(&ai); } END saveldlibs="${ldlibs}" if trymake then checked "yes" else for lib in '-lxnet' '-lsocket' '-lnsl' '-lsocket -lnsl' do ldlibs="${saveldlibs} ${lib}" if trymake then checked "with ${lib}" break fi done fi case "${checkresult}" in yes|with*) defconfigh "YASH_ENABLE_SOCKET" unset saveldlibs ;; no) checked "no" printf 'The socket library is unavailable!\n' >&2 printf 'Add the "--disable-socket" option and try again.\n' >&2 fail ;; esac fi # check if gettext is available if ${enable_nls} then checking 'for ngettext' cat >"${tempsrc}" < int main(void) { const char *s = ngettext("foo", "bar", 1); return s == 0; } END trycompile checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_NGETTEXT" fi checking 'for gettext library' cat >"${tempsrc}" < int main(void) { bindtextdomain("", ""); textdomain(""); const char *s = gettext(""); #if HAVE_NGETTEXT s = ngettext("", "", 0); #endif return s == 0; } END if trycompile then saveldlibs="${ldlibs}" if trylink then checked "yes" else for lib in ${intl_lib} do ldlibs="${saveldlibs} -l${lib}" if trylink then checked "with -l${lib}" break fi done fi fi case "${checkresult}" in yes|with*) defconfigh "HAVE_GETTEXT" unset saveldlibs ;; no) checked "no" printf 'The gettext library is unavailable!\n' >&2 printf 'Add the "--disable-nls" option and try again.\n' >&2 fail ;; esac fi # check if terminfo is available if ${enable_lineedit} then for i in curses.h:CURSES_H ncurses.h:NCURSES_H \ ncurses/ncurses.h:NCURSES_NCURSES_H \ ncursesw/ncurses.h:NCURSESW_NCURSES_H do checking "for ${i%:*}" cat >"${tempsrc}" < int main(void) { return ERR; } END trycompile checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_${i#*:}" break fi done for i in term.h:TERM_H ncurses/term.h:NCURSES_TERM_H \ ncursesw/term.h:NCURSESW_TERM_H do checking "for ${i%:*}" cat >"${tempsrc}" < #elif HAVE_NCURSES_H #include #elif HAVE_NCURSES_NCURSES_H #include #elif HAVE_NCURSESW_NCURSES_H #include #endif #include <${i%:*}> int main(void) { int (*f1)(char *, int, int *) = setupterm; f1("", 0, 0); int (*f2)(char *) = tigetflag; f2(""); int (*f3)(char *) = tigetnum; f3(""); char *(*f4)(char *) = tigetstr; f4(""); int (*f5)(const char *, int, int (*)(int)) = tputs; f5("", 0, 0); /* char *(*f6)(char *, long,long,long,long,long,long,long,long,long) = tparm; f6("", 0, 0, 0, 0, 0, 0, 0, 0, 0); */ int (*f7)(TERMINAL *) = del_curterm; f7(cur_term); } END trycompile checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_${i#*:}" break fi done checking 'for terminfo library' cat >"${tempsrc}" < #if HAVE_CURSES_H #include #elif HAVE_NCURSES_H #include #elif HAVE_NCURSES_NCURSES_H #include #elif HAVE_NCURSESW_NCURSES_H #include #endif #if HAVE_TERM_H #include #elif HAVE_NCURSES_TERM_H #include #elif HAVE_NCURSESW_TERM_H #include #endif int main(void) { int i1 = setupterm((char*)0, 1, (int*)0); int i2 = tigetflag(""); int i3 = tigetnum(""); char *s1 = tigetstr(""); char *s2 = tparm(s1, (long) i1, (long) i2, (long) i3, 0L, 0L, 0L, 0L, 0L, 0L); int i4 = tputs(s2, 1, putchar); del_curterm(cur_term); return i4; } END if trycompile then saveldlibs="${ldlibs}" if trylink then checked "yes" else for lib in ${term_lib} do ldlibs="${saveldlibs} -l${lib}" if trylink then checked "with -l${lib}" break fi done fi fi case "${checkresult}" in yes|with*) defconfigh "YASH_ENABLE_LINEEDIT" unset saveldlibs ;; no) checked "no" printf 'The terminfo (curses) library is unavailable!\n' >&2 printf 'Add the "--disable-lineedit" option and try again.\n' >&2 fail ;; esac fi # check whether system has /proc/self/exe or similar utility file if checking 'for /proc/self/exe' checkby /proc/self/exe -c true checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_PROC_SELF_EXE" elif checking 'for /proc/curproc/file' checkby /proc/curproc/file -c true checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_PROC_CURPROC_FILE" elif checking 'for /proc/$$/object/a.out' checkby eval '/proc/$$/object/a.out -c true' checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_PROC_OBJECT_AOUT" fi # check for strnlen checking 'for strnlen' cat >"${tempsrc}" < #ifndef strnlen size_t strnlen(const char*, size_t); #endif int main(void) { return strnlen("12345", 3) != 3; } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_STRNLEN" fi # check for wcsnlen checking 'for wcsnlen' cat >"${tempsrc}" < #ifndef wcsnlen size_t wcsnlen(const wchar_t*, size_t); #endif int main(void) { return wcsnlen(L"12345", 3) != 3; } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_WCSNLEN" fi # check for wcscasecmp checking 'for wcscasecmp' cat >"${tempsrc}" < #ifndef wcscasecmp int wcscasecmp(const wchar_t*, const wchar_t*); #endif int main(void) { return wcscasecmp(L"1a2b3c", L"1A2B3C") != 0; } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_WCSCASECMP" fi # check for wcsnrtombs checking 'for wcsnrtombs' cat >"${tempsrc}" < #include #include #ifndef wcsnrtombs size_t wcsnrtombs(char *restrict, const wchar_t **restrict, size_t, size_t, mbstate_t *restrict); #endif int main(void) { mbstate_t s; char out[10]; const wchar_t w[] = L"abcde"; const wchar_t *in = w; memset(&s, 0, sizeof s); return wcsnrtombs(out, &in, SIZE_MAX, sizeof out, &s) != 5 || in != NULL || strcmp(out, "abcde") != 0 || wcsnrtombs(out, (in = &w[1], &in), 3, sizeof out, &s) != 3 || in != &w[4] || strncmp(out, "bcd", 3) != 0; } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_WCSNRTOMBS" fi # check for wcstold checking 'for wcstold' cat >"${tempsrc}" < #ifndef wcstold long double wcstold(const wchar_t *restrict, wchar_t **restrict); #endif int main(void) { return wcstold(L"10.0", (wchar_t **) 0) != 10.0; } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_WCSTOLD" fi # check for wcwidth checking 'for wcwidth' cat >"${tempsrc}" < #ifndef wcwidth int wcwidth(wchar_t); #endif int main(void) { return wcwidth(L'\0'); } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_WCWIDTH" fi # check if sys/stat.h defines S_ISVTX checking 'if defines S_ISVTX' cat >"${tempsrc}" < int main(void) { return S_ISVTX & 0; } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_S_ISVTX" fi # check if unsetenv returns int checking 'if unsetenv returns int' cat >"${tempsrc}" < int main(void) { return 0 != unsetenv("x"); } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "UNSETENV_RETURNS_INT" fi # check if the "st_atim"/"st_atimespec"/"st_atimensec"/"__st_atimensec" member # of the "stat" structure is available if ${enable_test} then if checking 'for st_atim' cat >"${tempsrc}" < int main(void) { struct stat st; st.st_atim = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; struct timespec ts = st.st_atim; return ts.tv_nsec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_ST_ATIM" elif checking 'for st_atimespec' cat >"${tempsrc}" < int main(void) { struct stat st; st.st_atimespec = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; struct timespec ts = st.st_atimespec; return ts.tv_nsec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_ST_ATIMESPEC" elif checking 'for st_atimensec' cat >"${tempsrc}" < int main(void) { struct stat st; st.st_atimensec = 0; return st.st_atimensec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_ST_ATIMENSEC" elif checking 'for __st_atimensec' cat >"${tempsrc}" < int main(void) { struct stat st; st.__st_atimensec = 0; return st.__st_atimensec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE___ST_ATIMENSEC" fi fi # check if the "st_mtim"/"st_mtimespec"/"st_mtimensec"/"__st_mtimensec" member # of the "stat" structure is available if checking 'for st_mtim' cat >"${tempsrc}" < int main(void) { struct stat st; st.st_mtim = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; struct timespec ts = st.st_mtim; return ts.tv_nsec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_ST_MTIM" elif checking 'for st_mtimespec' cat >"${tempsrc}" < int main(void) { struct stat st; st.st_mtimespec = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; struct timespec ts = st.st_mtimespec; return ts.tv_nsec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_ST_MTIMESPEC" elif checking 'for st_mtimensec' cat >"${tempsrc}" < int main(void) { struct stat st; st.st_mtimensec = 0; return st.st_mtimensec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_ST_MTIMENSEC" elif checking 'for __st_mtimensec' cat >"${tempsrc}" < int main(void) { struct stat st; st.__st_mtimensec = 0; return st.__st_mtimensec != 0; } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE___ST_MTIMENSEC" fi # check if WCONTINUED and WIFCONTINUED are available checking 'for WCONTINUED and WIFCONTINUED' cat >"${tempsrc}" < #include static int s; int main(void) { if (WIFCONTINUED(s)) { } return waitpid(-1, &s, WNOHANG|WCONTINUED) < 0 && errno == EINVAL; } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_WCONTINUED" fi # check for faccessat/eaccess if checking 'for faccessat' cat >"${tempsrc}" < #include #ifndef faccessat extern int faccessat(int, const char *, int, int); #endif int main(void) { faccessat(AT_FDCWD, ".", F_OK | R_OK | W_OK | X_OK, AT_EACCESS); } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_FACCESSAT" elif checking 'for eaccess' cat >"${tempsrc}" < #ifndef eaccess extern int eaccess(const char *, int); #endif int main(void) { eaccess(".", F_OK | R_OK | W_OK | X_OK); } END trymake checked [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_EACCESS" fi # check for strsignal checking 'for strsingal' cat >"${tempsrc}" < #include #ifndef strsignal char *strsignal(int); #endif int main(void) { (void) strsignal(SIGKILL); } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_STRSIGNAL" fi # check for setpwent & getpwent & endpwent checking 'for setpwent/getpwent/endpwent' cat >"${tempsrc}" < #ifndef setpwent void setpwent(void); #endif #ifndef getpwent struct passwd *getpwent(void); #endif #ifndef endpwent void endpwent(void); #endif struct passwd *p; int main(void) { setpwent(); p = getpwent(); endpwent(); } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_GETPWENT" # check for pw_gecos checking 'for pw_gecos' cat >"${tempsrc}" < const char *s; struct passwd pwd; int main(void) { pwd.pw_gecos = ""; s = pwd.pw_gecos; } END trycompile checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_PW_GECOS" fi fi # check for setgrent & getgrent & endgrent checking 'for setgrent/getgrent/endgrent' cat >"${tempsrc}" < /* don't declare setgrent to avoid conflict on BSD */ #ifndef getgrent struct group *getgrent(void); #endif #ifndef endgrent void endgrent(void); #endif struct group *g; int main(void) { setgrent(); g = getgrent(); endgrent(); } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_GETGRENT" fi # check for sethostent & gethostent & endhostent # This check may fail if socket redirection is disabled # because the -lxnet compiler option is not specified. checking 'for sethostent/gethostent/endhostent' cat >"${tempsrc}" < /* don't declare sethostent and endhostent to avoid conflict on SunOS */ #ifndef gethostent struct hostent *gethostent(void); #endif struct hostent *h; int main(void) { sethostent(1); h = gethostent(); endhostent(); } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_GETHOSTENT" fi # check for paths.h checking 'for paths.h' cat >"${tempsrc}" < #include int main(void) { printf("%s\n", _PATH_BSHELL); } END trycompile checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_PATHS_H" fi # check if getcwd accepts (NULL,0) as argument checking "if getcwd(NULL,0) returns malloc'ed string" cat >"${tempsrc}" < #include #include #include char *xgetcwd(void) { size_t pwdlen = 80; char *pwd = malloc(pwdlen); if (!pwd) return NULL; while (getcwd(pwd, pwdlen) == NULL) { if (errno == ERANGE) { pwdlen *= 2; pwd = realloc(pwd, pwdlen); if (!pwd) return NULL; } else { free(pwd); return NULL; } } return pwd; } int main(void) { char *wd1 = getcwd(NULL, 0); if (!wd1) return 1; char *wd2 = xgetcwd(); if (!wd2 || strcmp(wd1, wd2) != 0) return 1; char *wd11 = realloc(wd1, strlen(wd1) + 10); if (!wd11 || strcmp(wd11, wd2) != 0) return 1; free(wd11); free(wd2); return 0; } END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "GETCWD_AUTO_MALLOC" fi # check if ioctl supports TIOCGWINSZ if ${enable_lineedit} then checking 'if ioctl supports TIOCGWINSZ' cat >"${tempsrc}" < int main(void) { struct winsize ws; ioctl(0, TIOCGWINSZ, &ws); (void) ws.ws_row, (void) ws.ws_col; } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_TIOCGWINSZ" fi fi # check if wide-oriented I/O is working checking 'if wide-oriented I/O is fully working' cat >"${tempsrc}" < #include #define LEN 12345 int main(void) { FILE *f; fpos_t pos; f = fopen("${tempsrc}", "w+"); if (f == NULL) return 1; if (fwprintf(f, L"123\n") != 4) return 2; if (fseek(f, 0, SEEK_SET) != 0) return 3; if (fgetwc(f) != L'1') return 4; if (fgetwc(f) != L'2') return 5; if (fgetpos(f, &pos) != 0) return 6; if (fseek(f, 0, SEEK_SET) != 0) return 7; if (fgetwc(f) != L'1') return 8; if (fsetpos(f, &pos) != 0) return 9; if (fgetwc(f) != L'3') return 10; if (fseek(f, 0, SEEK_SET) != 0) return 11; for (size_t i = 0; i < LEN; i++) if (fputwc(L'0', f) != L'0') return 12; if (fgetpos(f, &pos) != 0) return 13; if (fputwc(L'1', f) != L'1') return 14; if (fseek(f, 0, SEEK_SET) != 0) return 15; if (fgetwc(f) != L'0') return 16; if (fsetpos(f, &pos) != 0) return 17; if (fgetwc(f) != L'1') return 18; if (fseek(f, 0, SEEK_SET) != 0) return 19; for (size_t i = 0; i < LEN; i++) if (fgetwc(f) != L'0') return 20; if (fgetwc(f) != L'1') return 21; if (fclose(f) != 0) return 22; return 0; } END trymake && tryexec checked if [ x"${checkresult}" = x"no" ] then defconfigh "WIO_BROKEN" fi # check if fgetws is working checking 'if fgetws is fully working' cat >"${tempsrc}" < #include int main(void) { wchar_t buf[100]; FILE *f = fopen("${tempsrc}", "w+"); if (f == NULL) return 1; if (fwprintf(f, L"123\n") != 4) return 2; if (fseek(f, 0, SEEK_SET) != 0) return 3; if (fgetws(buf, 2, f) == NULL) return 4; if (wcscmp(buf, L"1") != 0) return 5; if (fclose(f) != 0) return 6; return 0; } END trymake && tryexec checked if [ x"${checkresult}" = x"no" ] then defconfigh "FGETWS_BROKEN" fi echo >&5 # enable/disable aliases if ${enable_alias} then defconfigh "YASH_ENABLE_ALIAS" objs="$objs "'$(ALIAS_OBJS)' fi # enable/disable the array builtin if ${enable_array} then defconfigh "YASH_ENABLE_ARRAY" fi # enable/disable the directory stack if ${enable_dirstack} then defconfigh "YASH_ENABLE_DIRSTACK" fi # enable/disable the help builtin if ${enable_help} then defconfigh "YASH_ENABLE_HELP" fi # enable/disable history if ${enable_history} then defconfigh "YASH_ENABLE_HISTORY" objs="$objs "'$(HISTORY_OBJS)' else if ${enable_lineedit} then printf 'History is required for lineedit but disabled.\n' >&2 printf 'Add the "--disable-lineedit" option and try again.\n' >&2 fail fi fi # enable/disable the echo/printf builtins if ${enable_printf} then defconfigh "YASH_ENABLE_PRINTF" builtin_objs="$builtin_objs "'$(PRINTF_OBJS)' fi # enable/disable the test builtin if ${enable_test} then defconfigh "YASH_ENABLE_TEST" builtin_objs="$builtin_objs "'$(TEST_OBJS)' fi # check for getrlimit and setrlimit if ${enable_ulimit} then checking "for getrlimit and setrlimit" cat >"${tempsrc}" < /* required before on freebsd */ #include /* required before on old Mac OS X */ #include int main(void) { struct rlimit l = { .rlim_cur = RLIM_INFINITY, .rlim_max = RLIM_INFINITY }; getrlimit(RLIMIT_FSIZE, &l); setrlimit(RLIMIT_FSIZE, &l); } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "YASH_ENABLE_ULIMIT" builtin_objs="$builtin_objs "'$(ULIMIT_OBJS)' else printf 'The getrlimit and setrlimit functions are unavailable.\n' >&2 printf 'Add the "--disable-ulimit" option and try again.\n' >&2 fail fi # check for RLIM_SAVED_CUR & RLIM_SAVED_MAX for i in CUR MAX do checking "for RLIM_SAVED_${i}" cat >"${tempsrc}" < /* required before on freebsd */ #include /* required before on old Mac OS X */ #include int main(void) { struct rlimit l = { .rlim_cur = RLIM_SAVED_${i}, .rlim_max = RLIM_SAVED_${i} }; return l.rlim_cur == l.rlim_max; } END trymake checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_RLIM_SAVED_${i}" fi done # check for RLIMIT_*** for i in AS LOCKS MEMLOCK MSGQUEUE NICE NPROC RSS RTPRIO SIGPENDING do checking "for RLIMIT_${i}" cat >"${tempsrc}" < /* required before on freebsd */ #include /* required before on old Mac OS X */ #include #if HAVE_RLIMIT_AS int main(void) { return RLIMIT_${i} == RLIMIT_AS; getrlimit(RLIMIT_${i}, 0); } #else int main(void) { return 0; getrlimit(RLIMIT_${i}, 0); } #endif END trymake && tryexec checked if [ x"${checkresult}" = x"yes" ] then defconfigh "HAVE_RLIMIT_${i}" fi done fi # check if ctags/etags accepts the --recurse option if [ x"${CTAGSARGS+set}" != x"set" ] then checking "if ctags accepts --recurse option" checkby ${ctags} --recurse -f /dev/null /dev/null checked if [ x"${checkresult}" = x"yes" ] then CTAGSARGS='--recurse' else CTAGSARGS='*.[ch]' fi fi if [ x"${ETAGSARGS+set}" != x"set" ] then checking "if etags accepts --recurse option" checkby ${etags} --recurse -o /dev/null /dev/null >/dev/null 2>&1 checked if [ x"${checkresult}" = x"yes" ] then ETAGSARGS='--recurse' else ETAGSARGS='*.[ch]' fi fi # set cscope invocation parameter : ${CSCOPEARGS=-bR} if [ -n "${builtin_objs}" ] then objs="${objs} "'$(BUILTINS_ARCHIVE)' fi if ${enable_lineedit} then objs="${objs} "'$(LINEEDIT_ARCHIVE)' fi if [ x"${LINGUAS+set}" = x"set" ] then CATALOGS='' for i in ${LINGUAS} do CATALOGS="${CATALOGS} ${i}.mo" done else CATALOGS='$(MOFILES)' fi MAKE_INCLUDE="${MAKE_INCLUDE-${make_include}}" MAKE_SHELL="${MAKE_SHELL-${make_shell}}" CC="${CC-${cc}}" CFLAGS="${CFLAGS-${cflags}}${CADDS:+ ${CADDS}}" CPPFLAGS="${CPPFLAGS-${cppflags}}${CPPADDS:+ ${CPPADDS}}" LDFLAGS="${LDFLAGS-${ldflags}}${LDADDS:+ ${LDADDS}}" LDLIBS="${LDLIBS-${ldlibs}}" AR="${AR-${ar}}" ARFLAGS="${ARFLAGS-${arflags}}" ARCHIVER="${ARCHIVER-${archiver}}" XGETTEXT="${XGETTEXT-${xgettext}}" XGETTEXTFLAGS="${XGETTEXTFLAGS-${xgettextflags}}" MSGINIT="${MSGINIT-${msginit}}" MSGFMT="${MSGFMT-${msgfmt}}" MSGFMTFLAGS="${MSGFMTFLAGS-${msgfmtflags}}" MSGMERGE="${MSGMERGE-${msgmerge}}" MSGMERGEFLAGS="${MSGMERGEFLAGS-${msgmergeflags}}" MSGCONV="${MSGCONV-${msgconv}}" MSGFILTER="${MSGFILTER-${msgfilter}}" ASCIIDOC="${ASCIIDOC-${asciidoc}}" ASCIIDOCFLAGS="${ASCIIDOCFLAGS-${asciidocflags}}" ASCIIDOCATTRS="${ASCIIDOCATTRS-${asciidocattrs}}" A2X="${A2X-${a2x}}" A2XFLAGS="${A2XFLAGS-${a2xflags}}" CTAGS="${CTAGS-${ctags}}" ETAGS="${ETAGS-${etags}}" CSCOPE="${CSCOPE-${cscope}}" DIRS="${dirs}" OBJS="${objs}" BUILTIN_OBJS="${builtin_objs}" TARGET="${target}" VERSION="${version}" COPYRIGHT="${copyright}" INSTALL="${INSTALL-${install}}" INSTALL_PROGRAM="${INSTALL_PROGRAM-${install_program}}" INSTALL_DATA="${INSTALL_DATA-${install_data}}" INSTALL_DIR="${INSTALL_DIR-${install_dir}}" case "${prefix}" in / ) prefix= ;; //) prefix=/ ;; esac case "${exec_prefix}" in / ) exec_prefix= ;; //) exec_prefix=/ ;; esac case "${bindir}" in / ) bindir= ;; //) bindir=/ ;; esac case "${datarootdir}" in / ) datarootdir= ;; //) datarootdir=/ ;; esac case "${datadir}" in / ) datadir= ;; //) datadir=/ ;; esac case "${localedir}" in / ) localedir= ;; //) localedir=/ ;; esac case "${mandir}" in / ) mandir= ;; //) mandir=/ ;; esac case "${docdir}" in / ) docdir= ;; //) docdir=/ ;; esac case "${htmldir}" in / ) htmldir= ;; //) htmldir=/ ;; esac sed_subst_cmd=" s!@MAKE_INCLUDE@!${MAKE_INCLUDE}!g s!@MAKE_SHELL@!${MAKE_SHELL}!g s!@CC@!${CC}!g s!@CFLAGS@!${CFLAGS}!g s!@CPPFLAGS@!${CPPFLAGS}!g s!@LDFLAGS@!${LDFLAGS}!g s!@LDLIBS@!${LDLIBS}!g s!@AR@!${AR}!g s!@ARFLAGS@!${ARFLAGS}!g s!@ARCHIVER@!${ARCHIVER}!g s!@XGETTEXT@!${XGETTEXT}!g s!@XGETTEXTFLAGS@!${XGETTEXTFLAGS}!g s!@MSGINIT@!${MSGINIT}!g s!@MSGFMT@!${MSGFMT}!g s!@MSGFMTFLAGS@!${MSGFMTFLAGS}!g s!@MSGMERGE@!${MSGMERGE}!g s!@MSGMERGEFLAGS@!${MSGMERGEFLAGS}!g s!@MSGCONV@!${MSGCONV}!g s!@MSGFILTER@!${MSGFILTER}!g s!@ASCIIDOC@!${ASCIIDOC}!g s!@ASCIIDOCFLAGS@!${ASCIIDOCFLAGS}!g s!@ASCIIDOCATTRS@!${ASCIIDOCATTRS}!g s!@A2X@!${A2X}!g s!@A2XFLAGS@!${A2XFLAGS}!g s!@CATALOGS@!${CATALOGS}!g s!@CTAGS@!${CTAGS}!g s!@CTAGSARGS@!${CTAGSARGS}!g s!@ETAGS@!${ETAGS}!g s!@ETAGSARGS@!${ETAGSARGS}!g s!@CSCOPE@!${CSCOPE}!g s!@CSCOPEARGS@!${CSCOPEARGS}!g s!@DIRS@!${DIRS}!g s!@OBJS@!${OBJS}!g s!@BUILTIN_OBJS@!${BUILTIN_OBJS}!g s!@TARGET@!${TARGET}!g s!@VERSION@!${VERSION}!g s!@COPYRIGHT@!${COPYRIGHT}!g s!@INSTALL@!${INSTALL}!g s!@INSTALL_PROGRAM@!${INSTALL_PROGRAM}!g s!@INSTALL_DATA@!${INSTALL_DATA}!g s!@INSTALL_DIR@!${INSTALL_DIR}!g s!@prefix@!${prefix}!g s!@exec_prefix@!${exec_prefix}!g s!@bindir@!${bindir}!g s!@datarootdir@!${datarootdir}!g s!@datadir@!${datadir}!g s!@localedir@!${localedir}!g s!@mandir@!${mandir}!g s!@docdir@!${docdir}!g s!@htmldir@!${htmldir}!g s!@default_loadpath@!${default_loadpath}!g s!@enable_nls@!${enable_nls}!g " printf '\n\n===== Output variables =====\n%s\n' "${sed_subst_cmd}" >&5 # create dependency files if there are none makedep() { for i in ${1}*.c do if [ -f "${i}" ] && [ ! -f "${i%.c}.d" ] then printf 'touching %s\n' "${i%.c}.d" >>"${i%.c}.d" printf 'Touched %s\n' "${i%.c}.d" >&5 fi done for i in ${1}*/ do if [ -d "${i}" ] then makedep "${i}" fi done } makedep '' # create config.status printf 'creating %s... ' "${configstatus}" cat >"${configstatus}" <&2 exit 1 ;; *) break ;; esac shift done if \$help then exec cat <'${configh}' <"\${target}" if ! ${make_supports_include} && ls "\${dir}"/*.d >/dev/null 2>&1 then printf '(including dependencies) ' cat "\${dir}"/*.d >>"\${target}" fi ;; esac printf 'done\n' done CONFIG_STATUS_END chmod a+x "${configstatus}" printf 'done\n' printf 'Created %s\n' "${configstatus}" >&5 if ! ${nocreate} then printf '%% %s\n' "${CONFIG_SHELL-sh} ${configstatus}" >&5 ${CONFIG_SHELL-sh} ${configstatus} fi # print warning if POSIX conformance is missing if [ -z "${posixver}" ] || [ "${posixver}" -lt 200112 ] then echo "WARNING: yash is designed for systems that conform to POSIX.1-2001" echo " but your system does not" fi # vim: set ft=sh ts=8 sts=4 sw=4 noet tw=80: yash-2.35/yash.h0000644000175000017500000000425312154557026013667 0ustar magicantmagicant/* Yash: yet another shell */ /* yash.h: basic functions of the shell and miscellanies */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_YASH_H #define YASH_YASH_H #include #include #include "xgetopt.h" extern pid_t shell_pid, shell_pgid; extern _Bool shell_initialized; static inline void exit_shell(void) __attribute__((noreturn)); extern void exit_shell_with_status(int status) __attribute__((noreturn)); extern struct input_file_info_T *stdin_input_file_info; extern void exec_wcs(const wchar_t *code, const char *name, _Bool finally_exit) __attribute__((nonnull(1))); typedef enum exec_input_options_T { XIO_INTERACTIVE = 1 << 0, XIO_SUBST_ALIAS = 1 << 1, XIO_FINALLY_EXIT = 1 << 2, } exec_input_options_T; extern void exec_input(int fd, const char *name, exec_input_options_T options); extern _Bool nextforceexit; extern const struct xgetopt_T force_help_options[]; extern int exit_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char exit_help[], exit_syntax[]; #endif extern int suspend_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char suspend_help[], suspend_syntax[]; #endif /* Exits the shell with the last exit status. * This function executes the EXIT trap. * This function never returns. * This function is reentrant and exits immediately if reentered. */ void exit_shell(void) { exit_shell_with_status(-1); } #endif /* YASH_YASH_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/alias.c0000644000175000017500000003654112154557026014014 0ustar magicantmagicant/* Yash: yet another shell */ /* alias.c: alias substitution */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "alias.h" #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include "builtin.h" #include "exec.h" #include "expand.h" #include "hashtable.h" #include "option.h" #include "parser.h" #include "plist.h" #include "strbuf.h" #include "util.h" #if YASH_ENABLE_LINEEDIT # include "xfnmatch.h" # include "lineedit/complete.h" #endif typedef enum { AF_BLANKEND = 1 << 0, /* alias value ends with a blank */ AF_GLOBAL = 1 << 1, /* is a global alias */ } aliasflags_T; typedef struct alias_T { aliasflags_T flags; unsigned refcount; /* reference count */ size_t valuelen; /* length of `value' */ wchar_t value[]; } alias_T; typedef struct aliaslist_T { struct aliaslist_T *next; alias_T *alias; size_t limitindex; } aliaslist_T; /* An alias list created of the `aliaslist_T' structure is used to prevent * infinite recursive substitution of an alias. When an alias is substituted, * the alias and the end index of the substituted string are saved in the list. * Substitution of the same alias is not performed before the saved index, * thus preventing recursive substitution. */ static void free_alias(alias_T *alias); static inline void vfreealias(kvpair_T kv); static void define_alias( const wchar_t *nameandvalue, const wchar_t *equal, bool global) __attribute__((nonnull)); static bool remove_alias(const wchar_t *name) __attribute__((nonnull)); static void remove_all_aliases(void); static aliaslist_T *clone_aliaslist(const aliaslist_T *list) __attribute__((malloc,warn_unused_result)); static bool contained_in_list(const aliaslist_T *list, const alias_T *alias) __attribute__((pure)); static void add_to_aliaslist( aliaslist_T **list, alias_T *alias, size_t limitindex) __attribute__((nonnull)); static aliaslist_T *remove_expired_aliases(aliaslist_T *list, size_t index) __attribute__((warn_unused_result)); static void shift_index(aliaslist_T *list, ptrdiff_t inc); static bool is_redir_fd(const wchar_t *s) __attribute__((nonnull,pure)); static bool print_alias(const wchar_t *name, const alias_T *alias, bool prefix); /* Hashtable mapping alias names (wide strings) to alias_T's. */ hashtable_T aliases; /* Initializes the alias module. */ void init_alias(void) { assert(aliases.capacity == 0); ht_init(&aliases, hashwcs, htwcscmp); } /* Returns true iff `c' is a character that can be used in an alias name. */ inline bool is_alias_name_char(wchar_t c) { return !wcschr(L" \t\n=$<>\\'\"`;&|()#", c) && !iswblank(c); } /* Decreases the reference count of `alias' and, if the count becomes zero, * frees it. This function does nothing if `alias' is a null pointer. */ void free_alias(alias_T *alias) { if (alias != NULL) { alias->refcount--; if (alias->refcount == 0) free(alias); } } /* Applies `free_alias' to the value of key-value pair `kv'. */ void vfreealias(kvpair_T kv) { free_alias(kv.value); } /* Defines an alias. * `nameandvalue' must be a wide string of the form "name=value" and `equal' * must point to the first L'=' in `nameandvalue'. * This function doesn't check if the name and the value are valid. */ void define_alias( const wchar_t *nameandvalue, const wchar_t *equal, bool global) { assert(wcschr(nameandvalue, L'=') == equal); size_t namelen = equal - nameandvalue; size_t valuelen = wcslen(equal + 1); alias_T *alias = xmallocs(sizeof *alias, namelen + valuelen + 2, sizeof *alias->value); alias->flags = 0; alias->refcount = 1; alias->valuelen = valuelen; if (global) alias->flags |= AF_GLOBAL; if (iswblank(equal[valuelen])) // `(equal + 1)[valuelen - 1]' alias->flags |= AF_BLANKEND; wmemcpy(alias->value, equal + 1, valuelen); alias->value[valuelen] = L'\0'; wmemcpy(alias->value + valuelen + 1, nameandvalue, namelen); alias->value[namelen + valuelen + 1] = L'\0'; vfreealias(ht_set(&aliases, alias->value + valuelen + 1, alias)); } /* Removes the alias definition with the specified name if any. * Returns true if the alias definition is successfully removed. * Returns false if no alias definition is found to be removed. */ bool remove_alias(const wchar_t *name) { alias_T *alias = ht_remove(&aliases, name).value; if (alias != NULL) { free_alias(alias); return true; } else { return false; } } /* Removes all alias definitions. */ void remove_all_aliases(void) { ht_clear(&aliases, vfreealias); } /* Returns the value of the specified alias (or null if there is no such). */ const wchar_t *get_alias_value(const wchar_t *aliasname) { const alias_T *alias = ht_get(&aliases, aliasname).value; if (alias != NULL) return alias->value; else return NULL; } /* Creates a copy of the specified alias list. */ aliaslist_T *clone_aliaslist(const aliaslist_T *list) { aliaslist_T *result = NULL; aliaslist_T **lastp = &result; while (list != NULL) { aliaslist_T *copy = xmalloc(sizeof *copy); copy->next = NULL; copy->alias = list->alias; copy->alias->refcount++; copy->limitindex = list->limitindex; *lastp = copy; lastp = ©->next; list = list->next; } return result; } /* Frees the specified alias list and its contents. */ void destroy_aliaslist(aliaslist_T *list) { list = remove_expired_aliases(list, SIZE_MAX); assert(list == NULL); } /* Checks if the specified alias list contains the specified alias. */ bool contained_in_list(const aliaslist_T *list, const alias_T *alias) { while (list != NULL) { if (list->alias == alias) return true; list = list->next; } return false; } /* Adds an alias to an alias list with the specified limit index. */ void add_to_aliaslist(aliaslist_T **list, alias_T *alias, size_t limitindex) { aliaslist_T *oldhead = *list; aliaslist_T *newelem = xmalloc(sizeof *newelem); assert(oldhead == NULL || limitindex <= oldhead->limitindex); newelem->next = oldhead; newelem->alias = alias; newelem->alias->refcount++; newelem->limitindex = limitindex; *list = newelem; } /* Removes items whose `limitindex' is less than or equal to `index'. */ aliaslist_T *remove_expired_aliases(aliaslist_T *list, size_t index) { /* List items are ordered by index; we don't have to check all the items. */ while (list != NULL && list->limitindex <= index) { aliaslist_T *next = list->next; free_alias(list->alias); free(list); list = next; } return list; } /* Increases the index of each item in the specified list by `inc'. */ void shift_index(aliaslist_T *list, ptrdiff_t inc) { while (list != NULL) { list->limitindex += inc; list = list->next; } } /* Performs alias substitution at index `i' in buffer `buf'. * If AF_NONGLOBAL is not in `flags', only global aliases are substituted. * If AF_NORECUR is not in `flags', substitution is repeated until there is * no more alias applicable. * Returns true iff any alias was substituted. */ bool substitute_alias(xwcsbuf_T *restrict buf, size_t i, aliaslist_T **restrict list, substaliasflags_T flags) { if (aliases.count == 0) return false; if (!(flags & AF_NONGLOBAL) && posixly_correct) return false; bool subst = false; substitute_alias: *list = remove_expired_aliases(*list, i); /* count the length of the alias name */ size_t j = i; while (is_alias_name_char(buf->contents[j])) j++; /* `i' is the starting index of the alias name and `j' is the ending index*/ /* check if there is an alias name */ if (i < j && is_token_delimiter_char(buf->contents[j]) && !is_redir_fd(buf->contents + i)) { alias_T *alias; wchar_t savechar; /* get alias definition */ savechar = buf->contents[j]; buf->contents[j] = L'\0'; alias = ht_get(&aliases, buf->contents + i).value; buf->contents[j] = savechar; /* check if we should do substitution */ if (alias != NULL && ((flags & AF_NONGLOBAL) | (alias->flags & AF_GLOBAL)) && !contained_in_list(*list, alias)) { /* do substitution */ wb_replace_force(buf, i, j - i, alias->value, alias->valuelen); shift_index(*list, (ptrdiff_t) alias->valuelen - (ptrdiff_t) (j - i)); subst = true; /* substitute the following word if AF_BLANKEND is set */ /* see note below */ if ((alias->flags & AF_BLANKEND) && !(alias->flags & AF_GLOBAL)) { size_t ii = i + alias->valuelen; aliaslist_T *savelist = clone_aliaslist(*list); while (iswblank(buf->contents[ii])) ii++; substitute_alias(buf, ii, &savelist, flags); destroy_aliaslist(savelist); } /* add the alias to the list to track recursion */ add_to_aliaslist(list, alias, i + alias->valuelen); /* recursively substitute alias */ if (!(flags & AF_NORECUR)) { while (iswblank(buf->contents[i])) i++; goto substitute_alias; } } } return subst; } /* When the value of the alias ends with a blank, we substitute the following * word if and only if the alias is not global. This is required to prevent * infinite substitution that would happen in some cases such as: * alias -g a='a a ' * echo a */ /* Returns true iff the specified string starts with any number of digits * followed by L'<' or L'>'. */ /* An IO_NUMBER token, which specifies the file descriptor a redirection * affects, must not be alias-substituted. This function check if the word is * such a token. */ bool is_redir_fd(const wchar_t *s) { while (iswdigit(*s)) s++; return *s == L'<' || *s == L'>'; } /* Prints an alias definition to the standard output. * On error, an error message is printed to the standard error. * Returns true iff successful. */ bool print_alias(const wchar_t *name, const alias_T *alias, bool prefix) { wchar_t *qvalue = quote_sq(alias->value); const char *format; bool success; if (!prefix) format = "%ls=%ls\n"; else if (alias->flags & AF_GLOBAL) if (name[0] == L'-') format = "alias -g -- %ls=%ls\n"; else format = "alias -g %ls=%ls\n"; else if (name[0] == L'-') format = "alias -- %ls=%ls\n"; else format = "alias %ls=%ls\n"; success = xprintf(format, name, qvalue); free(qvalue); return success; } /* Prints an alias definition to the standard output if defined. * This function is used in the "command" built-in. * Returns true iff a non-global alias had been defined for the specified name. */ bool print_alias_if_defined(const wchar_t *aliasname, bool user_friendly) { const alias_T *alias = ht_get(&aliases, aliasname).value; if (alias == NULL || (alias->flags & AF_GLOBAL)) return false; if (!user_friendly) print_alias(aliasname, alias, true); else xprintf(gt("%ls: an alias for `%ls'\n"), aliasname, alias->value); return true; } #if YASH_ENABLE_LINEEDIT /* Generates candidates to complete an alias matching the pattern. */ /* The prototype of this function is declared in "lineedit/complete.h". */ void generate_alias_candidates(const le_compopt_T *compopt) { if (!(compopt->type & CGT_ALIAS)) return; le_compdebug("adding alias name candidates"); if (!le_compile_cpatterns(compopt)) return; size_t i = 0; kvpair_T kv; while ((kv = ht_next(&aliases, &i)).key != NULL) { const alias_T *alias = kv.value; le_candgentype_T type = (alias->flags & AF_GLOBAL) ? CGT_GALIAS : CGT_NALIAS; if (compopt->type & type) if (le_wmatch_comppatterns(compopt, kv.key)) le_new_candidate(CT_ALIAS, xwcsdup(kv.key), NULL, compopt); } } #endif /* YASH_ENABLE_LINEEDIT */ /********** Built-ins **********/ /* Options for the "alias" built-in. */ const struct xgetopt_T alias_options[] = { { L'g', L"global", OPTARG_NONE, false, NULL, }, { L'p', L"prefix", OPTARG_NONE, false, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "alias" built-in, which accepts the following options: * -g: define global aliases * -p: print aliases in the form of whole commands */ int alias_builtin(int argc, void **argv) { bool global = false, prefix = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, alias_options, 0)) != NULL) { switch (opt->shortopt) { case L'g': global = true; break; case L'p': prefix = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (xoptind == argc) { /* print all aliases */ kvpair_T *kvs = ht_tokvarray(&aliases); qsort(kvs, aliases.count, sizeof *kvs, keywcscoll); for (size_t i = 0; i < aliases.count; i++) { print_alias(kvs[i].key, kvs[i].value, prefix); if (yash_error_message_count > 0) break; } free(kvs); } else { /* define or print aliases */ do { wchar_t *arg = ARGV(xoptind); wchar_t *nameend = arg; while (is_alias_name_char(*nameend)) nameend++; if (nameend != arg && *nameend == L'=') { /* define alias */ define_alias(arg, nameend, global); } else if (nameend != arg && *nameend == L'\0') { /* print alias */ const alias_T *alias = ht_get(&aliases, arg).value; if (alias != NULL) { if (!print_alias(arg, alias, prefix)) break; } else { xerror(0, Ngt("no such alias `%ls'"), arg); } } else { xerror(0, Ngt("`%ls' is not a valid alias name"), arg); } } while (++xoptind < argc); } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } #if YASH_ENABLE_HELP const char alias_help[] = Ngt( "define or print aliases" ); const char alias_syntax[] = Ngt( "\talias [-gp] [name[=value]...]\n" ); #endif /* The "unalias" built-in, which accepts the following option: * -a: remove all aliases */ int unalias_builtin(int argc, void **argv) { bool all = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, all_help_options, 0)) != NULL) { switch (opt->shortopt) { case L'a': all = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (all) { if (xoptind != argc) return too_many_operands_error(0); remove_all_aliases(); } else { if (xoptind == argc) return insufficient_operands_error(1); do { const wchar_t *arg = ARGV(xoptind); if (!remove_alias(arg)) xerror(0, Ngt("no such alias `%ls'"), arg); } while (++xoptind < argc); } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } #if YASH_ENABLE_HELP const char unalias_help[] = Ngt( "undefine aliases" ); const char unalias_syntax[] = Ngt( "\tunalias name...\n" "\tunalias -a\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/share/0000755000175000017500000000000012154557026013650 5ustar magicantmagicantyash-2.35/share/completion/0000755000175000017500000000000012154557026016021 5ustar magicantmagicantyash-2.35/share/completion/git-format-patch0000644000175000017500000000451212154557026021114 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-format-patch" command. # Supports Git 1.7.7. function completion/git-format-patch { WORDS=(git format-patch "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::format-patch:arg { OPTIONS=( #># "--add-header:; specify an additional header string" "--attach::; make patch contents an mail attachment" "--cc:; specify an additional receiver" "--cover-letter; create a file containing overall diffstat" "--ignore-if-in-upstream" "--inline::; like --attach, but use \"Content-Disposition: inline\"" "--in-reply-to:" "k --keep-subject; don't add/remove \"[PATCH]\"" "--no-attach; cancel the --attach option" "--no-binary; don't include diffs for binary files" "p --no-stat; create plain patches without diffstats" "N --no-numbered; name output in \"[PATCH]\" format" "--no-signature; don't append a signature to results" "--no-thread; don't thread mails" "n --numbered; name output in \"[PATCH n/m]\" format" "--numbered-files; use simple integers for output filenames" "o: --output-directory:; specify the directory to place the results in" "--quiet; don't print created patch filenames" "--root; treat the operand as a revision range" "--signature:; specify a signature appended to each message" "s --signoff; include a signed-off-by line" "--start-number:; specify a number to start numbering patches from" "--stdout; output results to the standard output rather than files" "--subject-prefix:; specify a string prefix to the subject" "--suffix:; specify a suffix appended to result filenames" "--thread::; specify mail threading behavior" "--to:; specify an additional receiver" ) #<# if command -vf completion/git::diff:getopt >/dev/null 2>&1 || . -AL completion/git-diff; then command -f completion/git::diff:getopt fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--add-header) ;; (--attach|--inline) ;; (--in-reply-to) ;; (o|--output-directory) complete -P "$PREFIX" -S / -T -d ;; (--signature) ;; (--start-number) ;; (--subject-prefix) ;; (--suffix) ;; (--to|--cc) ;; ('') command -f completion/git::completeref range=true ;; (*) command -f completion/git::diff:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/nohup0000644000175000017500000000316012154557026017075 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "nohup" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/nohup { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=() case $type in (GNU) OPTIONS=("$OPTIONS" #># "--help" "--version" ) #<# ;; (SunOS) OPTIONS=("$OPTIONS" #># "a; override signal handlers set by the target processes themselves" "F; grab control of target processes controlled by another process" "g; make running process groups immune to SIGHUP" "p; make running processes immune to SIGHUP" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') typeset word pid args for word in "${WORDS[2,-1]}"; do case $word in (-p) # complete a process ID while read -r pid args; do if kill -n 0 $pid; then complete -D "$args" -- "$pid" fi done 2>/dev/null <(ps -a -o pid= -o args=) break ;; (-g) # complete a process group ID while read -r pid args; do if kill -n 0 -$pid; then complete -D "$args" -- "$pid" fi done 2>/dev/null <(ps -a -o pgid= -o args=) break ;; (--) command -f completion//getoperands command -f completion//reexecute -e break ;; esac done ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-am0000644000175000017500000000322212154557026017121 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-am" command. # Supports Git 1.7.7. function completion/git-am { WORDS=(git am "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::am:arg { OPTIONS=( #># "3 --3way; try 3-way merge on conflict" "--abort; abort patching and restore the original branch" "--committer-date-is-author-date; use author date for committer date" "r --continue --resolved; commit the current index and continue patching" "--ignore-date; use committer date for author date" "i --interactive" "k --keep; use the mail subject intact as the commit message" "--keep-cr; don't remove carriage returns at the end of lines" "--no-keep-cr; remove carriage returns at the end of lines" "--no-scissors; cancels the --scissors OPTIONS" "--no-utf8; don't convert character encoding" "q --quiet; print error messages only" "--resolvemsg:" # not for command line use "c --scissors; remove lines before a scissors line" "s --signoff; add a \"signed-off-by\" line to the message" "--skip; skip the current patch (when restarting an aborted patch)" "u --utf8; re-encode the log message into UTF-8" ) #<# if command -vf completion/git::apply:getopt >/dev/null 2>&1 || . -AL completion/git-apply; then command -f completion/git::apply:getopt am fi command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') complete -P "$PREFIX" -f ;; (*) if command -vf completion/git::apply:compopt >/dev/null 2>&1 || . -AL completion/git-apply; then command -f completion/git::apply:compopt fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/chgrp0000644000175000017500000000411512154557026017050 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "chgrp" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/chgrp { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "h ${long:+--no-dereference}; change the group of symbolic links" "H; follow symbolic links to directories in operands (with -R)" "L; follow all symbolic links to directories (with -R)" "P; don't follow any symbolic links (with -R)" "R ${long:+--recursive}; recursively change the group of files in a directory" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "f ${long:+--silent --quiet}; suppress error messages" ) #<# case $type in (GNU|NetBSD|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "v ${long:+--verbose}; print a message for each file processed" ) #<# esac esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "c --changes; print a message when a change has been made" "--dereference; change the group of files referred to by symbolic links" "--no-preserve-root; cancel the --preserve-root option" "--preserve-root; don't recursively change the group of the root directory" "--reference:; specify a file to whose group changes are made" "--help" "--version" ) #<# ;; (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "x; stop recursion when reaching a different file system" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--reference) complete -P "$PREFIX" -f ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then complete -g else complete -f fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/egrep0000644000175000017500000000031612154557026017046 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "egrep" command. function completion/egrep { WORDS=(grep -E "${WORDS[2,-1]}") command -f completion//reexecute } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/bsdtar0000644000175000017500000000026712154557026017230 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "bsdtar" command. function completion/bsdtar { command -f completion//reexecute tar } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/test0000644000175000017500000000752412154557026016733 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "test" built-in command. # Completion function "completion/test" is used for the "[" built-in as well. function completion/test { WORDS=('(' "${WORDS[2,-1]}") # complete unary operator case ${WORDS[-1]} in ('('|!|-[ao]) #>># complete -D "check if a file is a block special file" -- -b complete -D "check if a file is a character special file" -- -c complete -D "check if a file is a directory" -- -d complete -D "check if a file exists" -- -e complete -D "check if a file is a regular file" -- -f complete -D "check if a file is owned by the current group" -- -G complete -D "check if a file's set-group-ID flag is set" -- -g complete -D "check if a file is a symbolic link" -- -h complete -D "check if a file's sticky bit is set" -- -k complete -D "check if a file is a symbolic link" -- -L complete -D "check if a file hasn't been accessed since last modified" -- -N complete -D "check if a file is owned by the current user" -- -O complete -D "check if a shell option is enabled" -- -o complete -D "check if a file is a FIFO (named pipe)" -- -p complete -D "check if a file is readable" -- -r complete -D "check if a file is a socket" -- -S complete -D "check if a file is not empty" -- -s complete -D "check if a file's set-user-ID flag is set" -- -u complete -D "check if a file is writable" -- -w complete -D "check if a file is executable" -- -x complete -D "check if a file descriptor is a terminal" -- -t complete -D "check if a string is not empty" -- -n complete -D "check if a string is empty" -- -z esac #<<# # complete binary operator case ${WORDS[-2]} in ('('|!|-[ao]) #>># complete -D "check if a file is newer than another" -- -nt complete -D "check if a file is older than another" -- -ot complete -D "check if a file is a hard link to another" -- -ef complete -D "check if a string is the same as another" -- = complete -D "check if a string is the same as another" -- == complete -D "check if a string is matched by a regex" -- =~ complete -D "check if a string is different from another" -- != complete -D "check if a string is the same as another according to the current locale" -- === complete -D "check if a string is different from another according to the current locale" -- !== complete -D "compare two strings in the alphabetical order" -- '<' '<=' '>' '>=' complete -D "check if an integer is equal to another" -- -eq complete -D "check if an integer is unequal to another" -- -ne complete -D "check if an integer is greater than another" -- -gt complete -D "check if an integer is greater than or equal to another" -- -ge complete -D "check if an integer is less than another" -- -lt complete -D "check if an integer is less than or equal to another" -- -le complete -D "check if a version number is equal to another" -- -veq complete -D "check if a version number is unequal to another" -- -vne complete -D "check if a version number is greater than another" -- -vgt complete -D "check if a version number is greater than or equal to another" -- -vge complete -D "check if a version number is less than another" -- -vlt complete -D "check if a version number is less than or equal to another" -- -vle esac #<<# # complete operand of the "-o" unary operator case ${WORDS[-2]} in ('('|!|-[ao]) case ${WORDS[-1]} in (-o) if command -fv completion/set::completelongoption >/dev/null 2>&1 || . -AL completion/set; then typeset SOPTIONS LOPTIONS PREFIX prog=set SOPTIONS=() LOPTIONS=() case $TARGETWORD in (\?*) TARGETWORD=${TARGETWORD#\?} PREFIX=\? ;; (*) PREFIX= ;; esac command -f completion/set::getopt set command -f completion/set::completelongoption fi return esac esac # complete operand of other operators complete -f } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/tail0000644000175000017500000000456612154557026016710 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "tail" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/tail { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c: ${long:+--bytes:}; specify the number of bytes to print" "f; keep watching the file for more data" "n: ${long:+--lines:}; specify the number of lines to print" ) #<# case $type in (*BSD|Darwin|SunOS) OPTIONS=("$OPTIONS" #># "r; print lines in reverse order" ) #<# esac case $type in (*BSD|Darwin|HP-UX) OPTIONS=("$OPTIONS" #># "b:; specify the number of 512-byte blocks to print" ) #<# esac case $type in (FreeBSD|NetBSD|Darwin) OPTIONS=("$OPTIONS" #># "F; like -f, but reopen the file if renamed" ) #<# esac case $type in (GNU|FreeBSD) OPTIONS=("$OPTIONS" #># "q ${long:+--quiet --silent}; never print filename headers" ) #<# esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "--follow::; specify how to watch the file for more data" "F; like --follow=name --retry" "--max-unchanged-stats:; recheck file status every n checks" "--pid:; specify the ID of a process to follow" "--retry; try to reopen the file if removed" "--sleep-interval:; specify the number of seconds to wait between checks for more data" "v --verbose; always print filename headers" "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([bcn]|--bytes|--lines) case $type in (GNU) if command -vf completion//prefixdigits >/dev/null 2>&1 || . -AL completion/_blocksize; then if command -f completion//prefixdigits; then command -f completion//completesizesuffix b GNU fi fi esac ;; (--follow) #>># complete -P "$PREFIX" -D "never reopen the file" descriptor complete -P "$PREFIX" -D "reopen the file when renamed/removed" name ;; #<<# (--pid) typeset pid args while read -r pid args; do complete -P "$PREFIX" -D "$args" -- "$pid" done <(ps -A -o pid= -o args= 2>/dev/null) ;; ('') complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/umask0000644000175000017500000000101112154557026017055 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "umask" built-in command. function completion/umask { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "S --symbolic; produce a symbolic output" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) if command -vf completion/chmod::mode >/dev/null 2>&1 || . -AL completion/chmod; then command -f completion/chmod::mode umask fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/alias0000644000175000017500000000067512154557026017045 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "alias" built-in command. function completion/alias { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "g --global; define global aliases" "p --prefix; print aliases as reusable shell commands" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -a ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/df0000644000175000017500000001023012154557026016331 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "df" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/df { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "k; print figures in kilobytes (1024-byte units)" "P ${long:+--portability}; print in the portable format defined by POSIX" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD|Darwin|SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "l ${long:+--local}; print info about local file systems only" ) #<# case $type in (GNU|*BSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "h ${long:+--human-readable}; print size using K, M, etc. for 1024^n" ) #<# case $type in (GNU|FreeBSD|NetBSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "a ${long:+--all}; print all file systems" ) #<# case $type in (GNU|FreeBSD|NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "m; print figures in megabytes (1048576-byte units)" ) #<# case $type in (GNU|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "H ${long:+--si}; print size using k, M, etc. for 1000^n" ) #<# case $type in (GNU|FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "T ${long:+--print-type}; print file system types" ) #<# esac esac case $type in (FreeBSD|NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "g; print figures in gigabytes (1073741824-byte units)" ) #<# case $type in (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "b; print figures in 512-byte units" ) #<# esac esac esac esac case $type in (*BSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "n; allow printing cached data that may be out of date" ) #<# esac esac case $type in (GNU|*BSD|Darwin|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "i ${long:+--inodes}; print inode information" ) #<# esac case $type in (SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "b; print the size of free area in kilobytes" "e; print the number of files free" "F:; specify a file system type to print" "g; print all the results of the statvfs function" "n; print file system types" "o:; specify options specific to file systems" "v; print block counts" "V; print full command lines" ) #<# esac esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "B: --block-size:; specify the block size unit to print figures in" "--total; print the grand total after the normal output" "--no-sync; allow printing cached data that may be out of date" "--sync; don't use cached data that may be out of date" "x: --exclude-type:; specify a file system type not to print" "--help" "--version" ) #<# ;; (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "c; print the grand total" ) #<# ;; (NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "G; print all the results of the statvfs function" ) #<# ;; (Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "T:; specify a file system type to print" ) #<# ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "Z; print file systems in all zones" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "f; print the number of blocks in the free list" "s; don't sync the file system data on the disk" ) #<# ;; esac case $type in (GNU|*BSD) ADDOPTIONS=("$ADDOPTIONS" #># "t: ${long:+--type:}; specify a file system type to print" ) #<# ;; (*) POSIXOPTIONS=("$POSIXOPTIONS" #># "t; include total counts in the output" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (B|--block-size) if command -vf completion//completeblocksize >/dev/null 2>&1 || . -AL completion/_blocksize; then command -f completion//completeblocksize fi ;; (?|-?*) ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-apply0000644000175000017500000000553512154557026017662 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-apply" command. # Supports Git 1.7.7. function completion/git-apply { WORDS=(git apply "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::apply:arg { OPTIONS=( #># "--allow-binary-replacement --binary" "--apply; force to apply patches" "--build-fake-ancestor:" # TODO "--cached; apply patches to the index without modifying the working tree" "--check; check if patches can be applied without errors instead of applying patches" "--exclude:; skip files whose names match the specified pattern" "--inaccurate-eof; work around diff errors about missing newlines at end of file" "--include:; apply to only files whose names match the specified pattern" "--index; apply patches to the index as well as the working tree" "--no-add; apply deletions but not additions" "--recount; ignore line counts in hunk headers" "R --reverse; patch in reverse" "--stat; print diffstat instead of applying patches" "--numstat; print a diffstat in the machine-friendly format instead of applying patches" "--summary; print summary instead of applying patches" "--unidiff-zero; accept unified diffs without context lines" "v --verbose; report progress in detail" "z; print a null byte after each filename" ) #<# command -f completion/git::apply:getopt apply command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (''|--exclude|--include) complete -P "$PREFIX" -f ;; (*) command -f completion/git::apply:compopt ;; esac } function completion/git::apply:getopt { typeset apply= case $1 in (am|apply) apply=true OPTIONS=("$OPTIONS" #># "--directory:; specify a directory to work in" "p:; specify the number of pathname components to strip from file names" "--reject; apply as much as possible and leave rejected hunks in *.rej file" ) #<# esac OPTIONS=("$OPTIONS" #># "C:; specify the number of context lines in each hunk that must match" "--ignore-whitespace ${apply:+--ignore-space-change}; ignore whitespaces in context when applying patches" "--whitespace:; specify what to do with whitespace errors" ) #<# } function completion/git::apply:compopt case $ARGOPT in # ([Cp]) # ;; (--directory) complete -P "$PREFIX" -S / -T -d command -f completion/git::completepath ;; (--whitespace) command -f completion/git::--whitespace:arg ;; esac function completion/git::--whitespace:arg { #>># complete -P "$PREFIX" -D "treat as errors and print some of them" error complete -P "$PREFIX" -D "treat as errors and print all of them" error-all complete -P "$PREFIX" -D "print warnings and fix errors" fix strip complete -P "$PREFIX" -D "don't print warnings about whitespace errors" nowarn complete -P "$PREFIX" -D "print warnings but apply the patch as is" warn } #<# # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-commit0000644000175000017500000000562212154557026020022 0ustar magicantmagicant# (C) 2011-2012 magicant # Completion script for the "git-commit" command. # Supports Git 1.7.7. function completion/git-commit { WORDS=(git commit "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::commit:arg { OPTIONS=( #># "a --all; include modified or deleted files that have not been added" "--allow-empty; allow a commit that makes no change" "--allow-empty-message" "--amend; redo the last commit on the current branch" "--author:; specify the author" "--cleanup:; specify the way the message is cleaned up" "--date:; specify the date" "--dry-run; don't actually commit, but show what would happen" "e --edit; reedit the message" "F: --file:; specify a file containing the message" "--fixup:; prepare the message to fix up the specified commit in later autosquash" "i --include; include operand files in the commit" "m: --message:; specify the message" "--no-edit; don't reedit the message" "--no-status; don't include file statuses in the message template" "n --no-verify; bypass the pre-commit and commit-msg hooks" "o --only; commit operand files only" "p --patch; interactive choose patch hunks to commit" "--porcelain; dry-run with the machine-friendly format" "q --quiet; suppress the commit summary message" "--reset-author; ignore the date and author of the original commit" "C: --reuse-message:; specify an existing commit from which the message is reused" "c: --reedit-message:; like -C, but reedit the message" "--short; dry-run with a short output format" "s --signoff; add a \"signed-off-by\" line to the message" "--squash:; prepare the message to squash the specified commit in later autosquash" "--status; include file statuses in the message template" "t: --template:; specify a file containing a template message to edit" "u:: --untracked-files::; print untracked files" "v --verbose; include diffs in the message template" "z; print a null byte after each filename" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--author) command -f completion/git::--author:arg ;; (--cleanup) #>># complete -P "$PREFIX" -D "like \"strip\" when editing and \"whitespace\" otherwise" default complete -P "$PREFIX" -D "delete empty lines and comments" strip complete -P "$PREFIX" -D "don't clean up the message at all" verbatim complete -P "$PREFIX" -D "delete empty lines" whitespace ;; #<<# # (--date) # TODO complete date # ;; ([Ft]|--file|--template) complete -P "$PREFIX" -f ;; ([Cc]|--fixup|--reuse-message|--reedit-message|--squash) command -f completion/git::completeref ;; (u|--untracked-files) command -f completion/git::--untracked-files:arg ;; ('') if command -vf completion/git::add:opr >/dev/null 2>&1 || . -AL completion/git-add; then command -f completion/git::add:opr fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/help0000644000175000017500000000053612154557026016700 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "help" built-in command. function completion/help { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -b ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/pwd0000644000175000017500000000066712154557026016547 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "pwd" built-in command. function completion/pwd { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "L --logical; keep symbolic links in the \$PWD variable as is" "P --physical; print path without symbolic links" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-show-branch0000644000175000017500000000254712154557026020750 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-show-branch" command. # Supports Git 1.7.7. function completion/git-show-branch { WORDS=(git show-branch "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::show-branch:arg { OPTIONS=( #># "a --all; show local and remotes-tracking branches" "--color::; show symbols in color" "--current; show the current branch" "--independent; show branch heads not contained by any others" "--list; like --more=-1 (show branch heads only)" "--merge-base; show possible merge bases" "--more:; specify the number of ancestors shown beyond the common ancestor" "--no-color; like --color=never" "--no-name; don't show commit names" "g:: --reflog::; show ref-log instead of branches" "r --remotes; show remote-tracking branches" "--sha1-name; show SHA1 prefixes instead of symbolic commit names" "--sparse; don't omit merges that aren't common ancestors of branches shown" "--topics; show branches not contained in the first one only" ) #<# command -f completion/git::getorderopts command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--color) command -f completion/git::--color:arg ;; # (--more) # ;; # (g|--reflog) # ;; ('') command -f completion/git::completeref ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/vimdiff0000644000175000017500000000031012154557026017362 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "vimdiff" command. # Supports Vim 7.3. function completion/vimdiff { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/fold0000644000175000017500000000175612154557026016701 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "fold" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/fold { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "b ${long:+--bytes}; count bytes rather than columns" "s ${long:+--spaces}; don't break at non-blank characters" "w: ${long:+--width:}; specify the maximum line width" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "c --characters; count characters rather than columns" "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ('') complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/bash0000644000175000017500000000026212154557026016661 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "bash" command. function completion/bash { command -f completion//reexecute sh } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-revert0000644000175000017500000000177212154557026020043 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-revert" command. # Supports Git 1.7.7. function completion/git-revert { WORDS=(git revert "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::revert:arg { OPTIONS=( #># "e --edit; (re)edit the message" "m: --mainline:; specify the mainline parent by number" "n --no-commit; don't commit the reversion result automatically" "--no-edit; don't reedit the message" "s --signoff; add a \"signed-off-by\" line to the message" "s: --strategy:; specify the merge strategy" "X: --strategy-option:; specify a strategy-specific option" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeref range=true ;; (*) if command -vf completion/git::merge:compopt >/dev/null 2>&1 || . -AL completion/git-merge; then command -f completion/git::merge:compopt fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gex0000644000175000017500000000030012154557026016520 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "gex" command. # Supports Vim 7.3. function completion/gex { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/man0000644000175000017500000001053312154557026016521 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "man" command. # Supports POSIX 2008, man-db 2.5.7, and other conventional syntaxes. function completion/man { if "${WORDS[1]}" --where man >/dev/null 2>&1; then typeset type=man-db else typeset type=POSIX fi case $type in (man-db) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a ${long:+--all}; show all manual pages, not only the first found one" "f ${long:+--whatis}; only print brief description" "k ${long:+--apropos}; search manual database and print brief description" "M: ${long:+--manpath:}; specify directories containing manual pages" "s: ${long:+--sections:}; specify manual sections" ) #<# case $type in (man-db) OPTIONS=("$OPTIONS" #># "7 --ascii; display ASCII translation of certain Latin-1 characters" "C: --config-file:; specify a pathname of the config file" "D --default; reset options (possibly set by \$MANOPT)" "e: --extension:; only search sections with the specified suffix" "H:: --html::; view the manual as HTML with the specified browser" "h --help; print help" "I --match-case; case-sensitive search" "i --ignore-case; case-insensitive search" "K --global-apropos; search for text in all manual pages" "L: --locale:; specify locale" "l --local-file; treat operands as manual page filenames" "m: --systems:; specify system names to show the manual for" "P: --pager:; specify a pager to show the manual" "p: --preprocessor:; specify a preprocessor sequence" "R: --recode:; specify an encoding to convert the manual page to" "r: --prompt:; specify a prompt string used in the less pager" "T:: --troff-device::; use groff with the specified device" "t --troff; use groff -mandoc to format pages" "u --update; check cache consistency" "V --version; print version info" "w --where --location; print the pathname of the manual page" "W --where-cat --location-cat; print the pathname of the cat file" "X:: --gxditview::; view the manual using gxditview with the specified DPI" "Z --ditroff; force groff to produce ditroff" "--names-only; match page names only (with --regex or --wildcard)" "--no-justification --nj; disable justification of text" "--no-hyphenation --nh; disable automatic hyphenation" "--no-subpages; don't try subpages like git-diff for \`git-diff'" "--regex; use regular expression in searching" "--warnings::; specify groff warning types to enable" "--wildcard; use shell-like pattern matching in searching" ) #<# esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (C|--config-file) complete -P "$PREFIX" -f ;; (H|--html) complete -P "$PREFIX" --external-command ;; (M|--manpath) typeset targetword="${TARGETWORD#"$PREFIX"}" targetword=${targetword##*:} PREFIX=${TARGETWORD%"$targetword"} complete -P "$PREFIX" -S / -T -d ;; ('') case $TARGETWORD in (*/*) complete -f ;; (*) command -f completion/man::operand ;; esac ;; esac } function completion/man::operand { typeset i=1 sections= manpath= while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--) if [ $((i+1)) -le ${WORDS[#]} ]; then case ${WORDS[i+1]} in ([[:digit:]]*) sections=${WORDS[i+1]} esac fi break ;; (-M*) manpath=${WORDS[i]#-M} ;; (-s*) sections=${WORDS[i]#-s} ;; esac i=$((i+1)) done IFS=':,' sections=($sections) [ "$manpath" ] || manpath=$(manpath 2>/dev/null) || manpath=${MANPATH:-/usr/man:/usr/share/man:/usr/local/man:/usr/local/share/man} IFS=: manpath=($manpath) IFS= typeset saveopts=$(set +o) set +o noglob -o nullglob +o nocaseglob typeset mandir section for mandir in "$manpath"; do if [ ${sections[#]} -gt 0 ]; then for section in "$sections"; do command -f completion/man::operand::search "${mandir}/man${section}" command -f completion/man::operand::search "${mandir}/sman${section}" command -f completion/man::operand::search "${mandir}/man${section}.Z" done else for mandir in "$mandir"/man* "$mandir"/sman*; do command -f completion/man::operand::search "${mandir}" done fi done eval "$saveopts" } function completion/man::operand::search { typeset files files=("$1"/*) files=("${${${${${${files##*/}%.[gx]z}%.bz2}%.lzma}%.Z}%.*}") complete -R '' -- "$files" } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/chmod0000644000175000017500000000762012154557026017043 0ustar magicantmagicant# (C) 2010-2013 magicant # Completion script for the "chmod" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/chmod { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "R ${long:+--recursive}; recursively change the permission of files in a directory" ) #<# ADDOPTIONS=() case $type in (GNU|FreeBSD|NetBSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "f ${long:+--silent --quiet}; ignore errors" ) #<# case $type in (GNU|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "v ${long:+--verbose}; print a message for each file processed" ) #<# esac case $type in (FreeBSD|NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "h; change the mode of symbolic links" ) #<# esac esac case $type in (*BSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "H; follow symbolic links in operands (with -R)" "L; follow all symbolic links (with -R)" "P; don't follow symbolic links (with -R)" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "c --changes; print a message when a change has been made" "--no-preserve-root; cancel the --preserve-root option" "--preserve-root; don't recursively change the permission of the root directory" "--reference:; specify a file to whose permission changes are made" "--help" "--version" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "A; preserve access control list entries" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--reference) complete -P "$PREFIX" -f ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then command -f completion/chmod::mode chmod else complete -f fi ;; esac } function completion/chmod::mode { typeset word="${TARGETWORD#"$PREFIX"}" # we don't complete a numeric mode value case $word in (*[[:digit:]]*) return esac word=${word##*,} case $word in (*[-+=]*) case $word in (*[-+=]*[ugo]*) return ;; (*[-+=]) #>># complete -P "$TARGETWORD" -D "copy from the user part of permission" u complete -P "$TARGETWORD" -D "copy from the group part of permission" g complete -P "$TARGETWORD" -D "copy from the other part of permission" o ;; #<<# esac #>># complete -P "$TARGETWORD" -D "read permission" r complete -P "$TARGETWORD" -D "write permission" w complete -P "$TARGETWORD" -D "execute permission" x complete -P "$TARGETWORD" -D "execute permission (only when there's already one)" X #<<# case ${1-} in (chmod|find|mkdir|tar|umask) #>># complete -P "$TARGETWORD" -D "set-user/group-ID" s esac #<<# case ${1-} in (chmod|find|mkdir|tar) #>># complete -P "$TARGETWORD" -D "sticky bit" t esac #<<# return esac case $word in ('') case ${1-} in (rsync) #>># complete -T -P "$TARGETWORD" -D "affect directories only" D complete -T -P "$TARGETWORD" -D "affect non-directories only" F esac #<<# esac case $word in (*a*) ;; (*) #>># complete -T -P "$TARGETWORD" -D "affect the user part of the permission" u complete -T -P "$TARGETWORD" -D "affect the group part of the permission" g complete -T -P "$TARGETWORD" -D "affect the other part of the permission" o complete -T -P "$TARGETWORD" -D "affect all parts of the permission" a ;; #<<# esac #>># complete -T -P "$TARGETWORD" -D "add the specified permission" -- + complete -T -P "$TARGETWORD" -D "remove the specified permission" -- - complete -T -P "$TARGETWORD" -D "set the permission to the specified one" -- = #<<# } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/view0000644000175000017500000000040612154557026016716 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "view" command. # Supports POSIX 2008, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, SunOS 5.10, # HP-UX 11i v3. function completion/view { command -f completion//reexecute ex } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/less0000644000175000017500000002252412154557026016717 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "less" command. # Supports less 436. function completion/less { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "? --help; show help" "a --search-skip-screen; don't match in the current screen when searching" "B --auto-buffers; don't increase the buffer size for data from the standard input" "b: --buffers:; specify the buffer size in kilobytes" "c C --clear-screen --CLEAR-SCREEN; don't scroll the screen" "d --dumb; don't print an error message for a dumb terminal" "E --QUIT-AT-EOF; exit immediately after printing the last line of the last file" "e --quit-at-eof; exit when scrolling beyond the last line of the last file" "F --quit-if-one-screen; exit immediately if the entire file fits one screen" "f --force; open non-regular files" "g --hilite-search; highlight matches for the last search only" "G --HILITE-SEARCH; don't highlight any matches for searches" "--old-bot; use the old bottom-of-screen behavior" "h: --max-back-scroll:; specify the max number of lines to scroll backward" "I --IGNORE-CASE; case-insensitive search" "i --ignore-case; case-insensitive search if the pattern is in all lowercase" "J --status-column; show a status column at the left" "j: --jump-target:; specify the line where a jump target is positioned" "K --quit-on-intr; exit when interrupted" "k: --lesskey-file:; specify a lesskey file" "L --no-lessopen; ignore the \$LESSOPEN variable" "M --LONG-PROMPT; use the very long prompt" "m --long-prompt; use the long prompt" "N --LINE-NUMBERS; show line numbers at the left" "n --line-numbers; don't handle line numbers" "O: --LOG-FILE:; copy the standard input to the specified file (always overwrite)" "o: --log-file:; copy the standard input to the specified file" "P: --prompt:; specify the prompt" "p: --pattern:; start at the specified pattern" "Q --QUIET --SILENT; never use the terminal bell" "q --quiet --silent; don't use the terminal bell for minor errors" "R --RAW-CONTROL-CHARS; output terminal control sequence as is" "r --raw-control-chars; output all control characters as is" "S --chop-long-lines; don't wrap long lines" "s --squeeze-blank-lines; squeeze adjacent empty lines into one" "T: --tag-file:; specify the tags file" "t: --tag:; specify an identifier to jump" "U --UNDERLINE-SPECIAL; disable special treatment of backspace, tab and carriage return" "u --underline-special; disable special treatment of backspace and carriage return" "V --version; print version info" "w --HILITE-UNREAD; highlight the new line after any forward movement" "w --hilite-unread; highlight the new line after forward-screen" "X --no-init; don't initialize the screen" "x: --tabs:; specify the width of a tab" "--no-keypad; don't initialize the screen for the keypad" "y: --max-forw-scroll:; specify the forward scroll limit" "z: --window:; specify the vertical scroll amount" "\": --quotes:; specify the shell quote characters" "~ --tilde; don't show tildes after the end of file" "#: --shift:; specify the horizontal scroll amount" "--follow-name; reopen the file when the file is recreated during the F command" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ([bhjxyz\"#]|--buffers|--max-back-scroll|--jump-target|--tabs\ |--max-forw-scroll|--window|--quotes|--shift) ;; (P|--prompt) typeset word="${TARGETWORD#"$PREFIX"}" if [ -z "$word" ]; then #>># complete -T -P "$PREFIX" -D "set the result format of the = command" = complete -T -P "$PREFIX" -D "set the help screen prompt" h complete -T -P "$PREFIX" -D "set the very long prompt" M complete -T -P "$PREFIX" -D "set the long prompt" m complete -T -P "$PREFIX" -D "set the short prompt" s complete -T -P "$PREFIX" -D "set the F command prompt" w else #<<# case $word in (*%*) typeset prefix="${TARGETWORD%\%*}" #>># complete -T -P "$prefix" -D "byte offset of the top line" '%bt' complete -T -P "$prefix" -D "byte offset of the middle line" '%bm' complete -T -P "$prefix" -D "byte offset of the bottom line" '%bb' complete -T -P "$prefix" -D "byte offset of the line just after the bottom" '%bB' complete -T -P "$prefix" -D "byte offset of the target line" '%bj' complete -T -P "$prefix" -D "file size" '%B' '%s' complete -T -P "$prefix" -D "column number of the leftmost column" '%c' complete -T -P "$prefix" -D "page number of the top line" '%dt' complete -T -P "$prefix" -D "page number of the middle line" '%dm' complete -T -P "$prefix" -D "page number of the bottom line" '%db' complete -T -P "$prefix" -D "page number of the line just after the bottom" '%dB' complete -T -P "$prefix" -D "page number of the target line" '%dj' complete -T -P "$prefix" -D "number of pages" '%D' complete -T -P "$prefix" -D "editor name" '%E' complete -T -P "$prefix" -D "filename" '%f' complete -T -P "$prefix" -D "index of the current file in the operands" '%i' complete -T -P "$prefix" -D "line number of the top line" '%lt' complete -T -P "$prefix" -D "line number of the middle line" '%lm' complete -T -P "$prefix" -D "line number of the bottom line" '%lb' complete -T -P "$prefix" -D "line number of the line just after the bottom" '%lB' complete -T -P "$prefix" -D "line number of the target line" '%lj' complete -T -P "$prefix" -D "number of lines" '%L' complete -T -P "$prefix" -D "number of the operands files" '%m' complete -T -P "$prefix" -D "line number percent of the top line" '%Pt' complete -T -P "$prefix" -D "line number percent of the middle line" '%Pm' complete -T -P "$prefix" -D "line number percent of the bottom line" '%Pb' complete -T -P "$prefix" -D "line number percent of the line just after the bottom" '%PB' complete -T -P "$prefix" -D "line number percent of the target line" '%Pj' complete -T -P "$prefix" -D "byte offset percent of the top line" '%pt' complete -T -P "$prefix" -D "byte offset percent of the middle line" '%pm' complete -T -P "$prefix" -D "byte offset percent of the bottom line" '%pb' complete -T -P "$prefix" -D "byte offset percent of the line just after the bottom" '%pB' complete -T -P "$prefix" -D "byte offset percent of the target line" '%pj' complete -T -P "$prefix" -D "remove trailing spaces" '%t' complete -T -P "$prefix" -D "next filename" '%x' esac #<<# case $word in (*\?*) typeset prefix="${TARGETWORD%\?*}" #>># complete -T -P "$prefix" -D "true if there is any character before here" '?a' complete -T -P "$prefix" -D "true if the value of %bt is known" '?bt' complete -T -P "$prefix" -D "true if the value of %bm is known" '?bm' complete -T -P "$prefix" -D "true if the value of %bb is known" '?bb' complete -T -P "$prefix" -D "true if the value of %bB is known" '?bB' complete -T -P "$prefix" -D "true if the value of %bj is known" '?bj' complete -T -P "$prefix" -D "true if the file size is known" '?B' '?s' complete -T -P "$prefix" -D "true if the text is horizontally shifted" '?c' complete -T -P "$prefix" -D "true if the value of %dt is known" '?dt' complete -T -P "$prefix" -D "true if the value of %dm is known" '?dm' complete -T -P "$prefix" -D "true if the value of %db is known" '?db' complete -T -P "$prefix" -D "true if the value of %dB is known" '?dB' complete -T -P "$prefix" -D "true if the value of %dj is known" '?dj' complete -T -P "$prefix" -D "true if at the end of the file" '?e' complete -T -P "$prefix" -D "true if the input file is not the standard input" '?f' complete -T -P "$prefix" -D "true if the value of %lt is known" '?lt' complete -T -P "$prefix" -D "true if the value of %lm is known" '?lm' complete -T -P "$prefix" -D "true if the value of %lb is known" '?lb' complete -T -P "$prefix" -D "true if the value of %lB is known" '?lB' complete -T -P "$prefix" -D "true if the value of %lj is known" '?lj' complete -T -P "$prefix" -D "true if the line number of the last line is known" '?L' complete -T -P "$prefix" -D "true if there are more than one input file" '?m' complete -T -P "$prefix" -D "true if is the first prompt" '?n' complete -T -P "$prefix" -D "true if the value of %Pt is known" '?Pt' complete -T -P "$prefix" -D "true if the value of %Pm is known" '?Pm' complete -T -P "$prefix" -D "true if the value of %Pb is known" '?Pb' complete -T -P "$prefix" -D "true if the value of %PB is known" '?PB' complete -T -P "$prefix" -D "true if the value of %Pj is known" '?Pj' complete -T -P "$prefix" -D "true if the value of %pt is known" '?pt' complete -T -P "$prefix" -D "true if the value of %pm is known" '?pm' complete -T -P "$prefix" -D "true if the value of %pb is known" '?pb' complete -T -P "$prefix" -D "true if the value of %pB is known" '?pB' complete -T -P "$prefix" -D "true if the value of %pj is known" '?pj' complete -T -P "$prefix" -D "true if there is a next file" '?x' esac #<<# fi ;; (t|--tag) typeset tagfile= word for word in "${WORDS[2,-1]}"; do case $word in (--tag-file=*) tagfile=${word#--tag-file=} ;; (-T*) tagfile=${word#-T} ;; (-*) ;; (*) break ;; esac done if [ -r "${tagfile:-tags}" ]; then complete -P "$PREFIX" -R "!_TAG_*" -- \ $(cut -f 1 "${tagfile:-tags}" 2>/dev/null) fi ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/cd0000644000175000017500000000253312154557026016335 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "cd" built-in command. # Completion function "completion/cd" is used for the "dirs", "pushd", "popd" # built-ins as well. function completion/cd { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--help" ) #<# case ${WORDS[1]} in (cd|pushd) OPTIONS=("$OPTIONS" #># "L --logical; keep symbolic links in the \$PWD variable as is" "P --physical; resolve symbolic links in the \$PWD variable" "--default-directory:; specify the default directory to change to" ) #<# if [ "${WORDS[1]}" = "pushd" ]; then OPTIONS=("$OPTIONS" #># "--remove-duplicates; remove duplicates in the directory stack" ) #<# fi ;; (dirs) OPTIONS=("$OPTIONS" #># "c --clear; clear the directory stack completely" "v --verbose; print stack entries with their indices" ) #<# ;; esac typeset dirstack=false command -f completion//parseoptions -es case $ARGOPT in (-) case $TARGETWORD in (-*[[:digit:]]*) ;; (*) command -f completion//completeoptions ;; esac dirstack=true ;; (--default-directory) complete -T -P "$PREFIX" -S / -d ;; (*) case ${WORDS[1]} in (cd|pushd) complete -T -S / -d esac dirstack=true ;; esac if $dirstack; then case ${WORDS[1]} in (dirs|pushd|popd) complete -P "$PREFIX" --dirstack-index esac fi } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/make0000644000175000017500000001407112154557026016664 0ustar magicantmagicant# (C) 2013 magicant # Completion script for the "make" command. # Supports POSIX 2008, GNU Make 3.82, FreeBSD 9.0, OpenBSD 5.0, NetBSD 3.0, # Solaris 11.1, HP-UX 11i v3. function completion/make { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU Make'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "e ${long:+--environment-overrides}; environment variables override variables defined in makefile" "f: ${long:+--file: --makefile:}; specify makefile" "i ${long:+--ignore-errors}; ignore errors returned by invoked commands" "k ${long:+--keep-going}; continue to make other targets if some can't be made" "n ${long:+--just-print --dry-run --recon}; don't actually make but print what would be done" "p ${long:+--print-data-base}; print defined macros and targets" "q ${long:+--question}; check if the target is up-to-date without making anything" "r ${long:+--no-builtin-rules}; disable the built-in rules" "S ${long:+--no-keep-going --stop}; stop immediately when some target can't be made" "s ${long:+--silent --quiet}; don't print invoked commands" "t ${long:+--touch}; touch targets instead of usual making" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD) ADDOPTIONS=("$ADDOPTIONS" #># "I: ${long:+--include-dir:}; specify a directory containing makefiles" "j: ${long:+--jobs:}; specify the number of concurrent jobs" ) #<# case $type in (GNU|FreeBSD|NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "C: ${long:+--directory:}; change to the specified directory" ) #<# case $type in (OpenBSD|NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "D:; define the specified variable to be 1" ) #<# esac esac esac case $type in (GNU|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "w ${long:+--print-directory}; print working directory name" ) #<# esac case $type in (GNU|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "d; print debugging info" ) #<# esac case $type in (SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "u; remake everything unconditionally" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "B --always-make; consider all targets out-of-date" "--debug::; specify debugging options" "--eval:; evaluate the specified rule" "h --help; print help" "L --check-symlink-times; consider the last modified time of symbolic links" "l::; --load-average:: --max-load::; keep concurrency below the specified load average" "--no-print-directory; cancel the -w option" "o: --old-file: --assume-old:; don't remake targets depending on the specified file" "R --no-builtin-variables; disable the build-in variables and rules" "v --version; print version info" "W: --what-if: --new-file: --assume-new:; assume the specified file has just been modified" "--warn-undefined-variables; print an error message when an undefined variable is encountered" ) #<# ;; (*BSD) ADDOPTIONS=("$ADDOPTIONS" #># "B; disable POSIX-incompatible optimization" "d:; specify debug flags" "m; specify a directory to add to the system include path" "V:; print the value of the specified variable" ) #<# case $type in (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "E:; specify a macro overridden by environment variable" "P; don't intermix output of concurrent jobs" "Q; be extra quiet" "v; be extra verbose" "X; don't expand variable values recursively (with -V)" "x:; specify warning options" ) #<# ;; (NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "N; don't execute any commands at all" "T:; specify a file to save a trace record" "W; treat warnings as errors" "X; export variables by MAKEFLAGS instead of environment variables" ) #<# ;; esac ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "D; print makefile contents" "d; print why make chooses to rebuild a target" "K:; specify a state file" "P; print defined macros and targets completely" "V; run in SysV mode" "x; enable compatibility mode" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "B; disable compatibility mode" "b; enable compatibility mode" "P; enable parallel command execution" "w; suppress warnings" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([fKoTW]|--file|--makefile|--old-file|--assume-old|--what-if|--new-file|--assume-new) complete -P "$PREFIX" -f ;; ([CIm]|--directory|--include-dir) complete -P "$PREFIX" -S / -T -d ;; ([DEV]) command -f completion/make::macro ;; # (d) # #TODO # ;; # (j|--jobs) # ;; # (l|--load-average|--max-load) # ;; # (x) # #TODO # ;; (*) command -f completion//getoperands command -f completion/make::operand ;; esac } function completion/make::macro { complete -P "$PREFIX" "$@" -v while read -rA targets; do complete -P "$PREFIX" "$@" -- "$targets" done 2>/dev/null <(make -pq | sed -n ' /^[[:space:]]*#/d /^ /d /:/d /=/ { s/=.*$// p } ') } function completion/make::operand { typeset allowmacro=true case $type in (GNU) ;; (*) typeset word for word in "$WORDS"; do case $word in (*=*) ;; (*) allowmacro=false ;; esac done ;; esac if $allowmacro; then command -f completion/make::macrooperand fi command -f completion/make::target } function completion/make::macrooperand { case $TARGETWORD in (*=*) typeset word="${TARGETWORD#*=}" typeset PREFIX="${TARGETWORD%"$word"}" complete -P "$PREFIX" -f ;; (*) command -f completion/make::macro -S = -T ;; esac } function completion/make::target { typeset completed=false while read -rA targets; do for target in "$targets"; do case $target in (.*|*[/%]*) ;; (*) complete -P "$PREFIX" -- "$target" completed=true ;; esac done done 2>/dev/null <(make -pq | sed -n ' /^[[:space:]]*#/d /^ /d /=/d /:/ { s/:.*$// p } ') if ! $completed; then complete -P "$PREFIX" -f fi } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/dirs0000644000175000017500000000026612154557026016711 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "dirs" built-in command. function completion/dirs { command -f completion//reexecute cd } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/mesg0000644000175000017500000000045212154557026016700 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "mesg" command. # Supports POSIX 2008. function completion/mesg if [ ${WORDS[#]} -eq 1 ]; then #>># complete -D "allow messages from other uses" y complete -D "deny messages from other uses" n fi #<<# # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/chown0000644000175000017500000000463712154557026017074 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "chown" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/chown { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "h ${long:+--no-dereference}; change the owner of symbolic links" "H; follow symbolic links to directories in operands (with -R)" "L; follow all symbolic links to directories (with -R)" "P; don't follow any symbolic links (with -R)" "R ${long:+--recursive}; recursively change the owner of files in a directory" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "f ${long:+--silent --quiet}; suppress error messages" ) #<# case $type in (GNU|NetBSD|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "v ${long:+--verbose}; print a message for each file processed" ) #<# esac esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "c --changes; print a message when a change has been made" "--dereference; change the owner of files referred to by symbolic links" "--from:; specify an owner:group only from which changes are made" "--no-preserve-root; cancel the --preserve-root option" "--preserve-root; don't recursively change the owner of the root directory" "--reference:; specify a file to whose owner changes are made" "--help" "--version" ) #<# ;; (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "x; stop recursion when reaching a different file system" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS typeset ownergroup=false command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--reference) complete -P "$PREFIX" -f ;; (--from) ownergroup=true ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then ownergroup=true else complete -f fi ;; esac if $ownergroup; then case ${TARGETWORD#"$PREFIX"} in (*:*) PREFIX=$PREFIX${${TARGETWORD#"$PREFIX"}%%:*}: complete -P "$PREFIX" -g ;; (*) complete -T -P "$PREFIX" -S : -u ;; esac fi } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/rsync0000644000175000017500000002010412154557026017077 0ustar magicantmagicant# (C) 2013 magicant # Completion script for the "rsync" command. # Supports rsync 3.0.9. function completion/rsync { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "0 --from0; treat filename list files as null-separated" "4 --ipv4; prefer IPv4" "6 --ipv6; prefer IPv6" "8 --8-bit-output; don't escape non-ASCII characters" "A --acls; like -P but preserve ACL as well" "--address:; specify an address to bind to" "--append; copy files by appending only" "--append-verify; like --append but verify whole files" "a --archive; like -Dgloprt" "b --backup; make a backup of existing destination files" "--backup-dir:; specify where to make a backup" "--blocking-io; use blocking IO" "B: --block-size:; specify the block size used in delta-transfer" "--bwlimit:; specify a speed limit in kilobytes/second" "c --checksum; use checksum to decide if a file needs to be sent" "--checksum-seed:; specify a seed for checksum" "--chmod:; specify permissions of copied files" "--compare-dest:; specify a directory to compare with as destination" "--compress-level:; specify the compression level" "--config:; specify a config file for daemon" "--contimeout:; specify timeout for rsync connection daemon" "--copy-dest:; like --compare-dest but copy from if possible" "--copy-unsafe-links; follow symbolic links to outside of source tree" "C --cvs-exclude; exclude files like CVS does" "D; like --devices --specials" "--daemon; run as a daemon" "--delay-updates; replace destination files after all transfer" "--devices; copy character and block device files" "d --dirs; copy directories but not their contents" "--exclude:; skip files whose names match the specified pattern" "--exclude-from:; skip files whose names match a pattern in the specified file" "E --executability; preserve file executability" "--existing --ignore-non-existing; copy only files existing on destination" "e: --rsh:; specify a program for remote connection" "F; like --filter='dir-merge /.rsync-filter'" "--fake-super; use extended attributes to preserve various attributes" "--files-from:; specify a file containing filenames to transfer" "f: --filter:; specify an exclusion rule" "--force; allow replacing non-empty directories with non-directories" "g --group; preserve file owner groups" "H --hard-links; preserve hard links" "h --human-readable; print size using K, M, etc." "--iconv:; specify filename encodings" "--ignore-existing; don't copy files existing on destination" "I --ignore-times; don't skip files that match size and time" "--include:; copy only files whose names match the specified pattern" "--include-from:; copy only files whose names match a pattern in the specified file" "--inplace; modify destination files in-place" "i --itemize-changes; print a summarized list of changes" "K --keep-dirlinks; follow symbolic links to directories on destination side" "k --copy-dirlinks; follow symbolic links to directories on source side" "L --copy-links; follow all symbolic links in source files" "--link-dest:; specify a directory to search for hard-linkable files" "l --links; copy symbolic links as symbolic links" "--list-only; list files without actual transfer" "--log-file:; specify a file to print log to" "--log-file-format:; specify a format used in logging with --log-file" "m --prune-empty-dirs; don't copy empty directories" "--max-delete:; specify the maximum number of files deleted" "--max-size:; specify the maximum size of files copied" "--min-size:; specify the minimum size of files copied" "--modify-window:; specify max time difference treated as same" "n --dry-run; don't actually copy files" "--no-detach; don't run in the background (with --daemon)" "--no-motd; don't print the message of the day sent from daemon" "--no-implied-dirs; don't copy intermediate directory paths (with -R)" "--no-inc-recursive --no-i-r; disable incremental recursion" "--numeric-ids; match numeric owner/group IDs rather than names" "O --omit-dir-times; don't preserve modification times for directories" "--only-write-batch:; like --write-batch, but no actual transfer" "--out-format:; specify a format printed for each file update" "o --owner; preserve file owners" "P; like --partial --progress" "--partial; leave partially copied files if interrupted" "--partial-dir:; specify a directory where intermediate files are kept" "--password-file:; specify a file containing a password" "p --perms; preserve file permissions" "--port:; specify a port for daemon connection" "--progress; show progress during transfer" "--protocol:; specify a protocol version" "q --quiet; print error messages only" "--read-batch:; specify a batch file containing transfer recipe" "R --relative; preserve all pathname components from source" "r --recursive; copy directories recursively" "--rsync-path:; specify a program executed on the remote host" "s --protect-args; protect filenames from word splitting by the remote shell" "--safe-links; ignore symbolic links to outside of source tree" "--size-only; skip files that match in size" "--skip-compress:; specify a list of suffixes that are not compressed" "--sockopts:; specify socket options" "S --sparse; handle sparse files efficiently" "--specials; copy named sockets, pipes, etc." "--stats; print transfer statistics" "--suffix:; specify a suffix to append to backup file names" "--super; exercise superuser rights to preserve various attributes" "T: --temp-dir:; specify a directory for temporary files on destination side" "--timeout:; specify timeout in seconds" "t --times; preserve file modification times" "u --update; don't copy if destination is newer than source" "v --verbose; print detail during execution" "W --whole-file; send whole files rather than just different parts" "--write-batch:; specify a file where transfer recipe is recorded" "X --xattrs; preserve extended attributes" "x --one-file-system; skip subdirectories on different file systems" "y --fuzzy; look for similar files to optimize transfer" "z --compress; enable compression" "--help" "--version" ) #<# # TODO --no-xxx option command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (--*-batch|--config|--exclude*|--files-from|--include*|--log-file|--password-file) complete -P "$PREFIX" -f ;; (--address) complete -P "$PREFIX" -h ;; # (--backup-dir) # ;; (B|--block-size) #TODO ;; # (--bwlimit) # ;; # (--checksum-seed) # ;; (--chmod) if command -vf completion/chmod::mode >/dev/null 2>&1 || . -AL completion/chmod; then command -f completion/chmod::mode rsync fi ;; # (--*-dest) # # How can we complete remote directory names before the remote # # host name is entered on the command line? # ;; # (--compress-level) # ;; # (--contimeout) # ;; (e|--rsh) complete -P "$PREFIX" --external-command ;; (f|--filter) #TODO ;; (--*-format) #TODO ;; (--iconv) typeset word="${TARGETWORD#"$PREFIX"}" word=${word#*,} PREFIX="${TARGETWORD%"$word"}" if command -vf completion/iconv::compenc >/dev/null 2>&1 || . -AL completion/iconv; then command -f completion/iconv::compenc fi ;; # (--max-delete) # ;; (--max-size|--min-size) if command -vf completion//prefixdigits >/dev/null 2>&1 || . -AL completion/_blocksize; then if command -f completion//prefixdigits; then command -f completion//completesizesuffix KMGB fi fi ;; # (--modify-window) # ;; # (--partial-dir) # # How can we complete remote directory names before the remote # # host name is entered on the command line? # ;; # (--port) # ;; # (--protocol) # ;; # (--rsync-path) # ;; # (--skip-compress) # ;; # (--sockopts) # ;; # (--suffix) # ;; # (T|--temp-dir) # # How can we complete remote directory names before the remote # # host name is entered on the command line? # ;; # (--timeout) # ;; ('') command -f completion/rsync::operand ;; esac } function completion/rsync::operand { #TODO support rsync daemon protocol command -f completion//getoperands if command -vf completion/scp::operand >/dev/null 2>&1 || . -AL completion/ssh; then command -f completion/scp::operand fi } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/wait0000644000175000017500000000121112154557026016703 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "wait" built-in command. function completion/wait { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) case $TARGETWORD in (%*) # complete job name complete -P % -j ;; (*) # complete job process ID typeset pid status while read -r pid status; do complete -D "$(ps -p $pid -o args=)" -- $pid done 2>/dev/null <(jobs -l | sed -e 's/^\[[[:digit:]]*\][[:blank:]]*[-+]//') ;; esac ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-show0000644000175000017500000000135712154557026017513 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-show" command. # Supports Git 1.7.7. function completion/git-show { WORDS=(git show "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::show:arg { OPTIONS=() { command -vf completion/git::log:getopt >/dev/null 2>&1 || . -AL completion/git-log; } && command -f completion/git::log:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeobject ;; (*) { command -vf completion/git::log:compopt >/dev/null 2>&1 || . -AL completion/git-log; } && command -f completion/git::log:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/cmp0000644000175000017500000000272212154557026016526 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "cmp" command. # Supports POSIX 2008, GNU diffutils 3.0, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # SunOS 5.10, HP-UX 11i v3. function completion/cmp { case $("${WORDS[1]}" --version 2>/dev/null) in (*'diffutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "l ${long:+--verbose}; print all differing byte values" "s ${long:+--silent --quiet}; print nothing" ) #<# ADDOPTIONS=() case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "b --print-bytes; print differing byte values in ^-notation" "i: --ignore-initial:; specify number of bytes to skip" "n: --bytes:; specify number of bytes to compare at most" "--help" "v --version; print version info" ) #<# ;; (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "h; don't follow symbolic links" "x; print all differing byte values in hexadecimal" "z; firstly compare by size" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (i|--ignore-initial) ;; (n|--bytes) ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -lt 2 ]; then complete -f fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gview0000644000175000017500000000030412154557026017062 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "gview" command. # Supports Vim 7.3. function completion/gview { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/vi0000644000175000017500000000040212154557026016356 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "vi" command. # Supports POSIX 2008, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, SunOS 5.10, # HP-UX 11i v3. function completion/vi { command -f completion//reexecute ex } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/scp0000644000175000017500000000025412154557026016532 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "scp" command. function completion/scp { command -f completion//reexecute ssh } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-push0000644000175000017500000000341512154557026017507 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-push" command. # Supports Git 1.7.7. function completion/git-push { WORDS=(git push "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::push:arg { OPTIONS=( #># "--all; push all local branches" "--delete; delete remote refs specified as operands" "n --dry-run; don't actually push anything" "f --force; allow non-fast-forward update" "--mirror; push all local refs" "--no-thin; cancel the --thin option" "--porcelain; print in the machine-friendly format" "--progress; report progress" "q --quiet; don't report progress" "--repo:; specify the default repository to push to" "--receive-pack: --exec:; specify a path for git-receive-pack on the remote host" "u --set-upstream; make pushed branches remote-tracking" "--tags; push all local tags" "--thin; send a thin pack to reduce traffic" "v --verbose" # TODO description ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (--receive-pack|--exec) command -f completion/git::--receive-pack:arg ;; (--repo|'') command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then #TODO complete remote URI command -f completion/git::completeremote elif [ "${WORDS[-1]}" = tag ]; then command -f completion/git::completeref --tags else typeset word="${TARGETWORD#"$PREFIX"}" word=${word#+} case $word in (*:*) # complete remote refs word=${word#*:} PREFIX=${TARGETWORD%"$word"} command -f completion/git::completeremoteref "${WORDS[1]}" ;; (*) # complete local refs PREFIX=${TARGETWORD%"$word"} command -f completion/git::completeref ;; esac fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/eval0000644000175000017500000000125612154557026016677 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "eval" built-in command. function completion/eval { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "i --iteration; perform iterative execution on each operand" "--help" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (*) typeset iteration=false word for word in "${WORDS[2,-1]}"; do case $word in (-i|--iteration) iteration=true ;; (--) break ;; esac done if $iteration; then complete -c else command -f completion//getoperands command -f completion//reexecute fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/time0000644000175000017500000000626612154557026016714 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "time" command. # Supports POSIX 2008, GNU time 1.7, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/time { case $("${WORDS[1]}" --version 2>&1) in (*'GNU'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "p ${long:+--portability}; use the POSIX format" ) #<# case $type in (GNU|FreeBSD) OPTIONS=("$OPTIONS" #># "a ${long:+--append}; append to the output file; don't overwrite the file" "o: ${long:+--output:}; specify the file to print time to" ) #<# esac case $type in (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "l; print the rusage values as well" ) #<# esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "f: --format:; specify the output format" "V --version; print version info" "v --verbose; print detailed time info" "--help" ) #<# ;; (FreeBSD) OPTIONS=("$OPTIONS" #># "h; use a human-friendly format" ) #<# ;; (NetBSD) OPTIONS=("$OPTIONS" #># "c; use the csh format" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (f|--format) command -f completion/time::format ;; (o|--output) complete -P "$PREFIX" -f ;; (*) command -f completion//getoperands command -f completion//reexecute -e ;; esac } function completion/time::format { typeset word="${TARGETWORD#"$PREFIX"}" word=${word//%%} case $word in (*%) PREFIX=${TARGETWORD%\%} #>># complete -T -P "$PREFIX" -D "command name and arguments" '%C' complete -T -P "$PREFIX" -D "preemptive context switch count" '%c' complete -T -P "$PREFIX" -D "average unshared data size in kilobytes" '%D' complete -T -P "$PREFIX" -D "elapsed real time ([H:]MM:SS.ss)" '%E' complete -T -P "$PREFIX" -D "elapsed real time in seconds" '%e' complete -T -P "$PREFIX" -D "major fault count" '%F' complete -T -P "$PREFIX" -D "file read count" '%I' complete -T -P "$PREFIX" -D "average total used memory in kilobytes" '%K' complete -T -P "$PREFIX" -D "number of signals the process received" '%k' complete -T -P "$PREFIX" -D "max resident set size in kilobytes" '%M' complete -T -P "$PREFIX" -D "file write count" '%O' complete -T -P "$PREFIX" -D "percentage of CPU time" '%P' complete -T -P "$PREFIX" -D "average unshared stack size in kilobytes" '%p' complete -T -P "$PREFIX" -D "minor fault count" '%R' complete -T -P "$PREFIX" -D "socket receive count" '%r' complete -T -P "$PREFIX" -D "kernel CPU time in seconds" '%S' complete -T -P "$PREFIX" -D "socket send count" '%s' complete -T -P "$PREFIX" -D "average resident set size in kilobytes" '%t' complete -T -P "$PREFIX" -D "swap-out count" '%W' complete -T -P "$PREFIX" -D "non-preemptive context switch count" '%w' complete -T -P "$PREFIX" -D "average shared text area size in kilobytes" '%X' complete -T -P "$PREFIX" -D "exit status of the process" '%x' complete -T -P "$PREFIX" -D "page size" '%Z' complete -T -P "$PREFIX" -D "%" '%%' return 0 #<<# esac return 1 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-fetch0000644000175000017500000000524612154557026017625 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-fetch" command. # Supports Git 1.7.7. function completion/git-fetch { WORDS=(git fetch "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::fetch:arg { OPTIONS=( #># "--dry-run; don't actually fetch anything" "--multiple; allow specifying multiple remotes" "p --prune; delete remote-tracking branches that no longer exist on the remote" "q --quiet; don't report progress" "--submodule-prefix" # not for command line use "--recurse-submodules-default::" # not for command line use "t --tags; fetch all tags from the remote" "v --verbose" # TODO description ) #<# command -f completion/git::fetch:getopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--recurse-submodules|--upload-pack) command -f completion/git::$ARGOPT:arg ;; (--recurse-submodules-default) ;; # (--depth) # ;; ('') typeset i=2 multiple=false while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--) i=$((i+1)) break ;; (--multiple) multiple=true break ;; (-?*) i=$((i+1)) ;; (*) break ;; esac done if $multiple || [ $i -gt ${WORDS[#]} ]; then #TODO complete remote URI command -f completion/git::completeremote { command -vf completion/git::completeremotegroup >/dev/null 2>&1 || . -AL completion/git-remote; } && command -f completion/git::completeremotegroup elif [ "${WORDS[-1]}" = tag ]; then command -f completion/git::completeref --tags else typeset word="${TARGETWORD#"$PREFIX"}" word=${word#+} case $word in (*:*) # complete local refs word=${word#*:} PREFIX=${TARGETWORD%"$word"} command -f completion/git::completeref ;; (*) # complete remote refs PREFIX=${TARGETWORD%"$word"} command -f completion/git::completeremoteref "${WORDS[i]}" ;; esac fi ;; esac } function completion/git::fetch:getopt { typeset fetch= case ${gitcmd-} in fetch) fetch=true;; esac OPTIONS=("$OPTIONS" #># "--all; fetch all remotes" "a --append; append to (not overwrite) existing FETCH_HEAD" "--depth:; specify the max number of history to fetch" "f --force; allow non-fast-forward update" "k --keep; keep downloaded pack" "--no-recurse-submodules; don't fetch submodules" "${fetch+n} --no-tags; don't fetch tags automatically" "--progress; report progress" "--recurse-submodules::; specify whether to fetch submodules" "u --update-head-ok" # not for command line use "--upload-pack:; specify a path for git-upload-pack on the remote host" ) #<# } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/command0000644000175000017500000000467212154557026017373 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "command" built-in command. # Completion function "completion/command" is used for the "type" built-in as # well. function completion/command { typeset OPTIONS ARGOPT PREFIX typeset COMMONOPTIONS VOPTIONS NOVOPTIONS COMMONOPTIONS=( #># "b --builtin-command; execute or find a built-in command" "e --external-command; execute or find an external command" "f --function; execute or find a function" "p --standard-path; use the standard path in searching for a command" "--help" ) #<# VOPTIONS=( #># "a --alias; find an alias" "k --keyword; find a shell keyword" ) #<# NOVOPTIONS=( #># "v --identify; print the full path of a command" "V --verbose-identify; describe how a command is interpreted" ) #<# OPTIONS=("$COMMONOPTIONS" "$VOPTIONS" "$NOVOPTIONS") command -f completion//parseoptions typeset i=2 options= while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i++]} in (--) break ;; (--help) return ;; (-a|--alias) options=${options}a ;; (-b|--builtin-command) options=${options}b ;; (-e|--external-command) options=${options}e ;; (-f|--function) options=${options}f ;; (-k|--keyword) options=${options}k ;; (-p|--standard-path) options=${options}p ;; (-v|--identify) options=${options}v ;; (-V|--verbose-identify) options=${options}V ;; esac done WORDS=("${WORDS[i,-1]}") case $ARGOPT in (-) case $options in (*[vV]*) OPTIONS=("$COMMONOPTIONS" "$VOPTIONS") ;; (*) OPTIONS=("$COMMONOPTIONS" "$NOVOPTIONS") ;; esac command -f completion//completeoptions ;; (*) if case $options in (*[vV]*) if [ -z "${options//[pvV]}" ]; then options=${options}abefk fi true ;; (*) if [ -z "${options//p}" ]; then options=${options}be fi [ ${WORDS[#]} -eq 0 ] ;; esac then # complete command name case $options in (*a*) complete --alias esac case $options in (*b*) complete --builtin-command esac case $options in (*e*) complete -T -S / -d case $TARGETWORD in (*/*) complete --executable-file ;; (* ) complete --external-command ;; esac esac case $options in (*f*) complete --function esac case $options in (*k*) complete --keyword esac else # complete command argument command -f completion//reexecute fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/fgrep0000644000175000017500000000031612154557026017047 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "fgrep" command. function completion/fgrep { WORDS=(grep -F "${WORDS[2,-1]}") command -f completion//reexecute } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-rev-list0000644000175000017500000001106312154557026020273 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-rev-list" command. # Supports Git 1.7.7. function completion/git-rev-list { WORDS=(git rev-list "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::rev-list:arg { OPTIONS=( #># "--bisect; print a midpoint commit in current bisect" "--bisect-all" "--bisect-vars" "--count; print the number of selected commits only" "--header; print commits in the raw format" "--timestamp; print the raw timestamp values" ) #<# command -f completion/git::rev-list:getopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completerefpath range=true ;; (*) command -f completion/git::rev-list:compopt ;; esac } function completion/git::rev-list:getopt { command -f completion/git::getorderopts command -f completion/git::getprettyopts OPTIONS=("$OPTIONS" #># "--ancestry-path" "--all; print all commits reachable from any refs" "--all-match; show commits that match all the other filter options only" "--after: --since:; show commits after the specified date only" "--author:; show commits by the specified author only" "--before: --until:; show commits before the specified date only" "--branches::; print all (or specified) branches" "--cherry; like --right-only --cherry-mark --no-merges" "--cherry-mark; like --cherry-pick, but mark commits" "--cherry-pick; omit commits duplicated by cherry-picking" "--children; print children's commit IDs as well" "--committer:; show commits by the specified committer only" "--date:; specify a date format" "--dense" "--do-walk; traverse commit ancestors" "E --extended-regexp; use extended regular expression" "--first-parent; follow first parent of each commit only" "F --fixed-strings; perform simple string matching rather than regular expression" "--full-history" "--glob:; show refs that match the specified pattern" "--graph; print commit ancestry tree graph" "--grep:; show commits whose log message matches the specified pattern only" "--ignore-missing; ignore nonexistent refs" "--left-only; show commits on the left-hand-side branch only" "--left-right; show reachability of commits from branches" # not meant for interactive use: "--max-age:" "n: --max-count:; specify the max number of commits shown" "--max-parents:; show commits with at most the specified number of parents only" "--merge; show refs that touch conflicting files" "--merges; like --min-parents=2 (show merge commits only)" # not meant for interactive use: "--min-age:" "--min-parents:; show commits with at least the specified number of parents only" "--no-max-parents; like --max-parents=-1" "--no-merges; like --max-parents=1 (don't show merge commits)" "--no-min-parents; like --min-parents=0" "--no-walk; don't traverse commit ancestors" "--objects; print object IDs referenced by selected commits" "--objects-edge; like --objects, but print excluded commits too" "--parents; print parents' commit IDs as well" "--quiet; print nothing" "i --regexp-ignore-case; case-insensitive regular expression matching" "--relative-date; like --date=relative" "--remotes::; print all (or specified) remote refs" "--remove-empty; stop when a given path disappears from the tree" "--reverse; print in reverse order" "--right-only; show commits on the right-hand-side branch only" "--simplify-by-decoration" "--simplify-merges" "--sparse" "--stdin; read arguments from the standard input" "--tags::; print all (or specified) tags" "--unpacked; print object IDs that are not in packs" "g --walk-reflogs; show reflogs instead of ancestry chain" ) #<# # TODO: some descriptions are missing! # "--not" is not included in this list because it is actually # an operand rather than an option. } function completion/git::rev-list:compopt case $ARGOPT in (n|--max-*|--min-*) # complete nothing ;; (--author|--date) command -f "completion/git::$ARGOPT:arg" ;; (--after|--before|--since|--until) # TODO complete date ;; (--branches) command -f completion/git::completeref --branches ;; (--committer) typeset committer while read -r committer; do complete -P "$PREFIX" -- "$committer" done 2>/dev/null \ <(git log --all --format=format:%cn | uniq) ;; (--glob) command -f completion/git::completeref ;; (--remotes) command -f completion/git::completeref --remotes ;; (--tags) command -f completion/git::completeref --tags ;; (*) command -f completion/git::completeprettyopts ;; esac # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/bindkey0000644000175000017500000002326712154557026017403 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "bindkey" built-in command. function completion/bindkey { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a --vi-command; change or print vi-command-mode key bindings" "e --emacs; change or print emacs-mode key bindings" "l --list; print all key binding command names" "v --vi-insert; change or print vi-insert-mode key bindings" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -le 0 ]; then # complete a key sequence TARGETWORD=${TARGETWORD//\\\\/} case $TARGETWORD in (*\\*) PREFIX=${TARGETWORD%\\*} #>># complete -T -P "$PREFIX" '\\' -D "backslash" complete -T -P "$PREFIX" '\B' -D "backspace" complete -T -P "$PREFIX" '\D' -D "down arrow" complete -T -P "$PREFIX" '\E' -D "end" complete -T -P "$PREFIX" '\H' -D "home" complete -T -P "$PREFIX" '\I' -D "insert" complete -T -P "$PREFIX" '\L' -D "left arrow" complete -T -P "$PREFIX" '\N' -D "page-down" complete -T -P "$PREFIX" '\P' -D "page-up" complete -T -P "$PREFIX" '\R' -D "right arrow" complete -T -P "$PREFIX" '\U' -D "up arrow" complete -T -P "$PREFIX" '\X' -D "delete" complete -T -P "$PREFIX" '\!' -D "INTR (normally Ctrl-C)" complete -T -P "$PREFIX" '\#' -D "EOF (normally Ctrl-D)" complete -T -P "$PREFIX" '\$' -D "KILL (normally Ctrl-U)" complete -T -P "$PREFIX" '\?' -D "ERASE (normally Ctrl-H)" complete -T -P "$PREFIX" '\^@' -D "Ctrl-@" complete -T -P "$PREFIX" '\^A' -D "Ctrl-A" complete -T -P "$PREFIX" '\^B' -D "Ctrl-B" complete -T -P "$PREFIX" '\^C' -D "Ctrl-C" complete -T -P "$PREFIX" '\^D' -D "Ctrl-D" complete -T -P "$PREFIX" '\^E' -D "Ctrl-E" complete -T -P "$PREFIX" '\^F' -D "Ctrl-F" complete -T -P "$PREFIX" '\^G' -D "Ctrl-G" complete -T -P "$PREFIX" '\^H' -D "Ctrl-H" complete -T -P "$PREFIX" '\^I' -D "Ctrl-I (tab)" complete -T -P "$PREFIX" '\^J' -D "Ctrl-J (newline)" complete -T -P "$PREFIX" '\^K' -D "Ctrl-K" complete -T -P "$PREFIX" '\^L' -D "Ctrl-L" complete -T -P "$PREFIX" '\^M' -D "Ctrl-M (carriage return)" complete -T -P "$PREFIX" '\^N' -D "Ctrl-N" complete -T -P "$PREFIX" '\^O' -D "Ctrl-O" complete -T -P "$PREFIX" '\^P' -D "Ctrl-P" complete -T -P "$PREFIX" '\^Q' -D "Ctrl-Q" complete -T -P "$PREFIX" '\^R' -D "Ctrl-R" complete -T -P "$PREFIX" '\^S' -D "Ctrl-S" complete -T -P "$PREFIX" '\^T' -D "Ctrl-T" complete -T -P "$PREFIX" '\^U' -D "Ctrl-U" complete -T -P "$PREFIX" '\^V' -D "Ctrl-V" complete -T -P "$PREFIX" '\^W' -D "Ctrl-W" complete -T -P "$PREFIX" '\^X' -D "Ctrl-X" complete -T -P "$PREFIX" '\^Y' -D "Ctrl-Y" complete -T -P "$PREFIX" '\^Z' -D "Ctrl-Z" complete -T -P "$PREFIX" '\^[' -D "Ctrl-[ (escape)" complete -T -P "$PREFIX" '\^\' -D 'Ctrl-\' complete -T -P "$PREFIX" '\^]' -D "Ctrl-]" complete -T -P "$PREFIX" '\^^' -D "Ctrl-^" complete -T -P "$PREFIX" '\^_' -D "Ctrl-_" complete -T -P "$PREFIX" '\^?' -D "Ctrl-?" complete -T -P "$PREFIX" '\F00' -D "F0" complete -T -P "$PREFIX" '\F01' -D "F1" complete -T -P "$PREFIX" '\F02' -D "F2" complete -T -P "$PREFIX" '\F03' -D "F3" complete -T -P "$PREFIX" '\F04' -D "F4" complete -T -P "$PREFIX" '\F05' -D "F5" complete -T -P "$PREFIX" '\F06' -D "F6" complete -T -P "$PREFIX" '\F07' -D "F7" complete -T -P "$PREFIX" '\F08' -D "F8" complete -T -P "$PREFIX" '\F09' -D "F9" complete -T -P "$PREFIX" '\F10' -D "F10" complete -T -P "$PREFIX" '\F11' -D "F11" complete -T -P "$PREFIX" '\F12' -D "F12" complete -T -P "$PREFIX" '\F13' -D "F13" complete -T -P "$PREFIX" '\F14' -D "F14" complete -T -P "$PREFIX" '\F15' -D "F15" complete -T -P "$PREFIX" '\F16' -D "F16" complete -T -P "$PREFIX" '\F17' -D "F17" complete -T -P "$PREFIX" '\F18' -D "F18" complete -T -P "$PREFIX" '\F19' -D "F19" complete -T -P "$PREFIX" '\F20' -D "F20" complete -T -P "$PREFIX" '\F21' -D "F21" complete -T -P "$PREFIX" '\F22' -D "F22" complete -T -P "$PREFIX" '\F23' -D "F23" complete -T -P "$PREFIX" '\F24' -D "F24" complete -T -P "$PREFIX" '\F25' -D "F25" complete -T -P "$PREFIX" '\F26' -D "F26" complete -T -P "$PREFIX" '\F27' -D "F27" complete -T -P "$PREFIX" '\F28' -D "F28" complete -T -P "$PREFIX" '\F29' -D "F29" complete -T -P "$PREFIX" '\F30' -D "F30" complete -T -P "$PREFIX" '\F31' -D "F31" complete -T -P "$PREFIX" '\F32' -D "F32" complete -T -P "$PREFIX" '\F33' -D "F33" complete -T -P "$PREFIX" '\F34' -D "F34" complete -T -P "$PREFIX" '\F35' -D "F35" complete -T -P "$PREFIX" '\F36' -D "F36" complete -T -P "$PREFIX" '\F37' -D "F37" complete -T -P "$PREFIX" '\F38' -D "F38" complete -T -P "$PREFIX" '\F39' -D "F39" complete -T -P "$PREFIX" '\F40' -D "F40" complete -T -P "$PREFIX" '\F41' -D "F41" complete -T -P "$PREFIX" '\F42' -D "F42" complete -T -P "$PREFIX" '\F43' -D "F43" complete -T -P "$PREFIX" '\F44' -D "F44" complete -T -P "$PREFIX" '\F45' -D "F45" complete -T -P "$PREFIX" '\F46' -D "F46" complete -T -P "$PREFIX" '\F47' -D "F47" complete -T -P "$PREFIX" '\F48' -D "F48" complete -T -P "$PREFIX" '\F49' -D "F49" complete -T -P "$PREFIX" '\F50' -D "F50" complete -T -P "$PREFIX" '\F51' -D "F51" complete -T -P "$PREFIX" '\F52' -D "F52" complete -T -P "$PREFIX" '\F53' -D "F53" complete -T -P "$PREFIX" '\F54' -D "F54" complete -T -P "$PREFIX" '\F55' -D "F55" complete -T -P "$PREFIX" '\F56' -D "F56" complete -T -P "$PREFIX" '\F57' -D "F57" complete -T -P "$PREFIX" '\F58' -D "F58" complete -T -P "$PREFIX" '\F59' -D "F59" complete -T -P "$PREFIX" '\F60' -D "F60" complete -T -P "$PREFIX" '\F61' -D "F61" complete -T -P "$PREFIX" '\F62' -D "F62" complete -T -P "$PREFIX" '\F63' -D "F63" complete -T -P "$PREFIX" '\a1' -D "keypad upper-left" complete -T -P "$PREFIX" '\a3' -D "keypad upper-right" complete -T -P "$PREFIX" '\b2' -D "keypad center" complete -T -P "$PREFIX" '\c1' -D "keypad lower-left" complete -T -P "$PREFIX" '\c3' -D "keypad lower-right" complete -T -P "$PREFIX" '\ca' -D "clear all tabs" complete -T -P "$PREFIX" '\cl' -D "close" complete -T -P "$PREFIX" '\cn' -D "cancel" complete -T -P "$PREFIX" '\co' -D "command" complete -T -P "$PREFIX" '\cp' -D "copy" complete -T -P "$PREFIX" '\cr' -D "create" complete -T -P "$PREFIX" '\cs' -D "clear screen" complete -T -P "$PREFIX" '\ct' -D "clear tab" complete -T -P "$PREFIX" '\dl' -D "delete line" complete -T -P "$PREFIX" '\ei' -D "exit insert mode" complete -T -P "$PREFIX" '\el' -D "clear to end of line" complete -T -P "$PREFIX" '\es' -D "clear to end of screen" complete -T -P "$PREFIX" '\et' -D "enter (send)" complete -T -P "$PREFIX" '\fd' -D "find" complete -T -P "$PREFIX" '\hp' -D "help" complete -T -P "$PREFIX" '\il' -D "insert line" complete -T -P "$PREFIX" '\ll' -D "home down" complete -T -P "$PREFIX" '\me' -D "message" complete -T -P "$PREFIX" '\mk' -D "mark" complete -T -P "$PREFIX" '\ms' -D "mouse event" complete -T -P "$PREFIX" '\mv' -D "move" complete -T -P "$PREFIX" '\nx' -D "next object" complete -T -P "$PREFIX" '\on' -D "open" complete -T -P "$PREFIX" '\op' -D "options" complete -T -P "$PREFIX" '\pr' -D "print (copy)" complete -T -P "$PREFIX" '\pv' -D "previous object" complete -T -P "$PREFIX" '\rd' -D "redo" complete -T -P "$PREFIX" '\re' -D "resume" complete -T -P "$PREFIX" '\rf' -D "reference" complete -T -P "$PREFIX" '\rh' -D "refresh" complete -T -P "$PREFIX" '\rp' -D "replace" complete -T -P "$PREFIX" '\rs' -D "restart" complete -T -P "$PREFIX" '\sf' -D "scroll forward" complete -T -P "$PREFIX" '\sl' -D "select" complete -T -P "$PREFIX" '\sr' -D "scroll backward" complete -T -P "$PREFIX" '\st' -D "set tab" complete -T -P "$PREFIX" '\su' -D "suspend" complete -T -P "$PREFIX" '\sv' -D "save" complete -T -P "$PREFIX" '\ud' -D "undo" complete -T -P "$PREFIX" '\SE' -D "shift + end" complete -T -P "$PREFIX" '\SH' -D "shift + home" complete -T -P "$PREFIX" '\SI' -D "shift + insert" complete -T -P "$PREFIX" '\SL' -D "shift + left arrow" complete -T -P "$PREFIX" '\SR' -D "shift + right arrow" complete -T -P "$PREFIX" '\SX' -D "shift + delete" complete -T -P "$PREFIX" '\Sbg' -D "shift + beginning" complete -T -P "$PREFIX" '\Scn' -D "shift + cancel" complete -T -P "$PREFIX" '\Sco' -D "shift + command" complete -T -P "$PREFIX" '\Scp' -D "shift + copy" complete -T -P "$PREFIX" '\Scr' -D "shift + create" complete -T -P "$PREFIX" '\Sdl' -D "shift + delete line" complete -T -P "$PREFIX" '\Sel' -D "shift + end of line" complete -T -P "$PREFIX" '\Sex' -D "shift + exit" complete -T -P "$PREFIX" '\Sfd' -D "shift + find" complete -T -P "$PREFIX" '\Shp' -D "shift + help" complete -T -P "$PREFIX" '\Smg' -D "shift + message" complete -T -P "$PREFIX" '\Smv' -D "shift + move" complete -T -P "$PREFIX" '\Snx' -D "shift + next" complete -T -P "$PREFIX" '\Sop' -D "shift + options" complete -T -P "$PREFIX" '\Spr' -D "shift + print" complete -T -P "$PREFIX" '\Spv' -D "shift + previous" complete -T -P "$PREFIX" '\Srd' -D "shift + redo" complete -T -P "$PREFIX" '\Sre' -D "shift + resume" complete -T -P "$PREFIX" '\Srp' -D "shift + replace" complete -T -P "$PREFIX" '\Ssu' -D "shift + suspend" complete -T -P "$PREFIX" '\Ssv' -D "shift + save" complete -T -P "$PREFIX" '\Sud' -D "shift + undo" #<<# esac else complete --bindkey -- - fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-request-pull0000644000175000017500000000154012154557026021167 0ustar magicantmagicant# (C) 2012 magicant # Completion script for the "git" command. # Supports Git 1.8.0.2. function completion/git-request-pull { WORDS=(git request-pull "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::request-pull:arg { OPTIONS=( #># "p; print a patch" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion//getoperands case ${WORDS[#]} in (1) command -f completion/git::request-pull:compurl ;; (*) command -f completion/git::completeref ;; esac ;; esac } function completion/git::request-pull:compurl { typeset name url type while read -r name url type; do complete -P "$PREFIX" -D "$name $type" -- "$url" done 2>/dev/null <(git remote -v) } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/dash0000644000175000017500000000026212154557026016663 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "dash" command. function completion/dash { command -f completion//reexecute sh } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/jobs0000644000175000017500000000162412154557026016704 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "jobs" built-in command. # Completion function "completion/jobs" is used for the "fg", "bg", "disown" # built-ins as well. function completion/jobs { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--help" ) #<# case ${WORDS[1]} in (disown) OPTIONS=("$OPTIONS" #># "a --all; disown all jobs" ) #<# ;; (jobs) OPTIONS=("$OPTIONS" #># "l --verbose; print process IDs of processes" "n --new; print only jobs whose status change is not yet reported" "p --pgid-only; print process group IDs only" "r --running-only; print running jobs only" "s --stopped-only; print stopped jobs only" ) #<# ;; esac command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) case $TARGETWORD in (%*) PREFIX=% esac complete -P "$PREFIX" -j ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/uniq0000644000175000017500000000331112154557026016716 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "uniq" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/uniq { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c ${long:+--count}; print repeat count for each unique line" "d ${long:+--repeated}; print repeated lines only" "f: ${long:+--skip-fields:}; skip first n fields on each line in comparison" "s: ${long:+--skip-chars:}; skip first n characters on each line in comparison" "u ${long:+--unique}; don't print repeated lines" ) #<# case $type in (GNU|FreeBSD|Darwin) OPTIONS=("$OPTIONS" #># "i ${long:+--ignore-case}; case-insensitive comparison" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "D; print only repeated lines in all" "--all-repeated::; print only repeated lines in all" "w: --check-chars:; compare at most n characters on each line" "z --zero-terminated; use null bytes as the line separator" "--help" "--version" ) #<# esac esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (--all-repeated) #>># complete -P "$PREFIX" -D "don't delimit group of repeated lines" none complete -P "$PREFIX" -D "print a newline before each group of repeated lines" prepend complete -P "$PREFIX" -D "print a newline between groups of repeated lines" separate ;; #<<# ('') complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/fc0000644000175000017500000000152212154557026016334 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "fc" built-in command. function completion/fc { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "e: --editor:; specify an editor to edit the command" "l --list; just print command history" "n --no-numbers; don't print history numbers in listing" "q --quiet; don't print the command before re-executing" "r --reverse; reverse the order of commands" "s --silent; re-execute the command without editing" "v --verbose; print history in detail (with -l)" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (e|--editor) complete -P "$PREFIX" -c --normal-alias ;; (*) typeset num cmd while read -r num cmd; do complete -D "$num" -- "$cmd" done <(fc -l 1) ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/exit0000644000175000017500000000060212154557026016713 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "exit" built-in command. function completion/exit { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "f --force; suppress warning about stopped jobs" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/tee0000644000175000017500000000161712154557026016526 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "tee" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/tee { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a ${long:+--append}; append to the output file; don't overwrite the file" "i ${long:+--ignore-interrupts}; ignore the SIGINT signal" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/rvim0000644000175000017500000000030212154557026016714 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "rvim" command. # Supports Vim 7.3. function completion/rvim { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-clean0000644000175000017500000000240412154557026017607 0ustar magicantmagicant# (C) 2013 magicant # Completion script for the "git-clean" command. # Supports Git 1.8.1.4. function completion/git-clean { WORDS=(git clean "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::clean:arg { OPTIONS=( #># "d; remove untracked directories" "f --force; really remove untracked files" "n --dry-run; don't actually remove files, but show what would be removed" "q --quiet; print error messages only" "e: --exclude:; skip files whose names match the specified pattern" "X; remove ignored files only" "x; remove ignored files too" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (e|--exclude) complete -P "$PREFIX" -f ;; ('') : DEBUG "${WORDS}" command -f completion/git::clean:opr ;; esac } # only complete untracked files function completion/git::clean:opr { typeset arg filter='^?' for arg in "${WORDS[2,-1]}"; do case $arg in (-X) filter='^!';; (-x) filter='^[?!]';; (--) break;; esac done typeset prefix="${TARGETWORD%"${TARGETWORD##*/}"}" command -f completion/git::completeuntrackedpath "$filter" \ --ignore-submodules=all --ignored --untracked-files=all } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-rebase0000644000175000017500000000470712154557026017776 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "git-rebase" command. # Supports Git 1.8.1.4. function completion/git-rebase { WORDS=(git rebase "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::rebase:arg { OPTIONS=() command -f completion/git::rebase:getopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeref ;; (*) command -f completion/git::rebase:compopt ;; esac } function completion/git::rebase:getopt { OPTIONS=("$OPTIONS" #># "--abort; abort the current rebasing and reset to the original" "--autosquash; find commits to be squashed (with -i)" "--committer-date-is-author-date; use author date for committer date" "--continue; continue the current rebasing" "--edit-todo; re-edit the to-do list of the current rebasing" "f --force-rebase; rebase even if the branch is up-to-date" "--ignore-date; use committer date for author date" "i --interactive; interactively reedit commits that are rebased" "--keep-empty; don't omit commits that make no change" "m --merge; use merging strategies to rebase" "--no-autosquash; cancel the --autosquash option" "--no-ff; don't fast-forward even if possible" "n --no-stat; don't print a diffstat" "--no-verify; don't run the pre-rebase hook" "--onto; specify a branch to rebase onto" "p --preserve-merges; don't ignore merge commits" "q --quiet; don't print anything" "--root; rebase all ancestor commits" "--skip; skip the current patch and continue rebasing" "--stat; print a diffstat from the last rebase" "s: --strategy:; specify the merge strategy" "x: --exec:; insert an \"exec\" line with the specified command after each commit (with -i)" "X: --strategy-option:; specify a strategy-specific option" "v --verbose" # TODO description "--verify; run the pre-rebase hook" ) #<# if command -vf completion/git::apply:getopt >/dev/null 2>&1 || . -AL completion/git-apply; then command -f completion/git::apply:getopt rebase fi } function completion/git::rebase:compopt case $ARGOPT in (*) if command -vf completion/git::apply:compopt >/dev/null 2>&1 || . -AL completion/git-apply; then command -f completion/git::apply:compopt fi if command -vf completion/git::merge:compopt >/dev/null 2>&1 || . -AL completion/git-merge; then command -f completion/git::merge:compopt fi ;; esac # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/tr0000644000175000017500000000462012154557026016373 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "tr" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/tr { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "C; complement the set of characters in the first operand" "c ${long:+--complement}; complement the set of bytes in the first operand" "d ${long:+--delete}; delete characters in the first operand" "s ${long:+--squeeze-repeats}; squeeze repeated characters in the last operand into one" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "t --truncate-set1; truncate the first operand to the length of the last operand" "--help" "--version" ) #<# ;; (FreeBSD|Darwin) OPTIONS=("$OPTIONS" #># "u; disable output buffering" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "A; don't handle multibyte characters" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (*) command -f completion/tr::class || if command -vf completion/printf::backslash >/dev/null 2>&1 || . -AL completion/printf; then command -f completion/printf::backslash tr fi ;; esac } function completion/tr::class { typeset word="$TARGETWORD" case $word in (*\[:*) PREFIX=${TARGETWORD%\[:*} #>># complete -T -P "$PREFIX" -D "alpha + digit" '[:alnum:]' complete -T -P "$PREFIX" -D "letters" '[:alpha:]' complete -T -P "$PREFIX" -D "space and tab" '[:blank:]' complete -T -P "$PREFIX" -D "control characters" '[:cntrl:]' complete -T -P "$PREFIX" -D "digits" '[:digit:]' complete -T -P "$PREFIX" -D "printable characters, not including space" '[:graph:]' complete -T -P "$PREFIX" -D "lowercase letters" '[:lower:]' complete -T -P "$PREFIX" -D "printable characters, including space" '[:print:]' complete -T -P "$PREFIX" -D "punctuations, not including space" '[:punct:]' complete -T -P "$PREFIX" -D "whitespaces, including blank and newline" '[:space:]' complete -T -P "$PREFIX" -D "uppercase letters" '[:upper:]' complete -T -P "$PREFIX" -D "hexadecimal digits" '[:xdigit:]' #<<# return 0 esac return 1 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-blame0000644000175000017500000000411512154557026017606 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-blame" command. # Supports Git 1.7.7. function completion/git-blame { WORDS=(git blame "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::blame:arg { OPTIONS=() command -f completion/git::blame:getopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completerefpath range=true ;; (*) command -f completion/git::blame:compopt ;; esac } function completion/git::blame:getopt { OPTIONS=("$OPTIONS" #># "--abbrev::; specify the number of commit ID digits to print" "b; show blank SHA-1 for boundary commits" "C::; detect moves and copies within a commit" "c; print in the \"git annotate\" format" "--contents:; specify a file to annotate" "--date:; specify a date format" "--encoding:; specify the encoding for commit metadata" "h; print help" "--incremental; print in a machine-friendly format" "L:; specify a line range to annotate" "l; show full commit IDs" "M::; detect moves and copies within a file" "p --porcelain; print in a machine-friendly format" "--line-porcelain; like --porcelain, but print commit info for all lines" "--reverse; search history forward instead of backward" "--root; don't treat root commits as boundary commits" "S:; specify a file containing revisions to search" "s; don't print author names and timestamps" "--score-debug; include debugging info" "e --show-email; print author emails instead of author names" "f --show-name; always print the filename" "n --show-number; print line numbers" "--show-stats; show additional stats at the end of output" "t; show times in the raw value format" "w; ignore whitespaces in comparison" ) #<# } function completion/git::blame:compopt { case $ARGOPT in # ([CLM]|--abbrev) # ;; (S|--contents) complete -P "$PREFIX" -f ;; (--*) command -vf "completion/git::$ARGOPT:arg" >/dev/null 2>&1 && command -f "completion/git::$ARGOPT:arg" ;; (*) return 1 ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/useradd0000644000175000017500000000770012154557026017377 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "useradd" command. # Supports shadow tool suite 4.1.4.2, OpenBSD 4.9, NetBSD 5.0, SunOS 5.11, # HP-UX 11i v3. function completion/useradd { typeset type="$(uname 2>/dev/null)" case $type in (Linux) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "b: ${long:+--base-dir:}; specify the directory the home directory is created in" "c: ${long:+--comment:}; specify a comment (typically the user's full name)" "d: ${long:+--home:}; specify the home directory" "D ${long:+--defaults}; print or show the default settings" "e: ${long:+--expiredate:}; specify the date the account expires on" "f: ${long:+--inactive:}; specify the date the password expires on" "G: ${long:+--groups:}; specify supplementary groups" "g: ${long:+--group:}; specify the group" "k: ${long:+--skel:}; specify the skeleton directory" "m ${long:+--create-home}; create the home directory" "o ${long:+--non-unique}; allow assigning one user ID to more than one user name" "s: ${long:+--shell:}; specify the login shell" "u: ${long:+--uid:}; specify the user ID number" ) #<# case $type in (Linux|SunOS) OPTIONS=("$OPTIONS" #># "K: ${long:+--key:}; specify an option to override the default" ) #<# ;; esac case $type in (SunOS) OPTIONS=("$OPTIONS" #># "p:; specify a project" ) #<# ;; (*) OPTIONS=("$OPTIONS" #># "p: ${long:+--password:}; specify the encrypted password" ) #<# ;; esac case $type in (Linux) OPTIONS=("$OPTIONS" #># "h --help; print help" "l --no-log-init; don't add the user to the lastlog and faillog databases" "M; don't create the home directory" "N --no-user-group; don't create the user's own group" "r --system; create a system account" "U --user-group; create the user's own group" "Z: --selinux-user:; specify the SELinux user" ) #<# ;; (*BSD) OPTIONS=("$OPTIONS" #># "L:; specify the login class" "v; print operations that are executed" ) #<# case $type in (OpenBSD) OPTIONS=("$OPTIONS" #># "r:; specify the integer range from which the new user ID is chosen" ) #<# ;; (NetBSD) OPTIONS=("$OPTIONS" #># "F; force the user to change the password on next login" "M:; specify the permission of the home directory" "S; allow samba user names with a trailing dollar sign to be added to the system" ) #<# ;; esac ;; (SunOS) OPTIONS=("$OPTIONS" #># "A:; specify authorizations" "P:; specify execution profiles" "R:; specify execution roles" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "i; inherit the existing home directory" "O:; specify if the -o option is enabled by default" "r:; specify if the existing home directory's permission is reset" "S:; specify the alternate password file of NIS" "t:; specify the template file containing default settings" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([bdk]|--base-dir|--home|--skel) complete -T -P "$PREFIX" -S / -d ;; (A) # TODO ;; # (c|--comment) # ;; (e|--expiredate) #TODO (f|--inactive) #TODO ;; (G|--groups) PREFIX="${TARGETWORD%"${${TARGETWORD#"$PREFIX"}##*,}"}" complete -T -P "$PREFIX" -S , -g ;; (g|--group) complete -P "$PREFIX" -g ;; (K|--key) # TODO ;; (L) # TODO ;; # (M) # ;; (O) complete -P "$PREFIX" -D "yes" yes complete -P "$PREFIX" -D "no" yes ;; (P) # TODO ;; (p) # TODO ;; (R) # TODO ;; (r) case $type in (HP-UX) complete -P "$PREFIX" -D "yes" yes complete -P "$PREFIX" -D "no" yes ;; esac ;; (S) # TODO ;; (s|--shell) complete -P "$PREFIX" -- $(sed -e 's/#.*//' /etc/shells 2>/dev/null) || { complete -T -P "$PREFIX" -S / -d complete -P "$PREFIX" --executable-file } ;; (t) complete -P "$PREFIX" -f ;; # (u|--uid) # ;; (Z|--selinux-user) # TODO ;; ('') complete -u ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-status0000644000175000017500000000167312154557026020057 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-status" command. # Supports Git 1.7.7. function completion/git-status { WORDS=(git status "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::status:arg { OPTIONS=( #># "b --branch; print the current branch" "--ignored; print ignored files as well" "--ignore-submodules::; ignore changes to submodules" "--porcelain; print in the machine-friendly format" "s --short; print in the short format" "u:: --untracked-files::; print untracked files" "z; print a null byte after each filename" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--ignore-submodules) command -f completion/git::--ignore-submodules:arg ;; (u|--untracked-files) command -f completion/git::--untracked-files:arg ;; ('') complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/date0000644000175000017500000002270112154557026016663 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "date" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/date { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "u ${long:+--utc --universal}; use Coordinated Universal Time (UTC)" ) #<# ADDOPTIONS=() case $type in (*BSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "j; don't change the system time" "n; change the system time on the current host only" "r:; specify seconds since the epoch to print" ) #<# case $type in (OpenBSD|NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "a; gradually change the system time using the adjtime syscall" ) #<# esac case $type in (OpenBSD|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "d:; specify the new daylight saving time" "t:; specify the new difference from UTC in minutes" ) #<# case $type in (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "f:; specify the format of the operand parsed" "v:; specify adjustment for the date and time to print" ) #<# esac esac esac case $type in (GNU|NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "d: ${long:+--date:}; specify a date and time to print instead of now" ) #<# esac case $type in (SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "a:; specify adjustment for the system clock" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "f: --file:; specify a file containing date/time data to print" "R --rfc-2822; print in the RFC 2822 format" "r: --reference:; specify a file whose last modified time is printed" "--rfc-3339:; specify the type of the RFC 3339 format to print in" "s: --set:; specify a date and time to set the system time to" "--help" "--version" ) #<# esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (f|--file|r|--reference) case $type in (GNU) complete -P "$PREFIX" -f esac ;; (--rfc-3339) #>># complete -P "$PREFIX" -D "e.g. 1999-12-31" date complete -P "$PREFIX" -D "e.g. 1999-12-31 13:45:56+05:30" seconds complete -P "$PREFIX" -D "e.g. 1999-12-31 13:45:56.123456789+05:30" ns ;; #<<# (v) typeset word="${TARGETWORD#"$PREFIX"}" word=${word#[+-]} case $word in ([[:digit:]]*) while [ "${word#[[:digit:]]}" != "$word" ]; do word=${word#[[:digit:]]} done PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" -D "year" y complete -P "$PREFIX" -D "month" m complete -P "$PREFIX" -D "day of week" w complete -P "$PREFIX" -D "day of month" d complete -P "$PREFIX" -D "hour" H complete -P "$PREFIX" -D "minute" M complete -P "$PREFIX" -D "second" S ;; #<<# (*) PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" -D "Sunday" Sunday complete -P "$PREFIX" -D "Monday" Monday complete -P "$PREFIX" -D "Tuesday" Tuesday complete -P "$PREFIX" -D "Wednesday" Wednesday complete -P "$PREFIX" -D "Thursday" Thursday complete -P "$PREFIX" -D "Friday" Friday complete -P "$PREFIX" -D "Saturday" Saturday complete -P "$PREFIX" -D "January" January complete -P "$PREFIX" -D "February" February complete -P "$PREFIX" -D "March" March complete -P "$PREFIX" -D "April" April complete -P "$PREFIX" -D "May" May complete -P "$PREFIX" -D "June" June complete -P "$PREFIX" -D "July" July complete -P "$PREFIX" -D "August" August complete -P "$PREFIX" -D "September" September complete -P "$PREFIX" -D "October" October complete -P "$PREFIX" -D "November" November complete -P "$PREFIX" -D "December" December ;; #<<# esac ;; (?|--?*) ;; (*) command -f completion//completestrftime ;; esac } function completion//completestrftime { typeset word="$TARGETWORD" word=${word#"$PREFIX"} word=${word//%%} case $word in (*%|*%[EO:]|*%::|*%:::) word=%${word##*%} PREFIX=${TARGETWORD%"$word"} #>># complete -T -P "$PREFIX" -D "day of week, full, localized" '%A' complete -T -P "$PREFIX" -D "day of week, short, localized" '%a' complete -T -P "$PREFIX" -D "month, full, localized" '%B' complete -T -P "$PREFIX" -D "month, short, localized" '%b' complete -T -P "$PREFIX" -D "century in numeral" '%C' complete -T -P "$PREFIX" -D "date and time, localized" '%c' complete -T -P "$PREFIX" -D "like %m/%d/%y (e.g. 12/31/99)" '%D' complete -T -P "$PREFIX" -D "day of month [01-31]" '%d' complete -T -P "$PREFIX" -D "day of month [ 1-31] (space-padded)" '%e' complete -T -P "$PREFIX" -D "hour [00-23]" '%H' complete -T -P "$PREFIX" -D "hour [01-12]" '%I' complete -T -P "$PREFIX" -D "day of year [001-366]" '%j' complete -T -P "$PREFIX" -D "minute [00-59]" '%M' complete -T -P "$PREFIX" -D "month [01-12]" '%m' complete -T -P "$PREFIX" -D "newline" '%n' complete -T -P "$PREFIX" -D "AM or PM, localized" '%p' complete -T -P "$PREFIX" -D "12-hour clock time with AM/PM, localized" '%r' complete -T -P "$PREFIX" -D "second [00-60]" '%S' complete -T -P "$PREFIX" -D "like %H:%M:%S (e.g. 13:45:56)" '%T' complete -T -P "$PREFIX" -D "tab" '%t' complete -T -P "$PREFIX" -D "week of year [00-53] (first Sunday in week 1)" '%U' complete -T -P "$PREFIX" -D "day of week in numeral [1-7]" '%u' complete -T -P "$PREFIX" -D "week of year [01-53] (first Monday in week 1 or 2)" '%V' complete -T -P "$PREFIX" -D "week of year [00-53] (first Monday in week 1)" '%W' complete -T -P "$PREFIX" -D "day of week in numeral [0-6]" '%w' complete -T -P "$PREFIX" -D "time, localized" '%X' complete -T -P "$PREFIX" -D "date, localized" '%x' complete -T -P "$PREFIX" -D "year, full (e.g. 1999)" '%Y' complete -T -P "$PREFIX" -D "year within century [00-99]" '%y' complete -T -P "$PREFIX" -D "timezone name" '%Z' complete -T -P "$PREFIX" -D "name of era, localized, alternative format" '%EC' complete -T -P "$PREFIX" -D "date and time, localized, alternative format" '%Ec' complete -T -P "$PREFIX" -D "time, localized, alternative format" '%EX' complete -T -P "$PREFIX" -D "date, localized, alternative format" '%Ex' complete -T -P "$PREFIX" -D "year, full, alternative format" '%EY' complete -T -P "$PREFIX" -D "year within era in numeral, alternative format" '%Ey' complete -T -P "$PREFIX" -D "day of month in localized alternative numeral" '%Od' complete -T -P "$PREFIX" -D "hour in localized alternative numeral, 24-hour clock" '%OH' complete -T -P "$PREFIX" -D "hour in localized alternative numeral, 12-hour clock" '%OI' complete -T -P "$PREFIX" -D "minute in localized alternative numeral" '%OM' complete -T -P "$PREFIX" -D "month in localized alternative numeral" '%Om' complete -T -P "$PREFIX" -D "second in localized alternative numeral" '%OS' complete -T -P "$PREFIX" -D "week of year in localized alternative numeral" '%OU' complete -T -P "$PREFIX" -D "day of week in localized alternative numeral for 1-7" '%Ou' complete -T -P "$PREFIX" -D "week of year in localized alternative numeral" '%OV' complete -T -P "$PREFIX" -D "week of year in localized alternative numeral" '%OW' complete -T -P "$PREFIX" -D "day of week in localized alternative numeral for 0-6" '%Ow' complete -T -P "$PREFIX" -D "year within century in localized alternative numeral" '%Oy' complete -T -P "$PREFIX" -D "%" '%%' #<<# case $type in (GNU|*BSD|Darwin|SunOS|HP-UX) #>># complete -T -P "$PREFIX" -D "like %H:%M (e.g. 13:45)" '%R' esac #<<# case $type in (GNU|*BSD|Darwin|SunOS) #>># complete -T -P "$PREFIX" -D "like %Y-%m-%d (e.g. 1999-12-31)" '%F' complete -T -P "$PREFIX" -D "year within century corresponding to %V [00-99]" '%g' complete -T -P "$PREFIX" -D "year corresponding to %V, full (e.g. 1999)" '%G' complete -T -P "$PREFIX" -D "hour [ 0-23] (space-padded)" '%k' complete -T -P "$PREFIX" -D "hour [ 1-12] (space-padded)" '%l' complete -T -P "$PREFIX" -D "RFC 2822 style numeric timezone (e.g. +0530)" '%z' esac #<<# case $type in (GNU|*BSD|Darwin) #>># complete -T -P "$PREFIX" -D "seconds since epoch in numeral" '%s' esac #<<# case $type in (*BSD|Darwin) #>># complete -T -P "$PREFIX" -D "like %e-%b-%Y" '%v' complete -T -P "$PREFIX" -D "the default localized format" '%+' esac case $type in (GNU|SunOS) #>># complete -T -P "$PREFIX" -D "year within century corresponding to %V in localized alternative numeral" '%Og' esac #<<# case $type in (GNU) #>># complete -T -P "$PREFIX" -D "nanosecond within second [000000000-999999999]" '%N' complete -T -P "$PREFIX" -D "AM or PM, localized, lower case" '%P' complete -T -P "$PREFIX" -D "RFC 2822 style numeric timezone (e.g. +05:30)" '%:z' complete -T -P "$PREFIX" -D "RFC 2822 style numeric timezone (e.g. +05:30:00)" '%::z' complete -T -P "$PREFIX" -D "RFC 2822 style numeric timezone with minimal colons" '%:::z' ;; #<<# (SunOS) #>># complete -T -P "$PREFIX" -D "year corresponding to %V, full, alternative format" '%EG' complete -T -P "$PREFIX" -D "year within era corresponding to %V, in numeral, alternative format" '%Eg' ;; #<<# (HP-UX) #>># complete -T -P "$PREFIX" -D "name of era" '%N' complete -T -P "$PREFIX" -D "year within era" '%o' ;; #<<# esac esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/mksh0000644000175000017500000000026212154557026016706 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "mksh" command. function completion/mksh { command -f completion//reexecute sh } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/patch0000644000175000017500000001115212154557026017043 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "patch" command. # Supports POSIX 2008, GNU patch 2.6.1, SunOS 5.10, HP-UX 11i v3. function completion/patch { if "${WORDS[1]}" --version >/dev/null 2>&1; then typeset type=GNU else typeset type="$(uname 2>/dev/null)" fi case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "b ${long:+--backup}; back up files before patching" "c ${long:+--context}; assume copied context format" "D: ${long:+--ifdef:}; output in merged #ifdef format with the specified conditional macro name" "d: ${long:+--directory:}; specify a directory to work in" "e ${long:+--ed}; assume ed script format" "i: ${long:+--input:}; specify the patch file" "l ${long:+--ignore-whitespace}; tolerate whitespace mismatches" "N ${long:+--forward}; ignore patches that seem reversed or already applied" "n ${long:+--normal}; assume normal diff format" "o: ${long:+--output:}; specify the result file name" "p: ${long:+--strip:}; specify the number of pathname components to strip from file names" "R ${long:+--reverse}; patch in reverse" "r: ${long:+-reject-file:}; specify the reject file name" "u ${long:+--unified}; assume unified context format" ) #<# ADDOPTIONS=() case $type in (GNU|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "F: ${long:+--fuzz:}; specify the number of lines in context that may mismatch" "f ${long:+--force}; don't ask anything to the user" "s ${long:+--silent --quiet}; suppress informative messages" "v ${long:+--version}; print version info" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "--backup-if-mismatch; back up a file if the patch doesn't match the file exactly" "--no-backup-if-mismatch; don't back up a file even if the patch doesn't match the file exactly" "B: --prefix:; specify a backup file pathname prefix" "--binary; don't convert CR-LF into LF" "--dry-run; don't modify files actually but print messages as usual" "E --remove-empty-files; remove empty result files" "g: --get:; specify what to do when a file is missing or read-only" "--merge::; leave conflicts in the result file like diff3 and merge" "--posix; disable non-POSIX extensions" "--quoting-style:; specify the quoting style for output names" "--reject-format:; specify the reject file format" "T --set-time; set the time stamp of result files using local time" "t --batch; don't ask anything to the user" "V: --version-control:; specify how to make a backup" "--verbose; print extra informative messages" "Y: --basename-prefix:; make backups in subdirectories with the specified name" "Z --set-utc; set the time stamp of result files using UTC" "z: --suffix:; make backups in the same directory with the specified suffix" "--help" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "S; ignore this patch and process the next patch" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS case $type in (HP-UX) typeset i="${WORDS[#]}" while [ $i -gt 1 ]; do if [ "${WORDS[i]}" = "+" ]; then WORDS=("${WORDS[1]}" "${WORDS[i+1,-1]}") break fi i=$((i-1)) done esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (D|--ifdef) if [ -r tags ]; then complete -P "$PREFIX" -R "!_TAG_*" -- \ $(cut -f 1 tags 2>/dev/null) fi ;; (d|--directory) complete -T -P "$PREFIX" -S / -d ;; (g|--get) #>># complete -P "$PREFIX" -D "check out the missing file" 1 complete -P "$PREFIX" -D "do nothing" 0 complete -P "$PREFIX" -D "ask whether to check out the file" -- -1 ;; #<<# (--merge) #>># complete -P "$PREFIX" -D "contains original lines from the patch" diff3 complete -P "$PREFIX" -D "doesn't contain original lines from the patch" merge ;; #<<# (--quoting-style) #>># complete -P "$PREFIX" -D "no quotation" literal complete -P "$PREFIX" -D "quotation suitable for the shell" shell complete -P "$PREFIX" -D "always quote in the shell style" shell-always complete -P "$PREFIX" -D "C string literal" c complete -P "$PREFIX" -D "C string literal without surrounding double-quotes" escape ;; #<<# (--reject-format) #>># complete -P "$PREFIX" -D "copied context format" context complete -P "$PREFIX" -D "unified context format" unified ;; #<<# (V|--version-control) if command -vf completion//completebackup >/dev/null 2>&1 || . -AL completion/_backup; then command -f completion//completebackup fi ;; ([Fp]|--fuzz|--strip) ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/more0000644000175000017500000000336712154557026016717 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "more" command. # Supports POSIX 2008, SunOS 5.10, HP-UX 11i v3. # (We don't support the util-linux-ng version because it's far from POSIX- # compliance.) function completion/more { case $("${WORDS[1]}" --version 2>/dev/null) in (*'less'*) command -f completion//reexecute less return ;; esac typeset type="$(uname 2>/dev/null)" typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c; don't scroll the screen" "e; exit immediately after printing the last line of the last file" "i; case-insensitive search" "n:; specify the number of lines in the screen" "p:; specify a command executed after loading each file" "s; squeeze adjacent empty lines into one" "t:; specify an identifier to jump" "u; disable special treatment of backspace" ) #<# case $type in (SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "d; display more user-friendly prompt" "f; don't wrap long lines" ) #<# esac case $type in (SunOS) OPTIONS=("$OPTIONS" #># "l; don't pause at form feeds" "w; don't exit immediately after printing the last line of the file" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "v; don't print unprintable characters like ^I or M-C" "W:; specify an additional option" "x:; specify the width of a tab" "z; print backspace, tab, line feed as ^H, ^I, ^M" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (t) if [ -r tags ]; then complete -P "$PREFIX" -R "!_TAG_*" -- \ $(cut -f 1 tags 2>/dev/null) fi ;; (W) #>># complete -P "$PREFIX" -D "don't initialize the screen" notite complete -P "$PREFIX" -D "initialize the screen" tite ;; #<<# ('') complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/sudo0000644000175000017500000000530612154557026016722 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "sudo" command. # Supports sudo 1.8.0. function completion/sudo { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "A; use a GUI program for password prompt" "a:; specify the authentication method" "b; run in the background" "C:; specify the file descriptor to be closed" "c:; specify the login class" "D:; specify the debugging level" "E; preserve environment variables" "e; edit operand files" "g:; specify the group to run the command as" "H; set \$HOME to target user's home directory" "h; print help" "i; run the command as a login shell" "K; remove cached credentials entirely" "k; remove cached credentials or don't cache credentials" "l; list commands allowed for the user" "n; never prompt for the password" "P; preserve supplementary group IDs" "p:; specify the prompt string" "r:; specify the new security context's role" "S; read the password from the standard input rather than the terminal" "s; run \$SHELL" "t:; specify the new security context's type" "U:; specify the user to change from (with -l)" "u:; specify the user to change to" "V; print version info" "v; cache credentials without running a command" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (a) if command -vf completion//bsd::completeauthmethod >/dev/null 2>&1 || . -AL completion/_bsd; then command -f completion//bsd::completeauthmethod fi ;; ([CD]) ;; (c) if command -vf completion//bsd::completeauthclass >/dev/null 2>&1 || . -AL completion/_bsd; then command -f completion//bsd::completeauthclass fi ;; (g) complete -P "$PREFIX" -g ;; (p) command -f completion/sudo::prompt ;; (r) #TODO security context's role ;; (t) #TODO security context's type ;; ([Uu]) complete -P "$PREFIX" -u ;; ('') typeset i=2 edit=false while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--) break;; (-e) edit=true;; esac i=$((i+1)) done if $edit; then complete -P "$PREFIX" -f else command -f completion//getoperands command -f completion//reexecute fi ;; esac } function completion/sudo::prompt { typeset word="$TARGETWORD" word=${word//%%} case $word in (*%) PREFIX=${TARGETWORD%\%} #>># complete -T -P "$PREFIX" -D "fully qualified domain name" '%H' complete -T -P "$PREFIX" -D "host name" '%h' complete -T -P "$PREFIX" -D "name of the user whose password is requested" '%p' complete -T -P "$PREFIX" -D "name of the user to run the command as" '%U' complete -T -P "$PREFIX" -D "name of the user invoking sudo" '%u' complete -T -P "$PREFIX" -D "%" '%%' return 0 #<<# esac return 1 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/comm0000644000175000017500000000267512154557026016711 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "comm" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/comm { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "1; don't print column of lines unique to file 1" "2; don't print column of lines unique to file 2" "3; don't print column of lines common to both files" ) #<# ADDOPTIONS=() case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "--check-order; check if files are correctly sorted" "--nocheck-order; don't check if files are correctly sorted" "--output-delimiter:; specify a delimiter to separate columns" "--help" "--version" ) #<# ;; (OpenBSD|NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "f; case-insensitive comparison" ) #<# ;; (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "i; case-insensitive comparison" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--output-delimiter) ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/nawk0000644000175000017500000000026312154557026016705 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "nawk" command. function completion/nawk { command -f completion//reexecute awk } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gitk0000644000175000017500000000034712154557026016706 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "gitk" command. # Supports Git 1.7.7. function completion/gitk { WORDS=(git rev-list "${WORDS[2,-1]}") command -f completion//reexecute } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/MEMO0000644000175000017500000000147612154557026016511 0ustar magicantmagicantmake POSIX GNU FreeBSD OpenBSD NetBSD SunOS HP-UX -B x -B x x x -B x -b i x -C... x x x -D... x x -D x -d x x -d... x x x -d x -E... x -e x x x x x x x -f... x x x x x x x -h x -I... x x x x -i x x x x x x x -j... x x x x -K... x -k x x x x x x x -L x -l[.] x -m i -m... x x x -N x -n x x x x x x x -o... x -P x -P x -P x -p x x x x x x -Q x -q x x x x x x x -R x -r x x x x x x x -S x x x x x x -s x x x x x x x -T... x -t x x x x x x -u x x -V... x x x -V x -v x -v x -W... x -W x -w x x -w x -X x -X x -x... x -x x GNU Make 3.82 FreeBSD 9.0 OpenBSD 5.0 NetBSD 3.0 MacOSX -> GNU Solaris 11.1 HP-UX 11i v3 yash-2.35/share/completion/INIT0000644000175000017500000004336712154557026016524 0ustar magicantmagicant# (C) 2010-2012 magicant # This file is autoloaded when completion is first performed by the shell. # This file contains utility functions that are commonly used by many # completion functions. # This is the function that is called when completing a command argument. if ! command -vf completion//argument >/dev/null 2>&1; then function completion//argument { command -f completion//reexecute -f } fi # This function parses array $WORDS and variable $TARGETWORD according to array # $OPTIONS and modifies $WORDS so that the caller can easily parse $WORDS. # # $WORDS is an array containing command line words that have been already # entered by the user before the word being completed. The first word of $WORDS # is considered the command name and ignored. The other words are considered # arguments to the command and parsed. # # $TARGETWORD is a variable containing the word being completed. # # $OPTIONS is an array containing data about parsed options. The value of each # element must follow the following syntax. # element := optionlist # | optionlist ";" description # optionlist := option # | optionlist " " option # option := optionvalue # | optionvalue ":" # | optionvalue "::" # optionvalue := character # | "-" characters # An element value consists of an option list that is possibly followed by a # description of the options. The option list and the description is separated # by a semicolon and the description may contain any characters. # The option list consists of any number of options separated by whitespaces. # An option is an option value possibly followed by one or two colons. # An option that takes no, mandatory, and optional argument should be specified # with zero, one, and two colons, respectively. # The option value may be either a single character or a character string # preceded by one or more hyphens. Note that a single-character option must be # specified without a hyphen though it is preceded by a hyphen on the command # line. Also note that multiple single-character options can be combined # together after one hyphen on the command line. Long options, on the other # hand, must be specified including their preceding hyphen(s). # # The following options can be specified to this function: # -e Without -e, options are parsed only before the first operand word in # $WORDS. Words after the first operand word are all considered operands. # With -e, options are parsed for any words in $WORDS (except after # "--"). Options and operands can be intermixed. # -n Without -n, array $WORDS is updated to reflect the parse result. # Multiple single-character options after one hyphen are separated and # separate option arguments are combined with the options so that the # option and its argument are in the same command line word. When -s is # specified or -e is not specified, options and operands in $WORDS are # separated by "--". # With -n, $WORDS is left intact. # -s Only meaningful when with -e and without -n. # Without -s, words in $WORDS are not reordered. # With -s, words in $WORDS are reordered so that all options come # before operands. # # After words in $WORDS are parsed, $TARGETWORD is parsed as well and it is # determined how $TARGETWORD should be completed. The results are returned as # two variables $ARGOPT and $PREFIX. # If $TARGETWORD is an operand to the command, $ARGOPT and $PREFIX are empty # strings. If $TARGETWORD is one or more single-character option, $ARGOPT is # "-" and $PREFIX is $TARGETWORD. If $TARGETWORD is a long option or "-", # $ARGOPT is "-" and $PREFIX is an empty string. If $TARGETWORD is an option # followed by an argument to that option or a separate option argument (in # which case $TARGETWORD should be completed as an option argument), $ARGOPT # is the name of that option (as specified by "optionvalue" in the syntax # above) and $PREFIX is the part of $TARGETWORD that is not the argument. # # Note: # Single-hyphened long options cannot be abbreviated. # Optional option arguments are not supported for single-hyphened long options. # Ambiguous options, invalid options, etc. are silently ignored. function completion//parseoptions { # parse options to this function itself typeset opt= OPTIND=1 typeset extension=false update=true sort=false while getopts :ens opt; do case $opt in (e) extension=true;; (n) update=false;; (s) sort=true;; esac done if [ "${WORDS+set}" != "set" ] || [ ${WORDS[#]} -le 0 ] || [ "${OPTIONS+set}" != "set" ] || [ "${TARGETWORD+set}" != "set" ]; then return 1 fi # results typeset result options operands result=() options=() operands=() # parse $WORDS typeset index=1 nomoreoptions=false typeset matches ARGOPT= PREFIX= while index=$((index+1)); [ $index -le ${WORDS[#]} ]; do typeset word="${WORDS[index]}" case $word in (--) result=("$result" "${WORDS[index,-1]}") operands=("$operands" "${WORDS[index+1,-1]}") nomoreoptions=true break ;; (--?*=*) # double-hyphened long option with argument matches=() for opt in ${OPTIONS%%;*}; do case ${${opt%:}%:} in ("${word%%=*}") matches=("$opt") break ;; ("${word%%=*}"*) matches=("$matches" "$opt") ;; esac done if [ ${matches[#]} -eq 1 ]; then opt=${matches[1]} case $opt in (*:) # option argument allowed opt=${${opt%:}%:} word=${word#*=} result=("$result" "$opt=$word") options=("$options" "$opt=$word") esac fi ;; (--?*) # double-hyphened long option without argument matches=() for opt in ${OPTIONS%%;*}; do case ${${opt%:}%:} in ("$word") matches=("$opt") break ;; ("$word"*) matches=("$matches" "$opt") ;; esac done if [ ${matches[#]} -eq 1 ]; then opt=${matches[1]} case $opt in (*[!:]:) # option argument required if [ $index -eq ${WORDS[#]} ]; then # $TARGETWORD is argument ARGOPT=${opt%:} # PREFIX= break else index=$((index+1)) # ${WORDS[index]} is argument result=("$result" "${opt%:}=${WORDS[index]}") options=("$options" "${opt%:}=${WORDS[index]}") fi ;; (*) # no option argument result=("$result" "${opt%::}") options=("$options" "${opt%::}") ;; esac fi ;; (-?*) # single-hyphened option # first check for single-hyphened long option for opt in ${OPTIONS%%;*}; do case ${${opt%:}%:} in ("${word%%=*}") case $opt in (*::) # optional argument not supported ;; (*:) # requires option argument case $word in (*=*) result=("$result" "$word") options=("$options" "$word") ;; (*) # argument is next word if [ $index -eq ${WORDS[#]} ]; then # $TARGETWORD is argument ARGOPT=${opt%:} # PREFIX= break 2 else index=$((index+1)) # ${WORDS[index]} is argument result=("$result" "${opt%:}=${WORDS[index]}") options=("$options" "${opt%:}=${WORDS[index]}") fi ;; esac ;; (*) # no option argument case $word in (*=*) # Bad! ;; (*) # OK! result=("$result" "$opt") options=("$options" "$opt") ;; esac ;; esac continue 2 esac done # Next, check for single-character options while word=${word#?}; [ "$word" ]; do for opt in ${OPTIONS%%;*}; do case $opt in ("${word[1]}") # no option argument result=("$result" "-$opt") options=("$options" "-$opt") ;; ("${word[1]}":) # requires option argument if [ "${word#?}" ]; then # rest of $word is argument result=("$result" "-$word") options=("$options" "-$word") elif [ $index -eq ${WORDS[#]} ]; then # $TARGETWORD is argument ARGOPT=${opt%:} # PREFIX break 3 else index=$((index+1)) # ${WORDS[index]} is argument result=("$result" "-${opt%:}${WORDS[index]}") options=("$options" "-${opt%:}${WORDS[index]}") fi break 2 ;; ("${word[1]}"::) # optional option argument result=("$result" "-$word") options=("$options" "-$word") break 2 ;; esac done done ;; (*) # operand if $extension; then result=("$result" "$word") operands=("$operands" "$word") else result=("$result" "${WORDS[index,-1]}") operands=("$operands" "${WORDS[index,-1]}") nomoreoptions=true break fi ;; esac done # determine if $TARGETWORD should be completed as an option if ! $nomoreoptions && [ -z "$ARGOPT" ]; then case $TARGETWORD in (--*=*) matches=() for opt in ${OPTIONS%%;*}; do case ${${opt%:}%:} in ("${TARGETWORD%%=*}") matches=("$opt") break ;; ("${TARGETWORD%%=*}"*) matches=("$matches" "$opt") ;; esac done if [ ${matches[#]} -eq 1 ]; then opt=${matches[1]} case $opt in (*:) # option argument allowed ARGOPT=${${opt%:}%:} PREFIX=${TARGETWORD%%=*}= esac fi ;; (-|--*) ARGOPT=- # PREFIX= ;; (-*) ARGOPT=- # PREFIX= # first check for single-hyphened long option typeset long=false for opt in ${OPTIONS%%;*}; do case ${opt%:} in ("${TARGETWORD%%=*}"*) long=true case $TARGETWORD in (*=*) if [ "${TARGETWORD%%=*}" = "${opt%:}" ]; then ARGOPT=${opt%:} PREFIX=${TARGETWORD%%=*}= break fi esac esac done # Next, check for single-character options if ! $long; then typeset word="$TARGETWORD" while word=${word#?}; [ "$word" ]; do for opt in ${OPTIONS%%;*}; do case $opt in ("${word[1]}") result=("$result" "-$opt") options=("$options" "-$opt") ;; ("${word[1]}":|"${word[1]}"::) ARGOPT=${${opt%:}%:} PREFIX=${TARGETWORD%${word#?}} break 2 ;; esac done done if [ -z "$word" ]; then PREFIX=$TARGETWORD fi fi ;; esac fi # update $WORDS if $update; then if ! $extension || $sort; then WORDS=("${WORDS[1]}" "$options" -- "$operands") else WORDS=("${WORDS[1]}" "$result") fi fi } # This function calls the "complete" built-in to generate candidates to # complete $TARGETWORD as an option. Candidates are generated according to # array $OPTIONS specifying options in the same syntax as the # "completion//parseoptions" function above. If more than one option matches # $TARGETWORD, only the first match is used to generate the candidate. # # This function accepts either of the -s and -S options. With -s, this function # completes single-character options only (in which case $TARGETWORD may have # other single-character options already entered). With -S, $TARGETWORD is # completed as a single option. These options are mutually exclusive. If # specified both, the last specified one is effective. If specified neither, # it defaults to whether $PREFIX is empty or not. # # Normally, a long option that takes an argument is completed with an `=' sign. # But if you specify the -e option, the option is completed with a space like a # normal word. # # The exit status of this function is 0 if at least one candidate was # generated. Otherwise, the exit status is 1. # # If variable $ARGOPT is defined but its value is not "-" or if $TARGETWORD # does not start with a hyphen, this function does nothing but returning the # exit status of 2 unless the -f option is specified. function completion//completeoptions { # check $PREFIX if [ "${PREFIX-}" ]; then typeset single=true else typeset single=false fi # parse options to this function itself typeset opt= OPTIND=1 longargeq=true force=false while getopts :efsS opt; do case $opt in (e) longargeq=;; (f) force=true;; (s) single=true;; (S) single=false;; esac done if ! $force; then if [ "${OPTIONS+set}" != "set" ] || [ "${TARGETWORD+set}" != "set" ] || [ "${ARGOPT--}" != "-" ]; then return 2 fi case $TARGETWORD in (-*) ;; (*) return 2 ;; esac fi # generate candidates typeset opts desc typeset generated=false for opts in "$OPTIONS"; do # get description case $opts in (*\;*) desc=${opts#*;} while true; do # trim surrounding spaces case $desc in ([[:space:]]*) desc=${desc#[[:space:]]} ;; (*[[:space:]]) desc=${desc%[[:space:]]} ;; (*) break ;; esac done ;; (*) desc= ;; esac if $single; then # generate single-character option for opt in ${opts%%;*}; do case $opt in ([!-]|[!-]:) complete -O -P "$TARGETWORD" ${desc:+-D "$desc"} "${opt%:}" && generated=true break ;; ([!-]::) complete -OT -P "$TARGETWORD" ${desc:+-D "$desc"} "${opt%::}" && generated=true break ;; esac done else # generate candidate for first match for opt in ${opts%%;*}; do case $opt in (-*:) # long option that takes argument case ${${opt%:}%:} in ("$TARGETWORD"*) complete ${desc:+-D "$desc"} ${longargeq:+-T -S =} -O -- "${${opt%:}%:}" && generated=true break esac ;; (-*) # long option that does not take argument case $opt in ("$TARGETWORD"*) complete ${desc:+-D "$desc"} -O -- "$opt" && generated=true break esac ;; (?::) # single-char option w/ optional argument if [ "$TARGETWORD" = "-" ]; then complete ${desc:+-D "$desc"} -OT -- "-${opt%::}" && generated=true break fi ;; (?|?:) # other single-char option if [ "$TARGETWORD" = "-" ]; then complete ${desc:+-D "$desc"} -O -- "-${opt%:}" && generated=true break fi ;; esac done fi done # return 0 if at least one candidate was generated $generated } # This function removes one or more elements from the $WORDS array. # When this function is called, the array is supposed to contain the following # elements (in this order): # * a command name word # * any number of options that start with a hyphen # * a "--" separator (optional) # * any number of operands # This function removes any words other than operands. function completion//getoperands { typeset i=2 while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--) i=$((i+1)) break ;; (-?*) i=$((i+1)) ;; (*) break ;; esac done WORDS=("${WORDS[i,-1]}") } # This function re-executes the completion function using the current $WORDS. # If the -e option is specified, only external commands are completed as the # command name. # If the -f option is specified, the following fall-back functions are not used: # * completion//command # * completion//argument # If an operand is given to this function, it is used as the command name # instead of ${WORDS[1]} and the -f option is assumed. # This function does not change $WORDS (but the completion function may do). function completion//reexecute { # parse options typeset opt= OPTIND=1 extonly=false fallback=true while getopts :ef opt; do case $opt in (e) extonly=true;; (f) fallback=false;; esac done # if there's no words, complete the command name if [ ${WORDS[#]} -le 0 ]; then if $fallback && command -vf completion//command >/dev/null 2>&1; then unset opt OPTIND extonly fallback command -f completion//command else complete -P "${PREFIX-}" -T -S / -d case ${TARGETWORD#"${PREFIX-}"} in (*/*) complete -P "${PREFIX-}" --executable-file ;; (*) if $extonly; then complete -P "${PREFIX-}" --external-command else complete -P "${PREFIX-}" -R '*/*' -ck --normal-alias fi ;; esac fi return fi if [ $OPTIND -le $# ]; then set -- "${@[OPTIND]}" fallback=false else set -- "${WORDS[1]}" fi if $fallback && command -vf completion//argument >/dev/null 2>&1; then unset opt OPTIND extonly fallback command -f completion//argument return fi unset opt OPTIND extonly fallback # load the function if not yet loaded, and call the function if command -vf "completion/$1" >/dev/null 2>&1; then command -f "completion/$1" elif command -vf "completion/${1##*/}" >/dev/null 2>&1; then command -f "completion/${1##*/}" elif . -AL "completion/$1" 2>/dev/null command -vf "completion/$1" >/dev/null 2>&1; then command -f "completion/$1" elif command -vf "completion/${1##*/}" >/dev/null 2>&1; then command -f "completion/${1##*/}" elif . -AL "completion/${1##*/}" 2>/dev/null command -vf "completion/$1" >/dev/null 2>&1; then command -f "completion/$1" elif command -vf "completion/${1##*/}" >/dev/null 2>&1; then command -f "completion/${1##*/}" else complete -P "${PREFIX-}" -f fi } # Prints all commands in $PATH. # Given an argument, it is treated as a pattern that filters results. function completion//allcommands { typeset IFS # check if $PATH is an array case $(typeset -p PATH 2>/dev/null) in (PATH=\(*) ;; ('') typeset PATH PATH=() ;; (*) # re-define $PATH as local array typeset IFS=: savepath="$PATH" typeset PATH PATH=($savepath) ;; esac IFS=' ' # use "find" if it supports "-min/maxdepth" if find -L . -mindepth 0 -maxdepth 0 -prune >&2; then find -L "$PATH" -mindepth 1 -maxdepth 1 \ ${1+-name "$1"} -type f -perm -u+x return fi 2>/dev/null typeset dir file pat="${1-*}" oldopt="$(set +o)" set -o glob -o dotglob -o nullglob -o caseglob -o markdirs for dir in "$PATH"; do case $dir in (*/) ;; (*) dir=$dir/ ;; esac for file in "$dir"*; do case $file in (*/.|*/..|*/) ;; (*/$pat) if [ -x "$file" ]; then printf '%s\n' "$file" fi ;; esac done done eval "$oldopt" } # The completion function for the "." built-in if ! command -vf completion/. >/dev/null 2>&1; then function completion/. { # load the "_dot" file and call the "completion/." function in it . -AL completion/_dot && command -f completion/. "$@" } fi # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/diff0000644000175000017500000001715212154557026016662 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "diff" command. # Supports POSIX 2008, GNU diffutils 3.0, OpenBSD 4.8, SunOS 5.10, HP-UX 11i v3. function completion/diff { case $("${WORDS[1]}" --version 2>/dev/null) in (*'diffutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "b ${long:+--ignore-space-change}; ignore changes in amount of whitespaces only" "C: ${long:+--context::}; output in copied context format with the specified number of context lines" "c; like -C 3" "e ${long:+--ed}; output in ed script format" "f ${long:+--forward-ed}; output in forward ed format" "r ${long:+--recursive}; recursively compare directories" "U: ${long:+--unified::}; output in unified context format with the specified number of context lines" "u; like -U 3" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD|SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "D: ${long:+--ifdef:}; output in merged #ifdef format with the specified conditional macro name" "i ${long:+--ignore-case}; case-insensitive comparison" "l ${long:+--paginate}; output in long format thru the pr command" "n ${long:+--rcs}; output in rcsdiff format" "S: ${long:+--starting-file:}; restart directory comparison from the specified file" "s ${long:+--report-identical-files}; explicitly report identical files" "t ${long:+--expand-tabs}; expand tabs in output" "w ${long:+--ignore-all-space}; ignore whitespaces in comparison" "X: ${long:+--exclude-from:}; skip files whose names match a pattern in the specified file" "x: ${long:+--exclude:}; skip files whose names match the specified pattern" ) #<# esac case $type in (GNU|*BSD) ADDOPTIONS=("$ADDOPTIONS" #># "a ${long:+--text}; assume all files are text" "d ${long:+--minimal}; make the output as small as possible" "I: ${long:+--ignore-matching-lines:}; don't output changes matching the specified regular expression" "L: ${long:+--label:}; specify the label used instead of the filename" "N ${long:+--new-file}; treat absent files as empty" "P ${long:+--unidirectional-new-file}; treat absent from-files as empty" "p ${long:+--show-c-function}; print the name of C function containing changes" "q ${long:+--brief}; just print the names of differing files" "T ${long:+--initial-tab}; prepend a tab to each output line to align text" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "B --ignore-blank-lines; ignore insertion/deletion of empty lines" "--binary; don't convert CR-LF into LF" "--changed-group-format:; specify the format of differing lines" "E --ignore-tab-expansion; ignore changes due to tab expansion" "F: --show-function-line:; specify a regular expression to find the name of the function containing the change" "--from-file:; specify a file to compare with each operand" "--horizon-lines:; don't discard the specified number of lines in the common prefix/suffix" "--ignore-file-name-case; case-insensitive filename comparison" "--left-column; print only the left column of two common lines (with -y)" "--line-format:; specify the --{old,new,unchanged}-line-format options at once" "--new-group-format:; specify the format of lines only in the second file" "--new-line-format:; specify the format of a line only in the second file" "--no-ignore-file-name-case; case-sensitive filename comparison" "--normal; output in normal format" "--old-group-format:; specify the format of lines only in the first file" "--old-line-format:; specify the format of a line only in the first file" "--speed-large-files; fast, half-hearted comparison" "--strip-trailing-cr; ignore carriage returns at the end of lines" "--suppress-blank-empty; don't end a line with a space unless there was one in the text" "--suppress-common-lines; don't print common lines (with -y)" "--tabsize:; specify how many spaces a tab stands for" "--to-file:; specify a file to compare each operand with" "--unchanged-group-format:; specify the format of lines common to the both files" "--unchanged-line-format:; specify the format of a line common to the both files" "v --version; print version info" "W: --width:; specify the max output width (with -y)" "y --side-by-side; output in side-by-side format" "--help" ) #<# esac case $type in (SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "h; fast, half-hearted comparison" ) #<# esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([CUW]|--context|--unified|--horizon-lines|--tabsize|--width) ;; (D|--ifdef) if [ -r tags ]; then complete -P "$PREFIX" -R "!_TAG_*" -- \ $(cut -f 1 tags 2>/dev/null) fi ;; (--*line-format) command -f completion/diff::line ;; (--*group-format) command -f completion/diff::group ;; (*) complete -P "$PREFIX" -f ;; esac } function completion/diff::line { typeset word="${TARGETWORD#"$PREFIX"}" word=${word//%%} case $word in (*%|*%[doxX]) PREFIX=${TARGETWORD%\%*} #>># complete -T -P "$PREFIX" -D "line contents, without newline" '%l' complete -T -P "$PREFIX" -D "line contents, with newline" '%L' complete -T -P "$PREFIX" -D "escape a following character enclosed in single-quotes" '%c' complete -T -P "$PREFIX" -D "line number in decimal" '%dn' complete -T -P "$PREFIX" -D "line number in octal" '%on' complete -T -P "$PREFIX" -D "line number in hexadecimal, lowercase" '%xn' complete -T -P "$PREFIX" -D "line number in hexadecimal, uppercase" '%Xn' complete -T -P "$PREFIX" -D "%" '%%' return 0 #<<# ;; esac } function completion/diff::group { typeset word="${TARGETWORD#"$PREFIX"}" word=${word//%%} case $word in (*%[doxX]) PREFIX=${TARGETWORD%\%?} word=${TARGETWORD#"$PREFIX"} #>># complete -T -P "$PREFIX" -D "line number just before the group in the first file" "${word}e" complete -T -P "$PREFIX" -D "line number just before the group in the second file" "${word}E" complete -T -P "$PREFIX" -D "line number of the first line in the group in the first file" "${word}f" complete -T -P "$PREFIX" -D "line number of the first line in the group in the second file" "${word}F" complete -T -P "$PREFIX" -D "line number of the last line in the group in the first file" "${word}l" complete -T -P "$PREFIX" -D "line number of the last line in the group in the second file" "${word}L" complete -T -P "$PREFIX" -D "line number just after the group in the first file" "${word}m" complete -T -P "$PREFIX" -D "line number just after the group in the second file" "${word}M" complete -T -P "$PREFIX" -D "number of lines in the group in the first file" "${word}n" complete -T -P "$PREFIX" -D "number of lines in the group in the second file" "${word}N" return 0 #<<# ;; (*%) PREFIX=${TARGETWORD%\%} #>># complete -T -P "$PREFIX" -D "lines from the first file" '%<' complete -T -P "$PREFIX" -D "lines from the second file" '%>' complete -T -P "$PREFIX" -D "lines common to the both files" '%=' complete -T -P "$PREFIX" -D "escape a following character enclosed in single-quotes" '%c' complete -T -P "$PREFIX" -D "format a decimal number" '%d' complete -T -P "$PREFIX" -D "format an octal number" '%o' complete -T -P "$PREFIX" -D "format a hexadecimal number in lowercase" '%x' complete -T -P "$PREFIX" -D "format a hexadecimal number in uppercase" '%X' complete -T -P "$PREFIX" -D "conditional expression" '%(' complete -T -P "$PREFIX" -D "%" '%%' return 0 #<<# ;; esac return 1 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-cherry-pick0000644000175000017500000000272712154557026020755 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "git-cherry-pick" command. # Supports Git 1.8.1.4. function completion/git-cherry-pick { WORDS=(git cherry-pick "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::cherry-pick:arg { OPTIONS=( #># "--abort; end suspended cherry-picking and restore the original state" "--allow-empty; allow commits that make no change" "--allow-empty-message" "--continue; resume suspended cherry-picking" "e --edit; reedit the message" "--ff; fast-forward if possible" "--keep-redundant-commits; don't omit already-merged commits" "m: --mainline:; apply diffs from the nth parent" "n --no-commit; don't commit the result automatically" "--quit; end suspended cherry-picking and keep the current state" "r; don't include the original commit ID in the message" "s --signoff; add a \"signed-off-by\" line to the message" "--strategy:; specify the merge strategy" "X: --strategy-option:; specify a strategy-specific option" "x; include the original commit ID in the message" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; # (m|--mainline) # ;; (X|--strategy*) if command -vf completion/git::merge:compopt >/dev/null 2>&1 || . -AL completion/git-merge; then command -f completion/git::merge:compopt fi ;; ('') command -f completion/git::completeref range=true ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/cut0000644000175000017500000000255512154557026016546 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "cut" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/cut { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "b: ${long:+--bytes:}; specify the positions of bytes to print" "c: ${long:+--characters:}; specify the positions of characters to print" "d: ${long:+--delimiter:}; specify a field delimiter (with -f)" "f: ${long:+--fields:}; specify the positions of fields to print" "n; don't split multibyte characters (with -b)" "s ${long:+--only-delimited}; don't print lines containing no delimiters (with -f)" ) #<# ADDOPTIONS=() case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "--complement; print fields not specified by -b/-c/-f option" "--help" "--version" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (?|--?*) ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-submodule0000644000175000017500000001022412154557026020523 0ustar magicantmagicant# (C) 2013 magicant # Completion script for the "git-submodule" command. # Supports Git 1.8.1.4. function completion/git-submodule { WORDS=(git submodule "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::submodule:arg { OPTIONS=( #># "q --quiet; print error messages only" ) #<# while [ x"${WORDS[2]}" = x"-q" ] || [ x"${WORDS[2]}" = x"--quiet" ]; do WORDS=("${WORDS[1]}" "${WORDS[3,-1]}") done if [ ${WORDS[#]} -le 1 ]; then case ${TARGETWORD#"$PREFIX"} in (-q) # avoid completing "-q" to "-qq" complete -P "$PREFIX" -- -q ;; (-*) command -f completion//parseoptions command -f completion//completeoptions ;; (*) #>># complete -P "$PREFIX" -D "add a submodule" add complete -P "$PREFIX" -D "execute a shell command in each submodule" foreach complete -P "$PREFIX" -D "configure submodules according to .gitmodules" init complete -P "$PREFIX" -D "show status of submodules" status complete -P "$PREFIX" -D "print summary of changes in submodules" summary complete -P "$PREFIX" -D "reset submodule remote URL" sync complete -P "$PREFIX" -D "clone and check out submodules" update ;; #<<# esac else WORDS=("${WORDS[2,-1]}") if command -vf "completion/git::submodule:${WORDS[1]}:arg" >/dev/null 2>&1; then command -f "completion/git::submodule:${WORDS[1]}:arg" fi fi } function completion/git::submodule:add:arg { OPTIONS=("$OPTIONS" #># "b: --branch:; specify a branch of the submodule to clone" "f --force; add an ignored path" "--name:; specify the name of the submodule" "--reference:; specify a reference repository to share objects (possibly dangerous operation)" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # (b|--branch) # ;; # (--name) # ;; (--reference) complete -P "$PREFIX" -S / -T -d ;; ('') command -f completion//getoperands if command -vf completion/git::clone:opr >/dev/null 2>&1 || . -AL completion/git-clone; then command -f completion/git::clone:opr fi ;; esac } function completion/git::submodule:foreach:arg { OPTIONS=("$OPTIONS" #># "--recursive; operate on all submodules recursively" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion//getoperands command -f completion//reexecute -e ;; esac } function completion/git::submodule:init:arg { complete -P "$PREFIX" -S / -T -d } function completion/git::submodule:status:arg { OPTIONS=("$OPTIONS" #># "--cached; print status of the supermodule index" "--recursive; operate on all submodules recursively" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') complete -P "$PREFIX" -S / -T -d ;; esac } function completion/git::submodule:summary:arg { OPTIONS=("$OPTIONS" #># "--cached; compare the supermodule HEAD and index" "--files; compare the supermodule index with the submodule HEAD" "n: --summary-limit:; specify the max number of commits to show" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # (n|--summary-limit) # ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then command -f completion/git::completeref fi complete -P "$PREFIX" -S / -T -d ;; esac } function completion/git::submodule:sync:arg { complete -P "$PREFIX" -S / -T -d } function completion/git::submodule:update:arg { OPTIONS=("$OPTIONS" #># "--init; do \"git submodule init\" before updating" "--merge; merge in submodules" "N --no-fetch; don't fetch from submodule remotes" "--rebase; rebase in submodules" "--recursive; operate on all submodules recursively" "--reference:; specify a reference repository to share objects (possibly dangerous operation)" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (--reference) complete -P "$PREFIX" -S / -T -d ;; ('') complete -P "$PREFIX" -S / -T -d ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/rm0000644000175000017500000000374312154557026016371 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "rm" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/rm { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "f ${long:+--force}; remove files without confirmation" "i; confirm before removing each file" "R r ${long:+--recursive}; recursively remove directories" ) #<# case $type in (GNU|*BSD|Darwin) OPTIONS=("$OPTIONS" #># "d; try to remove directories like other files" ) #<# case $type in (GNU|FreeBSD) OPTIONS=("$OPTIONS" #># "I; confirm before removing many files" ) #<# esac case $type in (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "P; clear file contents before removing" ) #<# case $type in (FreeBSD|NetBSD|Darwin) OPTIONS=("$OPTIONS" #># "W; undelete files" ) #<# esac esac case $type in (GNU|FreeBSD|NetBSD|Darwin) OPTIONS=("$OPTIONS" #># "v ${long:+--verbose}; print a message for each file processed" ) #<# esac esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "--interactive::; specify when to confirm removal" "--one-file-system; skip subdirectories on different file systems" "--no-preserve-root; don't treat the root directory specially" "--preserve-root; don't remove the root directory" "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--interactive) #>># complete -P "$PREFIX" -D "don't confirm removal" never complete -P "$PREFIX" -D "confirm before removing many files" once complete -P "$PREFIX" -D "confirm before removing each file" always ;; #<<# (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/mv0000644000175000017500000000431612154557026016372 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "mv" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/mv { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "f ${long:+--force}; overwrite existing files without prompt" "i ${long:+--interactive}; ask before overwriting existing files" ) #<# case $type in (GNU|FreeBSD|NetBSD|Darwin) OPTIONS=("$OPTIONS" #># "v ${long:+--verbose}; print a message for each file processed" ) #<# case $type in (GNU|FreeBSD|Darwin) OPTIONS=("$OPTIONS" #># "n ${long:+--no-clobber}; don't overwrite existing files" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "b; like --backup=existing" "--backup::; specify how to make a backup" "--strip-trailing-slashes; remove trailing slashes from source operands" "S: --suffix:; specify a suffix to append to backup file names" "T --no-target-directory; always treat the destination as a regular file" "t: --target-directory:; specify a destination directory" "u --update; don't move if destination is newer than source" "--help" "--version" ) #<# esac esac ;; (HP-UX) OPTIONS=("$OPTIONS" #># "e:; specify extent attributes treatment" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--backup) if command -vf completion//completebackup >/dev/null 2>&1 || . -AL completion/_backup; then command -f completion//completebackup fi ;; (e) #>># complete -P "$PREFIX" -D "print a message when failed to preserve an extent attribute" warn complete -P "$PREFIX" -D "don't preserve extent attributes" ignore complete -P "$PREFIX" -D "don't move a file when cannot preserve the extent attribute" force ;; #<<# (S|--suffix) ;; (t|--target-directory) complete -T -P "$PREFIX" -S / -d ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/evim0000644000175000017500000000030212154557026016677 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "evim" command. # Supports Vim 7.3. function completion/evim { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/nl0000644000175000017500000000422512154557026016360 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "nl" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/nl { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "b: ${long:+--body-numbering:}; specify the numbering style of body lines" "d: ${long:+--section-delimiter:}; specify section delimiter characters" "f: ${long:+--footer-numbering:}; specify the numbering style of footer lines" "h: ${long:+--header-numbering:}; specify the numbering style of header lines" "i: ${long:+--line-increment:}; specify the line number increment" "l: ${long:+--join-blank-lines:}; consider n adjacent empty lines as one" "n: ${long:+--number-format:}; specify the line numbering format" "p ${long:+--no-renumber}; don't reset the line number at the beginning of pages" "s: ${long:+--number-separator:}; specify the separator between the line number and the text" "v: ${long:+--starting-line-number:}; specify the initial line number" "w: ${long:+--number-width:}; specify the number of characters for the line number" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([bfh]|--body-numbering|--footer-numbering|--header-numbering) #>># complete -P "$PREFIX" -D "number all lines" a complete -P "$PREFIX" -D "number nonempty lines" t complete -P "$PREFIX" -D "number no lines" n complete -P "$PREFIX" -D "number lines matching the following regular expression" -T p ;; #<<# (n|--number-format) #>># complete -P "$PREFIX" -D "left justified, leading zeros suppressed" ln complete -P "$PREFIX" -D "right justified, leading zeros suppressed" rn complete -P "$PREFIX" -D "right justified, leading zeros kept" rz ;; #<<# ('') complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/sh0000644000175000017500000001457712154557026016374 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "sh" built-in command. # Completion function "completion/sh" is used for the "bash", "dash" and "mksh" # commands as well. Supports POSIX 2008, bash 4.1, dash 0.5.5.1, mksh R39c. function completion/sh { typeset compoptopts= typeset prog="${WORDS[1]##*/}" typeset OPTIONS FOPTIONS OOPTIONS ARGOPT PREFIX FOPTIONS=( #># "c; execute the first operand as a shell script" "i; work in the interactive mode" "o:; specify an option" ) #<# OOPTIONS=( #># "a --allexport; export all variables when assigned" "b --notify; print job status immediately when done" "C --noclobber; disallow >-redirection to overwrite an existing file" "e --errexit; exit immediately when a command's exit status is non-zero" "f --noglob; disable pathname expansion (globbing)" "m --monitor; enable job control" "n --noexec; don't execute any commands" "u --nounset; disallow expansion of undefined variables" "v --verbose; echo commands entered to the shell" "x --xtrace; print a command line before executing it" "--ignoreeof; don't exit when an end-of-file is entered" "--vi; vi-like line-editing" ) #<# case $prog in (bash) OOPTIONS=("$OOPTIONS" #># "h --hashall; cache full paths of commands in a function when defined" ) #<# ;; (mksh) OOPTIONS=("$OOPTIONS" #># "h --trackall; cache full paths of commands when entered" ) #<# ;; (*) OOPTIONS=("$OOPTIONS" #># "h; cache full paths of commands in a function when defined" ) #<# ;; esac case $prog in (bash) FOPTIONS=("$FOPTIONS" #># "l --login; work as a login shell" ) #<# ;; (dash) FOPTIONS=("$FOPTIONS" #># "l; work as a login shell" ) #<# ;; (mksh) OOPTIONS=("$OOPTIONS" #># "l --login; work as a login shell" ) #<# ;; esac case $prog in (mksh) OOPTIONS=("$OOPTIONS" #># "s --stdin; read commands from the standard input" ) #<# ;; (*) FOPTIONS=("$FOPTIONS" #># "s; read commands from the standard input" ) #<# ;; esac case $prog in ([bd]ash|mksh) OOPTIONS=("$OOPTIONS" #># "--emacs; emacs-like line-editing" ) #<# esac case $prog in (bash|mksh) OOPTIONS=("$OOPTIONS" #># "--posix; force strict POSIX conformance" "p --privileged; work in the privileged mode" "P --physical; make the -P option the default in the cd commands etc." ) #<# esac case $prog in (bash) FOPTIONS=("$FOPTIONS" #># "--help" "--version" "--noprofile; don't read profile file" "--debugger; enable extended debugging mode" "--dump-po-strings; extract translatable strings in po file format" "D --dump-strings; extract translatable strings" "--noediting; don't use the Readline library" "--norc; don't read rc file" "--rcfile: --init-file:; specify the rc file" "r --restricted; work in the restricted mode" "--rpm-requires; print package names required to run the script" "O:; specify a shopt option" ) #<# OOPTIONS=("$OOPTIONS" #># "H --histexpand; enable !-expansion on the command line" "k --keyword; allow assignments in the middle of command arguments" "--pipefail; return last non-zero exit status of commands in a pipe" "B --braceexpand; enable brace expansion" "E --errtrace; don't reset ERR trap in subshells" "T --functrace; don't reset DEBUG and RETURN traps in subshells" "t --onecmd; execute one command only" "--history; enable command history" ) #<# compoptopts="$compoptopts -e" esac case $prog in (mksh) OOPTIONS=("$OOPTIONS" #># "--braceexpand; enable brace expansion" "r --restricted; work in the restricted mode" "--bgnice; run background jobs at lower priorities" "--gmacs; gmacs-like line-editing" "U --utf8-mode; enable UTF-8 support" "X --markdirs; append a slash to directory names after pathname expansion" "--arc4random; use arc4random for random number generation" "--nohup; don't kill running jobs when exiting" "--sh; force very strict POSIX conformance" "--vi-esccomplete; use the Escape key for completion in the vi mode" "--vi-tabcomplete; use the Tab key for completion in the vi mode" ) #<# esac OPTIONS=("$FOPTIONS" "$OOPTIONS") # convert plus-prefixed options into hyphen-prefixed options typeset i=2 while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (-|--) break ;; ([+-]*o) i=$((i+2)) ;; ([+-]?*) i=$((i+1)) ;; (*) break ;; esac done WORDS=("${WORDS[1]}" "${WORDS[2,i-1]/#+/-}" "${WORDS[i,-1]}") # the same for $TARGETWORD typeset SAVETARGETWORD="$TARGETWORD" if [ $i -gt ${WORDS[#]} ]; then TARGETWORD=${TARGETWORD/#+/-} fi command -f completion//parseoptions case $ARGOPT in (-) case $prog in (set|yash|ksh) ;; (*) OPTIONS=("$OOPTIONS") command -f completion/set::removelongopts OPTIONS=("$FOPTIONS" "$OPTIONS") ;; esac case $SAVETARGETWORD in (-*) command -f completion//completeoptions $compoptopts ;; (+*) TARGETWORD=$SAVETARGETWORD command -f completion/set::option short ;; esac ;; (o) PREFIX=${SAVETARGETWORD%"${TARGETWORD#"$PREFIX"}"} TARGETWORD=$SAVETARGETWORD OPTIONS=("$OOPTIONS") command -f completion/set::option long ;; (O) typeset shopt value while read -r shopt value; do complete -P "$PREFIX" -- "$shopt" done 2>/dev/null <(bash -O /dev/null function completion/set::option { if [ "${1-}" != long ]; then typeset single=true else typeset single=false fi typeset opts desc typeset generated=false for opts in "$OPTIONS"; do # get description case $opts in (*\;*) desc=${opts#*;} while true; do # trim surrounding spaces case $desc in ([[:space:]]*) desc=${desc#[[:space:]]} ;; (*[[:space:]]) desc=${desc%[[:space:]]} ;; (*) break ;; esac done ;; (*) desc= ;; esac if $single; then # generate single-character option for opt in ${opts%%;*}; do case $opt in ([[:alnum:]]|[[:alnum:]]:) complete -O -P "$TARGETWORD" \ ${desc:+-D "$desc"} "${opt%:}" && generated=true break esac done else # generate candidate for first match for opt in ${opts%%;*}; do case $opt in (--*) complete -P "$PREFIX" \ ${desc:+-D "$desc"} \ -- "${opt#--}" && generated=true && break esac done fi done $generated } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gawk0000644000175000017500000000026312154557026016676 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "gawk" command. function completion/gawk { command -f completion//reexecute awk } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/complete0000644000175000017500000000051612154557026017556 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "complete" built-in command. function completion/complete { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-annotate0000644000175000017500000000140412154557026020335 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-annotate" command. # Supports Git 1.7.7. function completion/git-annotate { WORDS=(git annotate "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::annotate:arg { OPTIONS=() if command -vf completion/git::blame:getopt >/dev/null 2>&1 || . -AL completion/git-blame; then command -f completion/git::blame:getopt fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') if [ ${WORDS[#]} -le 1 ]; then command -f completion/git::completepath else command -f completion/git::completeref fi ;; (*) command -f completion/git::blame:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/typeset0000644000175000017500000000327012154557026017443 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "typeset" built-in command. # Completion function "completion/typeset" is used for the "export" and # "readonly" built-ins as well. function completion/typeset { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "p --print; print specified variables or functions" "X --unexport; cancel exportation of variables" "--help" ) #<# if [ "${WORDS[1]}" = "typeset" ]; then OPTIONS=("$OPTIONS" #># "g --global; define global variables" ) #<# fi if [ "${WORDS[1]}" != "export" ]; then OPTIONS=("$OPTIONS" #># "f --functions; define or print functions rather than variables" "x --export; export variables or print exported variables" ) #<# fi if [ "${WORDS[1]}" != "readonly" ]; then OPTIONS=("$OPTIONS" #># "r --readonly; define or print read-only variables or functions" ) #<# fi command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) typeset i=1 func=false while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i++]} in (-f|--functions) func=true ;; (--) break ;; esac done if $func; then complete --function else case $TARGETWORD in (*=*:*) # remove until the last colon after the first '=' and # complete as a filename. If $word is # PATH=/bin:/usr/bin:/u for example, we complete the # filename /u PREFIX=${TARGETWORD%"${${TARGETWORD#*=}##*:}"} complete -T -P "$PREFIX" -S : -f ;; (*=*) # remove until '=' and complete as a filename. PREFIX=${TARGETWORD%"${TARGETWORD#*=}"} complete -P "$PREFIX" -f ;; (*) complete -T -S = -v ;; esac fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/mkdir0000644000175000017500000000244512154557026017057 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "mkdir" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/mkdir { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "m: ${long:+--mode:}; specify the permission of the new directory" "p ${long:+--parents}; make parent directories if necessary" ) #<# case $type in (GNU|FreeBSD|Darwin) OPTIONS=("$OPTIONS" #># "v ${long:+--verbose}; print a message for each directory processed" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "Z: --context:; specify the security context of the new directory" "--help" "--version" ) #<# esac esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (m|--mode) if command -vf completion/chmod::mode >/dev/null 2>&1 || . -AL completion/chmod; then command -f completion/chmod::mode mkdir fi ;; (Z|--context) ;; (*) complete -S / -T -d ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/bg0000644000175000017500000000026412154557026016336 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "bg" built-in command. function completion/bg { command -f completion//reexecute jobs } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/rgvim0000644000175000017500000000030412154557026017065 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "rgvim" command. # Supports Vim 7.3. function completion/rgvim { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/getconf0000644000175000017500000001406212154557026017374 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "getconf" command. # Supports POSIX 2008, GNU libc 2.12.1, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/getconf { typeset type="$(uname 2>/dev/null)" typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "v:; specify a programming environment" ) #<# command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (v) complete -P "$PREFIX" XBS5_ILP32_OFF32 XBS5_ILP32_OFFBIG XBS5_LP64_OFF64 XBS5_LPBIG_OFFBIG complete -P "$PREFIX" POSIX_V6_ILP32_OFF32 POSIX_V6_ILP32_OFFBIG POSIX_V6_LP64_OFF64 POSIX_V6_LPBIG_OFFBIG complete -P "$PREFIX" POSIX_V7_ILP32_OFF32 POSIX_V7_ILP32_OFFBIG POSIX_V7_LP64_OFF64 POSIX_V7_LPBIG_OFFBIG ;; ('') command -f completion//getoperands case ${WORDS[#]} in (0) # fpathconf variables complete FILESIZEBITS LINK_MAX MAX_CANON MAX_INPUT NAME_MAX PATH_MAX PIPE_BUF complete POSIX2_SYMLINKS POSIX_ALLOC_SIZE_MIN POSIX_REC_INCR_XFER_SIZE POSIX_REC_MAX_XFER_SIZE POSIX_REC_MIN_XFER_SIZE POSIX_REC_XFER_ALIGN SYMLINK_MAX complete _POSIX_CHOWN_RESTRICTED _POSIX_NO_TRUNC _POSIX_VDISABLE _POSIX_ASYNC_IO _POSIX_PRIO_IO _POSIX_SYNC_IO _POSIX_TIMESTAMP_RESOLUTION # sysconf variables complete AIO_LISTIO_MAX AIO_MAX AIO_PRIO_DELTA_MAX ARG_MAX ATEXIT_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX BC_STRING_MAX CHILD_MAX COLL_WEIGHTS_MAX DELAYTIMER_MAX EXPR_NEST_MAX HOST_NAME_MAX IOV_MAX LINE_MAX LOGIN_NAME_MAX NGROUPS_MAX MQ_OPEN_MAX MQ_PRIO_MAX OPEN_MAX complete _POSIX_ADVISORY_INFO _POSIX_BARRIERS _POSIX_ASYNCHRONOUS_IO _POSIX_CLOCK_SELECTION _POSIX_CPUTIME _POSIX_FILE_LOCKING _POSIX_FSYNC _POSIX_IPV6 _POSIX_JOB_CONTROL _POSIX_MAPPED_FILES _POSIX_MEMLOCK _POSIX_MEMLOCK_RANGE _POSIX_MEMORY_PROTECTION _POSIX_MESSAGE_PASSING _POSIX_MONOTONIC_CLOCK _POSIX_MULTI_PROCESS _POSIX_PRIORITIZED_IO _POSIX_PRIORITY_SCHEDULING _POSIX_RAW_SOCKETS _POSIX_READER_WRITER_LOCKS _POSIX_REALTIME_SIGNALS _POSIX_REGEXP _POSIX_SAVED_IDS _POSIX_SEMAPHORES _POSIX_SHARED_MEMORY_OBJECTS _POSIX_SHELL _POSIX_SPAWN _POSIX_SPIN_LOCKS _POSIX_SPORADIC_SERVER _POSIX_SS_REPL_MAX _POSIX_SYMLOOP_MAX _POSIX_SYNCHRONIZED_IO _POSIX_THREAD_ATTR_STACKADDR _POSIX_THREAD_ATTR_STACKSIZE _POSIX_THREAD_CPUTIME _POSIX_THREAD_PRIO_INHERIT _POSIX_THREAD_PRIO_PROTECT _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_THREAD_PROCESS_SHARED _POSIX_THREAD_ROBUST_PRIO_INHERIT _POSIX_THREAD_ROBUST_PRIO_PROTECT _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_THREAD_SPORADIC_SERVER _POSIX_THREADS complete _POSIX_TIMEOUTS _POSIX_TIMERS _POSIX_TRACE _POSIX_TRACE_EVENT_FILTER _POSIX_TRACE_EVENT_NAME_MAX _POSIX_TRACE_INHERIT _POSIX_TRACE_LOG _POSIX_TRACE_NAME_MAX _POSIX_TRACE_SYS_MAX _POSIX_TRACE_USER_EVENT_MAX _POSIX_TYPED_MEMORY_OBJECTS _POSIX_VERSION _POSIX_V7_ILP32_OFF32 _POSIX_V7_ILP32_OFFBIG _POSIX_V7_LP64_OFF64 _POSIX_V7_LPBIG_OFFBIG _POSIX_V6_ILP32_OFF32 _POSIX_V6_ILP32_OFFBIG _POSIX_V6_LP64_OFF64 _POSIX_V6_LPBIG_OFFBIG _POSIX2_C_BIND _POSIX2_C_DEV _POSIX2_C_VERSION _POSIX2_CHAR_TERM _POSIX2_FORT_DEV _POSIX2_FORT_RUN _POSIX2_LOCALEDEF _POSIX2_PBS _POSIX2_PBS_ACCOUNTING _POSIX2_PBS_CHECKPOINT _POSIX2_PBS_LOCATE _POSIX2_PBS_MESSAGE _POSIX2_PBS_TRACK _POSIX2_SW_DEV _POSIX2_UPE _POSIX2_VERSION complete PAGE_SIZE PAGESIZE PTHREAD_DESTRUCTOR_ITERATIONS PTHREAD_KEYS_MAX PTHREAD_STACK_MIN PTHREAD_THREADS_MAX RE_DUP_MAX _REGEX_VERSION RTSIG_MAX SEM_NSEMS_MAX SEM_VALUE_MAX SIGQUEUE_MAX STREAM_MAX SYMLOOP_MAX TIMER_MAX TTY_NAME_MAX TZNAME_MAX complete _XBS5_ILP32_OFF32 _XBS5_ILP32_OFFBIG _XBS5_LP64_OFF64 _XBS5_LPBIG_OFFBIG _XOPEN_CRYPT _XOPEN_ENH_I18N _XOPEN_LEGACY _XOPEN_REALTIME _XOPEN_REALTIME_THREADS _XOPEN_SHM _XOPEN_STREAMS _XOPEN_UNIX _XOPEN_UUCP _XOPEN_VERSION _XOPEN_XCU_VERSION # confstr variables complete PATH complete POSIX_V7_ILP32_OFF32_CFLAGS POSIX_V7_ILP32_OFF32_LDFLAGS POSIX_V7_ILP32_OFF32_LIBS POSIX_V7_ILP32_OFFBIG_CFLAGS POSIX_V7_ILP32_OFFBIG_LDFLAGS POSIX_V7_ILP32_OFFBIG_LIBS POSIX_V7_LP64_OFF64_CFLAGS POSIX_V7_LP64_OFF64_LDFLAGS POSIX_V7_LP64_OFF64_LIBS POSIX_V7_LPBIG_OFFBIG_CFLAGS POSIX_V7_LPBIG_OFFBIG_LDFLAGS POSIX_V7_LPBIG_OFFBIG_LIBS POSIX_V7_THREADS_CFLAGS POSIX_V7_THREADS_LDFLAGS POSIX_V7_WIDTH_RESTRICTED_ENVS V7_ENV complete POSIX_V6_ILP32_OFF32_CFLAGS POSIX_V6_ILP32_OFF32_LDFLAGS POSIX_V6_ILP32_OFF32_LIBS POSIX_V6_ILP32_OFFBIG_CFLAGS POSIX_V6_ILP32_OFFBIG_LDFLAGS POSIX_V6_ILP32_OFFBIG_LIBS POSIX_V6_LP64_OFF64_CFLAGS POSIX_V6_LP64_OFF64_LDFLAGS POSIX_V6_LP64_OFF64_LIBS POSIX_V6_LPBIG_OFFBIG_CFLAGS POSIX_V6_LPBIG_OFFBIG_LDFLAGS POSIX_V6_LPBIG_OFFBIG_LIBS POSIX_V6_WIDTH_RESTRICTED_ENVS V6_ENV complete XBS5_ILP32_OFF32_CFLAGS XBS5_ILP32_OFF32_LDFLAGS XBS5_ILP32_OFF32_LIBS XBS5_ILP32_OFF32_LINTFLAGS XBS5_ILP32_OFFBIG_CFLAGS XBS5_ILP32_OFFBIG_LDFLAGS XBS5_ILP32_OFFBIG_LIBS XBS5_ILP32_OFFBIG_LINTFLAGS XBS5_LP64_OFF64_CFLAGS XBS5_LP64_OFF64_LDFLAGS XBS5_LP64_OFF64_LIBS XBS5_LP64_OFF64_LINTFLAGS XBS5_LPBIG_OFFBIG_CFLAGS XBS5_LPBIG_OFFBIG_LDFLAGS XBS5_LPBIG_OFFBIG_LIBS XBS5_LPBIG_OFFBIG_LINTFLAGS # other limits.h variables complete _POSIX_CLOCKRES_MIN complete _POSIX_AIO_LISTIO_MAX _POSIX_AIO_MAX _POSIX_ARG_MAX _POSIX_CHILD_MAX _POSIX_DELAYTIMER_MAX _POSIX_HOST_NAME_MAX _POSIX_LINK_MAX _POSIX_LOGIN_NAME_MAX _POSIX_MAX_CANON _POSIX_MAX_INPUT _POSIX_MQ_OPEN_MAX _POSIX_MQ_PRIO_MAX _POSIX_NAME_MAX _POSIX_NGROUPS_MAX _POSIX_OPEN_MAX _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_RE_DUP_MAX _POSIX_RTSIG_MAX _POSIX_SEM_NSEMS_MAX _POSIX_SEM_VALUE_MAX _POSIX_SIGQUEUE_MAX _POSIX_SSIZE_MAX _POSIX_SS_REPL_MAX _POSIX_STREAM_MAX _POSIX_SS_REPL_MAX _POSIX_SYMLINK_MAX _POSIX_SYMLOOP_MAX _POSIX_THREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_KEYS_MAX _POSIX_THREAD_THREADS_MAX _POSIX_TIMER_MAX _POSIX_TRACE_EVENT_NAME_MAX _POSIX_TRACE_NAME_MAX _POSIX_TRACE_SYS_MAX _POSIX_TRACE_USER_EVENT_MAX _POSIX_TTY_NAME_MAX _POSIX_TZNAME_MAX _POSIX2_BC_BASE_MAX _POSIX2_BC_DIM_MAX _POSIX2_BC_SCALE_MAX _POSIX2_BC_STRING_MAX _POSIX2_CHARCLASS_NAME_MAX _POSIX2_COLL_WEIGHTS_MAX _POSIX2_EXPR_NEST_MAX _POSIX2_LINE_MAX _POSIX2_RE_DUP_MAX _XOPEN_IOV_MAX _XOPEN_NAME_MAX _XOPEN_PATH_MAX ;; (1) complete -f ;; esac ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-remote0000644000175000017500000001136712154557026020030 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "git-remote" command. # Supports Git 1.7.7. function completion/git-remote { WORDS=(git remote "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::remote:arg { while [ x"${WORDS[2]}" = x"-v" ] || [ x"${WORDS[2]}" = x"--verbose" ]; do WORDS=("${WORDS[1]}" "${WORDS[3,-1]}") done if [ ${WORDS[#]} -le 1 ]; then case ${TARGETWORD#"$PREFIX"} in (-v) # avoid completing "-v" to "-vv" complete -P "$PREFIX" -- -v ;; (-*) OPTIONS=( #># "v --verbose; list remotes with URLs" ) #<# command -f completion//parseoptions command -f completion//completeoptions ;; (*) #>># complete -P "$PREFIX" -D "add a remote" add complete -P "$PREFIX" -D "rename a remote" rename complete -P "$PREFIX" -D "remove a remote" rm complete -P "$PREFIX" -D "set the default branch of a remote" set-head complete -P "$PREFIX" -D "set remote-tracking branches" set-branches complete -P "$PREFIX" -D "set the URL of a remote" set-url complete -P "$PREFIX" -D "show a remote" show complete -P "$PREFIX" -D "delete remote-tracking branches that no longer exist on a remote" prune complete -P "$PREFIX" -D "fetch remotes" update ;; #<<# esac else WORDS=("${WORDS[2,-1]}") if command -vf "completion/git::remote:${WORDS[1]}:arg" >/dev/null 2>&1; then command -f "completion/git::remote:${WORDS[1]}:arg" fi fi } function completion/git::remote:add:arg { OPTIONS=( #># "f; fetch the remote after adding" "m:; specify a remote branch to be refs/remotes/*/HEAD" "--mirror:; specify a mirroring method" "--no-tags; don't fetch all remote tags after adding" "t:; specify a branch to track" "--tags; fetch all remote tags after adding" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ([mt]) command -f completion/git::completeref --branches ;; (--mirror) #>># complete -P "$PREFIX" -D "mirror the remote into the local" fetch complete -P "$PREFIX" -D "set the remote.*.mirror option" push ;; #<<# ('') command -f completion/git::completeremote ;; esac } function completion/git::remote:rename:arg { command -f completion/git::completeremote } function completion/git::remote:rm:arg { command -f completion/git::completeremote } function completion/git::remote:set-head:arg { case ${WORDS[1]} in (set-head) OPTIONS=( #># "a --auto; query the remote default branch" "d --delete; remove the remote default branch" ) #<# ;; (set-branches) OPTIONS=( #># "a --add; add branch; don't remove existing settings" ) #<# ;; esac command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then command -f completion/git::completeremote else command -f completion/git::completeref \ abbrprefixes="refs/remotes/${WORDS[1]}/" \ dontcompletefull=true \ --remotes="${WORDS[1]}" fi ;; esac } function completion/git::remote:set-branches:arg { command -f completion/git::remote:set-head:arg "$@" } function completion/git::remote:set-url:arg { OPTIONS=( #># "--add; add a URL instead of changing URLs" "--delete; remove URLs instead of changing URLs" "--push; set push URLs instead of fetch URLs" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeremote ;; esac } function completion/git::remote:show:arg { OPTIONS=( #># "n; don't query the remote for the latest info" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeremote ;; esac } function completion/git::remote:prune:arg { OPTIONS=( #># "n --dry-run; don't actually prune, but show what would happen" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeremote ;; esac } function completion/git::remote:update:arg { OPTIONS=( #># "p --prune; delete remote-tracking branches that no longer exist on the remote" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeremote command -f completion/git::completeremotegroup ;; esac } function completion/git::completeremotegroup { typeset name value while read -r name value; do complete -P "$PREFIX" -D "= $value" -- "${name#remotes.}" done 2>/dev/null <(git config --get-regexp 'remotes\..*') } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/pathchk0000644000175000017500000000147412154557026017374 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "pathchk" command. # Supports POSIX 2008, GNU coreutils 8.4. function completion/pathchk { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type=POSIX;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "P; check for empty pathnames and leading hyphens" "p; check pathname length limits and character sets" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "--portability; like -Pp: full check" "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-ls-remote0000644000175000017500000000202012154557026020426 0ustar magicantmagicant# (C) 2013 magicant # Completion script for the "git-ls-remote" command. # Supports Git 1.8.1.4. function completion/git-ls-remote { WORDS=(git ls-remote "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::ls-remote:arg { OPTIONS=( #># "--exit-code; return a non-zero exit status if no refs were printed" "--get-url; just print remote URL" "--heads; print branches only" "--tags; print tags only" "u: --upload-pack:; specify a path for git-upload-pack on the remote host" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (u|--upload-pack) command -f completion/git::--upload-pack:arg ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then complete -P "$PREFIX" -- \ $( (ls -- "$(git rev-parse --git-dir)/branches") 2>/dev/null) command -f completion/git::completeremote else command -f completion/git::completeref fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/unalias0000644000175000017500000000060312154557026017377 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "unalias" built-in command. function completion/unalias { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a --all; remove all aliases" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -a ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/od0000644000175000017500000001143612154557026016353 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "od" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/od { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac case $type in (GNU|*BSD|Darwin) typeset bsd=true ;; (*) typeset bsd= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "A: ${long:+--address-radix:}; specify the radix of addresses printed at the beginning of lines" "b; like -t o1: interpret bytes in octal" "c; interpret bytes as characters" "d; like -t u2: interpret 2-byte words in unsigned decimal" "j: ${long:+--skip-bytes:}; specify the number of bytes to skip first" "N: ${long:+--read-bytes:}; specify the number of bytes to dump at most" "o ${bsd:+B}; like -t o2: interpret 2-byte words in octal" "s; like -t d2: interpret 2-byte words in signed decimal" "t: ${long:+--format:}; specify output format" "v ${long:+--output-duplicates}; don't omit lines containing the same data as the previous line" "x ${bsd:+h}; like -t x2: interpret 2-byte words in hexadecimal" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "F ${bsd:+e}; like -t fD: interpret double-precision floating point numbers" "f; like -t fF: interpret single-precision floating point numbers" "O; like -t o4: interpret 4-byte words in octal" "X ${bsd:+H}; like -t x4: interpret 4-byte words in hexadecimal" ) #<# case $type in (GNU|*BSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "a; like -t a: interpret named characters" "l L I; like -t dL: interpret signed long values in decimal" "i; like -t dI: interpret singed int values in decimal" ) #<# esac case $type in (GNU|FreeBSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "D; like -t u4: interpret 4-byte words in unsigned decimal" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "S: --strings::; output strings of at least n-byte long" "w:: --width::; specify the number of input bytes per output line" "--traditional; use the traditional syntax" "--help" "--version" ) #<# ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "C; interpret bytes as characters" "S; like -t d4: interpret 4-byte words in signed decimal" ) #<# ;; esac esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (A|--address-radix) #>># complete -P "$PREFIX" -D "decimal" d complete -P "$PREFIX" -D "octal" o complete -P "$PREFIX" -D "hexadecimal" x complete -P "$PREFIX" -D "none" n ;; #<<# (j|--skip-bytes) typeset word hex command -f completion/od::size && { if command -vf completion//completesizesuffix >/dev/null 2>&1 || . -AL completion/_blocksize; then command -f completion//completesizesuffix k m ${hex:-b} fi } ;; ([NS]|--read-bytes|--strings) typeset word hex command -f completion/od::size ;; (w|--width) ;; (t|--format) #>># complete -P "$TARGETWORD" -D "named character" a complete -P "$TARGETWORD" -D "character" c complete -P "$TARGETWORD" -D "signed decimal" d complete -P "$TARGETWORD" -D "floating point number" f complete -P "$TARGETWORD" -D "octal" o complete -P "$TARGETWORD" -D "unsigned decimal" u complete -P "$TARGETWORD" -D "hexadecimal" x #<<# case ${TARGETWORD#"$PREFIX"} in (*[doux]) #>># complete -P "$TARGETWORD" -D "char" C complete -P "$TARGETWORD" -D "short" S complete -P "$TARGETWORD" -D "int" I complete -P "$TARGETWORD" -D "long" L ;; #<<# (*f) #>># complete -P "$TARGETWORD" -D "float" F complete -P "$TARGETWORD" -D "double" D complete -P "$TARGETWORD" -D "long double" L ;; #<<# esac case $type in (GNU) case ${TARGETWORD#"$PREFIX"} in (*[acdfouxCDFSIL[:digit:]]) #>># complete -P "$TARGETWORD" -D "also print characters directly" z esac #<<# esac ;; (*) complete -f ;; esac } # This function sets the word, hex, PREFIX variables. function completion/od::size { word="${TARGETWORD#"$PREFIX"}" case $word in (0[Xx]*) hex=true ;; (*) hex= ;; esac case $word in ([[:digit:]]*) while [ "${word#[[:digit:]AaBbCcDdEeFfXx]}" != "$word" ]; do word=${word#[[:digit:]AaBbCcDdEeFfXx]} done PREFIX=${TARGETWORD%"$word"} case $type in (GNU) if command -vf completion//completesizesuffix >/dev/null 2>&1 || . -AL completion/_blocksize; then command -f completion//completesizesuffix GNU${hex:+-E} fi esac return 0 esac return 1 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/rview0000644000175000017500000000030412154557026017075 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "rview" command. # Supports Vim 7.3. function completion/rview { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/set0000644000175000017500000002227212154557026016544 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "set" built-in command. # Completion function "completion/set" is used for the "ksh" and "yash" # commands as well. Supports AT&T ksh 20100621, yash 2.26. function completion/set { typeset prog="${WORDS[1]##*/}" typeset OPTIONS SOPTIONS LOPTIONS OPTIONS=( #># "o:; specify an option" "--help" ) #<# SOPTIONS=() LOPTIONS=() case $prog in (yash) OPTIONS=("$OPTIONS" #># "--noprofile; don't read the profile file" "--norcfile; don't read the yashrc file" "--profile:; specify the profile file" "--rcfile:; specify the yashrc file" "V --version; print version info" ) #<# ;; (ksh) OPTIONS=("$OPTIONS" #># "D --dump-strings; extract translatable strings" "R:; create a cross reference database in the specified file" "--version" ) #<# ;; esac command -f completion/set::getopt "$prog" typeset i=2 ARGOPT PREFIX while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--|-|++) complete -f return ;; (++*) case $prog in (set|yash) ;; (*) complete -f return ;; esac ;; (-*|+?*) command -f completion/set::checkoption "${WORDS[i]}" false case $ARGOPT in (f) i=$((i+1)) if [ $i -gt ${WORDS[#]} ]; then complete -P "$PREFIX" -f return fi ;; (o) i=$((i+1)) if [ $i -gt ${WORDS[#]} ]; then command -f completion/set::completelongoption return fi ;; esac ;; (*) complete -P "$PREFIX" -f return ;; esac i=$((i+1)) done case $TARGETWORD in ([+-]*) command -f completion/set::checkoption "$TARGETWORD" true case $ARGOPT in (s) command -f completion/set::completeshortoption ;; (o) command -f completion/set::completelongoption ;; (*) complete -P "$PREFIX" -f ;; esac ;; (*) complete -f ;; esac } function completion/set::checkoption { case $1 in (--*|++*) command -f completion/set::checklongoption "$@" ;; (*) command -f completion/set::checkshortoption "$@" ;; esac } function completion/set::checkshortoption { typeset word="${1#[+-]}" while [ "$word" ]; do for opt in ${OPTIONS%%;*}; do case $opt in (?:) case ${word[1]} in ("${opt%:}") case $opt in (o:) ARGOPT=o ;; (*) ARGOPT=f ;; esac if $2; then PREFIX=${1%"${word#?}"} elif [ "${word#?}" ]; then ARGOPT= PREFIX= else PREFIX= fi return esac esac done word=${word#?} done if $2; then ARGOPT=s PREFIX=$1 else ARGOPT= PREFIX= fi } function completion/set::checklongoption { case $prog in (ksh) case $1 in (++*) ARGOPT= PREFIX= return esac esac typeset MATCHES opt word name MATCHES=() word=${1#[+-][+-]} name=${word%%=*} for opt in ${OPTIONS%%;*}; do case $opt in (--*) case ${opt%:} in ("--$name"*) MATCHES=("$MATCHES" "$opt") esac esac done case $prog in (set|yash) name=$(tr -Cd \[:alnum:] <<<$word 2>/dev/null) ;; (ksh) name=$(tr -d _- <<<$word 2>/dev/null) ;; (*) name=$word ;; esac for opt in ${LOPTIONS%%;*}; do for opt in $opt no$opt; do case $opt in ("$name"*) MATCHES=("$MATCHES" "$opt") esac done done if [ ${MATCHES[#]} -eq 1 ]; then case ${MATCHES[1]} in (--*:) case $word in (*=*) if $2; then ARGOPT=f PREFIX=${1%"${1#*=}"} return fi ;; (*) if $2; then ARGOPT=o PREFIX= else ARGOPT=f PREFIX= fi return ;; esac esac fi if $2; then ARGOPT=o PREFIX=${1[1,2]} else ARGOPT= PREFIX= fi } function completion/set::getopt { SOPTIONS=( #># "a; export all variables when assigned" "b; print job status immediately when done" "C; disallow >-redirection to overwrite an existing file" "e; exit immediately when a command's exit status is non-zero" "f; disable pathname expansion (globbing)" "m; enable job control" "n; don't execute any commands" "u; disallow expansion of undefined variables" "v; echo commands entered to the shell" "x; print a command line before executing it" ) #<# LOPTIONS=( #># "allexport; export all variables when assigned" "braceexpand; enable brace expansion" "clobber; allow >-redirection to overwrite an existing file" "emacs; emacs-like line-editing" "errexit; exit immediately when a command's exit status is non-zero" "exec; actually execute commands" "glob; enable pathname expansion (globbing)" "ignoreeof; don't exit when an end-of-file is entered" "markdirs; append a slash to directory names after pathname expansion" "monitor; enable job control" "notify; print job status immediately when done" "unset; allow expansion of undefined variables" "verbose; echo commands entered to the shell" "vi; vi-like line-editing" "xtrace; print a command line before executing it" ) #<# case $prog in (set|yash) SOPTIONS=("$SOPTIONS" #># "h; cache full paths of commands in a function when defined" ) #<# LOPTIONS=("$LOPTIONS" #># "caseglob; make pathname expansion case-sensitive" "curasync; a newly-executed background job becomes the current job" "curbg; a background job becomes the current job when resumed" "curstop; a background job becomes the current job when stopped" "dotglob; don't treat a period at the beginning of a filename specially" "extendedglob; enable recursive pathname expansion" "hashondef; cache full paths of commands in a function when defined" "histspace; don't save a command starting with a space in the history" "leconvmeta; always treat meta-key flags in line-editing" "lenoconvmeta; never treat meta-key flags in line-editing" "levisiblebell; alert with a flash, not a bell" "lepromptsp; ensure the prompt is printed at the beginning of a line" "lealwaysrp; always show the right prompt during line-editing" "lecompdebug; print debugging info during command line completion" "notifyle; print job status immediately when done while line-editing" "nullglob; remove words that matched nothing in pathname expansion" "posix; force strict POSIX conformance" "traceall; print trace of auxiliary commands" ) #<# ;; (ksh) SOPTIONS=("$SOPTIONS" #># "G; enable recursive pathname expansion" "H; enable !-expansion on the command line" "h; cache full paths of commands when entered" "k; allow assignments in the middle of command arguments" "p; work in the privileged mode" "r; work in the restricted mode" "t; execute one command only" ) #<# LOPTIONS=("$LOPTIONS" #># "bgnice; run background jobs at lower priorities" "gmacs; gmacs-like line-editing" "globstar; enable recursive pathname expansion" "histexpand; enable !-expansion on the command line" "keyword; allow assignments in the middle of command arguments" "multiline; allow multiple line editing" "pipefail; return last non-zero exit status of commands in a pipe" "privileged; work in the privileged mode" "restricted; work in the restricted mode" "showme; trace commands preceded by a semicolon" "trackall; cache full paths of commands when entered" "viraw; vi-like line-editing without canonical input handling" ) #<# ;; esac case $prog in (yash|ksh) SOPTIONS=("$SOPTIONS" #># "c; execute the first operand as a shell script" "i; work in the interactive mode" "l; work as a login shell" "s; read commands from the standard input" ) #<# LOPTIONS=("$LOPTIONS" #># "interactive; work in the interactive mode" "login; work as a login shell" ) #<# case $prog in (yash) LOPTIONS=("$LOPTIONS" #># "cmdline; execute the command specified on the command line" "stdin; read commands from the standard input" ) #<# ;; (ksh) SOPTIONS=("$SOPTIONS" #># "E; read the \$ENV file on shell invocation" ) #<# LOPTIONS=("$LOPTIONS" #># "rc; read the \$ENV file on shell invocation" ) #<# ;; esac esac } function completion/set::completeshortoption { typeset opt desc for opt in "$OPTIONS" "$SOPTIONS"; do command -f completion/set::getdesc for opt in ${opt%%;*}; do opt=${opt%:} case $opt in (?) complete -O -P "$PREFIX" ${desc:+-D "$desc"} -- "$opt" esac done done } function completion/set::completelongoption { typeset opt desc part normpart case $TARGETWORD in (--*) for opt in "$OPTIONS"; do command -f completion/set::getdesc for opt in ${opt%%;*}; do case $opt in (--*:) complete -T -P -- ${desc:+-D "$desc"} -- "${{opt#--}%:}=" ;; (--*) complete -P -- ${desc:+-D "$desc"} -- "${opt#--}" ;; esac done done esac part=${TARGETWORD#"$PREFIX"} case $prog in (set|yash) normpart=$(tr -Cd \[:alnum:] <<<$part 2>/dev/null) ;; (ksh) normpart=$(tr -d _- <<<$part 2>/dev/null) ;; (*) normpart=$part ;; esac for opt in "$LOPTIONS"; do command -f completion/set::getdesc opt=${opt%%;*} for opt in $opt no$opt; do case $opt in ("$normpart"*) complete -P "$PREFIX" ${desc:+-D "$desc"} -- "$part${opt#"$normpart"}" esac done done } function completion/set::getdesc { case $opt in (*\;*) desc=${opt#*;} while true; do # trim surrounding spaces case $desc in ([[:space:]]*) desc=${desc#[[:space:]]} ;; (*[[:space:]]) desc=${desc%[[:space:]]} ;; (*) break ;; esac done ;; (*) desc= ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-cherry0000644000175000017500000000077312154557026020030 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-cherry" command. # Supports Git 1.7.7. function completion/git-cherry { WORDS=(git cherry "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::cherry:arg { OPTIONS=( #># "v; print commit subjects" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeref ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/mkfifo0000644000175000017500000000224012154557026017215 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "mkfifo" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/mkfifo { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "m: ${long:+--mode:}; specify the permission of the new FIFO" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "Z: --context:; specify the security context of the new FIFO" "--help" "--version" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "p; make parent directories if necessary" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (m|--mode) if command -vf completion/chmod::mode >/dev/null 2>&1 || . -AL completion/chmod; then command -f completion/chmod::mode mkfifo fi ;; (Z|--context) ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/stty0000644000175000017500000002616712154557026016763 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "stty" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/stty { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a ${long:+--all}; print all the current settings" "g ${long:+--save}; print all the current settings in a reusable format" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "F: --file:; specify the terminal device file" "--help" "--version" ) #<# ;; (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "e; print all the current settings in the traditional BSD format" "f:; specify the terminal device file" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) case $PREFIX in ('') command -f completion//completeoptions esac ;; ([Ff]|--file) complete -P "$PREFIX" -f ;; esac case ${WORDS[-1]} in (eof|eol|eol2|erase|intr|kill|lnext|quit|start|status|stop|swtch|werase) #>># complete -T -D "control character" ^ complete -D "undefined" undef ;; #<<# (cols|columns|[io]speed|line|min|rows|time|[xy]pixels) ;; (*) case $TARGETWORD in (-*) typeset neg=- ;; (*) typeset neg= ;; esac # POSIX operands #>># complete -D "signal INTR on break" -- ${neg}brkint complete -D "backspace delay style" -- bs0 bs1 complete -D "assume a line with modem control" -- ${neg}clocal complete -D "disable raw mode settings" -- ${neg}cooked complete -D "carriage return delay style" -- cr0 cr1 cr2 cr3 complete -D "enable input receiver" -- ${neg}cread complete -D "number of bits transmitted per byte" -- cs5 cs6 cs7 cs8 complete -D "use two stop bits" -- ${neg}cstopb complete -D "echo typed characters" -- ${neg}echo complete -D "make ERASE visually erase a character" -- ${neg}echoe complete -D "echo a newline after KILL" -- ${neg}echok complete -D "always echo newline" -- ${neg}echonl complete -D "reset ERASE and KILL to the default" -- ek complete -D "specify the end of file character" -- eof complete -D "specify the end of line character" -- eol complete -D "specify the erase character" -- erase complete -D "enable even parity mode settings" -- ${neg}evenp ${neg}parity complete -D "form feed delay style" -- ff0 ff1 complete -D "hang up the connection on last close" -- ${neg}hup ${neg}hupcl complete -D "canonical input mode" -- ${neg}icanon complete -D "translate input carriage return to newline" -- ${neg}icrnl complete -D "enable extended functions" -- ${neg}iexten complete -D "ignore input break" -- ${neg}ignbrk complete -D "ignore input carriage return" -- ${neg}igncr complete -D "ignore characters with parity errors" -- ${neg}ignpar complete -D "translate input newline to carriage return" -- ${neg}inlcr complete -D "enable input parity checking" -- ${neg}inpck complete -D "specify the interrupt character" -- intr complete -D "enable INTR, QUIT, SUSP special characters" -- ${neg}isig complete -D "specify input baud rate" -- ispeed complete -D "clear 8th bit of input characters" -- ${neg}istrip complete -D "restart output on any input" -- ${neg}ixany complete -D "send STOP when input buffer is almost full" -- ${neg}ixoff complete -D "enable START/STOP special characters" -- ${neg}ixon complete -D "specify the kill character" -- kill complete -D "specify the MIN value" -- min complete -D "use newline rather than carriage return as line break" -- ${neg}nl complete -D "newline delay style" -- nl0 nl1 complete -D "don't flush after INTR, QUIT, SUSP" -- ${neg}noflsh complete -D "translate output carriage return to newline" -- ${neg}ocrnl complete -D "enable odd parity mode settings" -- ${neg}oddp complete -D "use DEL rather than NUL for fill" -- ${neg}ofdel complete -D "use fill instead of timing for delays" -- ${neg}ofill complete -D "newline works as carriage return on terminal" -- ${neg}onlret complete -D "don't print carriage returns at the first column" -- ${neg}onocr complete -D "enable output post-processing" -- ${neg}opost complete -D "specify output baud rate" -- ospeed complete -D "enable parity handling" -- ${neg}parenb complete -D "mark parity errors" -- ${neg}parmrk complete -D "select odd parity" -- ${neg}parodd complete -D "specify the quit character" -- quit complete -D "enable raw mode settings" -- ${neg}raw complete -D "reset all settings to the normal" -- sane complete -D "specify the start character" -- start complete -D "specify the stop character" -- stop complete -D "specify the suspend character" -- susp complete -D "horizontal tab delay style" -- tab0 tab1 tab2 tab3 complete -D "like tab0" -- tabs complete -D "specify the TIME value" -- time complete -D "send SIGTTOU for background output" -- ${neg}tostop complete -D "vertical tab delay style" -- vt0 vt1 #<<# if [ "$neg" ]; then complete -D "like tab3" -- -tabs fi case $type in (GNU|*BSD|Darwin|SunOS|HP-UX) #>># complete -D "specify screen width" -- columns cols complete -D "specify the delayed suspend character" -- dsusp complete -D "echo control characters in ^-notation" -- ${neg}echoctl complete -D "make KILL visually erase a line" -- ${neg}echoke complete -D "echo erased characters backwards" -- ${neg}echoprt complete -D "specify alternative end of line character" -- eol2 complete -D "specify the literal-next character" -- lnext complete -D "translate output newline to carriage return" -- ${neg}onlcr complete -D "specify screen height" -- rows complete -D "specify the word erase character" -- werase esac #<<# case $type in (GNU|*BSD|Darwin|SunOS) #>># complete -D "enable RTS/CTS flow control" -- ${neg}crtscts esac case $type in (GNU|*BSD|Darwin|HP-UX) #>># complete -D "print screen size" -- size esac #<<# case $type in (GNU|*BSD|Darwin) #>># complete -D "enable cbreak mode settings" -- cbreak complete -D "make ERASE visually erase a character" -- ${neg}crterase complete -D "make KILL visually erase a line" -- ${neg}crtkill complete -D "echo control characters in ^-notation" -- ${neg}ctlecho complete -D "set modes for DEC terminal" -- dec complete -D "like -ixany" -- ${neg}decctlq complete -D "specify the discard character" -- flush complete -D "set modes for literal output" -- ${neg}litout complete -D "set modes for 8-bit characters" -- ${neg}pass8 complete -D "echo erased characters backwards" -- ${neg}prterase complete -D "specify the reprint character" -- rprnt complete -D "send STOP when input buffer is almost full" -- ${neg}tandem esac #<<# case $type in (*BSD|Darwin|SunOS|HP-UX) #>># complete -D "assume output is discarded" -- ${neg}flusho complete -D "keep pending input characters after mode change" -- ${neg}pendin esac case $type in (*BSD|Darwin|SunOS) #>># complete -D "specify the discard character" -- discard complete -D "specify the reprint character" -- reprint esac case $type in (*BSD|Darwin) #>># complete -D "print all the current settings in the traditional BSD format" -- all everything complete -D "use alternative word erase algorithm" -- ${neg}altwerase complete -D "specify the end of line character" -- brk complete -D "set modes for a CRT" -- ${neg}crt ${neg}newcrt complete -D "make ERASE visually erase a character" -- ${neg}crtbs complete -- ${neg}extproc complete -D "enable STATUS special character" -- ${neg}kerninfo complete -D "enable CD hardware flow control on output" -- ${neg}mdmbuf complete -D "translate output tabs to spaces" -- ${neg}oxtabs complete -D "specify baud rate" -- speed complete -D "specify the status character" -- status complete -D "use the standard line discipline" -- tty new old esac #<<# case $type in (GNU|Darwin) #>># complete -D "assume input is in UTF-8" -- ${neg}iutf8 esac #<<# case $type in (FreeBSD|Darwin) #>># complete -D "specify alternative erase character" -- erase2 esac #<<# case $type in (OpenBSD|NetBSD) #>># complete -D "start output" -- ostart complete -D "stop output" -- ostop esac #<<# case $type in (GNU|OpenBSD|SunOS|HP-UX) #>># complete -D "translate input uppercase letters to lowercase" -- ${neg}iuclc complete -D "set modes for uppercase-only terminal" -- ${neg}lcase complete -D "translate output lowercase letters to uppercase" -- ${neg}olcuc complete -D "use canonical upper-/lowercase presentation" -- ${neg}xcase esac #<<# case $type in (GNU|SunOS|HP-UX) #>># complete -D "specify line discipline" -- line complete -D "specify the switch character" -- swtch esac #<<# case $type in (SunOS|HP-UX) #>># complete -D "enable CTS hardware flow control on output" -- ${neg}ctsxon complete -D "enable RTS hardware flow control on input" -- ${neg}rtsxoff complete -D "set modes for TEK terminal" -- tek complete -D "set modes for TI700 terminal" -- ti700 complete -D "set modes for TN300 terminal" -- tn300 complete -- tty33 complete -- tty37 complete -- vt05 esac #<<# case $type in (GNU) #>># complete -D "like echoe echoctl echoke" -- crt complete -D "print baud rate" -- speed ;; #<<# (OpenBSD) #>># complete -D "discard output end-of-file characters" -- ${neg}onoeot ;; #<<# (NetBSD) #>># complete -D "enable DTR/CTS flow control" -- ${neg}cdtrcts complete -D "set all modes to random values" -- insane ;; #<<# (SunOS) #>># complete -D "set normal asynchronous communication settings" -- async complete -D "enable CD hardware flow control on output" -- ${neg}cdxon complete -D "enable input hardware flow control" -- ${neg}crtsxoff complete -- ctab complete -D "set character widths for the current locale" -- ${neg}defeucw complete -D "enable DTR hardware flow control on input" -- ${neg}dtrxoff complete -D "enable isochronous hardware flow control on input" -- ${neg}isxoff complete -D "set modes for mark parity" -- ${neg}markp complete -D "enable extended parity handling" -- ${neg}parext complete -D "get receive clock from internal baud rate generator" -- rcibrg complete -D "receiver signal element timing clock not provided" -- rsetcoff complete -D "set modes for space parity" -- ${neg}spacep complete -D "use application mode on a synchronous line" -- ${neg}stappl complete -D "flush after every write on a synchronous line" -- ${neg}stflush complete -D "wrap long lines on a synchronous line" -- ${neg}stwrap complete -D "transmitter signal element timing clock not provided" -- tsetcoff complete -D "get transmit clock from internal baud rate generator" -- xcibrg complete -D "specify horizontal screen size" -- xpixels complete -D "specify vertical screen size" -- ypixels ;; #<<# (HP-UX) #>># complete -D "enable request-to-send" -- ${neg}crts complete -D "set modes for HP terminal" -- hp complete -D "enable ENQ-ACK handshaking" -- ${neg}ienqak complete -D "block output from non-current layer" -- ${neg}loblk ;; #<<# esac ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/rgview0000644000175000017500000000030612154557026017246 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "rgview" command. # Supports Vim 7.3. function completion/rgview { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/wc0000644000175000017500000000240712154557026016360 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "wc" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/wc { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c ${long:+--bytes}; print byte counts" "l ${long:+--lines}; print line counts" "m ${long:+--chars}; print character counts" "w ${long:+--words}; print word counts" ) #<# case $type in (GNU|FreeBSD|NetBSD) OPTIONS=("$OPTIONS" #># "L ${long:+--max-line-length}; print longest line lengths" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "--files0-from:; specify a file containing null-separated file names to count size" "--help" "--version" ) #<# esac ;; (OpenBSD) OPTIONS=("$OPTIONS" #># "h; print size using K, M, etc. for 1024^n" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gnutar0000644000175000017500000000026712154557026017251 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "gnutar" command. function completion/gnutar { command -f completion//reexecute tar } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-log0000644000175000017500000000323512154557026017311 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-log" command. # Supports Git 1.7.7. function completion/git-log { WORDS=(git log "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::log:arg { OPTIONS=() command -f completion/git::log:getopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completerefpath range=true ;; (*) command -f completion/git::log:compopt ;; esac } function completion/git::log:getopt { OPTIONS=("$OPTIONS" #># "--bisect; show commits between good and bad only" "--decorate::; show ref names of commits" "--follow; show history beyond filename renaming" "--full-diff; show diffs for all files affected in each commit" "--log-size; print its size before printing log messages" "--no-decorate; like --decorate=no" "--source; show from which ref each commit was reached" ) #<# if command -vf completion/git::rev-list:getopt >/dev/null 2>&1 || . -AL completion/git-rev-list; then command -f completion/git::rev-list:getopt fi if command -vf completion/git::diff-tree:getopt >/dev/null 2>&1 || . -AL completion/git-diff-tree; then command -f completion/git::diff-tree:getopt fi } function completion/git::log:compopt { case $ARGOPT in (--decorate) #>># complete -P "$PREFIX" -D "show full ref names" full complete -P "$PREFIX" -D "show ref names without prefixes" short complete -P "$PREFIX" -D "don't show ref names" no ;; #<<# (*) command -f completion/git::rev-list:compopt || command -f completion/git::diff:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/[0000644000175000017500000000026212154557026016156 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "[" built-in command. function completion/[ { command -f completion//reexecute test } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/xargs0000644000175000017500000000504212154557026017071 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "xargs" command. # Supports POSIX 2008, GNU findutils 4.5.9, FreeBSD 8.1, OpenBSD 4.8, # NetBSD 5.0, Darwin 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/xargs { case $("${WORDS[1]}" --version 2>/dev/null) in (*'findutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac case $type in (GNU|SunOS|HP-UX) typeset short=true ;; (*) typeset short= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "E: ${short:+e::} ${long:+--eof::}; specify a string to treat as end of input" "I: ${short:+i::} ${long:+--replace::}; specify a string replaced by input words" "L: ${short:+l::} ${long:+--max-lines::}; specify the max number of input lines to use at once" "n: ${long:+--max-args:}; specify the max number of input words to use at once" "p ${long:+--interactive}; confirm before each command invocation" "s: ${long:+--max-chars:}; specify the max length of executed command lines in bytes" "t ${long:+--verbose}; print each executed command line before execution" "x ${long:+--exit}; abort when executed command line length exceeds the limit" ) #<# case $type in (GNU|*BSD|Darwin) OPTIONS=("$OPTIONS" #># "0 ${long:+--null}; assume input words are separated by null bytes" "P: ${long:+--max-procs:}; specify the max number of commands executed at once" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "a: --arg-file:; specify the file to read words from" "d: --delimiter:; specify the delimiter that separates words" "--help" "--version" ) #<# esac case $type in (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "J:; like -I, but replace the first exact match only" "o; reopen standard input as /dev/tty when executing commands" "R:; specify the max number of operands replaced in -I" ) #<# case $type in (FreeBSD|NetBSD) OPTIONS=("$OPTIONS" #># "S:; specify how long the command line can grow in -I" ) #<# esac esac case $type in (GNU|OpenBSD) OPTIONS=("$OPTIONS" #># "r ${long:+--no-run-if-empty}; don't execute the command at all if input is empty" ) #<# esac esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ([dEeIiJLlnPRSs]|--delimiter|--eof|--replace|--max-*) ;; (a|--arg-file) complete -P "$PREFIX" -f ;; ('') command -f completion//getoperands command -f completion//reexecute -e ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/sudoedit0000644000175000017500000000035312154557026017565 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "sudoedit" command. # Supports sudo 1.8.0. function completion/sudoedit { WORDS=(sudo -e "${WORDS[2,-1]}") command -f completion//reexecute } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/fg0000644000175000017500000000026412154557026016342 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "fg" built-in command. function completion/fg { command -f completion//reexecute jobs } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/svn0000644000175000017500000006022512154557026016557 0ustar magicantmagicant# (C) 2011-2012 magicant # Completion script for the "svn" command. # Supports Subversion 1.7. function completion/svn { typeset OPTIONS COMMONOPTIONS ADDOPTIONS ARGOPT PREFIX COMMONOPTIONS=( #># "--config-dir:; specify a directory containing configuration files" "--config-option:; specify a configuration option" "h ? --help; print help" "--no-auth-cache; don't cache user name and password" "--non-interactive; disable interactive prompt" "--password:; specify a password for authentication" "--trust-server-cert; accept suspicious SSL server certificate" "--username:; specify a user name for authentication" ) #<# ADDOPTIONS=( #># "--accept:; specify an action for conflict resolution" "--allow-mixed-revisions" # not documented as not recommended "--auto-props; enable automatic property setting" "c: --change:; specify a change (revision)" "--changelist: --cl:; specify a changelist to operate on" "--depth:; specify directory depth to operate on" "--diff; show diff" "--diff-cmd:; specify an external program to be used as \"diff\"" "--diff3-cmd:; specify an external program to be used as \"diff3\"" "--dry-run; don't make any actual changes" "--editor-cmd:; specify an external program to be used as an editor" "--encoding:; specify the encoding of the log message" "x: --extensions:; specify arguments that is passed to the external diff command" "F: --file:; use the specified file's contents instead of invoking an editor" "--force; force operation to run" "--force-log; accept a suspicious parameter value for log messages" "--git; print in Git-like format" "--ignore-ancestry; ignore ancestry when calculating differences" "--ignore-externals; ignore externals and its working copies" "--ignore-whitespace; tolerate whitespace mismatches" "--incremental; print output in a format suitable for concatenation" "--keep-changelists; don't delete changelists after committing" "--keep-local; keep the local working copy" "l: --limit:; specify the number of log messages to be shown" "m: --message:; specify a log message" "--native-eol:; specify an end-of-line marker for native EOL settings" "--new:; specify the newer one of the compared files" "--no-auto-props; disable automatic property setting" "--no-diff-deleted; don't print diff for deleted files" "--no-ignore; don't ignore files" "--no-unlock; don't unlock files after committing" #deprecated "N --non-recursive" "--notice-ancestry; take ancestry into account when making a diff" "--old:; specify the older one of the compared files" "--parents; create nonexistent parent directories" "q --quiet; print essential information only" "--record-only; update mergeinfo without actually merging files" "R --recursive; operate on subdirectories recursively" "--reintegrate; merge a branch into the trunk" "--relocate; change the location of the repository" "--remove; remove files from a changelist" "--reverse-diff; patch in reverse" "r: --revision:; specify a revision or a revision range" "--revprop; operate on a revision property rather than a file property" "--set-depth:; specify a new sticky depth of working directories" "--show-copies-as-adds; treat copied files as newly added" "--show-revs:; specify the type of mergeinfo to print" "--show-updates; show which files will be updated by \"svn update\"" "--stop-on-copy; operate on revisions after the file was copied last" "--strict; output the raw value without pretty-formatting" "--strip:; specify the number of pathname components to strip from file names" "--summarize; print a summary of changes only" "--targets:; specify a file containing target paths" "g --use-merge-history; use mergeinfo to show history before merges" "v --verbose; print additional info" "--version" "--with-all-revprops; include all revision properties" "--with-no-revprops; include no revision properties" "--with-revprop:; specify a revision property to set or print" "--xml; print in the XML format" ) #<# OPTIONS=("$COMMONOPTIONS" "$ADDOPTIONS") command -f completion//parseoptions -es # find subcommand name typeset SUBCMD= separatorindex=2 while [ $separatorindex -lt ${WORDS[#]} ]; do case ${WORDS[separatorindex]} in (--) SUBCMD=${WORDS[separatorindex+1]} break esac separatorindex=$((separatorindex+1)) done # normalize subcommand name case $SUBCMD in (praise|annotate|ann) SUBCMD=blame;; (cl) SUBCMD=changelist;; (co) SUBCMD=checkout;; (ci) SUBCMD=commit;; (cp) SUBCMD=copy;; (del|remove|rm) SUBCMD=delete;; (di) SUBCMD=diff;; (h|\?) SUBCMD=help;; (ls) SUBCMD=list;; (mv|rename|ren) SUBCMD=move;; (pdel|pd) SUBCMD=propdel;; (pedit|pe) SUBCMD=propedit;; (pget|pg) SUBCMD=propget;; (plist|pl) SUBCMD=proplist;; (pset|ps) SUBCMD=propset;; (stat|st) SUBCMD=status;; (sw) SUBCMD=switch;; (up) SUBCMD=update;; esac case $ARGOPT in (-) OPTIONS=("$COMMONOPTIONS") if command -vf "completion/svn::$SUBCMD:opt" >/dev/null 2>&1; then command -f "completion/svn::$SUBCMD:opt" fi command -f completion//completeoptions ;; (--accept) #>># complete -P "$PREFIX" -D "discard all local and remote changes" base complete -P "$PREFIX" -D "discard all remote changes" mine-full complete -P "$PREFIX" -D "resolve conflicts by discarding remote changes" mine-conflict complete -P "$PREFIX" -D "discard all local changes" theirs-full complete -P "$PREFIX" -D "resolve conflicts by discarding local changes" theirs-conflict complete -P "$PREFIX" -D "mark the current working copy as resolved" working case $SUBCMD in (resolve) ;; (*) complete -P "$PREFIX" -D "launch an editor to merge by hand" edit complete -P "$PREFIX" -D "launch a predefined external program" launch complete -P "$PREFIX" -D "leave the conflict unresolved" postpone ;; esac ;; #<<# # (c|--change) # ;; (--changelist|--cl) command -f completion/svn::completechangelist ;; (--config-dir) complete -P "$PREFIX" -S / -T -d ;; (--config-option) #TODO ;; (--depth|--set-depth) #>># complete -P "$PREFIX" -D "only the target itself" empty complete -P "$PREFIX" -D "the target and non-directory immediate children" files complete -P "$PREFIX" -D "the target and immediate children" immediates complete -P "$PREFIX" -D "the target and all of its descendants" infinity #<<# case $ARGOPT in (--set-depth) #>># complete -P "$PREFIX" -D "exclude the target from the parent" exclude esac #<<# ;; (--encoding) #TODO ;; (x|--extensions) WORDS=(diff) command -f completion//reexecute ;; (F|--file) complete -P "$PREFIX" -f ;; # (l|--limit) # ;; # (m|--message) # ;; # (--password) # ;; (--native-eol) #>># complete -P "$PREFIX" LF CR CRLF ;; #<<# (--new|--old) command -f completion/svn::completelocal -cm command -f completion/svn::completeurl ;; (r|--revision) typeset word="${TARGETWORD#"$PREFIX"}" PREFIX="${TARGETWORD%"${word#*:}"}" #>># complete -P "$PREFIX" -D "the latest revision in the repository" HEAD complete -P "$PREFIX" -D "the revision you checked out" BASE complete -P "$PREFIX" -D "the latest revision in which a change was made" COMMITTED complete -P "$PREFIX" -D "the revision immediately before COMMITTED" PREV ;; #<<# (--show-revs) #>># complete -P "$PREFIX" -D "info about merges already performed" merged complete -P "$PREFIX" -D "info about possible merges that can be performed" eligible ;; #<<# (--target) complete -P "$PREFIX" -f ;; (--username) complete -P "$PREFIX" -u ;; (--with-revprop) #TODO ;; (--*-cmd) WORDS=() command -f completion//reexecute -e ;; ('') if [ $separatorindex -eq ${WORDS[#]} ] || command -f completion/svn::containshelp; then command -f completion/svn::completesubcmd else if command -vf "completion/svn::$SUBCMD:arg" >/dev/null 2>&1; then command -f "completion/svn::$SUBCMD:arg" fi fi ;; esac } function completion/svn::containshelp { typeset opt for opt in "${WORDS[2,separatorindex-1]}"; do case $opt in (--help|-[h\?]) return 0 esac done return 1 } function completion/svn::setoptions { typeset opt i=1 for opt in "$ADDOPTIONS"; do if [ $# -le 0 ]; then break fi case " ${{opt%%;*}//:} " in (*" --$1 "*) OPTIONS=("$OPTIONS" "$opt") shift esac done } function completion/svn::completesubcmd { complete -P "$PREFIX" -D "add files for versioning" add complete -P "$PREFIX" -D "show files with author and revision info" blame praise annotate complete -P "$PREFIX" -D "print the contents of files" cat complete -P "$PREFIX" -D "put files into a changelist" changelist cl complete -P "$PREFIX" -D "check out a working copy from a repository" checkout co complete -P "$PREFIX" -D "resolve file locks and unfinished operations" cleanup complete -P "$PREFIX" -D "make a new revision in the repository" commit ci complete -P "$PREFIX" -D "copy a file" copy cp complete -P "$PREFIX" -D "delete files" delete remove rm complete -P "$PREFIX" -D "print differences between two files or revisions" diff complete -P "$PREFIX" -D "make a copy of the versioned directory tree" export complete -P "$PREFIX" -D "print usage of subcommands" help complete -P "$PREFIX" -D "commit new files into the repository" import complete -P "$PREFIX" -D "print info about versioned files" info complete -P "$PREFIX" -D "print a list of versioned files" list ls complete -P "$PREFIX" -D "lock files in the repository" lock complete -P "$PREFIX" -D "print commit log messages" log complete -P "$PREFIX" -D "apply changes between two files or revisions" merge complete -P "$PREFIX" -D "print info about merge" mergeinfo complete -P "$PREFIX" -D "make directories" mkdir complete -P "$PREFIX" -D "move files" move mv complete -P "$PREFIX" -D "apply a patch" patch complete -P "$PREFIX" -D "delete a property of files" propdel pdel complete -P "$PREFIX" -D "edit a property of files" propedit pedit complete -P "$PREFIX" -D "print a property of files" propget pget complete -P "$PREFIX" -D "print properties of files" proplist plist complete -P "$PREFIX" -D "set a property of files" propset pset complete -P "$PREFIX" -D "change the repository root URL" relocate complete -P "$PREFIX" -D "resolve conflicts" resolve # deprecated: complete -P "$PREFIX" -D "" resolved complete -P "$PREFIX" -D "undo local edits" revert complete -P "$PREFIX" -D "print the status of working copy" status complete -P "$PREFIX" -D "update working copy to a different URL" switch complete -P "$PREFIX" -D "unlock files in the repository" unlock complete -P "$PREFIX" -D "update the working copy" update complete -P "$PREFIX" -D "upgrade the working copy format" upgrade } function completion/svn::completeurl { typeset OPTIND=1 opt dironly=false while getopts d opt; do case $opt in (d) dironly=true;; esac done typeset target="${TARGETWORD#"$PREFIX"}" case $target in (?*://* | ^/*) ;; (*) return ;; esac typeset targetdir="$(dirname -- "$target"X)" typeset file prefix="${TARGETWORD%"${TARGETWORD##*/}"}" while read -r file; do case $file in (*/) complete -P "$prefix" -T -- "$file" ;; (*) if ! $dironly; then complete -P "$prefix" -- "$file" fi ;; esac done <(svn --non-interactive ls -- "${targetdir}/" 2>/dev/null) } function completion/svn::completelocal { typeset OPTIND=1 opt clean= modified= unversioned= while getopts cmu opt; do case $opt in (c) clean=true;; (m) modified=true;; (u) unversioned=true;; esac done complete -P "$PREFIX" -S / -T -d case "$clean-$modified-$unversioned" in (true-true-true) complete -P "$PREFIX" -f return ;; (--) return ;; esac typeset target="${TARGETWORD#"$PREFIX"}" typeset targetdir="$(dirname -- "$target"X)" if ! command -f completion/svn::isworkingdir "$targetdir"; then if [ "$unversioned" ]; then complete -P "$PREFIX" -f fi return fi typeset path prefix opt while read -r path; do if [ "$path" -ef "$targetdir" ]; then continue fi case $target in (*/*) prefix="$PREFIX${target%/*}/" ;; (*) prefix="$PREFIX" ;; esac complete -P "$prefix" -- "${path##*/}" done 2>/dev/null <( if [ "$unversioned" ]; then svn st --depth=files --no-ignore -- "$targetdir" | grep '^[?I]' | cut -c 9- fi if [ "$clean$modified" ]; then case $clean-$modified in (true-true) regex='^[^?I]';; (true- ) regex='^ ';; ( -true) regex='^[^ ?I]|^.[^ ]';; esac svn st -v --depth=files -- "$targetdir" | grep -E "$regex" | cut -c 10- | while read -r _ _ _ file; do printf '%s\n' "$file" done fi ) # XXX should honor the dotglob option } function completion/svn::completepropname { #>># complete -P "$PREFIX" -D "make the file executable" svn:executable complete -P "$PREFIX" -D "specify the file's MIME type" svn:mime-type complete -P "$PREFIX" -D "specify unversioned filenames not listed in status" svn:ignore complete -P "$PREFIX" -D "specify keywords substituted in file" svn:keywords complete -P "$PREFIX" -D "specify how end-of-line markers are manipulated" svn:eol-style complete -P "$PREFIX" -D "specify external paths and repositories" svn:externals complete -P "$PREFIX" -D "indicate that the file is not a regular file" svn:special complete -P "$PREFIX" -D "disable editing without lock" svn:needs-lock complete -P "$PREFIX" -D "info about merge" svn:mergeinfo } #<<# function completion/svn::completechangelist { typeset changelist while read -r changelist; do changelist=${changelist%\':} changelist=${changelist##*\'} complete -P "$PREFIX" "$changelist" done 2>/dev/null <(svn status | grep "^--- .*'.*':\$") } function completion/svn::isworkingdir ( cd -P -- "$1" 2>/dev/null && until [ -d .svn ]; do if [ . -ef .. ] || [ . -ef / ]; then return 1 fi cd -P .. done ) function completion/svn:::opt { command -f completion/svn::setoptions version } function completion/svn::add:opt { command -f completion/svn::setoptions \ auto-props depth force no-auto-props no-ignore parents quiet \ targets } function completion/svn::add:arg { command -f completion/svn::completelocal -u } function completion/svn::blame:opt { command -f completion/svn::setoptions \ extensions force incremental revision use-merge-history \ verbose xml } function completion/svn::blame:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::cat:opt { command -f completion/svn::setoptions revision } function completion/svn::cat:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::changelist:opt { command -f completion/svn::setoptions \ changelist depth quiet recursive remove targets } function completion/svn::changelist:arg { typeset i=2 remove=false while [ $i -lt $separatorindex ]; do case ${WORDS[i]} in (--remove) remove=true;; esac i=$((i+1)) done if ! $remove && [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then command -f completion/svn::completechangelist else command -f completion/svn::completelocal -cm fi } function completion/svn::checkout:opt { command -f completion/svn::setoptions \ depth force ignore-externals quiet revision } function completion/svn::checkout:arg { command -f completion/svn::completeurl if [ $(($separatorindex+1)) -lt ${WORDS[#]} ]; then complete -P "$PREFIX" -f fi } function completion/svn::cleanup:opt { command -f completion/svn::setoptions diff3-cmd } function completion/svn::cleanup:arg { complete -P "$PREFIX" -S / -T -d } function completion/svn::commit:opt { command -f completion/svn::setoptions \ changelist depth editor-cmd encoding file force-log \ kee-changelists message no-unlock quiet targets with-revprop } function completion/svn::commit:arg { command -f completion/svn::completelocal -m } function completion/svn::copy:opt { command -f completion/svn::setoptions \ editor-cmd encoding file force-log ignore-externals message \ parents quiet revision with-revprop } function completion/svn::copy:arg { command -f completion/svn::completelocal -cmu command -f completion/svn::completeurl } function completion/svn::delete:opt { command -f completion/svn::setoptions \ editor-cmd encoding file force force-log keep-local \ message quiet targets with-revprop } function completion/svn::delete:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::diff:opt { command -f completion/svn::setoptions \ change changelist depth diff-cmd extensions force git new \ no-diff-deleted notice-ancestry old revision \ show-copies-as-adds summarize xml } function completion/svn::diff:arg { # XXX should be relative to the argument of --old=... command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::export:opt { command -f completion/svn::setoptions \ depth force ignore-externals native-eol quiet revision } function completion/svn::export:arg { case $((${WORDS[#]} - $separatorindex)) in (1) command -f completion/svn::completelocal -cm command -f completion/svn::completeurl ;; (2) complete -P "$PREFIX" -f ;; esac } function completion/svn::help:opt { } function completion/svn::help:arg { command -f completion/svn::completesubcmd } function completion/svn::import:opt { command -f completion/svn::setoptions \ auto-props depth editor-cmd encoding file force force-log \ message no-auto-props no-ignore quiet with-revprop } function completion/svn::import:arg { case $((${WORDS[#]} - $separatorindex)) in (1) command -f completion/svn::completelocal -u ;; (2) command -f completion/svn::completeurl ;; esac } function completion/svn::info:opt { command -f completion/svn::setoptions \ changelist depth incremental recursive revision targets xml } function completion/svn::info:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::list:opt { command -f completion/svn::setoptions \ depth incremental recursive revision verbose xml } function completion/svn::list:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::lock:opt { command -f completion/svn::setoptions \ encoding file force force-log message targets } function completion/svn::lock:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::log:opt { command -f completion/svn::setoptions \ change incremental limit quiet revision stop-on-copy targets \ use-merge-history verbose with-all-revprops with-no-revprops \ with-revprop xml } function completion/svn::log:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::merge:opt { command -f completion/svn::setoptions \ accept allow-mixed-revisions change depth diff3-cmd dry-run \ extensions force ignore-ancestry quiet record-only reintegrate \ revision } function completion/svn::merge:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::mergeinfo:opt { command -f completion/svn::setoptions revision show-revs } function completion/svn::mergeinfo:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::mkdir:opt { command -f completion/svn::setoptions editor-cmd encoding file \ force-log message parents quiet with-revprop } function completion/svn::mkdir:arg { complete -P "$PREFIX" -S / -T -d command -f completion/svn::completeurl -d } function completion/svn::move:opt { command -f completion/svn::setoptions editor-cmd encoding file force \ force-log message parents quiet revision with-revprop } function completion/svn::move:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::patch:opt { command -f completion/svn::setoptions \ dry-run ignore-whitespace quiet reverse-diff strip } function completion/svn::patch:arg { if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then complete -P "$PREFIX" -f else complete -P "$PREFIX" -S / -T -d fi } function completion/svn::propdel:opt { command -f completion/svn::setoptions \ changelist depth quiet recursive revision revprop } function completion/svn::propdel:arg { if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then command -f completion/svn::completepropname else command -f completion/svn::completelocal -cm command -f completion/svn::completeurl fi } function completion/svn::propedit:opt { command -f completion/svn::setoptions editor-cmd encoding file force \ force-log message revision revprop with-revprop } function completion/svn::propedit:arg { if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then command -f completion/svn::completepropname else command -f completion/svn::completelocal -cm command -f completion/svn::completeurl fi } function completion/svn::propget:opt { command -f completion/svn::setoptions \ changelist depth recursive revision revprop strict verbose xml } function completion/svn::propget:arg { if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then command -f completion/svn::completepropname else command -f completion/svn::completelocal -cm command -f completion/svn::completeurl fi } function completion/svn::proplist:opt { command -f completion/svn::setoptions \ changelist depth quiet recursive revision revprop verbose xml } function completion/svn::proplist:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::propset:opt { command -f completion/svn::setoptions changelist depth encoding file \ force quiet recursive revision revprop targets } function completion/svn::propset:arg { typeset i=2 hasfile=false while [ $i -lt $separatorindex ]; do case ${WORDS[i]} in (--file=*|-F*) hasfile=true;; esac i=$((i+1)) done if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then command -f completion/svn::completepropname elif ! $hasfile && [ $(($separatorindex+2)) -eq ${WORDS[#]} ]; then # there is no completion for a property value else command -f completion/svn::completelocal -cm command -f completion/svn::completeurl fi } function completion/svn::relocate:opt { command -f completion/svn::setoptions ignore-externals } function completion/svn::relocate:arg { command -f completion/svn::switch:arg "$@" } function completion/svn::resolve:opt { command -f completion/svn::setoptions \ accept depth quiet recursive targets } function completion/svn::resolve:arg { command -f completion/svn::completelocal -cm } function completion/svn::resolved:opt { command -f completion/svn::setoptions \ depth quiet recursive targets } function completion/svn::resolved:arg { command -f completion/svn::completelocal -cm } function completion/svn::revert:opt { command -f completion/svn::setoptions \ changelist depth quiet recursive targets } function completion/svn::revert:arg { command -f completion/svn::completelocal -m } function completion/svn::status:opt { command -f completion/svn::setoptions \ changelist depth ignore-externals incremental no-ignore quiet \ show-updates verbose xml } function completion/svn::status:arg { command -f completion/svn::completelocal -cm } function completion/svn::switch:opt { command -f completion/svn::setoptions \ accept depth diff3-cmd force ignore-externals ignore-ancestry \ quiet relocate revision set-depth } function completion/svn::switch:arg { if [ $(($separatorindex+1)) -lt ${WORDS[#]} ]; then complete -P "$PREFIX" -S / -T -d fi command -f completion/svn::completeurl } function completion/svn::unlock:opt { command -f completion/svn::setoptions force targets } function completion/svn::unlock:arg { command -f completion/svn::completelocal -cm command -f completion/svn::completeurl } function completion/svn::update:opt { command -f completion/svn::setoptions \ accept changelist depth diff3-cmd editor-cmd force \ ignore-externals parents quiet revision set-depth } function completion/svn::update:arg { command -f completion/svn::completelocal -cm } function completion/svn::upgrade:opt { command -f completion/svn::setoptions quiet } function completion/svn::upgrade:arg { complete -P "$PREFIX" -S / -T -d } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ulimit0000644000175000017500000000470012154557026017250 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "ulimit" built-in command. function completion/ulimit { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "H --hard; set or print the hard limit" "S --soft; set or print the soft limit" "a --all; print all resource types with the current limits" "--help" ) #<# typeset limits="$(command -b ulimit -a 2>/dev/null)" case $limits in (*'-c: '*) OPTIONS=("$OPTIONS" #># "c --core; maximum size of core files in 512-byte blocks" ) #<# esac case $limits in (*'-d: '*) OPTIONS=("$OPTIONS" #># "d --data; maximum size of a process's data segment in kilobytes" ) #<# esac case $limits in (*'-e: '*) OPTIONS=("$OPTIONS" #># "e --nice; maximum scheduling priority (nice value)" ) #<# esac case $limits in (*'-f: '*) OPTIONS=("$OPTIONS" #># "f --fsize; maximum size of files created by a process in 512-byte blocks" ) #<# esac case $limits in (*'-i: '*) OPTIONS=("$OPTIONS" #># "i --sigpending; maximum number of pending signals" ) #<# esac case $limits in (*'-l: '*) OPTIONS=("$OPTIONS" #># "l --memlock; maximum memory size that can be locked into RAM (in kilobytes)" ) #<# esac case $limits in (*'-m: '*) OPTIONS=("$OPTIONS" #># "m --rss; maximum size of a process's resident set (in kilobytes)" ) #<# esac case $limits in (*'-n: '*) OPTIONS=("$OPTIONS" #># "n --nofile; maximum file descriptor + 1" ) #<# esac case $limits in (*'-q: '*) OPTIONS=("$OPTIONS" #># "q --msgqueue; maximum size of POSIX message queues (in bytes)" ) #<# esac case $limits in (*'-r: '*) OPTIONS=("$OPTIONS" #># "r --rtprio; maximum real-time scheduling priority" ) #<# esac case $limits in (*'-s: '*) OPTIONS=("$OPTIONS" #># "s --stack; maximum stack size (in kilobytes)" ) #<# esac case $limits in (*'-t: '*) OPTIONS=("$OPTIONS" #># "t --cpu; CPU time that can be used by a process (in seconds)" ) #<# esac case $limits in (*'-u: '*) OPTIONS=("$OPTIONS" #># "u --nproc; maximum number of processes for a user" ) #<# esac case $limits in (*'-v: '*) OPTIONS=("$OPTIONS" #># "v --as; maximum size of memory used by a process (in kilobytes)" ) #<# esac case $limits in (*'-x: '*) OPTIONS=("$OPTIONS" #># "x --locks; maximum number of file locks" ) #<# esac command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) #>># complete unlimited ;; #<<# esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/grep0000644000175000017500000001106312154557026016702 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "grep" command. # Supports POSIX 2008, GNU grep 2.6.3, SunOS 5.10, HP-UX 11i v3. function completion/grep { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU grep'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "c ${long:+--count}; print only the count of selected lines" "E ${long:+--extended-regexp}; use extended regular expression" "e: ${long:+--regexp:}; specify a pattern to match" "F ${long:+--fixed-strings}; perform simple string matching rather than regular expression" "f: ${long:+--file:}; specify a file containing patterns to match" "i ${long:+--ignore-case}; case-insensitive matching" "l ${long:+--files-with-matches}; print filenames only" "n ${long:+--line-number}; print line numbers" "q ${long:+--quiet --silent}; don't print anything to the standard output" "s ${long:+--no-messages}; suppress error messages" "v ${long:+--invert-match}; select non-matching lines" "x ${long:+--line-regexp}; force the pattern to match whole lines only" ) #<# ADDOPTIONS=() case $type in (GNU|SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "h ${long:+--no-filename}; never print filenames in results" "w ${long:+--word-regexp}; force the pattern to match whole words only" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "A: --after-context:; print specified number of lines after each line printed" "a --text; treat binary files as test files" "B: --before-context:; print specified number of lines before each line printed" "b --byte-offset; print byte offset for each line printed" "C: --context:; print specified number of lines before and after each line printed" "D: --devices:; specify how to handle special files" "d: --directories:; specify how to handle directories" "G --basic-regexp; use basic regular expression" "H --with-filename; always print the filename for each line printed" "I; assume binary files don't match anything" "L --files-without-match; print only the names of files containing no selected lines" "m: --max-count:; specify the count to match at most" "o --only-matching; print only the matching part of line" "P --perl-regexp; use Perl's regular expression" "R r --recursive; recursively search directories" "T --initial-tab; align result lines" "U --binary; don't convert CR-LF into LF" "u --unix-byte-offsets; report offsets ignoring carriage returns" "V --version; print version info" "Z --null; print a null byte after each filename" "z --null-data; separate output lines with null byte rather than newline" "--binary-files:; specify how to handle binary files" "--color:: --colour::; specify when to print colored output" "--exclude:; skip files whose names match the specified pattern" "--exclude-dir:; skip directories whose names match the specified pattern" "--exclude-from:; skip files whose names match a pattern in the specified file" "--include:; search only files whose names match the specified pattern" "--label:; specify a filename for the standard output" "--line-buffered; print results as soon as possible" "--help" ) #<# ;; (SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "b; print 512-block offset for each line printed" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([ABCm]|--*context|--max-count) ;; (--binary-files) #>># complete -P "$PREFIX" -D "report but don't print the contents of binary files" binary complete -P "$PREFIX" -D "assume binary files don't match anything" without-match complete -P "$PREFIX" -D "treat binary files as test files" text ;; #<<# (--color|--colour) #>># complete -P "$PREFIX" -D "always print in color" yes always force complete -P "$PREFIX" -D "print in color if output is terminal" auto tty if-tty complete -P "$PREFIX" -D "don't print in color" no never none ;; #<<# (D|--devices) #>># complete -P "$PREFIX" -D "treat special files as regular files" read complete -P "$PREFIX" -D "skip special files" skip ;; #<<# (d|--directories) #>># complete -P "$PREFIX" -D "treat directories as regular files" read complete -P "$PREFIX" -D "recursively search directories" recurse complete -P "$PREFIX" -D "skip directories" skip ;; #<<# (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/readonly0000644000175000017500000000030312154557026017555 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "readonly" built-in command. function completion/readonly { command -f completion//reexecute typeset } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/chsh0000644000175000017500000000212612154557026016672 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "chsh" command. # Supports util-linux 2.18, FreeBSD 8.1, OpenBSD 4.9, NetBSD 5.0, # Mac OS X 10.6.4, HP-UX 11i v3. function completion/chsh { case $(uname 2>/dev/null) in (Linux) typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "s: --shell:; specify the new shell" "l --list-shells; print available shells" "u --help; print help" "v --version; print version into" ) #<# ;; (*BSD|Darwin) command -f completion//reexecute chpass return ;; (HP-UX) typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "r:; specify the repository to operate on" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (r) complete -P "$PREFIX" dce files nis ;; (s|--shell) complete -P "$PREFIX" -- $(grep -v ^# /etc/shells 2>/dev/null) ;; (*) command -f completion//getoperands case ${WORDS[#]} in (0) complete -u ;; (*) complete -P "$PREFIX" -- $(grep -v ^# /etc/shells 2>/dev/null) ;; esac ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/_bsd0000644000175000017500000000207212154557026016654 0ustar magicantmagicant# (C) 2011 magicant # This file contains auxiliary functions that handle BSD-specific features. # This function completes authentication methods function completion//bsd::completeauthmethod { # TODO description #>># complete -P "$PREFIX" activ complete -P "$PREFIX" chpass complete -P "$PREFIX" crypto complete -P "$PREFIX" krb5 complete -P "$PREFIX" krb5-or-pwd complete -P "$PREFIX" lchpass complete -P "$PREFIX" passwd complete -P "$PREFIX" radius complete -P "$PREFIX" reject complete -P "$PREFIX" rpasswd complete -P "$PREFIX" skey complete -P "$PREFIX" snk complete -P "$PREFIX" token #<<# } # This function completes authentication classes function completion//bsd::completeauthclass { typeset classes while IFS='|' read -rA classes; do case ${classes[#]} in (0) ;; (1) complete -P "$PREFIX" -- "${classes[1]}" ;; (*) complete -P "$PREFIX" -D "${classes[-1]}" -- "${classes[1,-2]}" ;; esac done <(sed -e ' /^#/ d :b /\\$/ { N bb } s/\\\n//g s/[:].*$// ' /etc/login.conf 2>/dev/null) } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/trap0000644000175000017500000000123212154557026016710 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "trap" built-in command. function completion/trap { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "p --print; print current trap settings" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) typeset i=1 print=false while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i++]} in (-p|--print) print=true ;; (--) break ;; esac done if $print || [ $i -le ${WORDS[#]} ]; then complete --signal complete -P "$PREFIX" EXIT else complete -T -c fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/disown0000644000175000017500000000027412154557026017252 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "disown" built-in command. function completion/disown { command -f completion//reexecute jobs } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ssh-agent0000644000175000017500000000132712154557026017640 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "ssh-agent" command. # Supports OpenSSH 6.2. function completion/ssh-agent { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a:; specify the pathname of the UNIX-domain socket used to communicate with the agent" "c; output shell commands for csh" "d; debug mode" "k; kill the current agent" "s; output shell commands for sh" "t:; specify the default lifetime of identities" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (a) complete -P "$PREFIX" -f ;; (t) ;; (*) command -f completion//getoperands command -f completion//reexecute ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/expand0000644000175000017500000000164012154557026017224 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "expand" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/expand { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "t: ${long:+--tabs:}; specify a tab width or a list of tab positions" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "i --initial; only expand first tabs on each line" "--help" "--version" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (t|--tabs) ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ed0000644000175000017500000000274612154557026016345 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "ed" command. # Supports POSIX 2008, GNU 1.1, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/ed { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "p: ${long:+--prompt:}; specify a prompt string" "s ${long:+--silent --quiet}; suppress diagnostic messages" ) #<# ADDOPTIONS=() case $type in (*BSD|SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "x; enable encryption" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "G --traditional; enable compatibility mode" "l --loose-exit-status; always exit with 0 status" "v --verbose; print detailed error messages" "h --help; print help" "V --version; print version info" ) #<# ;; (NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "E; use extended regular expression" ) #<# ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "C; enable encryption and assume all text has been encrypted" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (p|--prompt) ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/export0000644000175000017500000000027712154557026017273 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "export" built-in command. function completion/export { command -f completion//reexecute typeset } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-add0000644000175000017500000000267412154557026017266 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "git-add" command. # Supports Git 1.7.7. function completion/git-add { WORDS=(git add "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::add:arg { OPTIONS=( #># "A --all; add all files including untracked files" "n --dry-run; don't actually add files" "e --edit; edit patch hunks before adding" "f --force; add ignored files" "--ignore-errors; continue adding other files on an error" "--ignore-missing; ignore missing files (with -n)" "N --intent-to-add; add filepaths but not their contents" "i --interactive; enter the interactive mode" "p --patch; interactively choose patch hunks to add" "--refresh; refresh stat info in the index without adding" "u --update; add tracked files only; don't add new files" "v --verbose; print affected filenames" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::add:opr ;; esac } # only complete files that can be added function completion/git::add:opr { typeset force= i=2 while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--) break;; (--force) force=true; break;; (--*) ;; (-*f*) force=true; break;; esac i=$((i+1)) done command -f completion/git::completeuntrackedpath '^.[^ ]' \ --ignore-submodules=dirty ${force:+--ignored} } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-name-rev0000644000175000017500000000165112154557026020242 0ustar magicantmagicant# (C) 2012 magicant # Completion script for the "git" command. # Supports Git 1.8.0.2. function completion/git-name-rev { WORDS=(git name-rev "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::name-rev:arg { OPTIONS=( #># "--all; print all commits reachable from any refs" "--always; show uniquely abbreviated commit object as fallback" "--name-only; don't print SHA-1 before each name" "--no-undefined; exit with non-zero status for an undefined reference" "--refs:; specify refs that should be used by a pattern" "--stdin; filter the standard input, appending a name to each SHA-1" "--tags; use tag names only" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--refs) command -f completion/git::completeref ;; ('') command -f completion/git::completeref ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/pr0000644000175000017500000000601412154557026016366 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "pr" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/pr { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "a ${long:+--across}; arrange lines across columns" "d ${long:+--double-space}; double space" "e:: ${long:+--expand-tabs::}; expand tabs into spaces" "F f ${long:+--form-feed}; use form feeds to separate pages" "h: ${long:+--header:}; specify the header string" "i:: ${long:+--output-tabs::}; replace adjacent spaces with tabs" "l: ${long:+--length:}; specify the number of lines per page" "m ${long:+--merge}; print all files in parallel, each in one column" "n:: ${long:+--number-lines::}; print line numbers" "o: ${long:+--indent:}; specify the width of offset preceding each line" "p; pause before printing each page to the terminal" "r ${long:+--no-file-warnings}; don't warn about missing/unreadable files" "s:: ${long:+--separator::}; specify the column separator" "t ${long:+--omit-header}; omit page headers and footers" "w: ${long:+--width:}; specify the line width for multi-column layout" ) #<# ADDOPTIONS=() case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "c --show-control-chars; make unprintable characters visible by caret notation and backslashed octal notation" "D: --date-format:; specify the date format in the header" "J --join-lines; merge full lines" "N: --first-line-number:; specify the number to start counting line numbers from" "S:: --sep-string::; specify a string to separate columns" "T --omit-pagination; like -t, and eliminate form feeds in the input" "v --show-nonprinting; make unprintable characters visible by backslashed octal notation" "W: --page-width:; specify the line width" "--help" "--version" ) #<# ;; (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "L:; specify the locale" ) #<# ;; (NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "T:; specify the date format in the header" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "c:; specify the number of columns" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS WORDS=("${WORDS/#+/-}") command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([DT]|--date-format) if command -vf completion//completestrftime >/dev/null 2>&1 || . -AL completion/date; then command -f completion//completestrftime fi ;; (L) IFS=" " complete -P "$PREFIX" -- $(locale -a 2>/dev/null) ;; ([ceilNnosWw]|--expand-tabs|--output-tabs|--first-line-number|--length|--number-lines|--indent|--separator|--width|--page-width) ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ex0000644000175000017500000000416412154557026016365 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "ex" command. # Supports POSIX 2008, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, SunOS 5.10, # HP-UX 11i v3. function completion/ex { case $("${WORDS[1]}" --version 2>/dev/null) in (VIM*) command -f completion//reexecute vim return esac typeset type="$(uname 2>/dev/null)" typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "c:; specify a command to be executed after starting up" "R; read-only mode" "r; recover unsaved files" "t:; specify an identifier to jump" "w:; specify the value of the window option" ) #<# case ${WORDS[1]##*/} in (e*) POSIXOPTIONS=("$POSIXOPTIONS" #># "s; non-interactive batch processing mode" "v; operate as the vi editor" ) #<# esac ADDOPTIONS=() case $type in (*BSD) ADDOPTIONS=("$ADDOPTIONS" #># "F; don't copy the entire file when opening it" "S; enable the secure option" ) #<# case ${WORDS[1]##*/} in (v*) ADDOPTIONS=("$ADDOPTIONS" #># "e; operate as the ex editor" ) #<# esac case $type in (FreeBSD|NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "G; enable the gtagsmode option" ) #<# esac esac case $type in (SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "C; enable encryption and assume all text has been encrypted" "l; enable the lisp option" "x; enable encryption" ) #<# esac case $type in (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "L; print list of recoverable files" "V; echo input commands to the standard error" ) #<# case ${WORDS[1]##*/} in (v*) ADDOPTIONS=("$ADDOPTIONS" #># "S; don't assume the tags file is sorted" ) #<# esac ;; (HP-UX) case ${WORDS[1]##*/} in (v*) ADDOPTIONS=("$ADDOPTIONS" #># "V; echo input commands when sourcing a file" ) #<# esac ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (c) ;; (t) if [ -r tags ]; then complete -P "$PREFIX" -R "!_TAG_*" -- \ $(cut -f 1 tags 2>/dev/null) fi ;; (w) ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-reset0000644000175000017500000000150112154557026017644 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-reset" command. # Supports Git 1.7.7. function completion/git-reset { WORDS=(git reset "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::reset:arg { OPTIONS=( #># "--hard; reset the index and working tree" "--keep; like --hard, but keep working tree changes" "--merge; reset out of a conflicted merge" "--mixed; reset the index but keep the working tree" "p --patch; interactively choose patch hunks to reset" "q --quiet; print error and warning messages only" "--soft; keep the index and working tree intact" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completerefpath ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-describe0000644000175000017500000000000012154557026020273 0ustar magicantmagicantyash-2.35/share/completion/file0000644000175000017500000000526512154557026016673 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "file" command. # Supports POSIX 2008, Fine Free File 5.04, SunOS 5.10, HP-UX 11i v3. function completion/file { if "${WORDS[1]}" --help >/dev/null 2>&1; then typeset type=FFF else typeset type="$(uname 2>/dev/null)" fi case $type in (FFF) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "h ${long:+--no-dereference}; don't follow symbolic links" "m: ${long:+--magic-file:}; specify magic files" ) #<# case $type in (FFF|SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "c ${long:+--checking-printout}; check the format of the magic file" "f: ${long:+--files-from:}; specify a file containing filenames to examine" ) #<# esac case $type in (FFF) OPTIONS=("$OPTIONS" #># "0 --print0; separate output lines with null byte rather than newline" "b --brief; don't print the filename before each file type description" "C --compile; compile a magic file" "d --debug; print debugging messages" "e: --exclude:; specify a type of test to skip" "F: --separator:; specify a separator shown between filenames and file types" "i --mime; print mime types/encodings rather than human-readable results" "k --keep-going; print all matching file types" "L --dereference; follow symbolic links" "N --no-pad; don't align output" "n --no-buffer; don't buffer output" "p --preserve-date; restore the access time of examined files" "r --raw; don't escape unprintable characters" "s --special-files; read and examine non-regular files" "v --version; print version info" "z --uncompress; examine contents of compressed files" "--apple; print Apple creator/type" "--help" "--mime-type; print mime types only" "--mime-encoding; print mime encoding names only" ) #<# ;; (*) # POSIX options OPTIONS=("$OPTIONS" #># "d; do position/context-sensitive default system tests" "i; don't examine the contents of regular files" "M:; specify a file containing position-sensitive tests" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (e|--exclude) #>># complete -P "$PREFIX" -D "EMX application type" apptype complete -P "$PREFIX" -D "text encoding" encoding complete -P "$PREFIX" -D "text tokens" tokens complete -P "$PREFIX" -D "Compound Document Files details" cdf complete -P "$PREFIX" -D "contents of compressed files" compress complete -P "$PREFIX" -D "ELF file details" elf complete -P "$PREFIX" -D "magic file test" soft complete -P "$PREFIX" -D "contents of tar files" tar ;; #<<# (F|--separator) ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-checkout0000644000175000017500000000250212154557026020331 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-checkout" command. # Supports Git 1.7.7. function completion/git-checkout { WORDS=(git checkout "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::checkout:arg { OPTIONS=( #># "B; create or reset a new branch and check it out" "b; create a new branch and check it out" "--conflict:; like --merge, but specify format of unmerged files" "--detach; leave HEAD in detached head state" "f --force; overwrite local changes or ignore unmerged files" "l; enable reflog for the new branch" "m --merge; do 3-way merge for destination branch" "--no-track; create a non-tracking branch" "--orphan; create a new branch with no parent" "--ours; checkout local version for unmerged files" "p --patch; interactively choose hunks to check out" "q --quiet; print error and warning messages only" "--theirs; checkout remote version for unmerged files" "t --track; create a tracking branch" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--conflict) #>># complete -P "$PREFIX" -D "ours and theirs" merge complete -P "$PREFIX" -D "ours, theirs, and original" diff3 ;; #<<# ('') command -f completion/git::completerefpath ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/find0000644000175000017500000004474212154557026016677 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "find" command. # Supports POSIX 2008, GNU findutils 4.5.9, FreeBSD 8.1, OpenBSD 4.8, # NetBSD 5.0, Darwin 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/find { typeset SAVEWORDS SAVEWORDS=("$WORDS") case $("${WORDS[1]}" --version 2>/dev/null) in (*'findutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "H; follow symbolic links in operands" "L; follow all symbolic links" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "D:; specify debug options" "O::; specify optimization level" "P; don't follow symbolic links" "--help" "--version" ) #<# ;; (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "d; do post-order traversal rather than pre-order" "f:; specify a directory to search" "X; warn about filenames incompatible with xargs" "x; don't search in different file systems" ) #<# case $type in (FreeBSD|NetBSD|Darwin) OPTIONS=("$OPTIONS" #># "E; use extended regular expression" "P; don't follow symbolic links" "s; sort filenames within each directory" ) #<# esac ;; esac command -f completion//parseoptions case $ARGOPT in (-) case $TARGETWORD in (-|--*) command -f completion//completeoptions esac if [ "$type" = GNU ]; then typeset i=2 command -f completion/find::expr fi ;; (D) if [ "$PREFIX" ]; then complete -P "$PREFIX" "" else typeset targetword="${TARGETWORD##*,}" PREFIX=${TARGETWORD%"$targetword"} #>># complete -P "$PREFIX" -D "print help about the -D option" help complete -P "$PREFIX" -D "print the syntax tree of the expression" tree complete -P "$PREFIX" -D "print info during directory tree search" search complete -P "$PREFIX" -D "trace calls to the stat function" stat complete -P "$PREFIX" -D "print success rate for each predicate" rates complete -P "$PREFIX" -D "print debug info about optimization" opt complete -P "$PREFIX" -D "print debug info about execution of external commands" exec #<<# fi ;; (f) complete -P "$PREFIX" -S / -T -d ;; (O) ;; (*) typeset path=false expr=false i=2 WORDS=("$SAVEWORDS") if [ "$type" = GNU ]; then path=true fi while [ $i -le ${WORDS[#]} ]; do if [ "${WORDS[i]}" = -- ]; then i=$((i+1)) break fi case $type in (GNU) case ${WORDS[i]} in (-[!DHLOP-]*) break esac ;; (*BSD|Darwin) case ${WORDS[i]} in (-f*) path=true esac ;; esac case ${WORDS[i]} in (-?*) ;; (*) break ;; esac i=$((i+1)) done while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (\(|!|-*) expr=true break ;; (*) path=true ;; esac i=$((i+1)) done if ! $expr; then complete -S / -T -d fi if $path; then command -f completion/find::expr fi ;; esac } # This function depends on variables $i, $type. function completion/find::expr { while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (-acl|-aclv) case $type in (HP-UX) if [ $i -eq ${WORDS[#]} ]; then #>># complete -D "optional access control list entries" opt fi #<<# i=$((i+2)) ;; (*) i=$((i+1)) ;; esac ;; (-[acmB]newer|-fls|-fprint|-fprint0|-ilname|-iname|-ipath|-iwholename|-linkedto|-lname|-name|-newer*|-path|-samefile|-wholename) if [ $i -eq ${WORDS[#]} ]; then complete -f fi i=$((i+2)) ;; (-[acmB]time) if [ $i -eq ${WORDS[#]} ]; then case $type in (FreeBSD|Darwin) case $TARGETWORD in (*[[:digit:]]*) PREFIX=${TARGETWORD%"${TARGETWORD##*[[:digit:]]}"} #>># complete -P "$PREFIX" -D "second" s complete -P "$PREFIX" -D "minute" m complete -P "$PREFIX" -D "hour" h complete -P "$PREFIX" -D "day" d complete -P "$PREFIX" -D "week" w #<<# esac esac fi i=$((i+2)) ;; (-exec|-execdir|-ok|-okdir) i=$((i+1)) typeset j=$i while [ $j -le ${WORDS[#]} ]; do if [ "${WORDS[j]}" = ";" ]; then i=$((j+1)); break elif [ "${WORDS[j]} ${WORDS[j+1]}" = "{} +" ]; then i=$((j+2)); break fi j=$((j+1)) done if [ $i -le $j ]; then WORDS=("${WORDS[i,-1]}") command -f completion//reexecute -e return fi ;; (-flags) if [ $i -eq ${WORDS[#]} ]; then # TODO fi i=$((i+2)) ;; (-fprintf) if [ $i -eq ${WORDS[#]} ]; then complete -f elif [ $((i+1)) -eq ${WORDS[#]} ]; then command -f completion/find::printf fi i=$((i+3)) ;; (-group) if [ $i -eq ${WORDS[#]} ]; then complete -g fi i=$((i+2)) ;; (-perm) if [ $i -eq ${WORDS[#]} ]; then if command -vf completion/chmod::mode >/dev/null 2>&1 || . -AL completion/chmod; then command -f completion/chmod::mode find fi fi i=$((i+2)) ;; (-printf) if [ $i -eq ${WORDS[#]} ]; then command -f completion/find::printf fi i=$((i+2)) ;; (-regextype) if [ $i -eq ${WORDS[#]} ]; then complete emacs posix-awk posix-basic posix-egrep posix-extended fi i=$((i+2)) ;; (-size) if [ $i -eq ${WORDS[#]} ]; then case $TARGETWORD in (*[[:digit:]]*) PREFIX=${TARGETWORD%"${TARGETWORD##*[[:digit:]]}"} #>># complete -P "$PREFIX" -D "byte" c #<<# case $type in (GNU|FreeBSD|Darwin) #>># complete -P "$PREFIX" -D "kilobyte (2^10 bytes)" k complete -P "$PREFIX" -D "megabyte (2^20 bytes)" M complete -P "$PREFIX" -D "gigabyte (2^30 bytes)" G #<<# case $type in (GNU) #>># complete -P "$PREFIX" -D "block (2^9 bytes)" b complete -P "$PREFIX" -D "word (2 bytes)" w ;; #<<# (FreeBSD|Darwin) #>># complete -P "$PREFIX" -D "terabyte (2^40 bytes)" T complete -P "$PREFIX" -D "petabyte (2^50 bytes)" P ;; #<<# esac esac esac fi i=$((i+2)) ;; (-type|-xtype) if [ $i -eq ${WORDS[#]} ]; then #>># complete -D "block special file" b complete -D "character special file" c complete -D "directory" d complete -D "regular file" f complete -D "symbolic link" l complete -D "FIFO" p complete -D "socket" s fi #<<# case $(uname) in (SunOS) #>># complete -D "door" D esac #<<# case $type in (NetBSD) #>># complete -D "whiteout" w ;; #<<# (HP-UX) #>># complete -D "mount point" M complete -D "network special file" n ;; #<<# esac i=$((i+2)) ;; (-user) if [ $i -eq ${WORDS[#]} ]; then complete -u fi i=$((i+2)) ;; (-[acmB]min|-context|-cpio|-fsonly|-fstype|-[gu]id|-inum|-iregex|-links|-maxdepth|-mindepth|-ncpio|-regex|-used) i=$((i+2)) ;; (*) i=$((i+1)) ;; esac done if [ $i -eq $((${WORDS[#]}+1)) ]; then case $TARGETWORD in (-newer*) case $type in (GNU|FreeBSD|Darwin|HP-UX) typeset word="${TARGETWORD#-newer}" word=${word#?} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" -D "last access time" a complete -P "$PREFIX" -D "last status change time" c complete -P "$PREFIX" -D "last modified time" m #<<# case $type in (GNU|FreeBSD|Darwin) #>># complete -P "$PREFIX" -D "creation time" B #<<# case $TARGETWORD in (-newer?*) #>># complete -P "$PREFIX" -D "specify time" t esac #<<# esac ;; (*) complete -- -newer ;; esac ;; (-*) #>># complete -D "logical conjunction (and)" -- -a complete -D "true if the last access time is n days ago" -- -atime complete -D "true if the last status change time is n days ago" -- -ctime complete -D "search directories in post-order rather than pre-order" -- -depth complete -D "execute the specified command line" -- -exec complete -D "true if the group is the specified one" -- -group complete -D "true if the file has the specified hard link count" -- -links complete -D "true if the last modified time is n days ago" -- -mtime complete -D "true if the filename matches the specified pattern" -- -name complete -D "logical disjunction (or)" -- -o complete -D "prompt for execution of the specified command line" -- -ok complete -D "true if the pathname matches the specified pattern" -- -path complete -D "true if the file has the specified permission" -- -perm complete -D "print the pathname" -- -print complete -D "don't search the directory if evaluated" -- -prune complete -D "true if the file has the specified size" -- -size complete -D "true if the file has the specified type" -- -type complete -D "true if the owner is the specified one" -- -user complete -D "don't search different file systems" -- -xdev #<<# case $type in (GNU|*BSD|Darwin|SunOS|HP-UX) #>># complete -D "true if the file is on the specified file system" -- -fstype complete -D "true if the file has the specified inode number" -- -inum #<<# case $type in (GNU|*BSD|Darwin|SunOS) #>># complete -D "print the file in ls -dils format" -- -ls #<<# case $type in (GNU|FreeBSD|Darwin|SunOS) #>># complete -D "don't search different file systems" -- -mount esac #<<# esac case $type in (GNU|*BSD|Darwin|SunOS) #>># complete -D "print the pathname with a trailing null byte" -- -print0 esac #<<# esac case $type in (GNU|*BSD|Darwin) #>># complete -D "logical conjunction (and)" -- -and complete -D "true if the last access time is n minutes ago" -- -amin complete -D "true if the last access time is later than last modified time of the specified file" -- -anewer complete -D "true if the last status change time is n minutes ago" -- -cmin complete -D "true if the last status change time is later than last modified time of the specified file" -- -cnewer complete -D "true if the file is empty" -- -empty complete -D "execute the specified command line in the directory containing the file" -- -execdir complete -D "true if the filename matches the specified pattern (case-insensitive)" -- -iname complete -D "search directories of at most the specified depth only" -- -maxdepth complete -D "search directories of at least the specified depth only" -- -mindepth complete -D "true if the last modified time is n minutes ago" -- -mmin complete -D "true if the last modified time is later than that of the specified file" -T -- -newer complete -D "true if the file's group ID has no name" -T -- -nogroup complete -D "true if the file owner's user ID has no name" -T -- -nouser complete -D "prompt for execution of the specified command line in the directory containing the file" -- -okdir complete -D "logical disjunction (or)" -- -or #<<# case $type in (GNU|FreeBSD|NetBSD|Darwin) #>># complete -D "remove the file" -- -delete complete -D "false" -- -false complete -D "true if the pathname matches the specified regular expression (case-insensitive)" -- -iregex complete -D "true if the pathname matches the specified regular expression" -- -regex complete -D "true if the file is a hard link to the specified" -- -samefile #<<# case $type in (GNU|FreeBSD|Darwin) #>># complete -D "true if the file's group ID is the specified" -- -gid complete -D "true if the symbolic link's target matches the specified pattern (case-insensitive)" -- -ilname complete -D "true if the pathname matches the specified pattern (case-insensitive)" -- -ipath -iwholename complete -D "true if the symbolic link's target matches the specified pattern" -- -lname complete -D "true" -- -true complete -D "true if the file owner's user ID is the specified" -- -uid complete -D "true if the pathname matches the specified pattern" -- -wholename esac #<<# esac case $type in (GNU|NetBSD) #>># complete -D "print the pathname to the specified file" -- -fprint esac #<<# case $type in (*BSD|Darwin) #>># complete -D "true if the file has the specified flags" -- -flags #<<# case $type in (FreeBSD|Darwin) #>># complete -D "true if the creation time is n minutes ago" -- -Bmin complete -D "true if the creation time is later than last modified time of the specified file" -- -Bnewer complete -D "true if the creation time is n days ago" -- -Btime complete -D "true if the last modified time is later than that of the specified file" -- -mnewer esac #<<# esac esac case $type in (FreeBSD|SunOS|HP-UX) #>># complete -D "true if the file have additional ACLs defined" -- -acl #<<# case $type in (SunOS|HP-UX) #>># complete -D "write the file in cpio format to the specified device" -- -cpio complete -D "write the file in cpio -c format to the specified device" -- -ncpio complete -D "true if the file is on the same file system" -- -local esac #<<# esac case $type in (GNU) #>># complete -D "true if the SELinux context matches the specified pattern" -- -context complete -D "measure time from the beginning of today" -- -daystart complete -D "true if the file is executable" -- -executable complete -D "write file info to the specified file" -- -fls complete -D "print the null-terminated pathname to the specified file" -- -fprint0 complete -D "print the specified formatted string to the specified file" -- -fprintf complete -D "ignore files removed during traversal" -- -ignore_readdir_race complete -D "disable warning messages" -- -nowarn complete -D "print the specified formatted string" -- -printf complete -D "stop directory traversal" -- -quit complete -D "true if the file is readable" -- -readable complete -D "specify the type of regular expression" -- -regextype complete -D "true if the last access time is n days after the last status change" -- -used complete -D "enable warning messages" -- -warn complete -D "true if the file is writable" -- -writable complete -D "don't search autofs file systems" -- -xautofs complete -D "true if the file has the specified type (do/don't follow symbolic links)" -- -xtype esac #<<# case $type in (NetBSD) #>># complete -D "stop directory traversal" -- -exit complete -D "print the pathname with escapes for xargs" -- -printx complete -D "remove the file" -- -rm esac #<<# case $type in (SunOS) #>># complete -D "true if the file has extended attributes" -- -xattr esac #<<# case $type in (HP-UX) #>># complete -D "true if the file have additional JFS ACLs defined" -- -aclv complete -D "traverse the specified file system only" -- -fsonly complete -D "true if the file is a hard link to the specified" -- -linkedto complete -D "don't search different file systems" -- -mountstop complete -D "don't search the directory unless evaluated" -- -only esac #<<# ;; esac fi return 0 } function completion/find::printf { if command -vf completion/printf::backslash >/dev/null 2>&1 || . -AL completion/printf; then command -f completion/printf::backslash echo fi typeset word="$TARGETWORD" word=${word//%%} case $word in (*%) PREFIX=${TARGETWORD%\%} #>># complete -T -P "$PREFIX" -D "last access time, formatted" '%A' complete -T -P "$PREFIX" -D "last access time" '%a' complete -T -P "$PREFIX" -D "disk usage in 512-byte blocks" '%b' complete -T -P "$PREFIX" -D "last status change time, formatted" '%C' complete -T -P "$PREFIX" -D "last status change time" '%c' complete -T -P "$PREFIX" -D "device number" '%D' complete -T -P "$PREFIX" -D "depth in directory traversal" '%d' complete -T -P "$PREFIX" -D "file system type" '%F' complete -T -P "$PREFIX" -D "basename" '%f' complete -T -P "$PREFIX" -D "group ID (numeric)" '%G' complete -T -P "$PREFIX" -D "group" '%g' complete -T -P "$PREFIX" -D "the searched directory under which the file was found" '%H' complete -T -P "$PREFIX" -D "dirname" '%h' complete -T -P "$PREFIX" -D "inode number" '%i' complete -T -P "$PREFIX" -D "disk usage in kilobyte blocks" '%k' complete -T -P "$PREFIX" -D "target of symbolic link" '%l' complete -T -P "$PREFIX" -D "permission mode bits (symbolic)" '%M' complete -T -P "$PREFIX" -D "permission mode bits (octal)" '%m' complete -T -P "$PREFIX" -D "number of hard links" '%n' complete -T -P "$PREFIX" -D "pathname relative to the searched directory" '%P' complete -T -P "$PREFIX" -D "pathname" '%p' complete -T -P "$PREFIX" -D "sparseness" '%S' complete -T -P "$PREFIX" -D "file size in bytes" '%s' complete -T -P "$PREFIX" -D "last modified time, formatted" '%T' complete -T -P "$PREFIX" -D "last modified time" '%t' complete -T -P "$PREFIX" -D "owner's user ID (numeric)" '%U' complete -T -P "$PREFIX" -D "owner's user name" '%u' complete -T -P "$PREFIX" -D "file type (dereference symbolic link)" '%Y' complete -T -P "$PREFIX" -D "file type" '%y' complete -T -P "$PREFIX" -D "SELinux context" '%Z' complete -T -P "$PREFIX" -D "%" '%%' ;; #<<# (*%[ACT]) PREFIX=${TARGETWORD%\%?} word=${TARGETWORD#"$PREFIX"} #>># complete -T -P "$PREFIX" -D "day of week, full, localized" "${word}A" complete -T -P "$PREFIX" -D "day of week, short, localized" "${word}a" complete -T -P "$PREFIX" -D "month, full, localized" "${word}B" complete -T -P "$PREFIX" -D "month, short, localized" "${word}b" complete -T -P "$PREFIX" -D "date and time, localized" "${word}c" complete -T -P "$PREFIX" -D "like %m/%d/%y (e.g. 12/31/99)" "${word}D" complete -T -P "$PREFIX" -D "day of month [01-31]" "${word}d" complete -T -P "$PREFIX" -D "hour [00-23]" "${word}H" complete -T -P "$PREFIX" -D "hour [01-12]" "${word}I" complete -T -P "$PREFIX" -D "day of year [001-366]" "${word}j" complete -T -P "$PREFIX" -D "hour [ 0-23] (space-padded)" "${word}k" complete -T -P "$PREFIX" -D "hour [ 1-12] (space-padded)" "${word}l" complete -T -P "$PREFIX" -D "month [01-12]" "${word}m" complete -T -P "$PREFIX" -D "AM or PM, localized" "${word}p" complete -T -P "$PREFIX" -D "12-hour clock time with AM/PM, localized" "${word}r" complete -T -P "$PREFIX" -D "second" "${word}S" complete -T -P "$PREFIX" -D "like %H:%M:%S (e.g. 13:45:56)" "${word}T" complete -T -P "$PREFIX" -D "week of year [00-53] (first Sunday in week 1)" "${word}U" complete -T -P "$PREFIX" -D "week of year [00-53] (first Monday in week 1)" "${word}W" complete -T -P "$PREFIX" -D "day of week in numeral [0-6]" "${word}w" complete -T -P "$PREFIX" -D "time, localized" "${word}X" complete -T -P "$PREFIX" -D "date, localized" "${word}x" complete -T -P "$PREFIX" -D "year, full (e.g. 1999)" "${word}Y" complete -T -P "$PREFIX" -D "year within century [00-99]" "${word}y" complete -T -P "$PREFIX" -D "timezone name" "${word}Z" complete -T -P "$PREFIX" -D "seconds since epoch" "${word}@" complete -T -P "$PREFIX" -D "the default localized format" "${word}+" ;; #<<# esac return 0 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/getopts0000644000175000017500000000073612154557026017437 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "getopts" built-in command. function completion/getopts { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--help" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -eq 1 ]; then complete -v elif [ ${WORDS[#]} -gt 1 ]; then complete -f fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/popd0000644000175000017500000000026612154557026016712 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "popd" built-in command. function completion/popd { command -f completion//reexecute cd } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/which0000644000175000017500000000311212154557026017043 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "which" command. # Supports GNU which 2.20, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/which { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># ) #<# case $type in (GNU|Darwin|*BSD) OPTIONS=("$OPTIONS" #># "a ${long:+--all}; print all matches, not just the first one" ) #<# case $type in (Darwin|FreeBSD) OPTIONS=("$OPTIONS" #># "s; print nothing" ) #<# esac ;; esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "i --read-alias; read alias definitions from the standard input" "--skip-alias; cancel the --read-alias option" "--read-functions; read function definitions from the standard input" "--skip-functions; cancel the --read-functions option" "--skip-dot; ignore directory names that start with a dot" "--skip-tilde; ignore directories under \$HOME" "--show-dot; print \"./program\" for programs in a dot directory" "--show-tilde; use ~ for programs under \$HOME" "V v --version; print version info" "--help" ) #<# # --tty-only is not completed since it's meaningless in an # interactive shell session esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -P "$PREFIX" --external-command ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ln0000644000175000017500000000470012154557026016356 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "ln" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/ln { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "f ${long:+--force}; remove existing target" "L ${long:+--logical}; make a link to the file referred to by the symbolic link" "P ${long:+--physical}; make a link to the symbolic link itself" "s ${long:+--symbolic}; make a symbolic link rather than a hard link" ) #<# ADDOPTIONS=() case $type in (GNU|FreeBSD|NetBSD|Darwin|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "i ${long:+--interactive}; ask before overwriting existing files" ) #<# case $type in (GNU|FreeBSD|NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "v ${long:+--verbose}; print a message for each file processed" ) #<# esac esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "b; like --backup=existing" "--backup::; specify how to make a backup" "d F --directory; make a hard link to a directory" "n --no-dereference; don't follow symbolic links" "S: --suffix:; specify a suffix to append to backup file names" "T --no-target-directory; always treat the destination as a regular file" "t: --target-directory:; specify a destination directory" "--help" "--version" ) #<# ;; (*BSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "h n; don't follow symbolic links" ) #<# case $type in (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "F; replace the target directory with a link (with -s)" ) #<# case $type in (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "w; warn when making a symbolic link to a unexisting file" ) #<# esac esac ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--backup) if command -vf completion//completebackup >/dev/null 2>&1 || . -AL completion/_backup; then command -f completion//completebackup fi ;; (S|--suffix) ;; (t|--target-directory) complete -T -P "$PREFIX" -S / -d ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git0000644000175000017500000005736212154557026016544 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "git" command. # Supports Git 1.7.7. function completion/git { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c:; specify a configuration parameter" "--bare; treat the repository as a bare repository" "--exec-path::; specify or print the directory containing core git executables" "--git-dir:; specify the repository directory" "--html-path; print the directory where HTML documentation is installed" "--info-path; print the directory where info manuals are installed" "--man-path; print the directory where manual pages are installed" "p --paginate; run a pager to view Git's output" "--no-pager; don't run a pager to view Git's output" "--no-replace-objects; don't use replacement refs" "--work-tree:; specify the working tree directory" "--help" "--version" ) #<# # convert "--help" to "help" typeset i=2 while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (-c|--git-dir|--work-tree) i=$((i+1)) ;; (--help) WORDS=("${WORDS[1,i-1]}" "help" "${WORDS[i+1,-1]}") ;; (-?*) ;; (*) break ;; esac i=$((i+1)) done command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (c) if command -vf completion//git::completeoptionname >/dev/null 2>&1 || . -AL completion/git-config; then command -f completion//git::completeoptionname = fi ;; (--exec-path|--git-dir|--work-tree) complete -P "$PREFIX" -S / -T -d ;; ('') # find first non-option argument and # parse some global options typeset OPTIND=2 gitcmd= while [ $OPTIND -le ${WORDS[#]} ]; do case ${WORDS[OPTIND]} in (-c) OPTIND=$((OPTIND+1)) ;; (--git-dir) OPTIND=$((OPTIND+1)) typeset -x GIT_DIR="${WORDS[OPTIND]}" ;; (--git-dir=*) typeset -x GIT_DIR="${WORDS[OPTIND]#*=}" ;; (--work-tree) OPTIND=$((OPTIND+1)) typeset -x GIT_WORK_TREE="${WORDS[OPTIND]}" ;; (--work-tree=*) typeset -x GIT_WORK_TREE="${WORDS[OPTIND]#*=}" ;; (-?*) ;; (*) gitcmd=${WORDS[OPTIND]} break ;; esac OPTIND=$((OPTIND+1)) done if [ $OPTIND -le ${WORDS[#]} ]; then # resolve command alias typeset alias if alias="$(git config --get alias."$gitcmd")" 2>/dev/null; then case $alias in (!*) WORDS=(${alias#!} "${WORDS[OPTIND+1,-1]}") command -f completion//reexecute return ;; (?*) WORDS=("${WORDS[1,OPTIND-1]}" \ $alias "${WORDS[OPTIND+1,-1]}") gitcmd=${alias%%[[:space:]]*} ;; esac fi OPTIND=$((OPTIND+1)) # complete command argument typeset OLDWORDS OLDWORDS=("$WORDS") WORDS=("${WORDS[1]}" "${WORDS[OPTIND,-1]}") if [ ${WORDS[#]} -le 1 ]; then case $TARGETWORD in (-*) complete -- --help esac fi if { command -vf "completion/git::$gitcmd:arg" || . -AL "completion/git-$gitcmd"; } >/dev/null 2>&1; then command -f "completion/git::$gitcmd:arg" else complete -P "$PREFIX" -f fi else # complete command name command -f completion/git::completecmd command -f completion/git::completealias fi ;; esac } function completion/git::completecmd { #>># complete -P "$PREFIX" -D "add files to the index" add complete -P "$PREFIX" -D "apply patches from a mailbox" am complete -P "$PREFIX" -D "show a file with commit info" annotate blame complete -P "$PREFIX" -D "apply patches" apply complete -P "$PREFIX" -D "import an Arch repository" archimport complete -P "$PREFIX" -D "create an archive of file tree" archive complete -P "$PREFIX" -D "binary-search for a change that introduced a bug" bisect complete -P "$PREFIX" -D "list, create, or remove branches" branch complete -P "$PREFIX" -D "move objects and refs by archive" bundle complete -P "$PREFIX" -D "print info about object or files" cat-file # discouraged: complete -P "$PREFIX" -D "" check-attr # discouraged: complete -P "$PREFIX" -D "" check-ref-format complete -P "$PREFIX" -D "check out a branch to the working tree" checkout complete -P "$PREFIX" -D "copy files from the index to the working tree" checkout-index complete -P "$PREFIX" -D "list common commits between branches" cherry complete -P "$PREFIX" -D "apply the changes in existing commits" cherry-pick complete -P "$PREFIX" -D "commit using a GUI tool" citool complete -P "$PREFIX" -D "remove untracked files from the working tree" clean complete -P "$PREFIX" -D "copy a repository into a new directory" clone complete -P "$PREFIX" -D "record changes to the repository" commit complete -P "$PREFIX" -D "create a new commit object" commit-tree complete -P "$PREFIX" -D "show or set options" config complete -P "$PREFIX" -D "count unpacked objects and its disk consumption" count-objects complete -P "$PREFIX" -D "export a commit to a CVS checkout" cvsexportcommit complete -P "$PREFIX" -D "import a CVS repository" cvsimport complete -P "$PREFIX" -D "emulate a CVS server" cvsserver complete -P "$PREFIX" -D "simple TCP server" daemon complete -P "$PREFIX" -D "show the most recent tag reachable from a commit" describe complete -P "$PREFIX" -D "show differences between commits and files" diff complete -P "$PREFIX" -D "compare files in the index and working tree" diff-files complete -P "$PREFIX" -D "compare files in the index and a commit" diff-index complete -P "$PREFIX" -D "compare files in two tree object" diff-tree complete -P "$PREFIX" -D "run tools to view commit diff" difftool complete -P "$PREFIX" -D "dump objects in a text format" fast-export complete -P "$PREFIX" -D "import objects" fast-import complete -P "$PREFIX" -D "obtain objects and refs from another repository" fetch complete -P "$PREFIX" -D "fetch missing objects from another repository" fetch-pack complete -P "$PREFIX" -D "rewrite branches using shell commands" filter-branch # discouraged: complete -P "$PREFIX" -D "" fmt-merge-msg complete -P "$PREFIX" -D "run a command for each ref" for-each-ref complete -P "$PREFIX" -D "prepare patches for email submission" format-patch complete -P "$PREFIX" -D "verify integrity of the repository database" fsck complete -P "$PREFIX" -D "clean up and optimize the repository" gc complete -P "$PREFIX" -D "show the commit ID of a tar archive" get-tar-commit-id complete -P "$PREFIX" -D "search files using regular expressions" grep complete -P "$PREFIX" -D "GUI front end" gui complete -P "$PREFIX" -D "compute object IDs for files" hash-object complete -P "$PREFIX" -D "show help" help complete -P "$PREFIX" -D "server-side program for Git over HTTP" http-backend # discouraged: complete -P "$PREFIX" -D "" http-fetch # discouraged: complete -P "$PREFIX" -D "" http-push complete -P "$PREFIX" -D "send patches to an IMAP folder" imap-send complete -P "$PREFIX" -D "build a pack index file" index-pack complete -P "$PREFIX" -D "make a new empty repository" init complete -P "$PREFIX" -D "set up gitweb for browsing the repository" instaweb complete -P "$PREFIX" -D "show commit logs" log # deprecated: complete -P "$PREFIX" -D "recover lost refs" lost-found complete -P "$PREFIX" -D "show info on files in the index and working tree" ls-files complete -P "$PREFIX" -D "list remote refs" ls-remote complete -P "$PREFIX" -D "list files in a tree object" ls-tree # discouraged: complete -P "$PREFIX" -D "" mailinfo # discouraged: complete -P "$PREFIX" -D "" mailsplit complete -P "$PREFIX" -D "merge branches" merge complete -P "$PREFIX" -D "find a good common ancestor for a merge" merge-base complete -P "$PREFIX" -D "perform 3-way merge" merge-file complete -P "$PREFIX" -D "run a merge program" merge-index # discouraged: complete -P "$PREFIX" -D "" merge-one-file complete -P "$PREFIX" -D "show results of a 3-way merge" merge-tree complete -P "$PREFIX" -D "run tools to resolve merge conflicts" mergetool complete -P "$PREFIX" -D "create a tag object" mktag complete -P "$PREFIX" -D "create a tree object" mktree complete -P "$PREFIX" -D "move files" mv complete -P "$PREFIX" -D "show a symbolic name for a commit" name-rev complete -P "$PREFIX" -D "manipulate object notes" notes complete -P "$PREFIX" -D "pack objects into an archive" pack-objects complete -P "$PREFIX" -D "find redundant packs" pack-redundant complete -P "$PREFIX" -D "pack refs into a single file for performance" pack-refs # discouraged: complete -P "$PREFIX" -D "" parse-remote # discouraged: complete -P "$PREFIX" -D "" patch-id # deprecated: complete -P "$PREFIX" -D "" peek-remote # discouraged: complete -P "$PREFIX" -D "" prune complete -P "$PREFIX" -D "remove redundant objects that are already packed" prune-packed complete -P "$PREFIX" -D "fetch and merge remote branches" pull complete -P "$PREFIX" -D "send objects and update remote refs" push complete -P "$PREFIX" -D "apply a quilt patch set" quiltimport complete -P "$PREFIX" -D "read a tree into the index" read-tree complete -P "$PREFIX" -D "change the branching point of a branch" rebase # discouraged: complete -P "$PREFIX" -D "" receive-pack complete -P "$PREFIX" -D "manipulate logs of revs" reflog complete -P "$PREFIX" -D "hard-link common objects in local repositories" relink complete -P "$PREFIX" -D "manage remote repository settings" remote complete -P "$PREFIX" -D "pack unpacked objects" repack complete -P "$PREFIX" -D "manipulate object replacements" replace # deprecated: complete -P "$PREFIX" -D "" repo-config complete -P "$PREFIX" -D "print a message that helps a pull request" request-pull # discouraged: complete -P "$PREFIX" -D "" rerere complete -P "$PREFIX" -D "restore the index and working tree" reset complete -P "$PREFIX" -D "list commit objects" rev-list complete -P "$PREFIX" -D "parse git command arguments" rev-parse complete -P "$PREFIX" -D "undo some commits" revert complete -P "$PREFIX" -D "remove files" rm complete -P "$PREFIX" -D "send patches as emails" send-email complete -P "$PREFIX" -D "send objects to another repository" send-pack # discouraged: complete -P "$PREFIX" -D "" sh-setup # discouraged: complete -P "$PREFIX" -D "" shell complete -P "$PREFIX" -D "print a summary of commit logs" shortlog complete -P "$PREFIX" -D "show objects" show complete -P "$PREFIX" -D "list branches and their commits" show-branch complete -P "$PREFIX" -D "show packed archive index" show-index complete -P "$PREFIX" -D "list refs in the repository" show-ref complete -P "$PREFIX" -D "manipulate stashes" stash complete -P "$PREFIX" -D "show the status of the working tree" status # discouraged: complete -P "$PREFIX" -D "" stripspace complete -P "$PREFIX" -D "manipulate submodules" submodule complete -P "$PREFIX" -D "operate with a Subversion repository" svn complete -P "$PREFIX" -D "make or resolve a symbolic ref" symbolic-ref complete -P "$PREFIX" -D "manipulate tags" tag # deprecated: complete -P "$PREFIX" -D "" tar-tree complete -P "$PREFIX" -D "create a temporary file for a blob" unpack-file complete -P "$PREFIX" -D "unpack objects from an archive" unpack-objects complete -P "$PREFIX" -D "register file contents in the working tree to the index" update-index complete -P "$PREFIX" -D "modify a ref's target safely" update-ref complete -P "$PREFIX" -D "update auxiliary files for dumb servers" update-server-info # discouraged: complete -P "$PREFIX" -D "" upload-archive # discouraged: complete -P "$PREFIX" -D "" upload-pack complete -P "$PREFIX" -D "show a git logical variable" var complete -P "$PREFIX" -D "check integrity of packed objects" verify-pack complete -P "$PREFIX" -D "check the GPG signature of tags" verify-tag complete -P "$PREFIX" -D "show logs and differences between commits" whatchanged complete -P "$PREFIX" -D "create a tree object from the index" write-tree #<<# typeset cmd while read -r cmd; do cmd=${cmd##*/} complete -P "$PREFIX" -- "${cmd#git-}" done 2>/dev/null <(command -f completion//allcommands 'git-*') } function completion/git::completealias { typeset usesuffix= suffix if [ $# -gt 0 ]; then usesuffix=true suffix=$1 fi typeset name value while read -r name value; do complete -P "$PREFIX" -D "= $value" ${usesuffix:+-S "$suffix" -T} \ -- "${name#alias.}" done 2>/dev/null <(git config --get-regexp 'alias\..*') } function completion/git::completeref { typeset abbrprefixes completefull=true range usesuffix= suffix abbrprefixes=(refs/ refs/tags/ refs/heads/ refs/remotes/) while [ $# -gt 0 ]; do case $1 in (abbrprefixes=*) abbrprefixes=(${1#abbrprefixes=}) ;; (dontcompletefull=*) completefull= ;; (suffix=*) usesuffix=true suffix=${1#suffix=} ;; (range=*) typeset word="${TARGETWORD#"$PREFIX"}" case $word in (-*) complete -P "$PREFIX" -D "exclude following commits" -- --not esac word=${word##*..} typeset PREFIX=${TARGETWORD%"$word"} ;; (*) break ;; esac shift done typeset targetword="${TARGETWORD#"$PREFIX"}" if [ $# -eq 0 ]; then complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -A '*HEAD' \ -- $( (ls -- "$(git rev-parse --git-dir)") 2>/dev/null) set -- --all # complete commit ID if grep -Eq '^[[:xdigit:]]{2,7}$' <<<"$targetword" 2>/dev/null; then typeset id message while read -r id message; do complete -P "$PREFIX" -D "$message" \ ${usesuffix:+-S "$suffix" -T} -- "$id" done 2>/dev/null <(git rev-list --all --oneline | grep "^$targetword") fi fi # complete symbolic ref typeset fullref ref abbr typeset word="${targetword##*/}" typeset prefix="${targetword%"$word"}" while read -r fullref; do for abbr in ${completefull:+""} "$abbrprefixes"; do ref=${fullref#"$abbr"} case $ref in ("$targetword"*) ref="${ref#"$prefix"}" case $ref in (*/*) complete -P "$PREFIX$prefix" -S / -T -- "${ref%%/*}" ;; (*) complete -P "$PREFIX$prefix" \ ${usesuffix:+-S "$suffix" -T} -- "$ref" ;; esac esac done done 2>/dev/null <(git rev-parse --symbolic "$@") } # $1 = remote name function completion/git::completeremoteref { typeset word="${TARGETWORD#"$PREFIX"}" case $word in (refs/heads/*) word=${word#refs/heads/} PREFIX=${TARGETWORD%"$word"} ;; (*) # We don't have info about remote non-branch refs, # so complete local refs for tags. "--branches" is # specified so that "refs/heads/" can be a candidate. command -f completion/git::completeref \ abbrprefixes= --symbolic-full-name \ --branches --tags ;; esac # complete remote tracking branches command -f completion/git::completeref \ dontcompletefull=true abbrprefixes="refs/remotes/$1/" \ --remotes="$1" } function completion/git::completepath { if ! git rev-parse --git-dir >/dev/null 2>&1; then return 1 fi typeset opt OPTIND=1 type=auto while getopts ar opt; do case $opt in (a) type=abs ;; (r) type=rel ;; esac done shift $((OPTIND-1)) typeset tree="${1-HEAD}" targetpath="${TARGETWORD#"$PREFIX"}" lspath prefixpath if [ "$type" = auto ]; then case $targetpath in (./*|../*) type=rel ;; (*) type=abs ;; esac fi case $type in (abs) lspath=${targetpath} ;; (rel) lspath=$(git rev-parse --show-prefix)${targetpath} ;; esac case $lspath in (*/*) lspath=${lspath%/*}/ ;; (*) lspath= ;; esac case $targetpath in (*/*) prefixpath=${targetpath%/*}/ ;; (*) prefixpath= ;; esac typeset PREFIX="$PREFIX$prefixpath" typeset mode type id path while read -r mode type id path; do case $type in (tree) opt='-S / -T' ;; (*) opt= ;; esac complete -P "$PREFIX" $opt -- "${path##*/}" done 2>/dev/null \ <(git ls-tree --full-tree "$tree" -- "$lspath") } function completion/git::completerefpath { typeset i=2 hyphenhyphen=false treeish=HEAD while [ $i -le ${WORDS[#]} ]; do case "${WORDS[i]}" in (--) hyphenhyphen=true break ;; (-*) ;; (*) treeish=${WORDS[i]} ;; esac i=$((i+1)) done if ! $hyphenhyphen; then command -f completion/git::completeref "$@" fi if ! git show "$treeish^{tree}" >/dev/null 2>&1; then treeish=HEAD fi command -f completion/git::completepath -r "$treeish" } # $1 = regex to select paths # $2... = options for "git status" # not supporting $PREFIX function completion/git::completeuntrackedpath { typeset dir="$(dirname -- "${TARGETWORD}X")" if ! ( d1=$( git rev-parse --show-toplevel) && d2=$(cd -- "$dir" && git rev-parse --show-toplevel) && test "$d1" = "$d2") 2>/dev/null then # don't complete paths in submodule return fi typeset pathprefix="$({ cd -- "$dir" && git rev-parse --show-prefix } 2>/dev/null)" typeset prefix="${TARGETWORD%"${TARGETWORD##*/}"}" typeset file while read -r file; do file=${file#"$pathprefix"} case $file in (*/*) complete -P "$prefix" -S / -T -- "${file%%/*}" ;; (*) complete -P "$prefix" -- "$file" ;; esac done 2>/dev/null <( git status --porcelain "${@[2,-1]}" -- "$dir/" | grep "${1-}" | cut -c 4- ) } function completion/git::completeobject { typeset targetword="${TARGETWORD#"$PREFIX"}" typeset t=$(sed 's;[@^]{[^}]*};;g' <<<"$targetword") case $t in (*:*) typeset path=${t#*:} typeset treeish=${targetword%":$path"} typeset PREFIX="$PREFIX$treeish:" command -f completion/git::completepath "${treeish:-HEAD}" # XXX empty treeish should fall back to the current index rather than HEAD ;; (*) command -f completion/git::completeref ;; esac } function completion/git::completeremote { typeset remote while read -r remote; do complete -P "$PREFIX" -- "$remote" # XXX description done 2>/dev/null <( gitdir=$(git rev-parse --git-dir) || exit git remote (cd -- "$gitdir/remotes" && ls -A) (cd -- "$gitdir/branches" && ls -A) ) } function completion/git::getorderopts { OPTIONS=("$OPTIONS" #># "--date-order; sort commits by date while keeping children before parent" "--topo-order; show in topological order" ) #<# } function completion/git::getprettyopts { OPTIONS=("$OPTIONS" #># "--abbrev-commit; abbreviate commit IDs" "--encoding::; specify an output encoding" "--format:; specify an output format" "--no-abbrev-commit; print full commit IDs" "--no-notes --no-standard-notes; don't print notes" "--notes:: --standard-notes --show-notes::; print notes" "--oneline; like --format=oneline --abbrev-commit" "--pretty::; print in a human-friendly format" ) #<# } function completion/git::completeprettyopts { case $ARGOPT in (--encoding) #TODO ;; (--format|--pretty) command -f completion/git::--format:arg ;; (--notes|--standard-notes|--show-notes) command -f completion/git::completeref abbrprefixes=refs/notes/ --glob=refs/notes ;; (*) return 1 ;; esac } function completion/git::--author:arg { typeset author while read -r author; do complete -P "$PREFIX" -- "$author" done 2>/dev/null <(git log --all --format=format:%an | uniq) } function completion/git::--color:arg { #>># complete -P "$PREFIX" -D "always print in color" always complete -P "$PREFIX" -D "print in color if output is terminal" auto complete -P "$PREFIX" -D "don't print in color" never } #<<# function completion/git::--date:arg { #>># complete -P "$PREFIX" -D "print relative time like \"2 hours ago\"" relative complete -P "$PREFIX" -D "print in local timezone" local complete -P "$PREFIX" -D "print in original timezone" default complete -P "$PREFIX" -D "print in ISO 8601 format" iso8601 complete -P "$PREFIX" -D "print in RFC 2822 format" rfc2822 complete -P "$PREFIX" -D "print in YYYY-MM-DD format" short complete -P "$PREFIX" -D "print the raw timestamp value" raw } #<<# function completion/git::--format:arg { typeset word="${TARGETWORD#"$PREFIX"}" word=${word//%%} case $word in (format:*%*) word=%${word##*%} typeset PREFIX=${TARGETWORD%"$word"} #>># complete -T -P "$PREFIX" -D "full commit ID" '%H' complete -T -P "$PREFIX" -D "abbreviated commit ID" '%h' complete -T -P "$PREFIX" -D "full tree ID" '%T' complete -T -P "$PREFIX" -D "abbreviated tree ID" '%t' complete -T -P "$PREFIX" -D "full parent IDs" '%P' complete -T -P "$PREFIX" -D "abbreviated parent IDs" '%p' complete -T -P "$PREFIX" -D "author name respecting .mailmap" '%aN' complete -T -P "$PREFIX" -D "author name" '%an' complete -T -P "$PREFIX" -D "author email respecting .mailmap" '%aE' complete -T -P "$PREFIX" -D "author email" '%ae' complete -T -P "$PREFIX" -D "author date in the RFC 2822 format" '%aD' complete -T -P "$PREFIX" -D "author date (relative)" '%ar' complete -T -P "$PREFIX" -D "author timestamp" '%at' complete -T -P "$PREFIX" -D "author date in the ISO 8601 format" '%ai' complete -T -P "$PREFIX" -D "committer name respecting .mailmap" '%cN' complete -T -P "$PREFIX" -D "committer name" '%cn' complete -T -P "$PREFIX" -D "committer email respecting .mailmap" '%cE' complete -T -P "$PREFIX" -D "committer email" '%ce' complete -T -P "$PREFIX" -D "committer date in the RFC 2822 format" '%cD' complete -T -P "$PREFIX" -D "committer date (relative)" '%cr' complete -T -P "$PREFIX" -D "committer timestamp" '%ct' complete -T -P "$PREFIX" -D "committer date in the ISO 8601 format" '%ci' complete -T -P "$PREFIX" -D "encoding" '%e' complete -T -P "$PREFIX" -D "subject" '%s' complete -T -P "$PREFIX" -D "subject (suitable for a filename)" '%f' complete -T -P "$PREFIX" -D "body" '%b' complete -T -P "$PREFIX" -D "raw body" '%B' complete -T -P "$PREFIX" -D "commit notes" '%N' complete -T -P "$PREFIX" -D "full reflog selector" '%gD' complete -T -P "$PREFIX" -D "abbreviated reflog selector" '%gd' complete -T -P "$PREFIX" -D "reflog subject" '%gs' complete -T -P "$PREFIX" -D "switch color to red" '%Cred' complete -T -P "$PREFIX" -D "switch color to green" '%Cgreen' complete -T -P "$PREFIX" -D "switch color to blue" '%Cblue' complete -T -P "$PREFIX" -D "reset color" '%Creset' complete -T -P "$PREFIX" -D "left, right, or boundary mark" '%m' complete -T -P "$PREFIX" -D "newline" '%n' # complete -T -P "$PREFIX" -D "" '%x' complete -T -P "$PREFIX" -D "enable line wrapping" '%w' complete -T -P "$PREFIX" -D "%" '%%' ;; #<<# (format:*) ;; (*) #>># complete -P "$PREFIX" -D "commit ID and title" oneline complete -P "$PREFIX" -D "commit ID, author, and title" short complete -P "$PREFIX" -D "commit ID, author, date, and full log message" medium complete -P "$PREFIX" -D "commit ID, author, committer, and full log message" full complete -P "$PREFIX" -D "commit ID, author, date, committer, date, and full log message" fuller complete -P "$PREFIX" -D "imitate email" email complete -P "$PREFIX" -D "raw commit object" raw complete -P "$PREFIX" -D "specify a format" -T format: #<<# typeset name value while read -r name value; do complete -P "$PREFIX" -D "= $value" -- "${name#pretty.}" done 2>/dev/null <(git config --get-regexp 'pretty\..*') esac } function completion/git::--ignore-submodules:arg { #>># complete -P "$PREFIX" -D "ignore all changes in submodules" all complete -P "$PREFIX" -D "ignore uncommitted changes in submodules" dirty complete -P "$PREFIX" -D "show all changes in submodules" none complete -P "$PREFIX" -D "ignore untracked files in submodules" untracked } #<<# function completion/git::--pretty:arg { command -f completion/git::--format:arg "$@" } function completion/git::--receive-pack:arg { complete -P "$PREFIX" -S / -T -d # XXX should complete available remote commands } function completion/git::--recurse-submodules:arg { #>># complete -P "$PREFIX" no complete -P "$PREFIX" -D "update a submodule when the superproject has been changed" on-demand complete -P "$PREFIX" yes } #<<# function completion/git::--untracked-files:arg { #>># complete -P "$PREFIX" -D "print all individual files in untracked directories" all complete -P "$PREFIX" -D "print untracked files and directories" normal complete -P "$PREFIX" -D "don't print untracked files" no } #<<# function completion/git::--upload-pack:arg { complete -P "$PREFIX" -S / -T -d # XXX should complete available remote commands } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/touch0000644000175000017500000000343212154557026017070 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "touch" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/touch { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a; change the last access time only" "c ${long:+--no-create}; don't create files if missing; ignore missing files" "d: ${long:+--date:}; specify the time to change to (new syntax)" "m; change the last modified time only" "r: ${long:+--reference:}; change to the time of the specified file" "t:; specify the time to change to (traditional syntax)" ) #<# case $type in (FreeBSD) OPTIONS=("$OPTIONS" #># "A:; specify the time to change to (don't change date)" ) #<# esac case $type in (Darwin|FreeBSD|NetBSD) OPTIONS=("$OPTIONS" #># "f; try to change times regardless of permissions" ) #<# esac case $type in (GNU|FreeBSD|NetBSD) OPTIONS=("$OPTIONS" #># "h ${long:+--no-dereference}; change the time of a symbolic link itself" ) #<# esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "--time:; specify the type of time to change" "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (A) ;; (d|--date) ;; (t) ;; (--time) #>># complete -P "$PREFIX" -D "change the last access time only" atime access use complete -P "$PREFIX" -D "change the last modified time only" mtime modify ;; #<<# (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/printf0000644000175000017500000000506312154557026017252 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "printf" built-in command. function completion/printf { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then command -f completion/printf::backslash printf || command -f completion/printf::percent else complete -f fi ;; esac } function completion/printf::backslash { typeset word="$TARGETWORD" word=${word//\\\\} case $word in (*\\) PREFIX=${TARGETWORD%\\} #>># complete -T -P "$PREFIX" -D "alert (bell)" '\a' complete -T -P "$PREFIX" -D "backspace" '\b' complete -T -P "$PREFIX" -D "form feed" '\f' complete -T -P "$PREFIX" -D "newline" '\n' complete -T -P "$PREFIX" -D "carriage return" '\r' complete -T -P "$PREFIX" -D "tab" '\t' complete -T -P "$PREFIX" -D "vertical tab" '\v' complete -T -P "$PREFIX" -D "backslash" '\\' #<<# case ${1-} in (printf) #>># complete -T -P "$PREFIX" -D "double-quote" '\"' complete -T -P "$PREFIX" -D "single-quote" '\'"'" ;; #<<# (echo) #>># complete -T -P "$PREFIX" -D "stop printing" '\c' ;; #<<# esac return 0 esac return 1 } function completion/printf::percent { typeset word="$TARGETWORD" word=${word//%%} case $word in (*%) PREFIX=${TARGETWORD%\%} #>># complete -T -P "$PREFIX" -D "signed decimal integer" '%d' complete -T -P "$PREFIX" -D "signed decimal integer" '%i' complete -T -P "$PREFIX" -D "unsigned decimal integer" '%u' complete -T -P "$PREFIX" -D "unsigned octal integer" '%o' complete -T -P "$PREFIX" -D "unsigned hexadecimal integer (lowercase)" '%x' complete -T -P "$PREFIX" -D "unsigned hexadecimal integer (uppercase)" '%X' complete -T -P "$PREFIX" -D "floating-point number (lowercase)" '%f' complete -T -P "$PREFIX" -D "floating-point number (uppercase)" '%F' complete -T -P "$PREFIX" -D "floating-point number with exponent (lowercase)" '%e' complete -T -P "$PREFIX" -D "floating-point number with exponent (uppercase)" '%E' complete -T -P "$PREFIX" -D "%f or %e (automatically selected)" '%g' complete -T -P "$PREFIX" -D "%F or %E (automatically selected)" '%G' complete -T -P "$PREFIX" -D "first character of a string" '%c' complete -T -P "$PREFIX" -D "string" '%s' complete -T -P "$PREFIX" -D "string (escape sequences allowed)" '%b' complete -T -P "$PREFIX" -D "%" '%%' return 0 #<<# esac return 1 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/read0000644000175000017500000000067112154557026016663 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "read" built-in command. function completion/read { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "A --array; assign words to an array" "r --raw-mode; don't treat backslashes as escapes" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -v ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/crontab0000644000175000017500000000216412154557026017377 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "crontab" command. # Supports POSIX 2008, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, Mac OS X 10.6.3, # SunOS 5.10, HP-UX 11i v3. function completion/crontab { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=() case $type in (SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "e:; edit crontab with an editor" "l:; print the current crontab setting" "r:; remove crontab setting" ) #<# ;; (*) OPTIONS=("$OPTIONS" #># "e; edit crontab with an editor" "l; print the current crontab setting" "r; remove crontab setting" "u:; specify a user whose crontab is set, removed, or shown" ) #<# # We should check if crontab supports the -u option, but # there's no reliable way to do so. We just always complete the # -u option. ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (?) complete -u ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/uname0000644000175000017500000000331112154557026017047 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "uname" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/uname { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a ${long:+--all}; print all information" "m ${long:+--machine}; print the hardware type" "n ${long:+--nodename}; print the network host name" "r ${long:+--kernel-release}; print the OS release level" "s ${long:+--kernel-name}; print the operating system name" "v ${long:+--kernel-version}; print the OS version" ) #<# case $type in (GNU|SunOS) OPTIONS=("$OPTIONS" #># "i ${long:+--hardware-platform}; print the hardware platform name" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "o --operating-system; print the operating system name" "--help" "--version" ) #<# ;; (SunOS) OPTIONS=("$OPTIONS" #># "X; print expanded system information" ) #<# ;; esac ;; (FreeBSD) OPTIONS=("$OPTIONS" #># "i; print the OS kernel ident" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "i; print the machine identification number" "l; print the OS license level" ) #<# ;; esac case $type in (GNU|*BSD|Darwin|SunOS) OPTIONS=("$OPTIONS" #># "p ${long:+--processor}; print the processor architecture type" ) #<# esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (*) ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/array0000644000175000017500000000167712154557026017075 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "array" built-in command. function completion/array { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "d --delete; remove elements from an array" "i --insert; insert elements to an array" "s --set; replace an element of an array" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) typeset i=1 type= while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i++]} in (-d|--delete) type=d ;; (-i|--insert) type=i ;; (-s|--set ) type=s ;; (--) break ;; esac done if [ $i -gt ${WORDS[#]} ]; then complete --array else case $type in (d) ;; # TODO: complete array index (i|s) if [ $i -eq ${WORDS[#]} ]; then # TODO: complete array index else complete -f fi ;; (*) complete -f ;; esac fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/su0000644000175000017500000000477612154557026016411 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "su" command. # Supports GNU coreutils 8.10, FreeBSD 8.2, OpenBSD 4.9, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.11, HP-UX 11i v3. function completion/su { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset gnu=true ;; (*) typeset gnu= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=() case $type in (GNU|Darwin|*BSD) OPTIONS=("$OPTIONS" #># "f ${gnu:+--fast}; pass the -f option to the shell" "l ${gnu:+--login}; invoke the command as a login shell" "m ${gnu:+p --preserve-environment}; preserve all environment variables" ) #<# case $type in (GNU|OpenBSD) OPTIONS=("$OPTIONS" #># "s: ${gnu:+--shell:}; specify the shell to be run" ) #<# esac esac case $type in (*BSD) if [ "$(id -u 2>/dev/null)" -eq 0 ] 2>/dev/null; then OPTIONS=("$OPTIONS" #># "c:; specify the login class" ) #<# fi esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "c: --command:; specify the command run instead of the shell" "--help" "--version" ) #<# ;; (FreeBSD) OPTIONS=("$OPTIONS" #># "s; set the MAC label to the default" ) #<# ;; (OpenBSD) OPTIONS=("$OPTIONS" #># "a:; specify the authentication method" "L; loop till a successful authentication" ) #<# ;; (NetBSD) OPTIONS=("$OPTIONS" #># "d; like -l, but preserve the working directory" "K; don't use Kerberos" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "d; use distributed computing environment (DCE)" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (a) if command -vf completion//bsd::completeauthmethod >/dev/null 2>&1 || . -AL completion/_bsd; then command -f completion//bsd::completeauthmethod fi ;; (c) case $type in (GNU) complete -P "$PREFIX" -c ;; (*BSD) if command -vf completion//bsd::completeauthclass >/dev/null 2>&1 || . -AL completion/_bsd; then command -f completion//bsd::completeauthclass fi ;; esac ;; (s) WORDS=() command -f completion//reexecute -e ;; (*) command -f completion//getoperands if [ "${WORDS[1]:-}" = - ]; then WORDS=("${WORDS[2,-1]}") fi if [ "${WORDS[#]}" -le 0 ]; then complete -P "$PREFIX" -u else WORDS=(sh "${WORDS[2,-1]}") #XXX assume POSIX shell command -f completion//reexecute fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/nice0000644000175000017500000000157112154557026016666 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "nice" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/nice { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "n: ${long:+--adjustment:}; specify the nice value increment" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "--help" "--version" ) #<# esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion//getoperands command -f completion//reexecute -e ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/sort0000644000175000017500000001177412154557026016745 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "sort" command. # Supports POSIX 2008, GNU coreutils 8.6, OpenBSD 4.8, NetBSD 5.0, # SunOS 5.10, HP-UX 11i v3. function completion/sort { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "b ${long:+--ignore-leading-blanks}; ignore leading blanks in sort keys" "C; like -c, but don't report disorders" "c; check if the input is well-sorted" "d ${long:+--dictionary-order}; consider blank or alphanumeric characters only" "f ${long:+--ignore-case}; case-insensitive comparison" "i ${long:+--ignore-nonprinting}; consider printable characters only" "k: ${long:+--key:}; specify the sort field" "m ${long:+--merge}; assume all input files are already sorted" "n ${long:+--numeric-sort}; compare numeric values" "o: ${long:+--output:}; specify the output file" "r ${long:+--reverse}; sort in reverse order" "t: ${long:+--field-separator:}; specify the field separator character" "u ${long:+--unique}; make equal lines unique" ) #<# case $type in (GNU|*BSD|SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "T: ${long:+--temporary-directory:}; specify the directory to put temporary files in" ) #<# case $type in (GNU|SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "M ${long:+--month-sort}; compare month names" ) #<# case $type in (GNU|SunOS) OPTIONS=("$OPTIONS" #># "S: ${long:+--buffer-size:}; specify the initial buffer size in 1024 byte units" ) #<# esac esac case $type in (GNU|*BSD) OPTIONS=("$OPTIONS" #># "s ${long:+--stable}; stable sort" ) #<# case $type in (GNU|OpenBSD) OPTIONS=("$OPTIONS" #># "z ${long:+--zero-terminated}; use null bytes as the line separator" ) #<# esac case $type in (*BSD) OPTIONS=("$OPTIONS" #># "R:; specify the line separator" ) #<# esac esac esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "--batch-size:; specify the number of inputs to sort at once" "--check::; check if the input is well-sorted" "--compress-program:; specify the program to compress temporary files" "--debug; print debugging messages" "--files0-from:; specify a file containing null-separated filenames to read" "g --general-numeric-sort; compare floating-point numbers" "h --human-numeric-sort; compare numeric values followed by SI suffixes" "--parallel:; specify the number of sort processes to run at a time" "R --random-sort; sort in random order" "--random-source:; specify the random seed file" "--sort:; specify comparison type" "V --version-sort; compare version numbers" "--help" "--version" ) #<# ;; (OpenBSD) OPTIONS=("$OPTIONS" #># "H; use merge sort rather than radix sort" ) #<# ;; (NetBSD) OPTIONS=("$OPTIONS" #># "S; non-stable sort" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "A; simple byte-by-byte comparison" "z:; specify the buffer size per line" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([RStz]|--batch-size|--buffer-size|--field-separator|--parallel) ;; (--check) #>># complete -P "$PREFIX" -D "don't report disorders" quiet silent complete -P "$PREFIX" -D "report disorders" diagnose-first ;; #<<# (--compress-program) WORDS=() command -f completion//reexecute -e ;; (k|--key) typeset word="${TARGETWORD#"$PREFIX"}" case $word in (*[[:alnum:]]) #>># complete -T -P "$TARGETWORD" -D "ignore leading blanks in sort keys" b complete -T -P "$TARGETWORD" -D "consider blank or alphanumeric characters only" d complete -T -P "$TARGETWORD" -D "case-insensitive comparison" f complete -T -P "$TARGETWORD" -D "consider printable characters only" i complete -T -P "$TARGETWORD" -D "compare numeric values" n complete -T -P "$TARGETWORD" -D "sort in reverse order" r #<<# case $type in (GNU|SunOS|HP-UX) #>># complete -T -P "$TARGETWORD" -D "compare month names" M esac #<<# case $type in (GNU|SunOS|HP-UX) #>># complete -T -P "$TARGETWORD" -D "compare floating-point numbers" g complete -T -P "$TARGETWORD" -D "compare numeric values followed by SI suffixes" h complete -T -P "$TARGETWORD" -D "sort in random order" R complete -T -P "$TARGETWORD" -D "compare version numbers" V esac #<<# esac ;; (--sort) #>># complete -P "$PREFIX" -D "compare floating-point numbers" general-numeric complete -P "$PREFIX" -D "compare numeric values followed by SI suffixes" human-numeric complete -P "$PREFIX" -D "compare month names" month complete -P "$PREFIX" -D "compare numeric values" numeric complete -P "$PREFIX" -D "compare version numbers" version complete -P "$PREFIX" -D "sort in random order" random complete -P "$PREFIX" -D "" ;; #<<# (T|--temporary-directory) complete -P "$PREFIX" -S / -T -d ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-merge0000644000175000017500000000654412154557026017635 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-merge" command. # Supports Git 1.7.7. function completion/git-merge { WORDS=(git merge "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::merge:arg { OPTIONS=( #># "--abort; reset to the state before starting merge" "m:; specify the message" "--no-rerere-autoupdate; disable the rerere mechanism" "--rerere-autoupdate; enable the rerere mechanism" ) #<# command -f completion/git::merge:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeref ;; (*) command -f completion/git::merge:compopt ;; esac } function completion/git::merge:getopt { OPTIONS=("$OPTIONS" #># "--commit; commit the merge result automatically" "--ff; fast-forward if possible" "--ff-only; allow fast-forward only" "--log::; specify the number of commits in the merged branch of which the messages are reused" "--no-commit; don't commit the merge result automatically" "--no-ff; don't fast-forward even if possible" "--no-log; don't reuse messages from the commits on the merged branch" "--no-progress; don't print progress info" "--no-squash; cancel the --squash option" "n --no-stat --no-summary; don't print a diffstat" "--progress; print progress info" "q --quiet; don't print anything" "--squash; like --no-commit, but don't set MERGE_HEAD" "--stat --summary; print a diffstat" "s: --strategy:; specify the merge strategy" "X: --strategy-option:; specify a strategy-specific option" "v --verbose" # TODO description ) #<# } function completion/git::merge:compopt case $ARGOPT in (m|--log) ;; (s|--strategy) #>># complete -P "$PREFIX" -D "standard algorithm for merging more than 2 heads" octopus complete -P "$PREFIX" -D "simple algorithm that makes no change" ours complete -P "$PREFIX" -D "recursive 3-way merge" recursive complete -P "$PREFIX" -D "safe and fast 3-way merge" resolve complete -P "$PREFIX" -D "recursive 3-way merge with subtree matching" subtree ;; #<<# (X|--strategy-option) typeset i=2 strategy=recursive while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (-s*) strategy=${WORDS[i]#-s} ;; (--strategy=*) strategy=${WORDS[i]#--strategy=} ;; (--) break ;; esac i=$((i+1)) done case $strategy in (recursive) #>># complete -P "$PREFIX" -D "resolve conflicts by discarding remote changes" ours complete -P "$PREFIX" -D "resolve conflicts by discarding local changes" theirs complete -P "$PREFIX" -D "use the patience diff algorithm" patience complete -P "$PREFIX" -D "discard conflicting changes of the number of spaces" ignore-space-change complete -P "$PREFIX" -D "discard conflicting changes of spaces" ignore-all-space complete -P "$PREFIX" -D "discard conflicting changes of spaces at end of line" ignore-space-at-eol complete -P "$PREFIX" -D "run hooks to obtain trees to merge" renormalize complete -P "$PREFIX" -D "don't run hooks to obtain trees to merge" no-renormalize complete -P "$PREFIX" -D "specify the threshold for detecting renames" -T rename-threshold= complete -P "$PREFIX" -D "match directory trees before merging" subtree ;; #<<# esac ;; (*) return 1 ;; esac # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/_backup0000644000175000017500000000075212154557026017354 0ustar magicantmagicant# (C) 2010 magicant # This file contains a function that completes the argument to the --backup # option of the cp, ln, and mv commands. function completion//completebackup { #>># complete -P "$PREFIX" -D "don't make backups" none off complete -P "$PREFIX" -D "make numbered backups" numbered t complete -P "$PREFIX" -D "make backups according to existing ones" existing nil complete -P "$PREFIX" -D "make simple backups" simple never } #<<# # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gitg0000644000175000017500000000245112154557026016700 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "gitg" command. # Supports gitg 0.2.5. function completion/gitg { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--bisect; show commits between good and bad only" "--class:; specify a program class used by the window manager" "c --commit; start in the commit mode" "--display:; specify the X display to use" "--g-fatal-warnings; make all GTK+ warnings fatal" "--gtk-module:; specify an additional GTK+ module to load" "h ? --help; print help" "--help-all; print help for all options" "--help-gtk; print help for GTK+ options" "--name:; specify a program name used by the window manager" "-s --select; select commit after loading the repository" "V --version; print version info" ) #<# if command -vf completion/git >/dev/null 2>&1 || . -AL completion/git; then if command -vf completion/git::rev-list:getopt >/dev/null 2>&1 || . -AL completion/git-rev-list; then command -f completion/git::rev-list:getopt fi fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') # TODO support repository operands command -f completion/git::completerefpath range=true ;; (*) command -f completion/git::rev-list:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ssh-add0000644000175000017500000000154612154557026017275 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "ssh-add" command. # Supports OpenSSH 6.2. function completion/ssh-add { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c; confirm when authenticating with the identities being added" "D; delete all identities" "d; delete identities" "e:; remove keys from the specified PKCS#11 library" "k; don't load certificates" "L; print the public keys of the identities in the agent" "l; print the fingerprints of the identities in the agent" "s:; add keys from the specified PKCS#11 library" "t:; specify the lifetime of identities being added in seconds" "X; unlock the agent" "x; lock the agent" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ([est]) ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-stash0000644000175000017500000000674612154557026017664 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-stash" command. # Supports Git 1.7.7. function completion/git-stash { WORDS=(git stash "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::stash:arg if [ ${WORDS[#]} -le 1 ]; then #>># complete -P "$PREFIX" -D "restore stash contents" apply complete -P "$PREFIX" -D "restore stash contents in a new branch" branch complete -P "$PREFIX" -D "remove all stashes" clear complete -P "$PREFIX" -D "create a stash commit without adding it to the stash list" create complete -P "$PREFIX" -D "remove stash contents without restoring it" drop complete -P "$PREFIX" -D "list existing stashes" list complete -P "$PREFIX" -D "restore stash contents and remove it from the stash list" pop complete -P "$PREFIX" -D "save local changes in a new stash and reset to HEAD" save complete -P "$PREFIX" -D "show stash contents" show else #<<# WORDS=("${WORDS[2,-1]}") if command -vf "completion/git::stash:${WORDS[1]}:arg" >/dev/null 2>&1; then command -f "completion/git::stash:${WORDS[1]}:arg" fi fi function completion/git::stash:apply:arg { command -f completion/git::stash:pop:arg } function completion/git::stash:branch:arg { if [ ${WORDS[#]} -le 1 ]; then command -f completion/git::completeref --branches else command -f completion/git::stash:completestash fi } #function completion/git::stash:clear:arg { #} #function completion/git::stash:create:arg { #} function completion/git::stash:drop:arg { command -f completion/git::stash:pop:arg } function completion/git::stash:list:arg { OPTIONS=() if command -vf completion/git::log:getopt >/dev/null 2>&1 || . -AL completion/git-log; then command -f completion/git::log:getopt fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') ;; (*) command -f completion/git::log:compopt ;; esac } function completion/git::stash:pop:arg { OPTIONS=( #># "q --quiet; print error messages only" ) #<# case ${WORDS[1]} in (apply|pop) OPTIONS=("$OPTIONS" #># "--index; restore the index as well as the working copy" ) #<# esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::stash:completestash ;; esac } function completion/git::stash:save:arg { OPTIONS=( #># "a --all; stash all files including ignored/untracked files" "--keep-index; keep the index intact" "p --patch; interactively choose patch hunks to stash" "q --quiet; print error messages only" "--no-keep-index; stash and reset the index" "u --include-untracked; stash untracked files as well as tracked files" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # ('') # ;; esac } function completion/git::stash:show:arg { OPTIONS=() if command -vf completion/git::diff:getopt >/dev/null 2>&1 || . -AL completion/git-diff; then command -f completion/git::diff:getopt fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::stash:completestash ;; (*) command -f completion/git::diff:compopt ;; esac } function completion/git::stash:completestash { typeset name message while read -r name message; do name=${name%:} complete -P "$PREFIX" -D "$message" -- "$name" done 2>/dev/null <(git stash list) } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gitx0000644000175000017500000000146212154557026016722 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "gitx" command. # Supports GitX 0.7. function completion/gitx { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "--bisect; show commits between good and bad only" "c --commit; start in the commit mode" "h --help; print help" ) #<# if command -vf completion/git >/dev/null 2>&1 || . -AL completion/git; then if command -vf completion/git::rev-list:getopt >/dev/null 2>&1 || . -AL completion/git-rev-list; then command -f completion/git::rev-list:getopt fi fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completerefpath range=true ;; (*) command -f completion/git::rev-list:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/cp0000644000175000017500000001165212154557026016353 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "cp" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/cp { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "f ${long:+--force}; remove unwritable destination files before copying" "H; follow symbolic links in source operands" "i ${long:+--interactive}; ask before overwriting existing files" "L ${long:+--dereference}; follow all symbolic links in source files" "P ${long:+--no-dereference}; copy symbolic links as symbolic links" "R ${long:+--recursive}; recursively copy directories" ) #<# ADDOPTIONS=() case $type in (GNU|FreeBSD|NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "v ${long:+--verbose}; print a message for each file processed" ) #<# case $type in (GNU|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "n ${long:+--no-clobber}; don't overwrite existing files" "x ${long:+--one-file-system}; skip subdirectories on different file systems" ) #<# case $type in (GNU|FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "l ${long:+--link}; make hard links instead of copying" ) #<# esac case $type in (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "a; like -PpR" ) #<# esac esac esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "a --archive; like -PR --preserve=all" "b; like --backup=existing" "--backup::; specify how to make a backup" "c; like --preserve=context" "--copy-contents; treat special files as regular files in recursion" "d; like -P --preserve=links" "p; like --preserve=mode,ownership,timestamps" "--preserve::; specify file attributes to preserve" "--no-preserve:; specify file attributes not to preserve" "--parents; mirror parent directories in source to destination" "--reflink::; lightweight (copy-on-write) copy" "--remove-destination; remove existing destination files before copying" "--sparse:; specify when to make sparse copies" "--strip-trailing-slashes; remove trailing slashes from source operands" "s --symbolic-link; make symbolic links instead of copying" "S: --suffix:; specify a suffix to append to backup file names" "t: --target-directory:; specify a destination directory" "T --no-target-directory; always treat the destination as a regular file" "u --update; don't copy if destination is newer than source" "Z: --context:; specify security context of copies" "--help" "--version" ) #<# ;; (*BSD|Darwin|SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "p; preserve file attributes" ) #<# case $type in (NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "N; don't copy file flags (with -p)" ) #<# ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "@; preserve extended attributes" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "e:; specify extent attributes treatment" "S; safe mode" ) #<# ;; esac ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (--backup) if command -vf completion//completebackup >/dev/null 2>&1 || . -AL completion/_backup; then command -f completion//completebackup fi ;; (e) #>># complete -P "$PREFIX" -D "print a message when failed to copy an extent attribute" warn complete -P "$PREFIX" -D "don't copy extent attributes" ignore complete -P "$PREFIX" -D "don't copy a file when cannot copy the extent attribute" force ;; #<<# (--preserve|--no-preserve) typeset word word=${TARGETWORD#"$PREFIX"} word=${word##*,} PREFIX=${TARGETWORD%"$word"} #>># complete -T -P "$PREFIX" -S , -D "file permission bits" mode complete -T -P "$PREFIX" -S , -D "owner and group" ownership complete -T -P "$PREFIX" -S , -D "last access/modification time" timestamps complete -T -P "$PREFIX" -S , -D "hard links" links complete -T -P "$PREFIX" -S , -D "SELinux security context" context complete -T -P "$PREFIX" -S , -D "extended attributes" xattr complete -P "$PREFIX" -D "all attributes" all ;; #<<# (--reflink) #>># complete -P "$PREFIX" -D "print a message when failed to do copy-on-write copy" always complete -P "$PREFIX" -D "fall back to normal copy when failed to do copy-on-write copy" auto ;; #<<# (--sparse) #>># complete -P "$PREFIX" -D "make destination sparse if source is sparse" auto complete -P "$PREFIX" -D "always try to make sparse copies" always complete -P "$PREFIX" -D "never make sparse copies" never ;; #<<# (S|--suffix) ;; (t|--target-directory) complete -T -P "$PREFIX" -S / -d ;; (Z|--context) # TODO ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/break0000644000175000017500000000056412154557026017035 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "break" built-in command. function completion/break { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "i --iteration; break iterative execution" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/env0000644000175000017500000000375112154557026016542 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "env" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/env { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "i ${long:+--ignore-environment}; ignore variables exported from the shell" ) #<# case $type in (GNU|FreeBSD) OPTIONS=("$OPTIONS" #># "u: ${long:+--unset:}; specify a variable to remove from the environment" ) #<# esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "0 --null; separate variables by null bytes in printing" "--help" "--version" ) #<# ;; (FreeBSD) OPTIONS=("$OPTIONS" #># "P:; specify directory paths to search for the invoked command" "S:; specify a string to be parsed before processing" "v; describe what is going on during the process" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (P) typeset targetword="${TARGETWORD#"$PREFIX"}" targetword=${targetword##*:} PREFIX=${TARGETWORD%"$targetword"} complete -T -P "$PREFIX" -S / -d ;; (S) ;; (u|--unset) complete -P "$PREFIX" -v ;; (*) command -f completion//getoperands typeset i=1 while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (*=*) ;; (*) WORDS=("${WORDS[i,-1]}") command -f completion//reexecute return ;; esac i=$((i+1)) done case $TARGETWORD in (*=*) typeset targetword="${TARGETWORD#"$PREFIX"}" targetword=${targetword#*=} targetword=${targetword##*:} PREFIX=${TARGETWORD%"$targetword"} complete -P "$PREFIX" -f ;; (*) complete -T -S = -v WORDS=() command -f completion//reexecute -e ;; esac ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/echo0000644000175000017500000000336312154557026016667 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "echo" built-in command. function completion/echo { command -f completion/echo::option || command -f completion/echo::operand } function completion/echo::option { case ${ECHO_STYLE-} in ([BbDd]*) typeset options=n ;; ([GgZz]*) typeset options=neE ;; (*) return 1 ;; esac typeset word for word in "${WORDS[2,-1]}"; do case $word in (-?*) case ${word#-} in (*[!$options]*) return 1 esac ;; (*) return 1 ;; esac done case $TARGETWORD in (-*) case ${TARGETWORD#-} in (*[!$options]*) return 1 esac # option completion case $options in (*n*) #>># complete -P "$TARGETWORD" -D "don't print the last newline" -O n esac #<<# case $options in (*e*) #>># complete -P "$TARGETWORD" -D "enable escape sequences" -O e esac #<<# case $options in (*E*) #>># complete -P "$TARGETWORD" -D "disable escape sequences" -O E esac #<<# return 0 esac return 1 } function completion/echo::operand { typeset options escape case ${ECHO_STYLE-} in ([Bb]*) options=n escape=false ;; ([Dd]*) options=n escape=true ;; ([Gg]*) options=neE escape=false ;; ([Zz]*) options=neE escape=true ;; ([Rr]*) options= escape=false ;; (*) options= escape=true ;; esac typeset word for word in "${WORDS[2,-1]}"; do case $word in (-?*) case ${word#-} in (*[!$options]*) break esac case ${word//n} in (*E) escape=false ;; (*e) escape=true ;; esac ;; (*) break ;; esac done if $escape; then if command -vf completion/printf::backslash >/dev/null 2>&1 || . -AL completion/printf; then command -f completion/printf::backslash echo fi fi complete -f } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/hash0000644000175000017500000000135012154557026016666 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "hash" built-in command. function completion/hash { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a --all; don't exclude built-ins when printing cached paths" "d --directory; manipulate caches for home directory paths" "r --remove; remove cached paths" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) typeset directory=false word for word in "${WORDS[2,-1]}"; do case $word in (-d|--directory) directory=true ;; (--) break ;; esac done if $directory; then complete -u else complete --external-command fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/basename0000644000175000017500000000157512154557026017527 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "basename" command. # Supports POSIX 2008, GNU coreutils 8.4. function completion/basename { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type= ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=() case $type in (GNU) OPTIONS=("$OPTIONS" "--help" "--version") ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) command -f completion//getoperands case ${WORDS[#]} in (0) complete -f ;; (1) typeset word="$(sed -e 's;/*$;;' -e 's;^.*/;;' <<<"${WORDS[1]}")" while word=${word#?}; [ "$word" ]; do complete -- "$word" done ;; esac ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/newgrp0000644000175000017500000000066112154557026017251 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "newgrp" command. # Supports POSIX 2008. function completion/newgrp { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "l; reset environment variables, etc. as if you logged in again" ) #<# command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -g ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-clone0000644000175000017500000000405212154557026017626 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-clone" command. # Supports Git 1.7.7. function completion/git-clone { WORDS=(git clone "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::clone:arg { OPTIONS=( #># "--bare; clone as a bare repository" "b: --branch:; specify a branch to be the new repository's HEAD" "c: --config:; specify a config variable for the new repository" "--depth:; specify the max number of history to clone" "l --local; optimize local clone" "--mirror; clone as a mirror repository" "n --no-checkout; don't check out HEAD automatically" "--no-hardlinks; don't use hard links to spare disk space for local clone" "o: --origin:; specify a name for the source repository to set as a remote repository" "--progress; report progress" "q --quiet; don't report progress" "--recursive --recurse-submodules; initialize submodules recursively" "--reference:; specify a reference repository to share objects (possibly dangerous operation)" "--separate-git-dir:; specify a directory where the new repository is located" "s --shared; share objects in repositories (possibly dangerous operation)" "--template:; specify a directory that contains templates" "u: --upload-pack:; specify a path for git-upload-pack on the remote host" "v --verbose" # TODO description ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # (b|--branch) # ;; (c|--config) if command -vf completion//git::completeoptionname >/dev/null 2>&1 || . -AL completion/git-config; then command -f completion//git::completeoptionname = fi ;; # (--depth) # ;; # (o|--origin) # ;; (u|--reference|--template|--separate-git-dir|--upload-pack) complete -P "$PREFIX" -S / -T -d ;; ('') command -f completion//getoperands command -f completion/git::clone:opr ;; esac } function completion/git::clone:opr { if [ ${WORDS[#]} -eq 0 ]; then #TODO complete remote URI fi complete -P "$PREFIX" -S / -T -d } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/awk0000644000175000017500000000424212154557026016530 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "awk" command. # Supports POSIX 2008, GNU awk 3.1.8, OpenBSD 4.9, NetBSD 5.0. function completion/awk { case $("${WORDS[1]}" --version <>/dev/null 2>&0) in (*'GNU Awk'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "F: ${long:+--field-separator:}; specify the input field separator" "f: ${long:+--file:}; specify an AWK source file to execute" ) #<# if "${WORDS[1]}" -v foo=bar '' <>/dev/null >&0 2>&1; then OPTIONS=("$OPTIONS" #># "v: ${long:+--assign:}; specify an assignment to be done during startup" ) #<# fi case $type in (GNU) OPTIONS=("$OPTIONS" #># "O --optimize; enable optimization" "W:" "--copyright --copyleft; print copyright info" "--dump-variables::; print variables to the specified file" "--exec:; specify an AWK source file to execute last" "--gen-po; generate PO file" "--lint-old; print warnings about non-portable new constructs" "--lint::; print warnings about dubious or non-portable constructs" "--non-decimal-data; allow octal and hexadecimal numbers" "--posix; allow POSIX-compatible constructs only" "--profile::; write profiling data to the specified file" "--re-interval; allow intervals in regular expressions" "--source:; specify AWK source code to execute" "--traditional --compat; disable GNU extensions" "--use-lc-numeric; use locale's decimal point character" "--help --usage" "--version" ) #<# ;; (OpenBSD|NetBSD) OPTIONS=("$OPTIONS" #># "d::; debug mode" "-safe; disable file output, process creation, and accessing environment variables" "V; print version info" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (d) ;; (F) ;; (v|--assign) ;; (W) #TODO: -W long option ;; (--lint) #>># complete -D "treat warnings as errors" fatal complete -D "warn about invalid constructs only" invalid ;; #<<# (--source) ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gvim0000644000175000017500000000030212154557026016701 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "gvim" command. # Supports Vim 7.3. function completion/gvim { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/sftp0000644000175000017500000000025612154557026016723 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "sftp" command. function completion/sftp { command -f completion//reexecute ssh } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-pull0000644000175000017500000000320412154557026017500 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-pull" command. # Supports Git 1.7.7. function completion/git-pull { WORDS=(git pull "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::pull:arg { OPTIONS=( #># "--no-rebase; cancel the --rebase option" "q --quiet; don't report progress" "--rebase; rebase the current branch instead of merging" "v --verbose" # TODO description ) #<# if command -vf completion/git::fetch:getopt >/dev/null 2>&1 || . -AL completion/git-fetch; then command -f completion/git::fetch:getopt fi if command -vf completion/git::merge:getopt >/dev/null 2>&1 || . -AL completion/git-merge; then command -f completion/git::merge:getopt fi command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (--recurse-submodules|--upload-pack) command -f completion/git::$ARGOPT:arg ;; # (--depth) # ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then #TODO complete remote URI command -f completion/git::completeremote elif [ "${WORDS[-1]}" = tag ]; then command -f completion/git::completeref --tags else typeset word="${TARGETWORD#"$PREFIX"}" word=${word#+} case $word in (*:*) # complete local refs word=${word#*:} PREFIX=${TARGETWORD%"$word"} command -f completion/git::completeref ;; (*) # complete remote refs PREFIX=${TARGETWORD%"$word"} command -f completion/git::completeremoteref "${WORDS[1]}" ;; esac fi ;; (*) command -f completion/git::merge:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gvimdiff0000644000175000017500000000031212154557026017533 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "gvimdiff" command. # Supports Vim 7.3. function completion/gvimdiff { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/du0000644000175000017500000001251012154557026016353 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "du" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/du { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "a ${long:+--all}; print size for all files including non-directories" "H ${long:+--dereference-args}; follow symbolic links in operands" "k; print figures in kilobytes (1024-byte units)" "L ${long:+--dereference}; follow all symbolic links" "s ${long:+--summarize}; don't print subdirectory sizes" "x ${long:+--one-file-system}; count disk usage only in the same file system" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "h ${long:+--human-readable}; print size using K, M, etc. for 1024^n" ) #<# case $type in (GNU|*BSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "c ${long:+--total}; print the grand total after the normal output" "P ${long:+--no-dereference}; don't follow symbolic links" ) #<# case $type in (GNU|FreeBSD|NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "m; print figures in megabytes (1048576-byte units)" ) #<# case $type in (GNU|FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "l ${long:+--count-links}; count size as many times as the file's hard links" ) #<# esac case $type in (FreeBSD|NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "d:; specify directory depth to limit printing" ) #<# case $type in (FreeBSD|NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "n; ignore files with the nodump flag" ) #<# esac case $type in (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "I:; specify a glob pattern for files to ignore" ) #<# esac case $type in (NetBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "g; print figures in gigabytes (1073741824-byte units)" ) #<# esac esac esac esac esac case $type in (*BSD|Darwin|SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "r; warn about unreadable directories and unaccessible files" ) #<# esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "0 --null; separate output lines with null byte rather than newline" "B: --block-size:; specify the block size unit to print figures in" "b --bytes; like -B 1 --apparent-size" "S --separate-dirs; don't include subdirectories' size in the parent's size" "X: --exclude-from:; skip files whose names match a pattern in the specified file" "--apparent-size; print apparent file sizes rather than actual disk usage" "--exclude:; skip files whose names match the specified pattern" "--files0-from:; specify a file containing null-separated file names to count size" "--max-depth:; specify directory depth to limit printing" "--si:; print size using k, M, etc. for 1000^n" "--time:; specify which time to print" "--time-style:; specify format to print time in" "--help" "--version" ) #<# ;; (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "A; print apparent file sizes rather than actual disk usage" "B:; specify block size assumed in disk usage estimation" ) #<# ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "d; count disk usage only in the same file system" "o; don't include subdirectories' size in the parent's size" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "b; print the number of blocks used by swap" "t:; specify a file system type to print" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (B|--block-size) case $type in (GNU) if command -vf completion//completeblocksize >/dev/null 2>&1 || . -AL completion/_blocksize; then command -f completion//completeblocksize fi ;; esac ;; (d) ;; #(I) -- complete as filename as usual # ;; (t) ;; #(X|--exclude-from|--exclude|--files0-from) -- complete as filename as usual # ;; (--max-depth) ;; (--time) #>># complete -P "$PREFIX" -D "print or sort by last access time" atime access use complete -P "$PREFIX" -D "print or sort by last status change time" ctime status ;; #<<# (--time-style) case $TARGETWORD in ("$PREFIX+"*) if command -vf completion//completestrftime >/dev/null 2>&1 || . -AL completion/date; then command -f completion//completestrftime fi ;; (*) #>># complete -P "$PREFIX" -D "e.g. 2000-01-01 01:23:45.678901234 +0900" full-iso complete -P "$PREFIX" -D "e.g. 2010-06-29 00:37" long-iso complete -P "$PREFIX" -D "e.g. 01-23 01:23 or 2000-01-23" iso complete -P "$PREFIX" -D "locale-dependent time style" locale posix-locale complete -P "$PREFIX" -D "like full-iso, but only when not in POSIX locale" posix-full-iso complete -P "$PREFIX" -D "like long-iso, but only when not in POSIX locale" posix-long-iso complete -P "$PREFIX" -D "like iso, but only when not in POSIX locale" posix-iso complete -T -P "$PREFIX" -D "specify time format after +" + ;; #<<# esac ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/csplit0000644000175000017500000000276512154557026017254 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "csplit" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/csplit { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "f: ${long:+--prefix:}; specify the prefix of the output files" "k ${long:+--keep-files}; leave output files intact on an error" "n: ${long:+--digits:}; specify the suffix length for output files" "s ${long:+q --silent --quiet}; don't print output file sizes" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "b: --suffix-format:; specify the format of output file suffix" "z --elide-empty-files; remove empty output files" "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (f) complete -P "$PREFIX" -f ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then complete -f else #>># complete -T -D "split before a line matching the following regular expression" / complete -T -D "like / but don't include the matching line" % complete -T -D "repeat the previous operand's behavior the specified times" { fi #<<# ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/slogin0000644000175000017500000000026212154557026017237 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "slogin" command. function completion/slogin { command -f completion//reexecute ssh } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/iconv0000644000175000017500000000407212154557026017065 0ustar magicantmagicant# (C) 2010-2013 magicant # Completion script for the "iconv" command. # Supports POSIX 2008, GNU libc 2.12.1, GNU libiconv 1.13, NetBSD 5.0, # SunOS 5.10, HP-UX 11i v3. function completion/iconv { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU libc'*) typeset type=glibc ;; (*'GNU libiconv'*) typeset type=glibiconv ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (glibc|glibiconv) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c; discard unconvertible characters" "f: ${long:+--from-code:}; specify the input encoding" "l ${long:+--list}; print all supported encodings" "s ${long:+--silent}; suppress warnings about unconvertible characters" "t: ${long:+--to-code:}; specify the output encoding" ) #<# case $type in (glibc) OPTIONS=("$OPTIONS" #># "o: --output:; specify the file to output" "? --help; print help" "--verbose; print progress info" "V --version; print version info" ) #<# ;; (glibiconv) OPTIONS=("$OPTIONS" #># "--unicode-subst:; specify a format to substitute unconvertible Unicode characters with" "--byte-subst:; specify a format to substitute unconvertible bytes with" "--widechar-subst:; specify a format to substitute invalid wide characters with" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([ft]|--from-code|--to-code) command -f completion/iconv::compenc "${WORDS[1]}" ;; (*) complete -P "$PREFIX" -f ;; esac } function completion/iconv::compenc { typeset iconv="${1-iconv}" case $("$iconv" --version 2>/dev/null) in (*'GNU libc'*) typeset type=glibc ;; (*'GNU libiconv'*) typeset type=glibiconv ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac # POSIX does not specify the format of `iconv -l' output. # We support GNU libc and libiconv for now. case $type in (glibc|glibiconv) complete -P "$PREFIX" -- $("$iconv" -l 2>/dev/null) esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ps0000644000175000017500000001646412154557026016401 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "ps" command. # Supports POSIX 2008, procps 3.2.8, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/ps { typeset -x PS_PERSONALITY=posix case $("${WORDS[1]}" --version 2>/dev/null) in (*'procps'*) typeset type=procps ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (procps) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "A; print all processes" "a; print all processes with terminals" "G: ${long:+--Group:}; specify real group IDs of processes to print" "o: ${long:+--format:}; specify format items to print" "p: ${long:+--pid:}; specify process IDs of processes to print" "t: ${long:+--tty:}; specify terminals of processes to print" "U: ${long:+--User:}; specify real user IDs of processes to print" ) #<# case $type in (procps|*BSD|Darwin|SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "j; print job info" "l; print in the long format" ) #<# case $type in (procps|Darwin|SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "d; print all processes but session leaders" "e; print all processes" "f; print in the full format" "u: ${long:+--user:}; specify effective user IDs of processes to print" ) #<# case $type in (procps) OPTIONS=("$OPTIONS" #># "g:; specify session IDs or effective group IDs of processes to print" "--group:; specify effective group IDs of processes to print" ) #<# ;; (*) OPTIONS=("$OPTIONS" #># "g:; specify process group IDs of processes to print" ) #<# ;; esac esac esac case $type in (procps) OPTIONS=("$OPTIONS" #># "F; print in the extra full format" "m; print threads after each process" "N --deselect; print processes not selected by other options" "n:; specify the name list file" "T; print threads rather than processes" "Z M --context; print security contexts" "V --version; print version info" "--columns: --cols: --width:; specify the screen width" "--cumulative; include child processes' CPU time in their parent's" "--headers; print a header line for each screen page" "--info; print debugging info" "--lines: --rows:; specify the screen height" "--no-headers; don't print the header line" "--ppid:; specify parent process IDs of processes to print" "--sort:; specify sort keys" "--help" ) #<# esac case $type in (procps|*BSD|Darwin) OPTIONS=("$OPTIONS" #># "O:; specify format items to print in addition to the default ones" "w; wide format" ) #<# case $type in (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "C; use the raw CPU percentage" "c; print only the command name for the command column" "L; print available format items" "m; sort by memory usage" "N:; specify the name list file" "r; sort by current CPU usage" "S; include child processes' CPU time in their parent's" "T; print processes associated with the current terminal" "v; print in the virtual memory format" "x; print processes with terminals as well" ) #<# case $type in (FreeBSD) OPTIONS=("$OPTIONS" #># "d; print process family trees" "f; print data even for swapped-out processes" "H; print thread info" "X; don't print processes with terminals" "Z; print MAC labels as well" ) #<# ;; (OpenBSD) OPTIONS=("$OPTIONS" #># "k; print thread info" "W:; specify a file to extract swap info from" ) #<# ;; (NetBSD) OPTIONS=("$OPTIONS" #># "k:; specify sort keys" "s; print threads rather than processes" "W:; specify a file to extract swap info from" ) #<# ;; esac case $type in (Darwin) OPTIONS=("$OPTIONS" #># "E; print environment variables as well" "M; print thread info" "X; don't print processes with terminals" ) #<# ;; (*) OPTIONS=("$OPTIONS" #># "e; print environment variables as well" "M:; specify a core file to print" "u; print in the user-oriented format" ) #<# ;; esac esac esac case $type in (procps|SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "s: ${long:+--sid:}; specify session IDs of processes to print" ) #<# case $type in (procps|SunOS) OPTIONS=("$OPTIONS" #># "L; print thread info" "P; print running processor numbers (PSR) as well" "y; print RSS instead of F and ADDR (with -l)" ) #<# case $type in (SunOS) OPTIONS=("$OPTIONS" #># "Z; print zone info as well" "z:; specify zones of processes to print" ) #<# esac esac case $type in (procps|HP-UX) OPTIONS=("$OPTIONS" #># "C:; specify the name of process to print" "H ${long:+--forest}; print process family trees" "P; print process resource manager (PRM) info as well" ) #<# case $type in (HP-UX) OPTIONS=("$OPTIONS" #># "R:; specify PRM process group IDs of processes to print" "x; print in the extended format" "Z:; specify processor set IDs of processes to print" ) #<# esac esac esac command -f completion//parseoptions -e case $ARGOPT in (-) command -f completion//completeoptions ;; (C) typeset word="${TARGETWORD#"$PREFIX"}" PREFIX=${TARGETWORD%"${word##*[ ,]}"} complete -P "$PREFIX" -- $(ps -A -o comm= 2>/dev/null) ;; (G|--[Gg]roup) complete -P "$PREFIX" -g ;; (g) typeset word="${TARGETWORD#"$PREFIX"}" PREFIX=${TARGETWORD%"${word##*[ ,]}"} case $type in (procps) case $word in (*[![:digit:]\ ,]*) ;; (*) # complete a session ID typeset sid tty while read -r sid tty; do complete -P "$PREFIX" -R 0 -D "$tty" -- "$sid" done 2>/dev/null <(ps -A -o sid= -o tty= | sort -u) ;; esac complete -P "$PREFIX" -g ;; (*) ;; esac ;; ([MNnW]) complete -P "$PREFIX" -f ;; ([kOo]|--format|--sort) # complete a format item typeset word="${TARGETWORD#"$PREFIX"}" PREFIX=${TARGETWORD%"${word##*[ ,+-]}"} case $type in (procps) typeset key name while read -r key name; do complete -P "$PREFIX" -- "$key" done <(ps L) ;; (*BSD|Darwin) complete -P "$PREFIX" -- $(ps -L 2>/dev/null) ;; (*) case $type in (SunOS) complete -P "$PREFIX" -- addr class ctid gid f \ fname lwp nlwp osz pmem pri project \ projid pset psr rgid rss ruid s sid \ stime taskid uid wchan zone zoneid ;; (HP-UX) complete -P "$PREFIX" -- addr cls cpu flags \ gid pri prmgrp prmid pset rgid ruid \ sid state stime sz uid wchan ;; esac complete -P "$PREFIX" -- args comm etime group nice \ pcpu pgid pid ppid rgroup ruser time tty user vsz ;; esac ;; (p|--pid|--ppid) # complete a process ID typeset pid args while read -r pid args; do complete -P "$PREFIX" -D "$args" -- "$pid" done <(ps -A -o pid= -o args= 2>/dev/null) ;; (R) #TODO ;; (s|--sid) # complete a session ID typeset sid tty while read -r sid tty; do complete -P "$PREFIX" -R 0 -D "$tty" -- "$sid" done 2>/dev/null <(ps -A -o sid= -o tty= | sort -u) ;; (t|--tty) typeset ttys ttys=($(ps -A -o tty=)) complete -P "$PREFIX" -A '*[[:alnum:]]*' -- "$ttys" "${ttys#tty}" ;; ([Uu]|--[Uu]ser) complete -P "$PREFIX" -u ;; (Z) #TODO ;; (z) #TODO ;; (--columns|--cols|--width|--lines|--rows) ;; (*) command -f completion/ps::bsd ;; esac } # parse BSD style options function completion/ps::bsd { #TODO } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/cat0000644000175000017500000000471712154557026016524 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "cat" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/cat { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "u; disable buffering" ) #<# ADDOPTIONS=() case $type in (GNU|*BSD|Darwin|SunOS|HP-UX) ADDOPTIONS=( #># "b ${long:+--number-nonblank}; print line number for each non-empty line" "n ${long:+--number}; print line number for each line" "v ${long:+--show-nonprinting}; print unprintable characters like ^I or M-C" ) #<# case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "A --show-all; make everything visible" "E --show-ends; print \$ at end of each line" "e; like -vE: make everything visible but tabs" "T --show-tabs; print tabs as ^I" "t; like -vT: make everything visible but newlines" ) #<# ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "e; print \$ at end of each line (with -v)" "t; print tabs and form-feeds as ^I and ^L (with -v)" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "e; like -v and print \$ at end of each line" "t; like -v and print tabs and form-feeds as ^I and ^L" ) #<# ;; (*) ADDOPTIONS=("$ADDOPTIONS" #># "e; like -v and print \$ at end of each line" "t; like -v and print tabs as ^I" ) #<# ;; esac case $type in (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "s; suppress error messages" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "r; squeeze adjacent empty lines into one" "s; suppress error messages" ) #<# ;; (*) ADDOPTIONS=("$ADDOPTIONS" #># "s; squeeze adjacent empty lines into one" ) #<# ;; esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "--help" "--version" ) #<# ;; (NetBSD) ADDOPTIONS=("$ADDOPTIONS" #># "f; print regular files only" "l; acquire lock on the standard output while printing" ) #<# ;; esac esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/gtar0000644000175000017500000000026312154557026016702 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "gtar" command. function completion/gtar { command -f completion//reexecute tar } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/yash0000644000175000017500000000025612154557026016713 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "yash" command. function completion/yash { command -f completion//reexecute set } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ls0000644000175000017500000002112212154557026016360 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "ls" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.3, SunOS 5.10, HP-UX 11i v3. function completion/ls { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX POSIXOPTIONS=( #># "1; print files line by line" "A ${long:+--almost-all}; print all files but . and .." "a ${long:+--all}; print all files" "C; arrange filenames vertically" "c; print or sort by last status change time" "d ${long:+--directory}; print directory itself, not its contents" "F ${long:+--classify}; append symbols indicating file type" "f; print all files without sorting" "g; like -l but don't print owners" "H ${long:+--dereference-command-line}; follow symbolic links in operands" "i ${long:+--inode}; print file serial number (inode)" "k; print file size in kilobytes" "L ${long:+--dereference}; follow all symbolic links" "l; print in long format" "m; print in stream output format" "n ${long:+--numeric-uid-gid}; like -l but print owners and groups in numbers" "o; like -l but don't print group" "p; append slash to directory names" "q ${long:+--hide-control-chars}; print unprintable characters as ?" "R ${long:+--recursive}; print subdirectories recursively" "r ${long:+--reverse}; sort in reverse order" "S; sort by file size" "s ${long:+--size}; print block sizes occupied by files" "t; sort by last modified time" "u; print or sort by last access time" "x; arrange filenames horizontally" ) #<# ADDOPTIONS=() case $type in (GNU|NetBSD|FreeBSD|Darwin|SunOS|HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "b ${long:+--escape}; escape special characters like C string" ) #<# case $type in (NetBSD|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "B; escape special characters as backslashed octal value" ) #<# esac esac case $type in (GNU|*BSD|Darwin|SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "h ${long:+--human-readable}; print size using K, M, etc. for 1024^n" ) #<# esac case $type in (*BSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "T; print time in full (with -l)" ) #<# case $type in (NetBSD|FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "W; show whiteouts when scanning directories" "w; don't escape unprintable characters" ) #<# case $type in (FreeBSD|Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "G; print filenames in color" "P; don't follow symbolic links" "U; print or sort by file creation time" ) #<# esac esac esac case $type in (GNU) ADDOPTIONS=("$ADDOPTIONS" #># "--author; print file authors (with -l)" "--block-size:; specify block size" "B --ignore-backups; don't print filenames ending with ~" "--color::; print filenames in color" "D --dired; print in emacs dired format" "--file-type; like -F but don't append * to executables" "--format:; specify output format" "--full-time; like -l --time-style=full-iso" "--group-directories-first; print directories before other files" "G --no-group; don't print group (with -l)" "--si; print size using k, M, etc. for 1000^n" "--dereference-command-line-symlink-to-dir; follow symbolic links to directory in operands" "--hide:; specify pattern to exclude from listing" "--indicator-style:; append symbols indicating file type" "I: --ignore:; specify filename pattern to exclude from listing" "N --literal; don't quote filenames" "Q --quote-name; print filenames in double-quotes" "--quoting-style:; specify how to quote filenames" "--show-control-chars; print non-graphic characters as is" "--sort:; specify sort key" "--time:; specify which time to print and sort by" "--time-style:; specify format to print time in" "T: --tabsize:; specify how many spaces a tab stands for" "U; don't sort" "v; sort by filename regarding as version number" "w: --width:; specify screen width" "X; sort by filename extension" "--lcontext; print in long format with security context" "Z --context; print in simplified long format with security context" "--scontext; print security context of files" "--help" "--version" ) #<# ;; (FreeBSD) ADDOPTIONS=("$ADDOPTIONS" #># "D:; specify format to print time in" "I; don't assume -A for superuser" "Z; print MAC labels" ) #<# ;; (Darwin) ADDOPTIONS=("$ADDOPTIONS" #># "e; print access control list" "O; print file flags (with -l)" ) #<# ;; (SunOS) ADDOPTIONS=("$ADDOPTIONS" #># "E; like -l, with time in ISO 8601 format" "e; like -l, with time like Dec 31 13:34:56 1999" "V; like -l, with compact access control list info" "v; like -l, with verbose access control list info" ) #<# ;; (HP-UX) ADDOPTIONS=("$ADDOPTIONS" #># "e; print extent attributes (with -l)" ) #<# ;; esac OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS") unset POSIXOPTIONS ADDOPTIONS command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (D) if command -vf completion//completestrftime >/dev/null 2>&1 || . -AL completion/date; then command -f completion//completestrftime fi ;; (--block-size) if command -vf completion//completeblocksize >/dev/null 2>&1 || . -AL completion/_blocksize; then command -f completion//completeblocksize fi ;; (--color) #>># complete -P "$PREFIX" -D "always print in color" yes always force complete -P "$PREFIX" -D "print in color if output is terminal" auto tty if-tty complete -P "$PREFIX" -D "don't print in color" no never none ;; #<<# (--format) #>># complete -P "$PREFIX" -D "print files line by line" single-column complete -P "$PREFIX" -D "arrange filenames vertically" vertical complete -P "$PREFIX" -D "print permission, owner, file size, etc." long verbose complete -P "$PREFIX" -D "separate filenames by commas" commas complete -P "$PREFIX" -D "arrange filenames horizontally" horizontal across complete -P "$PREFIX" -D "print security context of files" context ;; #<<# #(--hide) -- complete as filename as usual # ;; (--indicator-style) #>># complete -P "$PREFIX" -D "don't append symbols indicating file type" none complete -P "$PREFIX" -D "append slash to directory names" slash complete -P "$PREFIX" -D "enable all indicators but *" file-type complete -P "$PREFIX" -D "enable all indicators" classify ;; #<<# #(I|--ignore) -- complete as filename as usual # ;; (--quoting-style) #>># complete -P "$PREFIX" -D "quote or escape nothing" literal complete -P "$PREFIX" -D "quote in format suitable for shell input" shell complete -P "$PREFIX" -D "quote all filenames in format suitable for shell input" shell-always complete -P "$PREFIX" -D "quote and escape like C string" c complete -P "$PREFIX" -D "quote and escape like C string if necessary" c-maybe complete -P "$PREFIX" -D "escape like C string" escape complete -P "$PREFIX" -D "locale-dependent quoting and escaping" locale complete -P "$PREFIX" -D "locale-dependent quoting and escaping" clocale ;; #<<# (--sort) #>># complete -P "$PREFIX" -D "don't sort" none complete -P "$PREFIX" -D "sort by filename extension" extension complete -P "$PREFIX" -D "sort by file size" size complete -P "$PREFIX" -D "sort by last modified time" time complete -P "$PREFIX" -D "sort by filename regarding as version number" version ;; #<<# (--time) #>># complete -P "$PREFIX" -D "print or sort by last access time" atime access use complete -P "$PREFIX" -D "print or sort by last status change time" ctime status ;; #<<# (--time-style) case $TARGETWORD in ("$PREFIX+"*) if command -vf completion//completestrftime >/dev/null 2>&1 || . -AL completion/date; then command -f completion//completestrftime fi ;; (*) #>># complete -P "$PREFIX" -D "e.g. 2000-01-01 01:23:45.678901234 +0900" full-iso complete -P "$PREFIX" -D "e.g. 2010-06-29 00:37" long-iso complete -P "$PREFIX" -D "e.g. 01-23 01:23 or 2000-01-23" iso complete -P "$PREFIX" -D "locale-dependent time style" locale posix-locale complete -P "$PREFIX" -D "like full-iso, but only when not in POSIX locale" posix-full-iso complete -P "$PREFIX" -D "like long-iso, but only when not in POSIX locale" posix-long-iso complete -P "$PREFIX" -D "like iso, but only when not in POSIX locale" posix-iso complete -T -P "$PREFIX" -D "specify time format after +" + ;; #<<# esac ;; (--tabsize) ;; (w|--width) complete -P "$PREFIX" 80 132 ${COLUMNS:+"$COLUMNS"} ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ssh-keygen0000644000175000017500000000522412154557026020024 0ustar magicantmagicant# (C) 2011-2013 magicant # Completion script for the "ssh-keygen" command. # Supports OpenSSH 6.2. function completion/ssh-keygen { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "A; create all types of host keys" "a:; specify the number of primality tests performed (with -T)" "B; print the bubblebabble digest" "b:; specify the number of bits of the key being created" "C:; specify the comment of the key" "c; change the comment of RSA1 private/public keys" "D:; download the RSA public keys from the specified PKCS#11 library" "e; print the key in the portable format" "F:; specify the host name to search the known hosts file for" "f:; specify the key file to operate on" "G:; specify the file to save candidate primes" "g; use generic DNS format (with -r)" "H; hash the known hosts file" "h; create a host certificate when signing a key" "I:; specify the key identity used when signing a key" "i; print the key in the non-portable format" "L; print the contents of a certificate" "l; print the fingerprint of the public key file" "M:; specify the memory size in megabytes used when generating candidate moduli" "m:; specify the key format (with -e or -i)" "N:; specify the new passphrase" "n:; specify principals included in a certificate when signing a key" "O:; specify a certificate option when signing a key" "P:; specify the (current) passphrase" "p; change the passphrase of the private key" "q; make ssh-keygen quiet" "R:; specify the host name to remove from the known hosts file" "r:; print the SSHFP fingerprint resource record of the specified host name" "S:; specify the start point for generating candidate moduli" "s:; specify the CA key file to sign the public key with" "T:; test DH group exchange candidate primes" "t:; specify the key type" "V:; specify the validity interval of the signed certificate" "v; print debugging messages" "W:; specify the DH generator" "y; extract the public key from the private key" "z:; specify the serial number of the certificate" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ([abMSVz]) ;; ([FR]) complete -P "$PREFIX" -h ;; (m) #>># complete -P "$PREFIX" -D 'SSH2 public or private key' RFC4716 complete -P "$PREFIX" -D 'PEM PKCS8 public key' PKCS8 complete -P "$PREFIX" -D 'PEM public key' PEM ;; #<<# (O) #TODO ;; (t) #>># complete -P "$PREFIX" -D 'RSA, protocol version 1' rsa1 complete -P "$PREFIX" -D 'RSA, protocol version 2' rsa complete -P "$PREFIX" -D 'DSA, protocol version 2' dsa ;; #<<# (W) complete 2 3 5 ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ssh0000644000175000017500000001632312154557026016546 0ustar magicantmagicant# (C) 2010-2013 magicant # Completion script for the "ssh" command. # Completion function "completion/ssh" is used for the "scp" and "sftp" commands # as well. # Supports OpenSSH 6.2. function completion/ssh { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "1; use the protocol version 1 only" "2; use the protocol version 2 only" "4; use IPv4 addresses only" "6; use IPv6 addresses only" "C; enable data compression" "c:; specify the encryption algorithm" "F:; specify the configuration file" "i:; specify the private key (identity) file" "o:; specify an option in the configuration file format" "v; print debugging messages" ) #<# case ${WORDS[1]} in (ssh) OPTIONS=("$OPTIONS" #># "A; enable authentication agent forwarding" "a; disable authentication agent forwarding" "b:; specify the local IP address to connect from" "D:; specify a port for local dynamic application-level port forwarding" "e:; specify the escape character" "f; run in the background after authentication" "g; allow remote hosts to connect to local forwarded ports" "I:; specify the PKCS#11 shared library" "K; enable GSSAPI-based authentication and forwarding" "k; disable GSSAPI-based authentication and forwarding" "L:; specify a local port and a remote host/port to forward" "l:; specify the user name to log in as" "M; run in the master mode for connection sharing" "m:; specify MACs (message authentication codes)" "N; don't run any remote command" "n; redirect the standard input of the remote command to /dev/null" "O:; specify a command to control the master process" "p:; specify the port to connect to" "q; suppress warning and diagnostic messages" "R:; specify a remote port and a local host/port to forward" "S:; specify the control socket for connection sharing" "s; run the command as the SSH2 subsystem" "T; run the command without a pseudo-terminal" "t; run the command in a pseudo-terminal" "V; print version info" "W:; specify a remote host/port to directly connect to" "w:; specify the tunnel device to forward" "X; enable X11 forwarding" "x; disable X11 forwarding" "Y; enable trusted X11 forwarding" "y; use syslog for logging" ) #<# ;; (scp) OPTIONS=("$OPTIONS" #># "3; copy via local host between remote source and destination" "B; batch mode: don't ask for passwords/phrases" "l:; specify the max bandwidth in Kbps" ) #<# ;; (sftp) OPTIONS=("$OPTIONS" #># "B:; specify the buffer size in bytes" "b:; batch mode: specify the file to read commands from" "D:; specify the path of local sftp server to connect to" "R:; specify the max number of outstanding requests" "s:; specify the SSH2 subsystem or the path for the remote sftp server" ) #<# ;; (*) return 1 ;; esac case ${WORDS[1]} in (scp|sftp) OPTIONS=("$OPTIONS" #># "P:; specify the port to connect to" "p; preserve file attributes" "q; suppress progress bar and warning and diagnostic messages" "r; recursively copy directories" "S:; specify the connection program used instead of ssh" ) #<# esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ([BDPp]) ;; (b) case ${WORDS[1]} in (sftp) complete -P "$PREFIX" -f ;; esac ;; ([Fi]) complete -P "$PREFIX" -f ;; (c) #TODO ;; (e) #>># complete -P "$PREFIX" '~' complete -P "$PREFIX" -D "none" none ;; #<<# (I) #TODO ;; (L) #TODO ;; (l) case ${WORDS[1]} in (ssh) complete -P "$PREFIX" -u ;; esac ;; (m) #TODO ;; (O) #>># complete -P "$PREFIX" -D "request the master process to stop port forwarding" cancel complete -P "$PREFIX" -D "check that the master process is running" check complete -P "$PREFIX" -D "request the master process to exit" exit complete -P "$PREFIX" -D "request forwarding without command execution" forward complete -P "$PREFIX" -D "request the master process to accept no more connections" stop ;; #<<# (o) #TODO ;; (R) #TODO ;; (S) case ${WORDS[1]} in (ssh) complete -P "$PREFIX" -f ;; (scp|sftp) WORDS=() command -f completion//reexecute -e ;; esac ;; (W) #TODO ;; (w) #TODO ;; ('') command -f completion/${WORDS[1]}::operand ;; esac } function completion/ssh::operand { typeset config ssh sshopts command -f completion/ssh::parseconfig if [ ${WORDS[#]} -gt 0 ]; then # complete the command WORDS=("${WORDS[2,-1]}") command -f completion//reexecute else command -f completion/ssh::completehostname fi } function completion/scp::operand { typeset config ssh sshopts command -f completion/ssh::parseconfig case $TARGETWORD in (*:*) typeset host="${TARGETWORD%%:*}" case $host in (*/*) # ignore the host name containing a slash ;; (*) # complete file names on the remote host PREFIX=${host}: typeset path="${TARGETWORD#"$PREFIX"}" typeset dir case $path in (*/*) dir=${path%/*}/ ;; (*) dir= ;; esac typeset filter flags= name="${path##*/}" filter=() case $name in # TODO check if --dotglob option is set (.*) filter=(-A '.*') ;; (*) filter=(-R '.*') ;; esac typeset f while read -r f; do case $f in (*/) flags='-T' ;; (*) flags= ;; esac complete -P "$PREFIX$dir" "$filter" $flags -- "$f" done <("$ssh" "$sshopts" -o BatchMode=yes -- "$host" "ls -ap -- '${${dir:-.}//\'/\'\\\'\'}'" <>/dev/null 2>&0) return ;; esac esac command -f completion/ssh::completehostname -T -S : if [ "${1-}" != nolocalfile ]; then typeset slash=false case $TARGETWORD in (*/*) slash= esac complete ${slash:+-R '*:*'} -f fi } function completion/sftp::operand { command -f completion/scp::operand nolocalfile } function completion/ssh::parseconfig { typeset i=2 config=${HOME:+"$HOME/.ssh/config"} ssh=ssh sshopts=() while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (-F*) sshopts=("$sshopts" "${WORDS[i]}") config=${WORDS[i]#-F} ;; (-[1246Cio]*) sshopts=("$sshopts" "${WORDS[i]}") ;; (-P*) sshopts=("$sshopts" -p"${WORDS[i]#-P}") ;; (-S*) case ${WORDS[1]} in (scp) ssh=${WORDS[1]#-S} esac ;; (--) i=$((i+1)); break ;; (-*) ;; (*) break ;; esac i=$((i+1)) done WORDS=("${WORDS[i,-1]}") } function completion/ssh::completehostname { PREFIX=${TARGETWORD%${TARGETWORD#*@}} typeset key values file words host while read -Ar key values; do case $key in ([Hh][Oo][Ss][Tt]) complete -P "$PREFIX" -R '\*' "$@" -- "$values" esac done <(sed -e 's/#.*//' -e 's/[Hh][Oo][Ss][Tt][[:blank:]]*=/host /' "$config" 2>/dev/null) # currently, we always read known-hosts files from the default location for file in /etc/ssh/ssh_known_hosts ~/.ssh/known_hosts; do if ! [ -r "$file" ]; then continue fi while read -Ar words; do case ${words[1]} in (\#*) continue ;; (@*) words=("${words[2,-1]}") ;; esac for host in ${words[1]//,/ }; do case $host in ([\|!]*|*[*?]*) ;; (\[*]:*) complete -P "$PREFIX" "$@" -- "${{host#\[}%]:*}" ;; (*) complete -P "$PREFIX" "$@" -- "$host" ;; esac done hosts=(${words[1]//,/ }) case $key in (\|*) ;; (*) complete -P "$PREFIX" "$@" -- ${key//,/ } esac done <"$file" done } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-config0000644000175000017500000003554012154557026020001 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-config" command. # Supports Git 1.7.7. function completion/git-config { WORDS=(git config "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::config:arg { OPTIONS=( #># "--add; add a new line to the option value" "--bool; ensure the option value is a boolean" "--bool-or-int; ensure the option value is a boolean or integer" "e --edit; start an editor to edit the config file" "f: --file:; specify the config file path" "--get; print an option value" "--get-all; print one or more option values" "--get-color; print ANSI color escape sequence" "--get-colorbool; check if output should be colored" "--get-regexp; print options whose keys match the specified regular expression" "--global; get or set the global options" "--int; ensure the option value is an integer" "l --list; print all options set" "z --null; print a null byte after each key-value pair" "--path; perform tilde expansion when printing option values" "--remove-section; remove a section" "--rename-section; rename a section" "--replace-all; replace all matching values" "--system; get or set the system-wide options" "--unset; remove (part of) an option" "--unset-all; remove (all matching parts of) an option" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (f|--file) complete -P "$PREFIX" -f ;; ('') command -f completion//git::completeoptionname ;; esac } function completion//git::completeoptionname { typeset usesuffix= suffix if [ $# -gt 0 ]; then usesuffix=true suffix=$1 fi typeset word="${TARGETWORD#"$PREFIX"}" # complete existing settings typeset word2 prefix2 name value word2="${word##*.}" prefix2="${TARGETWORD%"$word2"}" while read -r name value; do name=${name#"$prefix2"} case $name in (*.*) name=${name%%.*} complete -P "$prefix2" -S . -T -- "$name" ;; (*) complete -P "$prefix2" ${usesuffix:+-S "$suffix" -T} -- \ "$name" ;; esac done 2>/dev/null <(git config --get-regexp "${word//./'\.'}.*") case $word in (add.*) PREFIX=${PREFIX}add. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ ignoreErrors ;; #<<# (advice.*) PREFIX=${PREFIX}advice. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ commitBeforeMerge detachedHead implicitIdentity\ pushNonFastForward resolveConflict statusHints ;; #<<# (alias.*) PREFIX=${PREFIX}alias. #>># command -f completion/git::completealias ${usesuffix+"$suffix"} ;; (am.*) PREFIX=${PREFIX}am. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ keepcr ;; #<<# (apply.*) PREFIX=${PREFIX}apply. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ ignorewhitespace whitespace ;; #<<# (branch.*.*) word=${word#branch.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ merge mergeoptions rebase remote ;; #<<# (branch.*) PREFIX=${PREFIX}branch. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ autosetupmerge autosetuprebase #<<# command -f completion/git::completeref \ abbrprefixes=refs/heads/ dontcompletefull=true \ suffix=. --branches ;; (browser.*.*|difftool.*.*|man.*.*) word=${word#*.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ cmd path ;; #<<# (clean.*) PREFIX=${PREFIX}clean. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ requireForce ;; #<<# (color.branch.*) PREFIX=${PREFIX}color.branch. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ current local plain remote ;; #<<# (color.diff.*) PREFIX=${PREFIX}color.diff. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ commit frag func meta new old plain whitespace ;; #<<# (color.decorate.*) PREFIX=${PREFIX}color.decorate. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ branch HEAD remoteBranch stash tag ;; #<<# (color.grep.*) PREFIX=${PREFIX}color.grep. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ context filename function linenumber match \ selected separator ;; #<<# (color.interactive.*) PREFIX=${PREFIX}color.interactive. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ error header help prompt ;; #<<# (color.status.*) PREFIX=${PREFIX}color.status. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ added branch changed header nobranch untracked \ updated ;; #<<# (color.*) PREFIX=${PREFIX}color. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ branch diff grep interactive pager showbranch \ status ui #<<# complete -P "$PREFIX" -S . -T -- \ branch diff decorate grep interactive status ;; (commit.*) PREFIX=${PREFIX}commit. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ status template ;; #<<# (core.*) PREFIX=${PREFIX}core. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ abbrev askpass attributesfile autocrlf bare \ bigFileThreshold compression createObject \ deltaBaseCacheLimit editor eol excludesfile \ fileMode fsyncobjectfiles gitProxy \ ignoreCygwinFSTricks ignoreStat ignorecase \ logAllRefUpdates loosecompression notesRef \ packedGitLimit packedGitWindowSize pager \ preferSymlinkRefs preloadindex quotepath \ repositoryFormatVersion safecrlf \ sharedRepository sparseCheckout symlinks \ trustctime warnAmbiguousRefs whitespace \ worktree ;; #<<# (diff.*.*) word=${word#diff.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ binary cachetextconv command textconv \ wordregex xfuncname ;; #<<# (diff.*) PREFIX=${PREFIX}diff. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ autorefreshindex dirstat external \ ignoreSubmodules mnemonicprefix noprefix \ renameLimit renames suppressBlankEmpty tool \ wordRegex ;; #<<# # (difftool.*.*) -> (browser.*.*) (difftool.*) PREFIX=${PREFIX}difftool. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ prompt ;; #<<# (fetch.*) PREFIX=${PREFIX}fetch. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ recurseSubmodules unpackLimit ;; #<<# (format.*) PREFIX=${PREFIX}format. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ attach cc numbered headers pretty signature \ signoff subjectprefix suffix thread to ;; #<<# (filter.*.*) word=${word#filter.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ clean smudge ;; #<<# (gc.*.*) word=${word#gc.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ reflogexpire reflogexpireunreachable ;; #<<# (gc.*) PREFIX=${PREFIX}gc. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ aggressiveWindow auto autopacklimit packrefs \ pruneexpire reflogexpire \ reflogexpireunreachable \ rerereresolved rerereunresolved ;; #<<# (gitcvs.*) PREFIX=${PREFIX}gitcvs. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ allbinary commitmsgannotation \ dbTableNamePrefix dbdriver dbname dbpass \ dbuser enabled logfile usecrlfattr ;; #<<# (grep.*) PREFIX=${PREFIX}grep. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ extendedRegexp lineNumber ;; #<<# (gui.*) PREFIX=${PREFIX}gui. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ blamehistoryctx commitmsgwidth \ copyblamethreshold diffcontext encoding \ fastcopyblame matchtrackingbranch \ newbranchtemplate pruneduringfetch \ spellingdictionary trustmtime ;; #<<# (guitool.*.*) word=${word#guitool.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ argropmpt cmd confirm needsfile noconsole \ norescan prompt revprompt revunmerged title ;; #<<# (help.*) PREFIX=${PREFIX}help. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ autocorrect browser format ;; #<<# (http.*) PREFIX=${PREFIX}http. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ cookiefile lowSpeedLimit lowSpeedTime \ maxRequests minSessions noEPSV postBuffer \ proxy sslCAInfo sslCAPath sslCert \ sslCertPasswordProtected sslKey sslVerify \ useragent ;; #<<# (i18n.*) PREFIX=${PREFIX}i18n. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ commitEncoding logOutputEncoding ;; #<<# (imap.*) PREFIX=${PREFIX}imap. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ authMethod folder host pass port \ preformattedHTML sslverify tunnel user ;; #<<# (init.*) PREFIX=${PREFIX}init. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ templatedir ;; #<<# (instaweb.*) PREFIX=${PREFIX}instaweb. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ browser httpd local modulepath port ;; #<<# (interactive.*) PREFIX=${PREFIX}interactive. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ singlekey ;; #<<# (log.*) PREFIX=${PREFIX}log. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ abbrevCommit date decorate showroot ;; #<<# (mailmap.*) PREFIX=${PREFIX}mailmap. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ file ;; #<<# # (man.*.*) -> (browser.*.*) (man.*) PREFIX=${PREFIX}man. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ viewer ;; #<<# (merge.*.*) word=${word#merge.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ driver name recursive ;; #<<# (merge.*) PREFIX=${PREFIX}merge. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ conflictstyle defaultToUpstream ff log \ renameLimit renormalize stat tool verbosity ;; #<<# (mergetool.*.*) word=${word#mergetool.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ cmd path trustExitCode ;; #<<# (mergetool.*) PREFIX=${PREFIX}mergetool. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ keepBackup keepTemporaries prompt ;; #<<# (notes.*) PREFIX=${PREFIX}notes. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ displayRef rewriteMode rewriteRef complete -P "$PREFIX" -S . -T -- rewrite ;; #<<# (pack.*) PREFIX=${PREFIX}pack. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ compression deltaCacheLimit deltaCacheSize \ depth indexVersion packSizeLimit threads \ window windowMemory ;; #<<# (pull.*) PREFIX=${PREFIX}pull. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ octopus twohead ;; #<<# (push.*) PREFIX=${PREFIX}push. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ default ;; #<<# (rebase.*) PREFIX=${PREFIX}rebase. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ autosquash stat ;; #<<# (receive.*) PREFIX=${PREFIX}receive. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ autogc denyCurrentBranch denyDeleteCurrent \ denyDeletes denyNonFastForwards fsckObjects \ unpackLimit updateserverinfo ;; #<<# (remote.*.*) word=${word#remote.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ fetch mirror proxy push pushurl receivepack \ skipDefaultUpdate skipFetchAll tagopt \ uploadpack url vcs ;; #<<# (repack.*) PREFIX=${PREFIX}repack. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ usedeltabaseoffset ;; #<<# (rerere.*) PREFIX=${PREFIX}rerere. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ autoupdate enabled ;; #<<# (sendemail.*.*) word=${word#sendemail.*.} PREFIX=${TARGETWORD%"$word"} command -f completion//git::completesendemailoptionname ;; (sendemail.*) PREFIX=${PREFIX}sendemail. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ identity smtpencryption #<<# command -f completion//git::completesendemailoptionname ;; (status.*) PREFIX=${PREFIX}status. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ relativePaths showUntrackedFiles \ submodulesummary ;; #<<# (submodule.*.*) word=${word#submodule.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ fetchRecurseSubmodules ignore path update url ;; #<<# (svn-remote.*.*) word=${word#svn-remote.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ automkdirs branches commiturl fetch \ ignore-paths noMetadata pushurl rewriteRoot \ rewriteUUID tags url useSvmProps useSvnsyncprops ;; #<<# (svn.*) PREFIX=${PREFIX}svn. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ automkdirs authorsfile brokenSymlinkWorkaround \ commiturl edit findcopiesharder followparent l \ noMetadata pathnameencoding pushmergeinfo \ repack repackflags rmdir useSvmProps \ useSvnsyncprops ;; #<<# (tar.*) PREFIX=${PREFIX}tar. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ umask ;; #<<# (transfer.*) PREFIX=${PREFIX}transfer. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ unpackLimit ;; #<<# (url.*.*) word=${word#url.*.} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ insteadOf pushInsteadOf ;; #<<# (user.*) PREFIX=${PREFIX}user. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ email name signingkey ;; #<<# (web.*) PREFIX=${PREFIX}web. #>># complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ browser ;; #<<# (*) #>># complete -P "$PREFIX" -S . -T -- \ add advice alias am apply branch browser clean \ color commit core diff difftool fetch format \ filter gc gitcvs grep gui guitool help http \ i18n imap init instaweb interactive log \ mailmap man merge mergetool notes pack pager \ pretty pull push rebase receive remote remotes \ repack rerere sendemail showbranch status \ submodule svn svn-remote tar transfer url user \ web ;; #<<# esac } function completion//git::completesendemailoptionname { complete -P "$PREFIX" ${usesuffix:+-S "$suffix" -T} -- \ aliasesfile aliasfiletype bcc cc cccmd chainreplyto confirm \ envelopesender from multiedit signedoffbycc smtpdomain \ smtppass smtpserver smtpserveroption smtpserverport smtpuser \ suppresscc suppressfrom thread to validate } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/locale0000644000175000017500000000246212154557026017207 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "locale" command. # Supports POSIX 2008, GNU libc 2.12.1 function completion/locale { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU libc'*) typeset type=glibc ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (glibc) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a ${long:+--all-locales}; print all available locale names" "c ${long:+--category-name}; print names of the selected categories" "k ${long:+--keyword-name}; print names of the selected keywords" "m ${long:+--charmaps}; print all available charmaps" ) #<# case $type in (glibc) OPTIONS=("$OPTIONS" #># "v --verbose; print more information" "? --help; print help" "--usage" "V --version; print version info" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) IFS=" " typeset category keywords for category in $(locale 2>/dev/null); do category=${category%%=*} case $category in (LANG|LC_ALL) ;; (*) keywords=($(locale -k "$category" 2>/dev/null)) complete -- "$category" "${keywords%%=*}" ;; esac done complete charmap ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/_blocksize0000644000175000017500000000445612154557026020101 0ustar magicantmagicant# (C) 2010-2013 magicant # This file contains functions that help completion of file size suffixes. # Modifies the $PREFIX variable to include argument digits. # If $TARGETWORD does not start with a digit, a non-zero status is returned. function completion//prefixdigits { typeset word="${TARGETWORD#"$PREFIX"}" word=${word#[\'+-]} case $word in ([[:digit:]]*) while [ "${word#[[:digit:]]}" != "$word" ]; do word=${word#[[:digit:]]} done PREFIX=${TARGETWORD%"$word"} return 0 ;; (*) PREFIX=${TARGETWORD%"$word"} return 1 ;; esac } # Completes file size suffixes specified in arguments according to the current # $TARGETWORD and $PREFIX. function completion//completesizesuffix { typeset arg for arg do case $arg in (b) #>># complete -P "$PREFIX" -D "512 bytes" b ;; #<<# (k) #>># complete -P "$PREFIX" -D "1024 bytes" k ;; #<<# (m) #>># complete -P "$PREFIX" -D "1024^2 bytes" m ;; #<<# (g) #>># complete -P "$PREFIX" -D "1024^3 bytes" g ;; #<<# (KMGB) #>># complete -P "$PREFIX" -D "1024 bytes" K complete -P "$PREFIX" -D "1000 bytes" KB complete -P "$PREFIX" -D "1024^2 bytes" M complete -P "$PREFIX" -D "1000^2 bytes" MB complete -P "$PREFIX" -D "1024^3 bytes" G complete -P "$PREFIX" -D "1000^3 bytes" GB ;; #<<# (GNU*) #>># command -f completion//completesizesuffix KMGB complete -P "$PREFIX" -D "1024^4 bytes" T complete -P "$PREFIX" -D "1000^4 bytes" TB complete -P "$PREFIX" -D "1024^5 bytes" P complete -P "$PREFIX" -D "1000^5 bytes" PB complete -P "$PREFIX" -D "1024^7 bytes" Z complete -P "$PREFIX" -D "1000^7 bytes" ZB complete -P "$PREFIX" -D "1024^8 bytes" Y complete -P "$PREFIX" -D "1000^8 bytes" YB #<<# if [ "$arg" != GNU-E ]; then #>># complete -P "$PREFIX" -D "1024^6 bytes" E complete -P "$PREFIX" -D "1000^6 bytes" EB fi #<<# ;; esac done return 0 } # Completes the argument to the --block-size option of df, du, and ls commands. function completion//completeblocksize { if ! command -f completion//prefixdigits; then #>># complete -P "$PREFIX" -D "print size using K, M, etc. for 1024^n" human-readable complete -P "$PREFIX" -D "print size using k, M, etc. for 1000^n" si fi #<<# command -f completion//completesizesuffix GNU } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/unset0000644000175000017500000000124312154557026017102 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "unset" built-in command. function completion/unset { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "f --functions; remove functions" "v --variables; remove variables" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) typeset i=1 func=false while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i++]} in (-f|--functions) func=true ;; (-v|--variables) func=false ;; (--) break ;; esac done if $func; then complete --function else complete -v fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/return0000644000175000017500000000062012154557026017261 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "return" built-in command. function completion/return { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "n --no-return; don't return; just return the specified exit status" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/id0000644000175000017500000000301212154557026016334 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "id" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/id { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "G ${long:+--groups}; print all group IDs" "g ${long:+--group}; print the group ID only" "n ${long:+--name}; print the user/group name rather than number" "r ${long:+--real}; print the real ID rather than the effective ID" "u ${long:+--user}; print the user ID only" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "Z --context; print the security context only" "--help" "--version" ) #<# ;; (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "p; print in a human-readable form" ) #<# case $type in (FreeBSD|Darwin) OPTIONS=("$OPTIONS" #># "A; print process audit properties" "M; print the MAC label" "P; print in the passwd file format" ) #<# esac ;; (SunOS) OPTIONS=("$OPTIONS" #># "p; print project membership" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "P; print the process resource group ID" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -u ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-diff-tree0000644000175000017500000000316512154557026020377 0ustar magicantmagicant# (C) 2012 magicant # Completion script for the "git-diff-tree" command. # Supports Git 1.7.7. function completion/git-diff-tree { WORDS=(git diff-tree "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::diff-tree:arg { OPTIONS=() command -f completion/git::diff-tree:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -le 1 ]; then command -f completion/git::completerefpath else complete -P "$PREFIX" -f fi ;; (*) command -f completion/git::diff-tree:compopt ;; esac } function completion/git::diff-tree:getopt { OPTIONS=("$OPTIONS" #># "--always; show commit even if the diff is empty" "c; use the alternate format when printing a merge" "m; don't suppress showing diffs of merge commits" "--no-commit-id; don't print the commit ID" "r; compare directory trees recursively" "--root; compare against the null tree" "s; suppress normal diff output" "--stdin; read arguments from the standard input" "t; show tree entry itself as well as subtrees" "v; show commit messages as well" ) #<# command -f completion/git::getprettyopts { command -vf completion/git::diff:getopt >/dev/null 2>&1 || . -AL completion/git-diff; } && command -f completion/git::diff:getopt } function completion/git::diff-tree:compopt { command -f completion/git::completeprettyopts || { command -vf completion/git::diff:compopt >/dev/null 2>&1 || . -AL completion/git-diff; } && command -f completion/git::diff:compopt } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-grep0000644000175000017500000000674312154557026017474 0ustar magicantmagicant# (C) 2013 magicant # Completion script for the "git-grep" command. # Supports Git 1.8.2.2. function completion/git-grep { WORDS=(git grep "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::grep:arg { OPTIONS=( #># "A: --after-context:; print specified number of lines after each line printed" "--all-match; require all patterns to match in each file" "--and; join two patterns" "a --text; treat binary files as test files" "B: --before-context:; print specified number of lines before each line printed" "--break; insert an empty line between matches from different files" "--cached; search files in the index" "--color::; specify when to print colored output" "C: --context:; print specified number of lines before and after each line printed" "c --count; print only the count of selected lines" "E --extended-regexp; use extended regular expression" "e:; specify a pattern to match" "--exclude-standard; don't search ignored files" "F --fixed-strings; perform simple string matching rather than regular expression" "f: --file:; specify a file containing patterns to match" "--full-name; print filenames relative to the working tree's root directory" "G --basic-regexp; use basic regular expression" "H; always print the filename for each line printed" "h; never print filenames in results" "--heading; print filenames in separate lines" "I; assume binary files don't match anything" "i --ignore-case; case-insensitive matching" "L --files-without-match; print only the names of files containing no selected lines" "l --files-with-matches --name-only; print filenames only" "--max-depth:; specify directory depth to limit search" "n --line-number; print line numbers" "--no-color; like --color=never" "--no-exclude-standard; search ignored files" "--no-index; search files outside a working tree" "--not; negate a pattern" "O:: --open-files-in-pager::; open matching files in a pager" "--or; join two patterns" "p --show-function; print the name of the function containing the match" "P --perl-regexp; use Perl's regular expression" "q --quiet; don't print anything to the standard output" "--untracked; search untracked files as well" "v --invert-match; select non-matching lines" "W --function-context; print the whole functions containing matches" "w --word-regexp; force the pattern to match whole words only" "z --null; print a null byte after each filename" ) #<# command -f completion/git::grep:removeparen command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ([ABC]|--*context|--max*) ;; (--color) command -f completion/git::--color:arg ;; (O|--open-files-in-pager) complete -P "$PREFIX" --external-command ;; ('') if command -f completion/git::grep:shouldcompleteuntracked; then complete -P "$PREFIX" -f fi command -f completion/git::completerefpath ;; (*) complete -P "$PREFIX" -f ;; esac } function completion/git::grep:removeparen { typeset i=2 while [ "$i" -le "${WORDS[#]}" ]; do case ${WORDS[i]} in ([\(\)]) # remove this parenthesis WORDS=("${WORDS[1,i-1]}" "${WORDS[i+1,-1]}") ;; (--) break ;; (*) : $((i++)) ;; esac done : words = "$WORDS" } function completion/git::grep:shouldcompleteuntracked { typeset i=2 while [ "$i" -le "${WORDS[#]}" ]; do case ${WORDS[i]} in (--no-index|--untracked) return 0;; (--) return 1;; esac : $((i++)) done return 1 } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/who0000644000175000017500000000413112154557026016540 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "who" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/who { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "H ${long:+--heading}; print the header line" "m; print info about the current user only" "q ${long:+--count}; print the number of users on the system with their names" "T ${long:+w --message --mesg --writable}; print if each terminal accepts write messages" "u; print how long the user has been idle" ) #<# case $type in (GNU|Darwin|NetBSD|SunOS|HP-UX) OPTIONS=("$OPTIONS" #># "a ${long:+--all}; print all information" "b ${long:+--boot}; print last system boot time" "d ${long:+--dead}; print info about dead processes" "l ${long:+--login}; print terminals not used by users" "p ${long:+--process}; print active processes spawned by init" "r ${long:+--runlevel}; print runlevel" "s ${long:+--short}; print name, line, and time fields" "t ${long:+--time}; print last system clock change time" ) #<# esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "--lookup; canonicalize host names via DNS lookup" "--help" "--version" ) #<# ;; (NetBSD) OPTIONS=("$OPTIONS" #># "v; print more info (with -u)" ) #<# ;; (SunOS) OPTIONS=("$OPTIONS" #># "n:; specify the number of users to print per line" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "A; print when accounting system was turned on/off" "R; print host name" "W; use /var/adm/wtmps" ) #<# ;; esac command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -eq 1 ] && [ "${WORDS[1]}" = am ]; then complete i elif [ ${WORDS[#]} -eq 0 ]; then complete -f am fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/split0000644000175000017500000000356112154557026017104 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "split" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/split { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a: ${long:+--suffix-length:}; specify the suffix length for output files" "b: ${long:+--bytes:}; specify the output file size in bytes" "l: ${long:+--lines:}; specify the number of lines in each output file" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "C: --line-bytes:; like -b, but split at line breaks" "d --numeric-suffixes; use numeric suffixes rather than lowercase letters" "--verbose; print a message for each output file processed" "--help" "--version" ) #<# esac case $type in (FreeBSD|NetBSD) OPTIONS=("$OPTIONS" #># "n:; specify the number of output files" ) #<# esac case $type in (Darwin|FreeBSD|OpenBSD) OPTIONS=("$OPTIONS" #># "p:; split at lines matching the specified extended regular expression" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([alnp]|--suffix-length|--lines) ;; ([bC]|--bytes|--line-bytes) if command -vf completion//prefixdigits >/dev/null 2>&1 || . -AL completion/_blocksize; then if command -f completion//prefixdigits; then command -f completion//completesizesuffix k m case $type in (GNU) command -f completion//completesizesuffix GNU b ;; (FreeBSD) command -f completion//completesizesuffix g ;; esac fi fi ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/sed0000644000175000017500000000375312154557026016527 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "sed" command. # Supports POSIX 2008, GNU sed 4.2.1, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/sed { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU sed'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "e: ${long:+--expression:}; specify a sed script directly" "f: ${long:+--file:}; specify a file containing sed script" "n ${long:+--quiet --silent}; suppress default output" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "b --binary; don't convert CR-LF into LF" "i:: --in-place::; modify files in-place, making backups with the specified filename suffixes" "l: --line-length:; specify the line length for the l command" "r --regexp-extended; use extended regular expression" "s --separate; treat each operand file separately" "u --unbuffered; disable input/output buffering" "--follow-symlinks; follow symbolic links in operands (with -i)" "--posix; disable non-POSIX extensions" "--help" "--version" ) #<# ;; (*BSD|Darwin) OPTIONS=("$OPTIONS" #># "a; open files for the w command only when needed" "E; use extended regular expression" ) #<# case $type in (FreeBSD|Darwin) OPTIONS=("$OPTIONS" #># "i:; modify files in-place, making backups with the specified filename suffixes" "l; disable output buffering" ) #<# case $type in (FreeBSD) OPTIONS=("$OPTIONS" #># "I:; like -i, but don't treat input files separately" ) #<# esac ;; (OpenBSD) OPTIONS=("$OPTIONS" #># "u; disable output buffering" ) #<# ;; esac ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (e|--expression) ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/pgawk0000644000175000017500000000026512154557026017060 0ustar magicantmagicant# (C) 2010-2011 magicant # Completion script for the "pgawk" command. function completion/pgawk { command -f completion//reexecute awk } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/history0000644000175000017500000000151412154557026017446 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "history" built-in command. function completion/history { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "c --clear; clear the history completely" "d: --delete:; clear the specified history item" "F --flush-file; refresh the history file" "r: --read:; read history from the specified file" "s: --set:; replace the last history item with the specified command" "w: --write:; write history to the specified file" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (d|--delete|s|--set) typeset num cmd while read -r num cmd; do complete -P "$PREFIX" -D "$num" -- "$cmd" done <(fc -l 1) ;; (r|--read|w|--write) complete -P "$PREFIX" -f ;; (*) ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/configure0000644000175000017500000000127312154557026017730 0ustar magicantmagicant# (C) 2012 magicant # Completion script for the "configure" script. function completion/configure { case $TARGETWORD in (*=*) complete -P "${TARGETWORD%%=*}=" -f return ;; (-*) ;; (*) return ;; esac typeset words option desc i IFS=' ' while read -A words; do i=1 while true; do case ${words[i]} in (-*) i=$((i+1)) ;; (*) break ;; esac done desc=${words[i,-1]} for option in "${words[1,i-1]%,}"; do case $option in (--*=*) complete -OT -D "$desc" -- "${option%=*}=" ;; (-*) complete -O -D "$desc" -- "${option}" ;; esac done done <("${WORDS[1]}" --help 2>&1) } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/suspend0000644000175000017500000000061512154557026017427 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "suspend" built-in command. function completion/suspend { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "f --force; suppress warning about possible deadlock" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; (*) ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/paste0000644000175000017500000000233312154557026017061 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "paste" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/paste { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "d: ${long:+--delimiters:}; specify delimiter characters" "s ${long:+--serial}; concatenate all lines in each input file" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "--help" "--version" ) #<# esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (d|--delimiters) typeset word="${TARGETWORD#"$PREFIX"}" word=${word//\\\\} case $word in (*\\*) PREFIX=${TARGETWORD%\\*} #>># complete -T -P "$PREFIX" -D "empty string" '\0' complete -T -P "$PREFIX" -D "newline" '\n' complete -T -P "$PREFIX" -D "tab" '\t' complete -T -P "$PREFIX" -D "backslash" '\\' esac #<<# ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/join0000644000175000017500000000251112154557026016702 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "join" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/join { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "1:; join on the nth field of the first file" "2:; join on the nth field of the second file" "a:; print unpairable lines from the nth file" "e:; specify a string to replace missing fields with" "o:; specify the output format" "t:; specify the field separator character" "v:; only print unpairable lines from the nth file" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "i --ignore-case; case-insensitive comparison" "--check-order; accept correctly sorted input only" "--nocheck-order; don't check that the input is correctly sorted" "--help" "--version" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([12jot]) ;; ([av]) complete -P "$PREFIX" 1 2 ;; (*) complete -P "$PREFIX" -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/tar0000644000175000017500000005032312154557026016535 0ustar magicantmagicant# (C) 2011-2012 magicant # Completion script for the "tar" command. # Supports SUSv2, GNU tar 1.25, BSD tar 2.8, OpenBSD 4.8, NetBSD 5.1, # SunOS 5.11, HP-UX 11i v3. function completion/tar { case $("${WORDS[1]}" --version 2>/dev/null) in (*'GNU '*) typeset type=GNU ;; (*'bsdtar'*) typeset type=BSD ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac typeset long= gnubsd= gnu= bsd= openbsd= netbsd= sunos= hpux= case $type in (GNU) long=true gnubsd=true gnu=true esac case $type in (BSD) long=true gnubsd=true bsd=true esac case $type in (OpenBSD) openbsd=true esac case $type in (NetBSD) long=true netbsd=true esac case $type in (SunOS) sunos=true esac case $type in (HP-UX) hpux=true esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "${sunos:+@}; include extended attributes in the archive" "${sunos:+/}; include extended system attributes in the archive" "${gnu:+? }${gnubsd:+--help}; print help" "${gnu:+A --catenate --concatenate}; append archives to another archive" "${sunos:+A}; suppress warnings about ACL" "${gnu:+a --auto-compress}; compress the archive according to the filename suffix" "${gnu:+B --read-full-records}${bsd:+B --read-full-blocks}${netbsd:+B --read-full-blocks}${sunos:+B}; keep reading until data are fully read" "b: ${gnu:+--blocking-factor:}${bsd:+--block-size:}${netbsd:+--blocking-factor:}; specify the blocking factor" "${long:+C: --directory: ${bsd:+--cd:}}${openbsd:+C:}${sunos:+C:}; specify a directory to operate in" "c ${long:+--create}; create a new archive" "${sunos:+D}; warn when a file is modified while being read by tar" "${gnu:+d --diff --compare}; compare archive contents to files in the file system" "${sunos:+E}; write extended headers" "${openbsd:+e}${netbsd:+e}${sunos:+e}; abort on any error" "${hpux:+e}; fail if the extent attributes are present in the files archived" "${gnu:+F: --info-script: --new-volume-script:}; specify a script run at the end of each tape" "${sunos:+F}; exclude directories named SCCS and RCS" "f: ${long:+--file:}; specify the archive file to operate on" "${gnu:+G --incremental}; do old GNU-style incremental backup" "${gnu:+g: --listed-incremental:}; specify a snapshot file to do new GNU-style incremental backup with" "${gnu:+H: --format:}${bsd:+--format:}; specify the archive format" "${bsd:+H}${openbsd:+H}${netbsd:+H}; follow symbolic links in operands" "${long:+h --dereference ${bsd:+L}}${openbsd:+h L}${sunos:+h}${hpux:+h}; follow all symbolic links" "${long:+${gnu:+I: }--use-compress-program:}; specify a program to (de)compress the archive" "${sunos:+i}; ignore directory checksum errors" "${gnubsd:+J --xz}; use xz to (de)compress the archive" "${long:+j ${bsd:+y} --bzip2 ${netbsd:+--bunzip2}}${openbsd:+j}${sunos:+j}; use bzip2 to (de)compress the archive" "${gnu:+K: --starting-file:}; specify a file in the archive to start extraction from" "${long:+k --keep-old-files}; don't overwrite existing files in extraction" "${gnu:+L: --tape-length:}; specify the tape length" "${gnu:+M --multi-volume}; operate on a multi-volume archive" "m ${gnu:+--touch}${bsd:+--modification-time}${netbsd:+--modification-time}; don't restore modification times when extracting" "${gnu:+N: --newer: --after-date:}; only add files newer than the specified date or file" "${openbsd:+N}${gnubsd:+--numeric-owner}; use numeric user/group IDs only" "${hpux:+N}; create a POSIX format archive" "${gnu:+n --seek}${sunos:+n}; assume the archive is random-accessible" "${bsd:+n}${long:+ --no-recursion}${bsd:+ --norecurse}; don't recursively operate on directories" "${gnu:+P --absolute-names}${bsd:+P --absolute-paths --insecure}${openbsd:+P}${netbsd:+P --absolute-paths}${sunos:+P}; preserve absolute pathnames in the archive" "${gnu:+p --preserve-permissions --same-permissions}; preserve file permissions" "${bsd:+p --preserve-permissions --same-permissions}${openbsd:+p}${sunos:+p}${hpux:+p}; preserve file ownerships and permissions" "${bsd:+q --fast-read}${openbsd:+q}${netbsd:+q --fast-read}; extract only the first matching file in the archive" "${gnu:+R --block-number}; include block numbers in error messages" "r ${long:+--append}; append files to an existing archive" "${gnu:+S --sparse}${bsd:+S}${netbsd:+S --sparse}; treat sparse files efficiently" "${gnu:+s --preserve-order --same-order}; assume file operands are sorted according to the archive contents" "${gnu:+--transform: --xform:}${bsd:+s:}${openbsd:+s:}${netbsd:+s:}; specify a regular expression to modify filenames" "${long:+T: --files-from: ${bsd:+I:}}${openbsd:+I:}; specify a file containing the names of files to archive/extract" "${sunos:+T}; store/check sensitivity label of files in the archive" "t ${long:+--list}; list files in an existing archive" "${gnubsd:+U --unlink-first}; remove existing files before extraction" "u ${long:+--update}; update files in an archive" "${gnu:+V: --label:}; specify a file label" "${hpux:+V}; print file types (only when listing)" "v ${gnubsd:+--verbose}; print files being processed" "${gnu:+W --verify}; verify the archive was correctly written" "${bsd:+W:}" "w ${long:+--interactive --confirmation}; confirm before processing each file" "${long:+X: --exclude-from:}${sunos:+X:}; specify a file containing the names of files not to be archived" "${openbsd:+X}${gnubsd:+--one-file-system}${netbsd:+l --one-file-system}; archive files only in the same file system" "${long:+Z --compress --uncompress}${openbsd:+Z}${sunos:+Z}; use compress to (de)compress the archive" "${long:+z --gzip --gunzip ${gnu:+--ungzip}}${openbsd:+z}${sunos:+z}; use gzip to (de)compress the archive" "x ${long:+--extract ${gnu:+--get}${netbsd:+--get}}; extract files from an existing archive" "${gnu:+--anchored}; force patterns to match only the beginning of filename components" "${gnu:+--atime-preserve::}${netbsd:+--atime-preserve}; read files without updating access time" "${gnu:+--backup:}; specify how to make a backup before overwriting files" "${gnu:+--check-device}; check device numbers in incremental archiving" "${gnu:+--checkpoint::}; print periodic checkpoint messages" "${gnu:+--checkpoint-action:}; specify the action to take on each checkpoint" "${bsd:+--chroot}${netbsd:+--chroot}; chroot to the current directory before extraction" "${gnu:+--delay-directory-restore}; delay restoring directory permissions until all files are extracted" "${gnu:+--delete}; delete files from an archive" "${gnubsd:+--exclude:}; skip files whose names match the specified pattern" "${gnu:+--exclude-backups}; exclude backup and lock files" "${gnu:+--exclude-caches}; exclude cache directory contents except the tag files" "${gnu:+--exclude-caches-under}; exclude cache directory contents and tag files" "${gnu:+--exclude-caches-all}; exclude cache directories" "${gnu:+--exclude-tag:}; exclude contents of directories containing the specified file except the file" "${gnu:+--exclude-tag-under:}; exclude contents of directories containing the specified file" "${gnu:+--exclude-tag-all:}; exclude directories containing the specified file" "${gnu:+--exclude-vcs}; exclude internal files used by version control systems" "${gnu:+--force-local}; always treat filenames as local pathnames" "${gnu:+--full-time}; show timestamps in full resolution" "${gnu:+--group:}; specify the group ID of archived files" "${gnu:+--hard-dereference}; treat hard links to the same file separately" "${gnu:+--ignore-case}; case-insensitive pattern matching" "${gnu:+--ignore-command-error}; ignore errors in subprocesses" "${gnu:+--ignore-failed-read}; ignore unreadable files" "${gnu:+--ignore-zeros}; ignore zeroed blocks in the archive" "${bsd:+--include:}; archive only files whose names match the specified pattern" "${gnu:+--index-file:}; specify a file where verbose output go" "${netbsd:+--insecure}; accept pathnames containing .." "${gnubsd:+--keep-newer-files}; don't overwrite existing files newer than archive contents" "${gnu:+--level:}; specify the level of incremental backup" "${gnu:+--lzip}; use lzip to (de)compress the archive" "${gnubsd:+--lzma}; use lzma to (de)compress the archive" "${gnu:+--lzop}; use lzop to (de)compress the archive" "${gnu:+--mode:}; specify the permission of archived files" "${gnu:+--mtime:}; specify the modification time of archived files" "${bsd:+--newer-ctime:}; only add files newer than the specified date" "${bsd:+--newer-ctime-than: --newer-than:}; only add files newer than the specified file" "${bsd:+--newer-mtime:}; only add files newer than the specified date" "${bsd:+--newer-mtime-than:}; only add files newer than the specified file" "${gnu:+--no-anchored}; allow patterns to match any part of filename components" "${gnu:+--no-auto-compress}; don't automatically compress the archive according to the filename suffix" "${gnu:+--no-check-device}; don't check device numbers in incremental archiving" "${gnu:+--no-delay-directory-restore}; cancel the --delay-directory-restore option" "${bsd:+--nodump}; skip files with the nodump flag" "${gnu:+--no-ignore-case}; case-sensitive pattern matching" "${gnu:+--no-ignore-command-error}; warn about errors in subprocesses" "${gnu:+--no-null}; cancel the --null option" "${gnu:+--no-overwrite-dir}; preserve metadata of existing directories when extracting" "${gnu:+--no-quote-chars:}; specify characters to be removed from the list of quoted characters" "${gnubsd:+--no-same-permissions}; don't restore file permissions when extracting" "${gnu:+--no-seek}; assume the archive media doesn't support random access" "${gnu:+--no-unquote}; don't interpret escape characters" "${gnu:+--no-wildcards}; don't use wildcards" "${gnu:+--no-wildcards-match-slash}; wildcards don't match slashes" "${gnubsd:+--null}; use null-separated list of pathnames" "${gnubsd:+--numeric-owner}; use numeric user/group IDs" "${gnu:+--occurrence::}; process the nth occurrence of each file in the archive" "${bsd:+--options:}; specify options for internal modules" "${gnu:+--overwrite}; overwrite existing files when extracting" "${gnu:+--overwrite-dir}; overwrite directory metadata when extracting" "${gnu:+--owner:}; specify the owner of files in the created archive" "${gnu:+--pax-option:}; create a pax archive with the specified options" "${gnu:+--posix}; like --format=posix" "${gnu:+--preserve}; like --preserve-permissions --preserve-order" "${gnu:+--quote-chars:}; specify characters to always quote" "${gnu:+--quoting-style:}; specify how to quote filenames" "${gnu:+--record-size:}; specify the record size" "${gnu:+--recursion}; recursively operate on directories" "${gnu:+--recursive-unlink}; remove entire existing directories before extracting directories" "${gnu:+--remove-files}; remove original files after archiving them" "${gnu:+--restrict}; disallow some potentially harmful options" "${gnu:+--rmt-command:}; specify the rmt command" "${gnu:+--rsh-command:}; specify the rsh command" "${gnu:+--same-owner}; preserve file owners when extracting" "${gnu:+--show-defaults}; print the default option settings" "${gnu:+--show-omitted-dirs}; print unprocessed directories" "${gnu:+--show-transformed-names --show-stored-names}; print names of processed files in the archive" "${gnu:+--sparse-version:}; specify the format version used for sparse files" "${netbsd:+--strict}; disable GNU extensions" "${gnubsd:+--strip-components:}; specify the number of leading pathname components to remove in extraction" "${gnu:+--suffix:}; specify a suffix to append to backup file names" "${gnu:+--test-label}; only print the volume label" "${gnu:+--to-command:}; specify a command that receives extracted file contents" "${gnubsd:+--totals${gnu:+::}}; print total byte count" "${gnu:+--unquote}; unquote input pathnames" "${gnu:+--utc}; print dates in Coordinated Universal Time (UTC)" "${gnubsd:+--version}; print version info" "${gnu:+--volno-file:}; specify a file to keep track of volumes with" "${gnu:+--warning:}; specify a warning category to enable or disable" "${gnu:+--wildcards}; enable wildcards" "${gnu:+--wildcards-match-slash}; wildcards match slashes" ) #<# case $type in (OpenBSD|NetBSD) OPTIONS=("$OPTIONS" #># "0; use /dev/rst0" "1; use /dev/rst1" "4; use /dev/rst4" "5; use /dev/rst5" "7; use /dev/rst7" "8; use /dev/rst8" ) #<# ;; (SunOS) OPTIONS=("$OPTIONS" #># "0; use the default tape drive" "1; use alternate tape drive 1" "2; use alternate tape drive 2" "3; use alternate tape drive 3" "4; use alternate tape drive 4" "5; use alternate tape drive 5" "6; use alternate tape drive 6" "7; use alternate tape drive 7" ) #<# ;; esac case $type in (NetBSD) ;; (*) OPTIONS=("$OPTIONS" #># "l ${gnu:+--check-links}${bsd:+--check-links}; warn unless all hard links to each file are archived" ) #<# ;; esac # parse old-style options typeset SAVEWORDS SAVEWORDS=("$WORDS") set -- "${WORDS[2,-1]}" if [ $# -eq 0 ]; then set -- "$TARGETWORD" fi case $1 in (-*) typeset oldopt=false ;; (*) typeset oldopt="$1" oldopt1 opt WORDS=("${WORDS[1]}") shift while [ "$oldopt" ]; do oldopt1=${oldopt[1]} for opt in ${OPTIONS%%;*}; do case $opt in (${oldopt1}) WORDS=("$WORDS" -$oldopt1) ;; (${oldopt1}:) if [ $# -gt 0 ]; then WORDS=("$WORDS" -$oldopt1 "$1") shift else WORDS=("$WORDS" -$oldopt1) break 2 fi ;; esac done oldopt=${oldopt#?} done WORDS=("$WORDS" "$@") oldopt=true ;; esac command -f completion//parseoptions -es # add other options typeset word file= compressopts in=true compressopts=() for word in "$WORDS"; do case $word in (-[cru]|--append|--create|--update) OPTIONS=("$OPTIONS" #># "${openbsd:+O}${netbsd:+O}${hpux:+O}; use old non-POSIX archive format" "${long:+o${gnu:+ --old-archive}${netbsd:+ --old-archive --portability}}${openbsd:+o}${hpux:+o}; use V7-compatible archive format" ) #<# ;; (--delete) in=false ;; (-t|--list) in=false OPTIONS=("$OPTIONS" #># "${bsd:+O --to-stdout}; print file list to the standard error" ) #<# ;; (-x|--extract|--get) in=false OPTIONS=("$OPTIONS" #># "${long:+O ${gnubsd:+--to-stdout}}; extract files to the standard output" "o ${gnubsd:+--no-same-owner}; don't restore owners of extracted files" ) #<# ;; (-f*) file=${word#-f} ;; (--file=*) file=${word#--file=} ;; (-[aJjyZz]|--auto-compress|--bunzip2|--bzip2|--compress|--gunzip|--gzip|--lzip|--lzma|--lzop|--no-auto-compress|--uncompress|--ungzip|--use-compress-program=*|--xz) compressopts=("$compressopts" "$word") ;; (-I*) if [ "$gnu" ]; then compressopts=("$compressopts" "$word") fi ;; (--) break ;; esac done if $oldopt && [ ${SAVEWORDS[#]} -le 1 ]; then command -f completion//completeoptions -fs else case $ARGOPT in (-) command -f completion//completeoptions ;; (b|--blocking-factor|--block-size|--record-size) ;; (C|--cd|--directory) complete -P "$PREFIX" -S / -T -d ;; # (F|--info-script|--new-volume-script) # complete -P "$PREFIX" -f # ;; (f|--file) complete -P "$PREFIX" -S / -T -d { typeset generated=false ext for ext in .tar .tar.gz .tar.bz2 .tar.z .tar.Z .tar.lzma .tar.xz .tgz .tbz .taz .tlz .txz; do if complete -P "$PREFIX" -A "*$ext" -f; then generated=true fi done $generated } || complete -P "$PREFIX" -f ;; # (g|--listed-incremental) # complete -P "$PREFIX" -f # ;; (H|--format) #>># complete -P "$PREFIX" -D "Unix V7" v7 complete -P "$PREFIX" -D "GNU tar 1.12 or earlier" oldgnu complete -P "$PREFIX" -D "GNU tar 1.13" gnu complete -P "$PREFIX" -D "POSIX.1-1988" ustar complete -P "$PREFIX" -D "POSIX.1-2001" posix ;; #<<# (I|--use-compress-program) WORDS=() command -f completion//reexecute -e ;; # (K|--starting-file) # same as ('') # ;; # (L|--tape-length) # ;; # (N|--newer|--after-date) # complete -P "$PREFIX" -f # ;; # ([IT]|--files-from) # complete -P "$PREFIX" -f # ;; # (V|--label) # complete -P "$PREFIX" -f # ;; # (W) # # not supported # ;; # (X|--exclude-from) # complete -P "$PREFIX" -f # ;; (--atime-preserve) #>># complete -P "$PREFIX" -D "remember timestamp and restore it after reading file" replace complete -P "$PREFIX" -D "use a special reading method to keep timestamp" system ;; #<<# (--backup) if command -vf completion//completebackup >/dev/null 2>&1 || . -AL completion/_backup; then command -f completion//completebackup fi ;; (--checkpoint) ;; (--checkpoint-action) case ${TARGETWORD#"$PREFIX"} in (exec=*) PREFIX=${PREFIX}exec= WORDS=() command -f completion//reexecute -e ;; (*) #>># complete -P "$PREFIX" -D "ring a bell on the terminal" bell complete -P "$PREFIX" -D "print a dot" dot . complete -P "$PREFIX" -D "print the specified text to the standard error" -S = -T echo complete -P "$PREFIX" -D "execute the specified command" -S = -T exec complete -P "$PREFIX" -D "wait for the specified seconds" -S = -T sleep complete -P "$PREFIX" -D "print the specified text to the terminal" -S = -T ttyout ;; #<<# esac ;; # (--exclude) # complete -P "$PREFIX" -f # ;; # (--exclude-tag*) # complete -P "$PREFIX" -f # ;; (--group) complete -P "$PREFIX" -g ;; # (--include) # complete -P "$PREFIX" -f # ;; # (--index-file) # complete -P "$PREFIX" -f # ;; (--level) complete -P "$PREFIX" 0 ;; (--mode) if command -vf completion/chmod::mode >/dev/null 2>&1 || . -AL completion/chmod; then command -f completion/chmod::mode tar fi ;; # (--mtime) # ;; # (--newer-[cm]time) # ;; # (--newer-[cm]time-than|--newer-than) # complete -P "$PREFIX" -f # ;; (--occurrence) ;; (--options) ;; (--owner) complete -P "$PREFIX" -u ;; (--pax-option) # TODO: not yet supported # This option is equivalent to pax's -o option ;; (--quote-chars|--no-quote-chars) ;; (--rmt-command|--rsh-command) WORDS=() command -f completion//reexecute -e ;; (--sparse-vertion) #>># # TODO: description complete -P "$PREFIX" 0.0 complete -P "$PREFIX" 0.1 complete -P "$PREFIX" 1.0 ;; #<<# (--strip-components) ;; (--to-command) WORDS=() command -f completion//reexecute -e ;; (--totals) case ${TARGETWORD#"$PREFIX"} in (SIG*) PREFIX=${PREFIX}SIG esac complete -P "$PREFIX" -A HUP --signal complete -P "$PREFIX" -A QUIT --signal complete -P "$PREFIX" -A INT --signal complete -P "$PREFIX" -A USR1 --signal complete -P "$PREFIX" -A USR2 --signal ;; # (--volno-file) # complete -P "$PREFIX" -f # ;; (--warning) #>># complete -P "$PREFIX" -D "enable all warning messages" all complete -P "$PREFIX" -D "disable all warning messages" none # TODO: description complete -P "$PREFIX" alone-zero-block complete -P "$PREFIX" bad-dumpdir complete -P "$PREFIX" cachedir complete -P "$PREFIX" contiguous-cast complete -P "$PREFIX" decompress-program complete -P "$PREFIX" file-changed complete -P "$PREFIX" file-ignored complete -P "$PREFIX" file-removed complete -P "$PREFIX" file-shrank complete -P "$PREFIX" file-unchanged complete -P "$PREFIX" filename-with-nuls complete -P "$PREFIX" ignore-archive complete -P "$PREFIX" ignore-newer complete -P "$PREFIX" new-directory complete -P "$PREFIX" rename-directory complete -P "$PREFIX" symlink-cast complete -P "$PREFIX" timestamp complete -P "$PREFIX" unknown-cast complete -P "$PREFIX" unknown-keyword complete -P "$PREFIX" xdev ;; #<<# (''|K|--starting-file) if $in; then complete -P "$PREFIX" -f else command -f completion/tar::completecontainedfiles fi ;; (*) complete -P "$PREFIX" -f ;; esac fi } function completion/tar::completecontainedfiles { if ! [ "$file" ]; then return fi typeset targetpath="${TARGETWORD#"$PREFIX"}" typeset targetfile="${targetpath##*/}" typeset targetdir="${targetpath%"$targetfile"}" typeset path opt while read -r path; do path="${path#"$targetdir"}" opt= if [ "$path" ]; then case $path in (*/*) path=${path%%/*} opt='-S / -T' esac complete -P "$PREFIX$targetdir" $opt -- "$path" fi done 2>/dev/null \ <("${SAVEWORDS[1]}" -t -f "$file" "$compressopts" -- \ ${targetdir:+"$targetdir"} # "g; treat operands as process group IDs" "n:; specify the nice value increment" "p; treat operands as process IDs" "u; treat operands as user names" ) #<# command -f completion//parseoptions -e case $ARGOPT in (-) command -f completion//completeoptions ;; ('') typeset type=pid arg for arg in "${WORDS[2,-1]}"; do case $arg in (-p|--pid) type=pid ;; (-g|--pgrp) type=pgrp ;; (-u|--user) type=user ;; esac done case $type in (pid) # complete a process ID typeset pid args while read -r pid args; do if kill -n 0 $pid; then complete -D "$args" -- "$pid" fi done 2>/dev/null <(ps -A -o pid= -o args=) ;; (pgrp) # complete a process group ID typeset pid args while read -r pid args; do if kill -n 0 -$pid; then complete -D "$args" -- "$pid" fi done 2>/dev/null <(ps -A -o pgid= -o args=) ;; (user) # complete a user name complete -u ;; esac ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/eview0000644000175000017500000000030412154557026017060 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "eview" command. # Supports Vim 7.3. function completion/eview { command -f completion//reexecute vim } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/type0000644000175000017500000000033012154557026016721 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "type" built-in command. function completion/type { WORDS=(command -V "${WORDS[2,-1]}") command -f completion//reexecute } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-tag0000644000175000017500000000260012154557026017276 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-tag" command. # Supports Git 1.7.7. function completion/git-tag { WORDS=(git tag "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::tag:arg { OPTIONS=( #># "a; make an unsigned annotated tag" "--contains:; list tags that are ancestors of the specified commit" "d; delete tags" "F:; specify a file containing the message" "f --force; overwrite an existing tag" "l; list tag names that match an operand" "m:; specify the message" "n::; specify the number of lines of annotation to print" "s; make a GPG-signed tag with the default email address's key" "u:; specify a key to make a GPG-signed tag with" "v; verify tags" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--contains) command -f completion/git::completeref ;; ('') typeset i=2 nomake=false while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--) i=$((i+1)) break ;; (--*) i=$((i+1)) ;; (-*[dlv]*) nomake=true break ;; (-?*) i=$((i+1)) ;; (*) break ;; esac done if $nomake || [ $i -gt ${WORDS[#]} ]; then command -f completion/git::completeref --tags else command -f completion/git::completeref fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/exec0000644000175000017500000000113512154557026016670 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "exec" built-in command. function completion/exec { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "a: --as:; specify a name to execute the command as" "c --clear; don't export variables from the shell" "f --force; suppress warning about stopped jobs" "--help" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (a|--as) complete -P "$PREFIX" -c ;; (*) command -f completion//getoperands command -f completion//reexecute -e ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/head0000644000175000017500000000303212154557026016643 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "head" command. # Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/head { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "n: ${long:+--lines:}; specify the number of lines to print" ) #<# case $type in (GNU|FreeBSD|NetBSD|Darwin) OPTIONS=("$OPTIONS" #># "c: ${long:+--bytes:}; specify the number of bytes to print" ) #<# case $type in (GNU|NetBSD) OPTIONS=("$OPTIONS" #># "q ${long:+--quiet --silent}; never print filename headers" "v ${long:+--verbose}; always print filename headers" ) #<# case $type in (GNU) OPTIONS=("$OPTIONS" #># "--help" "--version" ) #<# esac esac ;; (HP-UX) OPTIONS=("$OPTIONS" #># "c; count text in bytes rather than lines" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; ([cn]|--bytes|--lines) case $type in (GNU) if command -vf completion//prefixdigits >/dev/null 2>&1 || . -AL completion/_blocksize; then if command -f completion//prefixdigits; then command -f completion//completesizesuffix b GNU fi fi esac ;; (*) complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/pushd0000644000175000017500000000027012154557026017066 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "pushd" built-in command. function completion/pushd { command -f completion//reexecute cd } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-whatchanged0000644000175000017500000000164212154557026021005 0ustar magicantmagicant# (C) 2013 magicant # Completion script for the "git-whatchanged" command. # Supports Git 1.8.1.4. function completion/git-whatchanged { WORDS=(git whatchanged "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::whatchanged:arg { OPTIONS=() if command -vf completion/git::diff-tree:getopt >/dev/null 2>&1 || . -AL completion/git-diff-tree; then command -f completion/git::diff-tree:getopt fi if command -vf completion/git::rev-list:getopt >/dev/null 2>&1 || . -AL completion/git-rev-list; then command -f completion/git::rev-list:getopt fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completerefpath range=true ;; (*) command -f completion/git::diff-tree:compopt || command -f completion/git::rev-list:compopt ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/vim0000644000175000017500000000664012154557026016545 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "vim" command. # Supports Vim 7.3. function completion/vim { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "A; Arabic mode" "b; binary mode" "C; enable the compatible option" "c:; specify a command to be executed after starting up" "D; debug mode" "d; diff mode" "E; operate as the ex editor (improved Ex mode)" "e; operate as the ex editor" "F; Farsi mode" "f --nofork; don't start a new process to execute the GUI" "g; operate in GUI mode" "H; Hebrew mode" "h --help; print help" "i:; specify the viminfo filename" "l; lisp mode" "M; disable the modifiable and write options" "m; disable the write option" "N; disable the compatible option" "n; don't use any swap files" "O::; specify the number of windows to open (vertical split)" "o::; specify the number of windows to open" "p::; specify the number of tab pages to open" "q:; specify a quickfix error file to read" "R; read-only mode" "r L; recover unsaved files" "S:; specify a file to be sourced after starting up" "T:; specify the terminal type" "t:; specify an identifier to jump" "U:; specify the gvimrc filename" "u:; specify the vimrc filename" "V::; specify the value of the verbose option" "v; operate as the vi editor" "w:; specify the value of the window option" "X; don't connect to the X server" "x; enable encryption" "y; easy mode" "Z; restricted mode" "--cmd:; specify a command to be executed before processing vimrc" "--echo-wid; print GTK+ GUI window ID" "--literal; don't expand wild card characters in filename arguments" "--noplugin; don't load plug-ins" "--remote; open files in the remote Vim server" "--remote-silent; like --remote, but don't complain if there is no server" "--remote-wait; like --remote, but wait for the editing to be finished" "--remote-wait-silent; like --remote-wait and --remote-silent" "--remote-tab; like --remote, but open each file in a new tab page" "--remote-tab-silent; like --remote-tab and --remote-silent" "--remote-tab-wait; like --remote-tab and --remote-wait" "--remote-tab-wait-silent; like --remote-tab and --remote-wait-silent" "--remote-expr:; specify an expression to be evaluated on the remote server" "--remote-send:; specify a key sequence to send to the remote server" "--role:; specify a role for GTK+ 2 GUI" "--serverlist; print list of servers" "--servername:; specify a server name to operate as or connect to" "--startuptime:; specify a file to write timing messages while starting up" "--version" ) #<# case ${WORDS[1]##*/} in (*ex*) OPTIONS=("$OPTIONS" #># "s; non-interactive batch processing mode" ) #<# ;; (*) OPTIONS=("$OPTIONS" #># "s:; specify a file to be source!ed after starting up" ) #<# ;; esac command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions -e ;; # ([cOopVw]|--cmd|--remote-expr|--remote-send|--role|--servername) # ;; ([iSsUu]|--startuptime) if [ "$PREFIX" ]; then complete -P "$PREFIX" "" else complete -f fi ;; (q) complete -P "$PREFIX" -f ;; (T) if [ "$PREFIX" ]; then complete -P "$PREFIX" "" else typeset term desc while read -r term desc; do complete -D "$desc" -- "$term" done 2>/dev/null <(toe -a || toe) fi ;; (t) if [ -r tags ]; then complete -P "$PREFIX" -R "!_TAG_*" -- \ $(cut -f 1 tags 2>/dev/null) fi ;; ('') complete -f ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-bisect0000644000175000017500000000373012154557026020001 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-bisect" command. # Supports Git 1.7.7. function completion/git-bisect { WORDS=(git bisect "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::bisect:arg { if [ ${WORDS[#]} -le 1 ]; then #>># complete -P "$PREFIX" -D "mark a commit as bad" bad complete -P "$PREFIX" -D "mark a commit as good" good complete -P "$PREFIX" -D "print help" help complete -P "$PREFIX" -D "show the bisection log" log complete -P "$PREFIX" -D "replay a bisection log" replay complete -P "$PREFIX" -D "end bisection" reset complete -P "$PREFIX" -D "start automated bisection" run complete -P "$PREFIX" -D "mark a commit as untestable" skip complete -P "$PREFIX" -D "start bisection" start complete -P "$PREFIX" -D "show remaining suspects with GUI" visualize #<<# case ${TARGETWORD#"$PREFIX"} in (vie*) complete -P "$PREFIX" -D "show remaining suspects with GUI" view esac else WORDS=("${WORDS[2,-1]}") if command -vf "completion/git::bisect:${WORDS[1]}:arg" >/dev/null 2>&1; then command -f "completion/git::bisect:${WORDS[1]}:arg" fi fi } function completion/git::bisect:bad:arg { command -f completion/git::completeref } function completion/git::bisect:good:arg { command -f completion/git::completeref } #function completion/git::bisect:help:arg { #} #function completion/git::bisect:log:arg { #} function completion/git::bisect:replay:arg { complete -P "$PREFIX" -f } function completion/git::bisect:reset:arg { command -f completion/git::completeref } function completion/git::bisect:run:arg { WORDS=("${WORDS[2,-1]}") command -f completion//reexecute -e } function completion/git::bisect:skip:arg { command -f completion/git::completeref range=true } function completion/git::bisect:start:arg { command -f completion/git::completerefpath } #function completion/git::bisect:view:arg { #} #function completion/git::bisect:visualize:arg { #} # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/ksh0000644000175000017500000000025412154557026016532 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "ksh" command. function completion/ksh { command -f completion//reexecute set } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/rmdir0000644000175000017500000000243212154557026017062 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "rmdir" command. # Supports POSIX 2008, GNU coreutils 8.6, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0, # Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3. function completion/rmdir { case $("${WORDS[1]}" --version 2>/dev/null) in (*'coreutils'*) typeset type=GNU ;; (*) typeset type="$(uname 2>/dev/null)" ;; esac case $type in (GNU) typeset long=true ;; (*) typeset long= ;; esac typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "p ${long:+--parents}; remove parent directories as well" ) #<# case $type in (GNU|FreeBSD) OPTIONS=("$OPTIONS" #># "v ${long:+--verbose}; print a message for each directory processed" ) #<# esac case $type in (GNU) OPTIONS=("$OPTIONS" #># "--ignore-fail-on-non-empty; suppress error messages about non-empty directories" "--help" "--version" ) #<# ;; (SunOS) OPTIONS=("$OPTIONS" #># "s; suppress error messages (with -p)" ) #<# ;; (HP-UX) OPTIONS=("$OPTIONS" #># "f; remove directories without confirmation" "i; confirm before removing each directory" ) #<# ;; esac command -f completion//parseoptions ${long:+-es} case $ARGOPT in (-) command -f completion//completeoptions ;; (*) complete -T -S / -d ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/_dot0000644000175000017500000000134012154557026016667 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "." built-in command. function completion/. { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "A --no-alias; disable alias substitution while executing the script" "L --autoload; load script from \$YASH_LOADPATH" "--help" ) #<# command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (*) command -f completion//getoperands if [ ${WORDS[#]} -le 0 ]; then # complete as a script file name case $TARGETWORD in */*) complete -f ;; * ) complete --external-command ;; esac else # complete an argument to the script command -f completion//reexecute fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-branch0000644000175000017500000000367012154557026017770 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-branch" command. # Supports Git 1.7.7. function completion/git-branch { WORDS=(git branch "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::branch:arg { OPTIONS=( #># "a; print local and remote-tracking branches" "--abbrev:; specify the number of commit ID digits to print" "--color::; show symbols in color" "--contains; show branches that contain the specified commit only" "D; delete a branch that has not been merged" "d; delete a branch" "f --force; overwrite an existing branch" "l; enable reflog for the new branch" "--merged; show branches that are contained in the specified commit only" "--no-abbrev; print full commit IDs" "--no-color; like --color=never" "--no-merged; show branches that aren't contained in the specified commit only" "--no-track; create a non-tracking branch" "M; rename a branch, overwriting an existing branch" "m; rename a branch" "r; print or delete remote-tracking branches" "--set-upstream; like --track, but don't move HEAD" "t --track; create a remote-tracking branch" "v --verbose; print commit ID and summary for each branch" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; (--abbrev) ;; (--color) command -f completion/git::--color:arg ;; ('') typeset i=2 all=false delete=false while [ $i -le ${WORDS[#]} ]; do case ${WORDS[i]} in (--) i=$((i+1)) break ;; (--merged|--no-merged|--contains) all=true break ;; (--*) i=$((i+1)) ;; (-*[Dd]*) delete=true break ;; (-?*) i=$((i+1)) ;; (*) break ;; esac done if ! $all && $delete || [ $i -gt ${WORDS[#]} ]; then command -f completion/git::completeref --branches else command -f completion/git::completeref fi ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/continue0000644000175000017500000000057512154557026017577 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "continue" built-in command. function completion/continue { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "i --iteration; continue iterative execution" "--help" ) #<# command -f completion//parseoptions -es case $ARGOPT in (-) command -f completion//completeoptions ;; esac } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-diff0000644000175000017500000001413712154557026017443 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-diff" command. # Supports Git 1.7.7. function completion/git-diff { WORDS=(git diff "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::diff:arg { OPTIONS=( #># "--cached --staged; compare the index with a commit" ) #<# command -f completion/git::diff:getopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completerefpath range=true ;; (*) command -f completion/git::diff:compopt ;; esac } function completion/git::diff:getopt { typeset diff= case $gitcmd in (diff|log|show|stash) diff=true;; esac OPTIONS=("$OPTIONS" #># "--abbrev::; abbreviate commit IDs" "--binary; print diffs for binary files" "B:: --break-rewrites::; treat a way different file as a new file" "--cc; show diffs for resolved merge conflicts only" "--check; check for whitespace errors" "--color::; show symbols in color" "--color-words::; like --word-diff=color --word-diff-regex=..." "--diff-filter:; specify categories of changes to show" "--dirstat::; print a dirstat with the specified style" "--dirstat-by-file::; print the number of changed files" "--dst-prefix:; specify a prefix for destination filenames in diffs" "--exit-code; return the exit status of 1 when there is any diffs" "--ext-diff; use an external diff program" "C:: --find-copies::; detect copies of files with the specified threshold" "--find-copies-harder; find files copied from unmodified existing files" "M:: --find-renames::; detect renames of files with the specified threshold" "--full-index; print full commit IDs in the patch format" "G:; specify a regular expression to look for in diffs" "w --ignore-all-space; ignore whitespaces in comparison" "--ignore-space-at-eol; ignore changes in whitespace at end of lines" "b --ignore-space-change; ignore changes in amount of whitespaces only" "--ignore-submodules::; ignore changes to submodules" "--inter-hunk-context:; specify the number of lines to show between hunks" "D --irreversible-delete; don't print diffs for deleted files" "l:; specify a threshold at which rename/copy detection is given up" "--name-only; just print the names of differing files" "--name-status; just print the names and statuses of differing files" "--no-color; like --color=never" "--no-ext-diff; use the internal diff program" "--no-index; compare a file with another file outside the repository" "--no-prefix; don't prefix filenames in diffs" "--no-renames; disable rename detection" "--no-textconv; don't use an external text filter to compare binary files" "--numstat; print a diffstat in the machine-friendly format" "O:; specify a file containing the order in which diffs are printed" "${diff:+p} --patch; print a patch" "--patch-with-raw; like --patch --raw" "--patch-with-stat; like --patch --stat" "--patience; generate a diff using the patience diff algorithm" "--pickaxe-all; show the whole changeset when -S/-G is specified" "--pickaxe-regex; treat the specified string as a regular expression (with -S)" "--quiet; don't print anything" "R; print reverse diffs" "--raw; print in the raw format" "--relative::; only show diffs in the specified directory" "S:; specify a string to look for in diffs" "--shortstat; print a diffstat summary" "--src-prefix:; specify a prefix for source filenames in diffs" "--stat::; print a diffstat with the specified column widths" "--stat-count:; specify the max number of files shown in the diffstat" "--stat-name-width:; specify the width of filenames in the diffstat" "--stat-width:; specify the width of the diffstat" "--submodule::; print diffs in submodules" "--summary; print summary" "a --text; assume all files are text" "--textconv; use an external text filter to compare binary files" "U:: --unified::; output in unified context format with the specified number of context lines" "u; like -U3" "--word-diff::; print word-based diffs" "--word-diff-regex:; specify a regular expression that defines a word" "z; print a null byte after each filename" ) #<# } function completion/git::diff:compopt case $ARGOPT in ([BClMU]|--abbrev|--break-rewrites|--find-*|--inter-hunk-context|--stat|--stat-*|--unified) ;; (--color|--ignore-submodules) command -f completion/git::$ARGOPT:arg ;; (--color-words|--word-diff-regex) ;; (--diff-filter) #>># complete -P "$TARGETWORD" -D "added" A complete -P "$TARGETWORD" -D "pair broken" B complete -P "$TARGETWORD" -D "copied" C complete -P "$TARGETWORD" -D "deleted" D complete -P "$TARGETWORD" -D "modified" M complete -P "$TARGETWORD" -D "renamed" R complete -P "$TARGETWORD" -D "type modified" T complete -P "$TARGETWORD" -D "unmerged" U complete -P "$TARGETWORD" -D "unknown" X complete -P "$TARGETWORD" -D "all, if any of other flag matches" '*' ;; #<<# (--dirstat|--dirstat-by-file) typeset word="${TARGETWORD#"$PREFIX"}" word=${word##*,} PREFIX=${TARGETWORD%"$word"} #>># complete -P "$PREFIX" -S , -T -D "count lines that are added or removed, but not moved" changes complete -P "$PREFIX" -S , -T -D "include changes in subdirectories when operating on the parent" cumulative complete -P "$PREFIX" -S , -T -D "count files that are changed" files complete -P "$PREFIX" -S , -T -D "count lines that appear as added or removed in diffs" lines complete -P "$PREFIX" -S , -T -D "exclude changes in subdirectories when operating on the parent" noncumulative ;; #<<# ([GS]) ;; (--relative) complete -P "$PREFIX" -S / -T -d ;; (--submodule) #>># complete -P "$PREFIX" -D "print logs for commits in submodules" log complete -P "$PREFIX" -D "just print pairs of commit IDs" short ;; #<<# (--word-diff) #>># complete -P "$PREFIX" -D "use colors" color complete -P "$PREFIX" -D "use delimiters" plain complete -P "$PREFIX" -D "print in the machine-friendly format" porcelain complete -P "$PREFIX" -D "disable word-based diffs" none ;; #<<# (O|--dst-prefix|--src-prefix) complete -P "$PREFIX" -f ;; (*) return 1 ;; esac # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/kill0000644000175000017500000000274012154557026016702 0ustar magicantmagicant# (C) 2010 magicant # Completion script for the "kill" built-in command. function completion/kill { typeset OPTIONS ARGOPT PREFIX OPTIONS=( #># "s: n:; specify a signal to send" "l; print signal names" "v; print signal names and description" "--help" ) #<# typeset signame=false SAVEWORDS SAVEWORDS=("$WORDS") command -f completion//parseoptions case $ARGOPT in (-) case $TARGETWORD in (-[[:upper:]]*) signame=true PREFIX=- ;; (-[[:digit:]]*) typeset signame=true word for word in "${WORDS[2,-1]}" "${SAVEWORDS[2,-1]}"; do case $word in (-[ns[:upper:][:digit:]]*) signame=false esac done if $signame; then PREFIX=- fi ;; (*) command -f completion//completeoptions return ;; esac ;; ([ns]) signame=true ;; (*) typeset word for word in "${WORDS[2,-1]}"; do case $word in (-[lv]) signame=true esac done ;; esac if $signame; then complete -P "$PREFIX" --signal else typeset pid args case $TARGETWORD in (%*) # complete a job name complete -P % -j ;; (-*) # complete a process group ID while read -r pid args; do if kill -n 0 -$pid; then complete -D "$args" -- "-$pid" fi done 2>/dev/null <(ps -A -o pgid= -o args=) ;; (*) # complete a process ID while read -r pid args; do if kill -n 0 $pid; then complete -D "$args" -- "$pid" fi done 2>/dev/null <(ps -A -o pid= -o args=) ;; esac fi } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-svn0000644000175000017500000003322612154557026017341 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-svn" command. # Supports Git 1.7.7. function completion/git-svn { WORDS=(git svn "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::svn:arg if [ ${WORDS[#]} -le 1 ]; then #>># complete -P "$PREFIX" -D "commit a diff to a Subversion repository" commit-diff complete -P "$PREFIX" -D "commit local commits to the Subversion repository" dcommit complete -P "$PREFIX" -D "commit to the Subversion repository without checking for conflicts" set-tree complete -P "$PREFIX" -D "convert commit IDs and revision numbers" find-rev complete -P "$PREFIX" -D "create a branch" branch complete -P "$PREFIX" -D "create a gitignore file" create-ignore complete -P "$PREFIX" -D "create a tag" tag complete -P "$PREFIX" -D "fetch and rebase local commits" rebase complete -P "$PREFIX" -D "fetch revisions from a remote Subversion repository" fetch complete -P "$PREFIX" -D "init and fetch" clone complete -P "$PREFIX" -D "initialize a Git repository associated with a Subversion repository" init complete -P "$PREFIX" -D "print a property of a file" propget complete -P "$PREFIX" -D "print candidates for the info/exclude file" show-ignore complete -P "$PREFIX" -D "print external repositories" show-externals complete -P "$PREFIX" -D "print info about files" info complete -P "$PREFIX" -D "print properties of a file" proplist complete -P "$PREFIX" -D "print revision log" log complete -P "$PREFIX" -D "recreate empty directories" mkdirs complete -P "$PREFIX" -D "reduce local repository size" gc complete -P "$PREFIX" -D "show a file with commit info" blame complete -P "$PREFIX" -D "undo fetch" reset else #<<# WORDS=("${WORDS[2,-1]}") if command -vf "completion/git::svn:${WORDS[1]}:arg" >/dev/null 2>&1; then command -f "completion/git::svn:${WORDS[1]}:arg" fi fi function completion/git::svn:blame:arg { OPTIONS=( #># "--git-format; print in the git blame format" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completepath -a ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:branch:arg { OPTIONS=( #># "--commit-url:; specify a repository URL to commit to" "d: --destination:; specify a branch/tag path to operate on" "n --dry-run; don't actually make a branch/tag" "m: --message:; specify the commit message" "t --tag; create a tag rather than a branch" "--username:; specify a user name for authentication" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (--destination) # TODO ;; # (m|--message) # ;; ('') command -f completion/git::completeref --branches ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:clone:arg { OPTIONS=( #># "--preserve-empty-dirs; create empty directories with dummy files" "--placeholder-filename:; specify the name of dummy files in empty directories" ) #<# command -f completion/git::svn:getcommonopt command -f completion/git::svn:fetch:getopt command -f completion/git::svn:init:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; (--placeholder-filename) complete -P "$PREFIX" -f ;; # ('') # # Hmm... How can we complete a URL? # ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:commit-diff:arg { OPTIONS=() command -f completion/git::svn:getcommonopt command -f completion/git::svn:commit-diff:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # (l) # #TODO # ;; ('') command -f completion//getoperands case ${WORDS[#]} in ([01]) command -f completion/git::completeref ;; # (2) # # Hmm... How can we complete a URL? # ;; esac ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:commit-diff:getopt { OPTIONS=("$OPTIONS" #># "--add-author-from; add an author name to each log message" "e --edit; reedit the message" "--find-copies-harder" #TODO "l:" #TODO "--rmdir; remove empty directories from the Subversion tree" ) #<# command -f completion/git::svn:getauthoropt } function completion/git::svn:create-ignore:arg { OPTIONS=( #># "r: --revision:; specify a revision to show" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; # (r|--revision) # ;; # ('') # ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:dcommit:arg { OPTIONS=( #># "--commit-url:; specify a repository URL to commit to" "n --dry-run; don't actually commit anything" "m --merge; use merging strategies to rebase" "--mergeinfo:; specify mergeinfo to add" "--no-rebase; don't rebase after committing" "s: --strategy:; specify the merge strategy" ) #<# command -f completion/git::svn:getcommonopt command -f completion/git::svn:commit-diff:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # (l) # #TODO # ;; # ('') # ;; (s|--strategy) if command -vf completion/git::rebase:compopt >/dev/null 2>&1 || . -AL completion/git-rebase; then command -f completion/git::rebase:compopt fi ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:fetch:arg { OPTIONS=( #># "--parent; fetch only from the Subversion parent of the current HEAD" ) #<# command -f completion/git::svn:getcommonopt command -f completion/git::svn:fetch:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::svn:completesvnremotes ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:fetch:getopt { OPTIONS=("$OPTIONS" #># "--ignore-paths:; specify a regular expression whose matching pathnames are ignored when fetching" "--localtime; store Git commit dates in the local timezone" #"--repack::" obsolete option #"--repack-flags:" obsolete option "--use-log-author; find author names out of log messages" ) #<# command -f completion/git::svn:getauthoropt } function completion/git::svn:find-rev:arg { OPTIONS=() command -f completion/git::svn:getcommonopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completeref ;; (*) command -f completion/git::svn:compopt ;; esac } #function completion/git::svn:gc:arg { #} function completion/git::svn:info:arg { OPTIONS=( #># "--url; only print the URL of the remote Subversion repository" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; ('') command -f completion/git::completepath -a ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:init:arg { OPTIONS=("$OPTIONS" #># "--shared::; share the repository with other users" "--template:; specify a directory that contains templates" ) #<# command -f completion/git::svn:getcommonopt command -f completion/git::svn:init:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # ('') # # Hmm... How can we complete a URL? # ;; (*) { { command -vf completion/git::init:compopt >/dev/null 2>&1 || . -AL completion/git-init; } && command -f completion/git::init:compopt; } || command -f completion/git::svn:compopt ;; esac } function completion/git::svn:init:getopt { OPTIONS=("$OPTIONS" #># "b: --branches:; specify the branches subdirectory name" "--ignore-paths:; specify a regular expression whose matching pathnames are ignored when fetching" "--no-metadata; set the noMetadata option" "--no-minimize-url; don't normalize URL to the repository root" "--prefix:; specify the prefix for trunk/branches/tags" "--rewrite-root:; specify the rewriteRoot option value" "--rewrite-uuid:; specify the rewriteUUID option value" "s --stdlayout; follow the standard trunk/branches/tags directory layout" "t: --tags:; specify the tags subdirectory name" "T: --trunk:; specify the trunk subdirectory name" "--username:; specify a user name for authentication" "--use-svm-props; set the useSvmProps option" "--use-svnsync-props; set the useSvnsyncProps option" ) #<# } function completion/git::svn:log:arg { OPTIONS=( #># "--incremental; print output in a format suitable for concatenation" "--limit:; specify the number of revisions to show at most" "--oneline; use only one line for each revision" "r: --revision:; specify a revision (range) to show" "--show-commit; show git commit IDs as well" "v --verbose; print additional info" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; # (--limit) # ;; # (r|--revision) # ;; ('') command -f completion/git::completepath -a ;; (*) command -f completion/git::svn:compopt ;; esac } #function completion/git::svn:mkdirs:arg { #} function completion/git::svn:propget:arg { OPTIONS=( #># "r: --revision:; specify a revision to show" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # (r|--revision) # ;; ('') command -f completion//getoperands if [ ${WORDS[#]} -eq 0 ]; then if command -vf completion/svn::completepropname >/dev/null 2>&1 || . -AL completion/svn; then command -f completion/svn::completepropname fi else command -f completion/git::completepath -r fi ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:proplist:arg { OPTIONS=( #># "r: --revision:; specify a revision to show" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; # (r|--revision) # ;; ('') command -f completion/git::completepath -r ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:rebase:arg { OPTIONS=( #># "n --dry-run; just print the remote branch name and URL" "l --local; don't fetch remotely; just rebase to already-fetched revision" ) #<# command -f completion/git::svn:getcommonopt command -f completion/git::svn:fetch:getopt if command -vf completion/git::rebase:getopt >/dev/null 2>&1 || . -AL completion/git-rebase; then command -f completion/git::rebase:getopt fi command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') ;; (*) { { command -vf completion/git::rebase:compopt >/dev/null 2>&1 || . -AL completion/git-rebase; } && command -f completion/git::rebase:compopt; } || command -f completion/git::svn:compopt ;; esac } function completion/git::svn:reset:arg { OPTIONS=( #># "p --parent; discard the specified revision as well" "r: --revision:; specify the most recent revision to keep" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; # (r|--revision) # ;; # ('') # ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:set-tree:arg { OPTIONS=( #># "--stdin; read a list of commits from the standard input and commit them" ) #<# command -f completion/git::svn:getcommonopt command -f completion/git::svn:commit-diff:getopt command -f completion//parseoptions case $ARGOPT in (-) command -f completion//completeoptions ;; # (l) # #TODO # ;; ('') command -f completion/git::completeref ;; (*) command -f completion/git::svn:compopt ;; esac } function completion/git::svn:show-externals:arg { OPTIONS=( #># "r: --revision:; specify a revision to show" ) #<# command -f completion/git::svn:getcommonopt command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; # (r|--revision) # ;; # ('') # ;; (*) command -f completion/git::svn:compopt ;; esac } #function completion/git::svn:show-ignore:arg { #} function completion/git::svn:tag:arg { command -f completion/git::svn:branch:arg } function completion/git::svn:getcommonopt { OPTIONS=("$OPTIONS" #># "q --quiet; print less messages" ) #<# } function completion/git::svn:getauthoropt { OPTIONS=("$OPTIONS" #># "A: --authors-file:; specify a file containing author names" "--authors-prog:; specify a program that returns an author name and email" ) #<# } function completion/git::svn:compopt case $ARGOPT in (A|--authors-file|--ignore-paths|--placeholder-filename) complete -P "$PREFIX" -f ;; (--authors-prog) WORDS=() command -f completion//reexecute -e ;; # (b|--branches) # #TODO # ;; # (--commit-url) # # Hmm... How can we complete a URL? # ;; # (l) # #TODO # ;; (--username) complete -P "$PREFIX" -u ;; (*) return 1 ;; esac function completion/git::svn:completesvnremotes { typeset name url while read -r name url; do complete -P "$PREFIX" -D "$url" -- "${{name#*.}%.*}" done 2>/dev/null <(git config --get-regexp 'svn-remote\..*\.url') } # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/share/completion/git-init0000644000175000017500000000230312154557026017466 0ustar magicantmagicant# (C) 2011 magicant # Completion script for the "git-init" command. # Supports Git 1.7.7. function completion/git-init { WORDS=(git init "${WORDS[2,-1]}") command -f completion//reexecute } function completion/git::init:arg { OPTIONS=( #># "--bare; create a bare repository" "q --quiet; print error and warning messages only" "--separate-git-dir:; specify the repository directory" "--shared::; share the repository with other users" "--template:; specify a directory that contains templates" ) #<# command -f completion//parseoptions -n case $ARGOPT in (-) command -f completion//completeoptions ;; ('') complete -P "$PREFIX" -S / -T -d ;; (*) command -f completion/git::init:compopt ;; esac } function completion/git::init:compopt case $ARGOPT in (--shared) #>># complete -P "$PREFIX" -D "set permissions according to the current umask" umask false complete -P "$PREFIX" -D "make the repository group-writable" group true complete -P "$PREFIX" -D "make the repository world-writable" all world everybody ;; #<<# (--separate-git-dir|--template) complete -P "$PREFIX" -S / -T -d ;; (*) return 1 ;; esac # vim: set ft=sh ts=8 sts=8 sw=8 noet: yash-2.35/hashtable.c0000644000175000017500000003367612154557026014664 0ustar magicantmagicant/* Yash: yet another shell */ /* hashtable.c: hashtable library */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "hashtable.h" #include #include #include #include #include "util.h" /* A hashtable is a mapping from keys to values. * Keys and values are all of type (void *). * NULL is allowed as a value, but not as a key. * The capacity of a hashtable is always no less than one. */ /* The hashtable_T structure is defined as follows: * struct hashtable_T { * size_t capacity; * size_t count; * hashfunc_T *hashfunc; * keycmp keycmp; * size_t emptyindex; * size_t tailindex; * size_t *indices; * struct hash_entry *entries; * } * `capacity' is the size of array `entries'. * `count' is the number of entries contained in the hashtable. * `hashfunc' is a pointer to the hash function. * `keycmp' is a pointer to the function that compares keys. * `emptyindex' is the index of the first empty entry. * `tailindex' is the index of the first tail entry. * `indices' is a pointer to the bucket array. * `entries' is a pointer to the array of entries. * * The collision resolution strategy used in this implementation is a kind of * separate chaining, but it differs from normal chaining in that entries are * stored in a single array (`entries'). An advantage over normal chaining, * which stores entries in linked lists, is spatial locality: entries can be * quickly referenced because they are collected in one array. Another advantage * is that we don't have to call `malloc' or `free' each time an entry is added * or removed. */ //#define DEBUG_HASH 1 #if DEBUG_HASH /* For debugging */ # define DEBUG_PRINT_STATISTICS(ht) (print_statistics(ht)) # include static void print_statistics(const hashtable_T *ht); #else # define DEBUG_PRINT_STATISTICS(ht) ((void) 0) #endif /* The null index */ #define NOTHING ((size_t) -1) /* hashtable entry */ struct hash_entry { size_t next; hashval_T hash; kvpair_T kv; }; /* An entry is occupied iff `.kv.key' is non-NULL. * When an entry is unoccupied, the values of the other members of the entry are * unspecified. */ /* Initializes a hashtable with the specified capacity. * `hashfunc' is a hash function to hash keys. * `keycmp' is a function that compares two keys. */ hashtable_T *ht_initwithcapacity( hashtable_T *ht, hashfunc_T *hashfunc, keycmp_T *keycmp, size_t capacity) { if (capacity == 0) capacity = 1; ht->capacity = capacity; ht->count = 0; ht->hashfunc = hashfunc; ht->keycmp = keycmp; ht->emptyindex = NOTHING; ht->tailindex = 0; ht->indices = xmallocn(capacity, sizeof *ht->indices); ht->entries = xmallocn(capacity, sizeof *ht->entries); for (size_t i = 0; i < capacity; i++) { ht->indices[i] = NOTHING; ht->entries[i].kv.key = NULL; } return ht; } /* Changes the capacity of the specified hashtable. * If the specified new capacity is smaller than the number of the entries in * the hashtable, the capacity is not changed. * Note that the capacity cannot be zero. If `newcapacity' is zero, it is * assumed to be one. */ /* Capacity should be an odd integer, especially a prime number. */ hashtable_T *ht_setcapacity(hashtable_T *ht, size_t newcapacity) { if (newcapacity == 0) newcapacity = 1; if (newcapacity < ht->count) newcapacity = ht->count; size_t oldcapacity = ht->capacity; size_t *oldindices = ht->indices; size_t *newindices = xmallocn(newcapacity, sizeof *ht->indices); struct hash_entry *oldentries = ht->entries; struct hash_entry *newentries = xmallocn(newcapacity, sizeof *ht->entries); size_t tail = 0; for (size_t i = 0; i < newcapacity; i++) { newindices[i] = NOTHING; newentries[i].kv.key = NULL; } /* move the data from oldentries to newentries */ for (size_t i = 0; i < oldcapacity; i++) { void *key = oldentries[i].kv.key; if (key != NULL) { hashval_T hash = oldentries[i].hash; size_t newindex = (size_t) hash % newcapacity; newentries[tail] = (struct hash_entry) { .next = newindices[newindex], .hash = hash, .kv = oldentries[i].kv, }; newindices[newindex] = tail; tail++; } } free(oldindices); free(oldentries); ht->capacity = newcapacity; ht->emptyindex = NOTHING; ht->tailindex = tail; ht->indices = newindices; ht->entries = newentries; return ht; } /* Increases the capacity as large as necessary * so that the capacity is no less than the specified. */ hashtable_T *ht_ensurecapacity(hashtable_T *ht, size_t capacity) { if (capacity <= ht->capacity) return ht; size_t cap15 = ht->capacity + (ht->capacity >> 1); if (capacity < cap15) capacity = cap15; if (capacity < ht->capacity + 6) capacity = ht->capacity + 6; return ht_setcapacity(ht, capacity); } /* Removes all the entries of a hashtable. * If `freer' is non-NULL, it is called for each entry removed (in an * unspecified order). * The capacity of the hashtable is not changed. */ hashtable_T *ht_clear(hashtable_T *ht, void freer(kvpair_T kv)) { size_t *indices = ht->indices; struct hash_entry *entries = ht->entries; if (ht->count == 0) return ht; for (size_t i = 0, cap = ht->capacity; i < cap; i++) { indices[i] = NOTHING; if (entries[i].kv.key != NULL) { if (freer) freer(entries[i].kv); entries[i].kv.key = NULL; } } ht->count = 0; ht->emptyindex = NOTHING; ht->tailindex = 0; return ht; } /* Returns the entry whose key is equal to the specified `key', * or { NULL, NULL } if `key' is NULL or there is no such entry. */ kvpair_T ht_get(const hashtable_T *ht, const void *key) { if (key != NULL) { hashval_T hash = ht->hashfunc(key); size_t index = ht->indices[(size_t) hash % ht->capacity]; while (index != NOTHING) { struct hash_entry *entry = &ht->entries[index]; if (entry->hash == hash && ht->keycmp(entry->kv.key, key) == 0) return entry->kv; index = entry->next; } } return (kvpair_T) { NULL, NULL, }; } /* Makes a new entry with the specified key and value, * removing and returning the old entry for the key. * If there is no such old entry, { NULL, NULL } is returned. * `key' must not be NULL. */ kvpair_T ht_set(hashtable_T *ht, const void *key, const void *value) { assert(key != NULL); /* if there is an entry with the specified key, simply replace the value */ hashval_T hash = ht->hashfunc(key); size_t mhash = (size_t) hash % ht->capacity; size_t index = ht->indices[mhash]; struct hash_entry *entry; while (index != NOTHING) { entry = &ht->entries[index]; if (entry->hash == hash && ht->keycmp(entry->kv.key, key) == 0) { kvpair_T oldkv = entry->kv; entry->kv = (kvpair_T) { (void *) key, (void *) value, }; DEBUG_PRINT_STATISTICS(ht); return oldkv; } index = entry->next; } /* No entry with the specified key was found; we add a new entry. */ index = ht->emptyindex; if (index != NOTHING) { /* if there is an empty entry, use it */ entry = &ht->entries[index]; ht->emptyindex = entry->next; } else { /* if there is no empty entry, use a tail entry */ ht_ensurecapacity(ht, ht->count + 1); mhash = (size_t) hash % ht->capacity; index = ht->tailindex++; entry = &ht->entries[index]; } *entry = (struct hash_entry) { .next = ht->indices[mhash], .hash = hash, .kv = (kvpair_T) { (void *) key, (void *) value, }, }; ht->indices[mhash] = index; ht->count++; DEBUG_PRINT_STATISTICS(ht); return (kvpair_T) { NULL, NULL, }; } /* Removes and returns the entry with the specified key. * If `key' is NULL or there is no such entry, { NULL, NULL } is returned. */ kvpair_T ht_remove(hashtable_T *ht, const void *key) { if (key != NULL) { hashval_T hash = ht->hashfunc(key); size_t *indexp = &ht->indices[(size_t) hash % ht->capacity]; while (*indexp != NOTHING) { size_t index = *indexp; struct hash_entry *entry = &ht->entries[index]; if (entry->hash == hash && ht->keycmp(entry->kv.key, key) == 0) { kvpair_T oldkv = entry->kv; *indexp = entry->next; entry->next = ht->emptyindex; ht->emptyindex = index; entry->kv.key = NULL; ht->count--; return oldkv; } indexp = &entry->next; } } return (kvpair_T) { NULL, NULL, }; } #if 0 /* Calls the specified function `f' for each entry in the specified hashtable. * The order in which the entries are applied the function to is unspecified. * If `f' returns a non-zero value for some entry, `f' is not called any more * and `ht_each' immediately returns the non-zero value. Otherwise, that is, * if `f' returns zero for all the entry, `ht_each' also returns zero. * You must not add or remove any entry inside function `f'. */ int ht_each(const hashtable_T *ht, int f(kvpair_T kv)) { struct hash_entry *entries = ht->entries; for (size_t i = 0, cap = ht->capacity; i < cap; i++) { kvpair_T kv = entries[i].kv; if (kv.key != NULL) { int r = f(kv); if (r != 0) return r; } } return 0; } #endif /* Iterates the entries of the specified hashtable. * When starting new iteration, `*indexp' must have been initialized to zero. * Each time this function is called, it updates `*indexp' and returns one * entry. * You must not change the value of `*indexp' from outside this function or * add/remove any entry in the hashtable until the iteration finishes. * Each entry is returned exactly once, in an unspecified order. * If there is no more entry to be iterated, { NULL, NULL } is returned. */ kvpair_T ht_next(const hashtable_T *restrict ht, size_t *restrict indexp) { while (*indexp < ht->capacity) { kvpair_T kv = ht->entries[*indexp].kv; (*indexp)++; if (kv.key != NULL) return kv; } return (kvpair_T) { NULL, NULL, }; } /* Returns a newly malloced array of key-value pairs that contains all the * elements of the specified hashtable. * The returned array is terminated by the { NULL, NULL } element. */ kvpair_T *ht_tokvarray(const hashtable_T *ht) { kvpair_T *array = xmallocn(ht->count + 1, sizeof *array); size_t index = 0; for (size_t i = 0; i < ht->capacity; i++) { if (ht->entries[i].kv.key != NULL) array[index++] = ht->entries[i].kv; } assert(index == ht->count); array[index] = (kvpair_T) { NULL, NULL, }; return array; } /* A hash function for a byte string. * The argument is a pointer to a byte string (const char *). * You can use `htstrcmp' as a corresponding comparison function. */ hashval_T hashstr(const void *s) { /* The hashing algorithm is FNV hash. * Cf. http://www.isthe.com/chongo/tech/comp/fnv/ */ const unsigned char *c = s; hashval_T h = 0; while (*c != '\0') h = (h ^ (hashval_T) *c++) * FNVPRIME; return h; } /* A hash function for a wide string. * The argument is a pointer to a wide string (const wchar_t *). * You can use `htwcscmp' for a corresponding comparison function. */ hashval_T hashwcs(const void *s) { /* The hashing algorithm is a slightly modified version of FNV hash. * Cf. http://www.isthe.com/chongo/tech/comp/fnv/ */ const wchar_t *c = s; hashval_T h = 0; while (*c != L'\0') h = (h ^ (hashval_T) *c++) * FNVPRIME; return h; } /* A comparison function for wide strings. * The arguments are pointers to wide strings (const wchar_t *). * You can use `hashwcs' for a corresponding hash function. */ int htwcscmp(const void *s1, const void *s2) { return wcscmp((const wchar_t *) s1, (const wchar_t *) s2); } /* A comparison function for key-value pairs with multibyte-string keys. * The arguments are pointers to kvpair_T's (const kvpair_T *) whose keys are * multibyte strings. */ int keystrcoll(const void *k1, const void *k2) { return strcoll(((const kvpair_T *) k1)->key, ((const kvpair_T *) k2)->key); } /* A comparison function for key-value pairs with wide-string keys. * The arguments are pointers to kvpair_T's (const kvpair_T *) whose keys are * wide strings. */ int keywcscoll(const void *k1, const void *k2) { return wcscoll(((const kvpair_T *) k1)->key, ((const kvpair_T *) k2)->key); } /* `Free's the key of the specified key-value pair. * Can be used as the freer function to `ht_clear'. */ void kfree(kvpair_T kv) { free(kv.key); } /* `Free's the value of the specified key-value pair. * Can be used as the freer function to `ht_clear'. */ void vfree(kvpair_T kv) { free(kv.value); } /* `Free's the key and the value of the specified key-value pair. * Can be used as the freer function to `ht_clear'. */ void kvfree(kvpair_T kv) { free(kv.key); free(kv.value); } #if DEBUG_HASH /* Prints statistics. * This function is used in debugging. */ void print_statistics(const hashtable_T *ht) { fprintf(stderr, "DEBUG: id=%p hash->count=%zu, capacity=%zu\n", (void *) ht, ht->count, ht->capacity); fprintf(stderr, "DEBUG: hash->emptyindex=%zu, tailindex=%zu\n", ht->emptyindex, ht->tailindex); unsigned emptycount = 0, collcount = 0; for (size_t i = ht->emptyindex; i != NOTHING; i = ht->entries[i].next) emptycount++; for (size_t i = 0; i < ht->capacity; i++) if (ht->entries[i].kv.key && ht->entries[i].next != NOTHING) collcount++; fprintf(stderr, "DEBUG: hash empties=%u collisions=%u\n\n", emptycount, collcount); } #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/sig.h0000644000175000017500000000467712154557026013517 0ustar magicantmagicant/* Yash: yet another shell */ /* sig.h: signal handling */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_SIG_H #define YASH_SIG_H #include #include #include "xgetopt.h" extern _Bool process_exists(pid_t pid); extern const wchar_t *get_signal_name(int signum) __attribute__((const)); extern int get_signal_number(const wchar_t *name) __attribute__((nonnull,pure)); extern int get_signal_number_toupper(wchar_t *name) __attribute__((nonnull)); extern _Bool any_trap_set; extern void init_signal(void); extern void set_signals(void); extern void restore_signals(_Bool leave); extern void reset_job_signals(void); extern void set_interruptible_by_sigint(_Bool onoff); extern void ignore_sigquit_and_sigint(void); extern void ignore_sigtstp(void); extern void stop_myself(void); extern void handle_signals(void); extern int wait_for_sigchld(_Bool interruptible, _Bool return_on_trap); extern _Bool wait_for_input(int fd, _Bool trap, int timeout); extern int handle_traps(void); extern void execute_exit_trap(void); extern void clear_exit_trap(void); extern void clear_traps(void); extern _Bool is_interrupted(void); extern void set_laststatus_if_interrupted(void); extern void set_interrupted(void); extern void reset_sigint(void); #if YASH_ENABLE_LINEEDIT extern void reset_sigwinch(void); #endif extern int trap_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char trap_help[], trap_syntax[]; #endif extern const struct xgetopt_T trap_options[]; extern int kill_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char kill_help[], kill_syntax[]; #endif #if HAVE_STRSIGNAL && !defined(strsignal) extern char *strsignal(int signum); #endif #endif /* YASH_SIG_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtins/0000755000175000017500000000000012154557026014377 5ustar magicantmagicantyash-2.35/builtins/printf.d0000644000175000017500000000021312154557026016042 0ustar magicantmagicantprintf.o: printf.c ../common.h ../config.h printf.h ../builtin.h \ ../exec.h ../xgetopt.h ../option.h ../strbuf.h ../util.h ../variable.h yash-2.35/builtins/test.d0000644000175000017500000000020312154557026015516 0ustar magicantmagicanttest.o: test.c ../common.h ../config.h test.h ../option.h ../xgetopt.h \ ../path.h ../plist.h ../strbuf.h ../util.h ../xfnmatch.h yash-2.35/builtins/ulimit.c0000644000175000017500000002003412154557026016045 0ustar magicantmagicant/* Yash: yet another shell */ /* ulimit.c: ulimit builtin */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "ulimit.h" #include #include #include #ifdef HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include "../builtin.h" #include "../exec.h" #include "../util.h" /* Including is required before including on * FreeBSD, but is automatically included in . */ /* On old Mac OS X, depends on but does not include * . We have to include it manually. */ #if !HAVE_RLIM_SAVED_MAX # define RLIM_SAVED_MAX RLIM_INFINITY #endif #if !HAVE_RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY #endif struct resource { int type; rlim_t factor; const char *description; }; static int print_all_limits(bool soft); static void print_limit_value(bool soft, const struct rlimit *rlimit, const struct resource *resource) __attribute__((nonnull)); #define RES(type,factor,desc) \ (struct resource) { type, factor, desc, } static const struct resource res_fsize = { RLIMIT_FSIZE, 512, Ngt("file size (blocks)") }; const struct xgetopt_T ulimit_options[] = { { L'H', L"hard", OPTARG_NONE, true, NULL, }, { L'S', L"soft", OPTARG_NONE, true, NULL, }, { L'a', L"all", OPTARG_NONE, true, NULL, }, { L'c', L"core", OPTARG_NONE, true, &RES(RLIMIT_CORE, 512, Ngt("core file size (blocks)")), }, { L'd', L"data", OPTARG_NONE, true, &RES(RLIMIT_DATA, 1024, Ngt("data segment size (kbytes)")), }, #if HAVE_RLIMIT_NICE { L'e', L"nice", OPTARG_NONE, true, &RES(RLIMIT_NICE, 1, Ngt("max nice")), }, #endif { L'f', L"fsize", OPTARG_NONE, true, (void *) &res_fsize, }, #if HAVE_RLIMIT_SIGPENDING { L'i', L"sigpending", OPTARG_NONE, true, &RES(RLIMIT_SIGPENDING, 1, Ngt("pending signals")), }, #endif #if HAVE_RLIMIT_MEMLOCK { L'l', L"memlock", OPTARG_NONE, true, &RES(RLIMIT_MEMLOCK, 1024, Ngt("locked memory (kbytes)")), }, #endif #if HAVE_RLIMIT_RSS { L'm', L"rss", OPTARG_NONE, true, &RES(RLIMIT_RSS, 1024, Ngt("resident set size (kbytes)")), }, #endif { L'n', L"nofile", OPTARG_NONE, true, &RES(RLIMIT_NOFILE, 1, Ngt("open files")), }, #if HAVE_RLIMIT_MSGQUEUE { L'q', L"msgqueue", OPTARG_NONE, true, &RES(RLIMIT_MSGQUEUE, 1, Ngt("message queue size (bytes)")), }, #endif #if HAVE_RLIMIT_RTPRIO { L'r', L"rtprio", OPTARG_NONE, true, &RES(RLIMIT_RTPRIO, 1, Ngt("real-time priority")), }, #endif { L's', L"stack", OPTARG_NONE, true, &RES(RLIMIT_STACK, 1024, Ngt("stack size (kbytes)")), }, { L't', L"cpu", OPTARG_NONE, true, &RES(RLIMIT_CPU, 1, Ngt("CPU time (seconds)")), }, #if HAVE_RLIMIT_NPROC { L'u', L"nproc", OPTARG_NONE, true, &RES(RLIMIT_NPROC, 1, Ngt("user processes")), }, #endif #if HAVE_RLIMIT_AS { L'v', L"as", OPTARG_NONE, true, &RES(RLIMIT_AS, 1024, Ngt("memory (kbytes)")), }, #endif #if HAVE_RLIMIT_LOCKS { L'x', L"locks", OPTARG_NONE, true, &RES(RLIMIT_LOCKS, 1, Ngt("file locks")), }, #endif #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "ulimit" built-in. */ int ulimit_builtin(int argc, void **argv) { enum { HARD = 1 << 0, SOFT = 1 << 1, } type = HARD | SOFT; wchar_t resourceoption = L'\0'; const struct resource *resource = &res_fsize; bool print_all = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, ulimit_options, 0)) != NULL) { switch (opt->shortopt) { case L'H': type = HARD; break; case L'S': type = SOFT; break; case L'a': print_all = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: if (opt->ptr != NULL) { resourceoption = opt->shortopt; resource = opt->ptr; break; } else { return Exit_ERROR; } } } assert(type & (HARD | SOFT)); if (print_all) { if (resourceoption != L'\0') return mutually_exclusive_option_error(L'a', resourceoption); if (!validate_operand_count(argc - xoptind, 0, 0)) return Exit_ERROR; return print_all_limits(type & SOFT); } if (!validate_operand_count(argc - xoptind, 0, 1)) return Exit_ERROR; struct rlimit rlimit; if (getrlimit(resource->type, &rlimit) < 0) { xerror(errno, Ngt("cannot get the current limit " "for the resource type of `%s'"), gt(resource->description)); return Exit_FAILURE; } if (xoptind == argc) { print_limit_value(type & SOFT, &rlimit, resource); return yash_error_message_count == 0 ? Exit_SUCCESS : Exit_FAILURE; } /* parse the operand */ rlim_t value; if (wcscmp(ARGV(xoptind), L"hard") == 0) { value = rlimit.rlim_max; } else if (wcscmp(ARGV(xoptind), L"soft") == 0) { value = rlimit.rlim_cur; } else if (wcscmp(ARGV(xoptind), L"unlimited") == 0) { value = RLIM_INFINITY; } else if (iswdigit(ARGV(xoptind)[0])) { unsigned long v; if (!xwcstoul(ARGV(xoptind), 10, &v)) goto err_format; value = (rlim_t) v * resource->factor; if (value / resource->factor != v || value == RLIM_INFINITY || value == RLIM_SAVED_MAX || value == RLIM_SAVED_CUR) { xerror(ERANGE, NULL); return Exit_FAILURE; } } else { goto err_format; } if (type & HARD) rlimit.rlim_max = value; if (type & SOFT) rlimit.rlim_cur = value; /* check if soft limit does not exceed hard limit */ if (rlimit.rlim_max != RLIM_INFINITY && rlimit.rlim_max != RLIM_SAVED_MAX && rlimit.rlim_max != RLIM_SAVED_CUR && (rlimit.rlim_cur == RLIM_INFINITY || (rlimit.rlim_cur != RLIM_SAVED_MAX && rlimit.rlim_cur != RLIM_SAVED_CUR && rlimit.rlim_cur > rlimit.rlim_max))) { xerror(0, Ngt("the soft limit cannot exceed the hard limit")); return Exit_FAILURE; } if (setrlimit(resource->type, &rlimit) < 0) { xerror(errno, Ngt("failed to set the limit")); return Exit_FAILURE; } return Exit_SUCCESS; err_format: xerror(0, Ngt("`%ls' is not a valid integer"), ARGV(xoptind)); return Exit_ERROR; } /* Prints all current ulimit values to the standard output. * Returns the exit status of the ulimit built-in. */ int print_all_limits(bool soft) { const struct xgetopt_T *opt; for (opt = ulimit_options; opt->shortopt != L'\0'; opt++) { const struct resource *resource = opt->ptr; if (resource == NULL) continue; struct rlimit rlimit; if (getrlimit(resource->type, &rlimit) < 0) { xerror(errno, Ngt("cannot get the current limit " "for the resource type of `%s'"), gt(resource->description)); continue; } xprintf(gt("-%lc: %-30s "), (wint_t) opt->shortopt, gt(resource->description)); print_limit_value(soft, &rlimit, resource); } return yash_error_message_count == 0 ? Exit_SUCCESS : Exit_FAILURE; } void print_limit_value(bool soft, const struct rlimit *rlimit, const struct resource *resource) { rlim_t value = soft ? rlimit->rlim_cur : rlimit->rlim_max; if (value == RLIM_INFINITY) xprintf("%s\n", gt("unlimited")); else xprintf("%ju\n", (uintmax_t) (value / resource->factor)); } #if YASH_ENABLE_HELP const char ulimit_help[] = Ngt( "set or print a resource limitation" ); const char ulimit_syntax[] = Ngt( "\tulimit -a [-H|-S]\n" "\tulimit [-H|-S] [-efilnqrstuvx] [limit]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtins/test.h0000644000175000017500000000175612154557026015540 0ustar magicantmagicant/* Yash: yet another shell */ /* test.h: test builtin */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_TEST_H #define YASH_TEST_H extern int test_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char test_help[], test_syntax[]; #endif #endif /* YASH_TEST_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtins/ulimit.h0000644000175000017500000000210712154557026016053 0ustar magicantmagicant/* Yash: yet another shell */ /* ulimit.h: ulimit builtin */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_ULIMIT_H #define YASH_ULIMIT_H #include "../xgetopt.h" extern int ulimit_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char ulimit_help[], ulimit_syntax[]; #endif extern const struct xgetopt_T ulimit_options[]; #endif /* YASH_ULIMIT_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtins/printf.c0000644000175000017500000004655612154557026016065 0ustar magicantmagicant/* Yash: yet another shell */ /* printf.c: the echo/printf built-ins */ /* (C) 2007-2013 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "printf.h" #include #include #include #if HAVE_GETTEXT # include #endif #include #include #include #include #include #include #include #include "../builtin.h" #include "../exec.h" #include "../option.h" #include "../strbuf.h" #include "../util.h" #include "../variable.h" #if HAVE_WCSTOLD && !defined(wcstold) extern long double wcstold(const wchar_t *restrict s, wchar_t **restrict endp) __attribute__((nonnull(1))); #endif /* type of format data used in the "printf" built-in */ struct format_T { struct format_T *next; enum formattype_T { FT_NONE, FT_RAW, FT_STRING, FT_CHAR, FT_INT, FT_UINT, FT_FLOAT, FT_ECHO, } type; union { struct { char *value; size_t length; } raw; char *convspec; struct { bool left; unsigned long width, max; } echo; } value; }; /* The FT_NONE format type corresponds to the "%%" conversion specification. * The FT_RAW format type is used for literal strings that are not conversion * specifications. The format types of FT_STRING, FT_CHAR, FT_INT, FT_UINT, and * FT_FLOAT are used for various types of conversion specifications (`convspec') * that require a value of the corresponding type. * The FT_ECHO format type is used for the "b" conversion specification. */ /* FT_STRING -> wchar_t * * FT_CHAR -> wint_t * FT_INT -> intmax_t * FT_UINT -> uintmax_t * FT_FLOAT -> long double */ enum printf_result_T { PR_OK, PR_OK_END, PR_ERROR, }; static enum printf_result_T echo_parse_escape(const wchar_t *restrict s, xstrbuf_T *restrict buf, mbstate_t *restrict st) __attribute__((nonnull)); static bool printf_parse_format( const wchar_t *format, struct format_T **resultp) __attribute__((nonnull)); static struct format_T **printf_parse_percent( const wchar_t **formatp, struct format_T **resultp) __attribute__((nonnull,warn_unused_result)); static struct format_T *printf_parse_percent_b(xstrbuf_T *convspec) __attribute__((nonnull,malloc,warn_unused_result)); static enum printf_result_T printf_printf( const struct format_T *format, const wchar_t *arg, xstrbuf_T *buf) __attribute__((nonnull(1,3))); static uintmax_t printf_parse_integer(const wchar_t *arg, bool is_signed); static enum printf_result_T printf_print_escape( const struct format_T *format, const wchar_t *arg, xstrbuf_T *buf) __attribute__((nonnull)); static void freeformat(struct format_T *f); /* The "echo" built-in. */ int echo_builtin(int argc, void **argv) { bool nonewline, escape, noption, eoption; const wchar_t *echo_style; /* Determine the behavior of "echo" according to $ECHO_STYLE. * The possible values for $ECHO_STYLE are: * SYSV, XSI, BSD, GNU, ZSH, DASH, RAW * But we only care about the first character of it. */ nonewline = false; echo_style = getvar(L VAR_ECHO_STYLE); switch ((echo_style != NULL) ? echo_style[0] : L'\0') { case L'S': case L's': case L'X': case L'x': default: escape = true, noption = false, eoption = false; break; case L'B': case L'b': escape = false, noption = true, eoption = false; break; case L'G': case L'g': escape = false, noption = true, eoption = true; break; case L'Z': case L'z': escape = true, noption = true, eoption = true; break; case L'D': case L'd': escape = true, noption = true, eoption = false; break; case L'R': case L'r': escape = false, noption = false, eoption = false; break; } /* parse options */ int index = 1; if (eoption) { assert(noption); for (index = 1; index < argc; index++) { if (ARGV(index)[0] != L'-') break; if (ARGV(index)[wcsspn(&ARGV(index)[1], L"neE") + 1] != L'\0') break; for (const wchar_t *opt = &ARGV(index)[1]; *opt != L'\0'; opt++) { switch (*opt) { case L'n': nonewline = true; break; case L'e': escape = true; break; case L'E': escape = false; break; default: assert(false); } } } } else if (noption) { if (argc >= 2 && wcscmp(ARGV(index), L"-n") == 0) { nonewline = true; index++; } } /* parse arguments */ xstrbuf_T buf; mbstate_t state; sb_init(&buf); memset(&state, 0, sizeof state); // initialize as the initial shift state if (index < argc) { for (;;) { if (escape) { switch (echo_parse_escape(ARGV(index), &buf, &state)) { case PR_OK: break; case PR_OK_END: nonewline = true; goto print; case PR_ERROR: goto error; } } else { if (sb_wcscat(&buf, ARGV(index), &state) != NULL) { errno = EILSEQ; goto error; } } index++; if (index >= argc) break; if (!sb_wccat(&buf, L' ', &state)) goto error; } } if (!nonewline) if (!sb_wccat(&buf, L'\n', &state)) goto error; /* print to the standard output */ print: clearerr(stdout); fwrite(buf.contents, sizeof *buf.contents, buf.length, stdout); if (ferror(stdout)) goto error; if (fflush(stdout) != 0) goto error; sb_destroy(&buf); return Exit_SUCCESS; error: xerror(errno, Ngt("cannot print to the standard output")); sb_destroy(&buf); return Exit_FAILURE; } /* Parses string `s' that may include escape sequences. * The result is appended to string buffer `buf'. * Shift state `st' is used to convert wide characters into multibyte * characters. * On error, `errno' is set and PR_ERROR is returned. */ enum printf_result_T echo_parse_escape(const wchar_t *restrict s, xstrbuf_T *restrict buf, mbstate_t *restrict st) { while (*s != L'\0') { if (*s != L'\\') { normal: if (!sb_wccat(buf, *s, st)) return PR_ERROR; s++; } else { switch (s[1]) { wchar_t c; case L'a': c = L'\a'; goto print_char; case L'b': c = L'\b'; goto print_char; case L'c': return PR_OK_END; case L'f': c = L'\f'; goto print_char; case L'n': c = L'\n'; goto print_char; case L'r': c = L'\r'; goto print_char; case L't': c = L'\t'; goto print_char; case L'v': c = L'\v'; goto print_char; case L'\\': c = L'\\'; goto print_char; print_char: if (!sb_wccat(buf, c, st)) return PR_ERROR; s += 2; break; /* At most three digits are recognized in an octal escape * excluding the first zero. */ case L'0': { int value = 0; s += 2; for (int i = 0; i < 3 && L'0' <= *s && *s <= L'7'; i++, s++) value = value * 8 + (*s - L'0'); sb_ccat(buf, TO_CHAR(value)); break; } default: goto normal; } } } return PR_OK; } #if YASH_ENABLE_HELP const char echo_help[] = Ngt( "print arguments" ); const char echo_syntax[] = Ngt( "\techo [string...]\n" ); #endif /* The "printf" built-in. */ int printf_builtin(int argc, void **argv) { const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, help_option, XGETOPT_POSIX)) != NULL) { switch (opt->shortopt) { #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (xoptind == argc) return insufficient_operands_error(1); /* parse the format string */ struct format_T *format = NULL; if (!printf_parse_format(ARGV(xoptind), &format)) { freeformat(format); return Exit_FAILURE; } xoptind++; /* format the operands */ int oldoptind; xstrbuf_T buf; sb_init(&buf); do { oldoptind = xoptind; for (struct format_T *f = format; f != NULL; f = f->next) { switch (printf_printf(f, ARGV(xoptind), &buf)) { case PR_OK: break; case PR_OK_END: goto print; case PR_ERROR: goto error; } } } while (xoptind < argc && xoptind != oldoptind); print: freeformat(format); /* print the result to the standard output */ clearerr(stdout); fwrite(buf.contents, sizeof *buf.contents, buf.length, stdout); if (ferror(stdout)) goto error; if (fflush(stdout) != 0) goto error; sb_destroy(&buf); return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; error: xerror(errno, Ngt("cannot print to the standard output")); sb_destroy(&buf); return Exit_FAILURE; } /* Parses the format for the "printf" built-in. * If successful, a pointer to the result is assigned to `*resultp' and true is * returned. * If unsuccessful, an error message is printed and false is returned. A pointer * to a partial result may be assigned to `*resultp'. */ bool printf_parse_format(const wchar_t *format, struct format_T **resultp) { #define MAKE_STRING \ do { \ if (buf.length > 0) { \ struct format_T *f = xmalloc(sizeof *f); \ sb_wccat(&buf, L'\0', &state); \ f->next = NULL; \ f->type = FT_RAW; \ f->value.raw.length = buf.length; \ f->value.raw.value = sb_tostr(&buf); \ *resultp = f; \ resultp = &f->next; \ } else \ sb_destroy(&buf); \ } while (0) xstrbuf_T buf; mbstate_t state; sb_init(&buf); memset(&state, 0, sizeof state); while (*format != L'\0') { switch (*format) { case L'%': MAKE_STRING; resultp = printf_parse_percent(&format, resultp); if (resultp == NULL) return false; sb_init(&buf); break; case L'\\': switch (format[1]) { char c; case L'a': c = '\a'; goto put_char; case L'b': c = '\b'; goto put_char; case L'f': c = '\f'; goto put_char; case L'n': c = '\n'; goto put_char; case L'r': c = '\r'; goto put_char; case L't': c = '\t'; goto put_char; case L'v': c = '\v'; goto put_char; case L'\\': c = '\\'; goto put_char; case L'\"': c = '\"'; goto put_char; case L'\'': c = '\''; goto put_char; put_char: sb_ccat(&buf, c); format += 2; break; /* At most three digits are recognized in an octal escape */ case L'0': case L'1': case L'2': case L'3': case L'4': case L'5': case L'6': case L'7': { int value = 0; format++; for (int i = 0; i < 3 && L'0' <= *format && *format <= L'7'; i++, format++) value = value * 8 + (*format - L'0'); sb_ccat(&buf, TO_CHAR(value)); break; } default: goto normal; } break; default: normal: { if (!sb_wccat(&buf, *format, &state)) { xerror(errno, Ngt("cannot parse the format")); sb_destroy(&buf); return false; } format++; break; } } } MAKE_STRING; return true; #undef MAKE_STRING } /* Parses the conversion specification that starts with L'%' pointed to by * `*formatp'. * If successful, a pointer to the character to parse next is assigned to * `*formatp', a pointer to the result is assigned to `*resultp', and the next * `resultp' value is returned. * If unsuccessful, an error message is printed and NULL is returned. A pointer * to a partial result may be assigned to `*resultp'. */ struct format_T **printf_parse_percent( const wchar_t **formatp, struct format_T **resultp) { const wchar_t *format = *formatp; xstrbuf_T buf; bool hashflag = false, zeroflag = false; enum formattype_T type; struct format_T *result; #ifdef __STDC_MB_MIGHT_NEQ_WC__ mbstate_t state; memset(&state, 0, sizeof state); # define BUFCAT(c) sb_wccat(&buf, c, &state) #else # define BUFCAT(c) sb_ccat(&buf, (char) (c)) #endif assert(*format == L'%'); format++; sb_init(&buf); sb_ccat(&buf, '%'); /* parse flags */ for (;;) { switch (*format) { case L'#': hashflag = true; goto add_char; case L'0': zeroflag = true; goto add_char; case L'-': case L'+': case L' ': add_char: BUFCAT(*format++); break; default: goto parse_width; } } parse_width: while (iswdigit(*format)) BUFCAT(*format++); /* parse precision */ if (*format == L'.') { do { BUFCAT(*format++); } while (iswdigit(*format)); } /* parse conversion specifier */ switch (*format) { case L'd': case L'i': if (hashflag) goto flag_error; type = FT_INT; sb_ccat(&buf, 'j'); break; case L'u': if (hashflag) goto flag_error; /* falls thru! */ case L'o': case L'x': case L'X': type = FT_UINT; sb_ccat(&buf, 'j'); break; case L'f': case L'F': case L'e': case L'E': case L'g': case L'G': type = FT_FLOAT; sb_ccat(&buf, 'L'); break; case L'c': if (hashflag || zeroflag) goto flag_error; type = FT_CHAR; sb_ccat(&buf, 'l'); break; case L's': if (hashflag || zeroflag) goto flag_error; type = FT_STRING; sb_ccat(&buf, 'l'); break; case L'b': if (hashflag || zeroflag) goto flag_error; format++; result = printf_parse_percent_b(&buf); goto end; case L'%': if (buf.length != 1) goto flag_error; type = FT_NONE; break; case L'\0': xerror(0, Ngt("the conversion specifier is missing")); sb_destroy(&buf); return NULL; default: xerror(0, Ngt("`%lc' is not a valid conversion specifier"), (wint_t) *format); sb_destroy(&buf); return NULL; flag_error: xerror(0, Ngt("invalid flag for conversion specifier `%lc'"), (wint_t) *format); sb_destroy(&buf); return NULL; } BUFCAT(*format++); result = xmalloc(sizeof *result); result->next = NULL; result->type = type; switch (type) { case FT_NONE: sb_destroy(&buf); break; case FT_RAW: case FT_ECHO: assert(false); default: result->value.convspec = sb_tostr(&buf); break; } end: *formatp = format; *resultp = result; return &result->next; #undef BUFCAT } /* Parses the conversion specification given in buffer `convspec'. * The specification in the buffer must not have the conversion specifier, which * is assumed to be 'b'. The buffer is destroyed in this function. */ struct format_T *printf_parse_percent_b(xstrbuf_T *convspec) { size_t index = 0; struct format_T *result = xmalloc(sizeof *result); result->next = NULL; result->type = FT_ECHO; result->value.echo.left = false; assert(convspec->contents[index] == '%'); for (;;) { index++; switch (convspec->contents[index]) { case '#': case '0': case '+': case ' ': break; case '-': result->value.echo.left = true; break; default: goto parse_width; } } char *endp; parse_width: result->value.echo.width = strtoul(convspec->contents + index, &endp, 10); index = endp - convspec->contents; if (convspec->contents[index] == '.') { index++; result->value.echo.max = strtoul(convspec->contents + index, &endp, 10); index = endp - convspec->contents; } else { result->value.echo.max = ULONG_MAX; } assert(index == convspec->length); sb_destroy(convspec); return result; } /* Formats the specified string. The result is appended to buffer `buf'. * Increases `xoptind' if `arg' is used. Otherwise, `arg' is ignored. */ enum printf_result_T printf_printf( const struct format_T *format, const wchar_t *arg, xstrbuf_T *buf) { switch (format->type) { case FT_NONE: sb_ccat(buf, '%'); return PR_OK; case FT_RAW: sb_ncat_force(buf, format->value.raw.value, format->value.raw.length); return PR_OK; case FT_STRING: if (arg != NULL) xoptind++; else arg = L""; if (sb_printf(buf, format->value.convspec, arg) < 0) return PR_ERROR; return PR_OK; case FT_CHAR: if (arg != NULL && arg[0] != L'\0') { xoptind++; if (sb_printf(buf, format->value.convspec, (wint_t) arg[0]) < 0) return PR_ERROR; } return PR_OK; case FT_INT: if (sb_printf(buf, format->value.convspec, printf_parse_integer(arg, true)) < 0) return PR_ERROR; return PR_OK; case FT_UINT: if (sb_printf(buf, format->value.convspec, printf_parse_integer(arg, false)) < 0) return PR_ERROR; return PR_OK; case FT_FLOAT: { long double value; wchar_t *end; if (arg != NULL) xoptind++; else arg = L"0"; errno = 0; #if HAVE_WCSTOLD if (!posixly_correct) value = wcstold(arg, &end); else #endif value = wcstod(arg, &end); if (errno || arg[0] == L'\0' || *end != L'\0') xerror(errno, Ngt("`%ls' is not a valid number"), arg); if (sb_printf(buf, format->value.convspec, value) < 0) return PR_ERROR; return PR_OK; } case FT_ECHO: if (arg != NULL) xoptind++; else arg = L""; return printf_print_escape(format, arg, buf); } assert(false); } /* Parses the specified string as an integer. */ uintmax_t printf_parse_integer(const wchar_t *arg, bool is_signed) { uintmax_t value; wchar_t *end; if (arg != NULL) xoptind++; else arg = L"0"; if (arg[0] == L'"' || arg[0] == L'\'') { value = (uintmax_t) arg[1]; } else { errno = 0; if (is_signed) value = (uintmax_t) wcstoimax(arg, &end, 0); else value = wcstoumax(arg, &end, 0); if (errno || arg[0] == L'\0' || *end != L'\0') xerror(errno, Ngt("`%ls' is not a valid integer"), arg); } return value; } /* Prints the specified string that may include escape sequences and formats it * in the specified format. */ enum printf_result_T printf_print_escape( const struct format_T *format, const wchar_t *s, xstrbuf_T *buf) { xstrbuf_T subbuf; mbstate_t state; sb_init(&subbuf); memset(&state, 0, sizeof state); enum printf_result_T result = echo_parse_escape(s, &subbuf, &state); if (result == PR_OK) sb_wccat(&subbuf, L'\0', &state); if (format->value.echo.max < subbuf.length) sb_truncate(&subbuf, format->value.echo.max); if (format->value.echo.width <= subbuf.length) { sb_ncat_force(buf, subbuf.contents, subbuf.length); } else { size_t increment = format->value.echo.width - subbuf.length; if (format->value.echo.left) { sb_ncat_force(buf, subbuf.contents, subbuf.length); sb_ccat_repeat(buf, ' ', increment); } else { sb_ccat_repeat(buf, ' ', increment); sb_ncat_force(buf, subbuf.contents, subbuf.length); } } sb_destroy(&subbuf); return result; } /* Frees the specified format data. */ void freeformat(struct format_T *f) { while (f != NULL) { struct format_T *next = f->next; switch (f->type) { case FT_NONE: break; case FT_RAW: free(f->value.raw.value); break; case FT_ECHO: break; default: free(f->value.convspec); break; } free(f); f = next; } } #if YASH_ENABLE_HELP const char printf_help[] = Ngt( "print a formatted string" ); const char printf_syntax[] = Ngt( "\tprintf format [value...]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtins/printf.h0000644000175000017500000000223512154557026016054 0ustar magicantmagicant/* Yash: yet another shell */ /* printf.h: echo/printf built-ins */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_PRINTF_H #define YASH_PRINTF_H extern int echo_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char echo_help[], echo_syntax[]; #endif extern int printf_builtin(int argc, void **argv) __attribute__((nonnull)); #if YASH_ENABLE_HELP extern const char printf_help[], printf_syntax[]; #endif #endif /* YASH_PRINTF_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtins/ulimit.d0000644000175000017500000000016212154557026016046 0ustar magicantmagicantulimit.o: ulimit.c ../common.h ../config.h ulimit.h ../xgetopt.h \ ../builtin.h ../exec.h ../xgetopt.h ../util.h yash-2.35/builtins/test.c0000644000175000017500000004312012154557026015522 0ustar magicantmagicant/* Yash: yet another shell */ /* test.c: test builtin */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../common.h" #include "test.h" #include #include #include #include #include #include #include #include #include #include "../option.h" #include "../path.h" #include "../plist.h" #include "../strbuf.h" #include "../util.h" #include "../xfnmatch.h" #define Exit_TRUE 0 /* Exit_SUCCESS */ #define Exit_FALSE 1 /* Exit_FAILURE */ #define Exit_TESTERROR 2 /* Exit_ERROR */ struct test_state { void **args; int argc; int index; }; enum filecmp { FC_ID, FC_SAME, FC_NEWER, FC_OLDER, FC_UNKNOWN, }; static inline bool test_single(void *args[static 1]); static bool test_double(void *args[static 2]); static bool test_file(wchar_t type, const char *file) __attribute__((nonnull)); static bool test_triple(void *args[static 3]); static bool test_long_or(struct test_state *state) __attribute__((nonnull)); static bool test_long_and(struct test_state *state) __attribute__((nonnull)); static bool test_long_term(struct test_state *state) __attribute__((nonnull)); static bool is_unary_primary(const wchar_t *word) __attribute__((nonnull,pure)); static bool is_binary_primary(const wchar_t *word) __attribute__((nonnull,pure)); static bool is_term_delimiter(const wchar_t *word) __attribute__((nonnull,pure)); static int compare_integers(const wchar_t *left, const wchar_t *right) __attribute__((nonnull,pure)); static int compare_versions(const wchar_t *left, const wchar_t *right) __attribute__((nonnull)); static enum filecmp compare_files(const wchar_t *left, const wchar_t *right) __attribute__((nonnull)); /* The "test" ("[") built-in. */ int test_builtin(int argc, void **argv) { if (wcscmp(ARGV(0), L"[") == 0) { argc--; if (wcscmp(ARGV(argc), L"]") != 0) { xerror(0, Ngt("`%ls' is missing"), L"]"); return Exit_TESTERROR; } } assert(argc > 0); argc--, argv++; struct test_state state; bool result; switch (argc) { case 0: result = false; break; case 1: result = test_single(argv); break; case 2: result = test_double(argv); break; case 3: result = test_triple(argv); break; case 4: if (wcscmp(argv[0], L"!") == 0) { result = !test_triple(&argv[1]); break; } if (wcscmp(argv[0], L"(") == 0 && wcscmp(argv[3], L")") == 0) { result = test_double(&argv[1]); break; } /* falls thru! */ default: state.args = argv; state.argc = argc; state.index = 0; result = test_long_or(&state); if (yash_error_message_count == 0 && state.index < state.argc) xerror(0, Ngt("`%ls' is not a valid operator"), (const wchar_t *) state.args[state.index]); break; } if (yash_error_message_count > 0) return Exit_TESTERROR; return result ? Exit_TRUE : Exit_FALSE; } /* Tests the specified one-token expression. */ bool test_single(void *args[static 1]) { const wchar_t *arg0 = args[0]; return arg0[0] != L'\0'; } /* Tests the specified two-token expression. */ bool test_double(void *args[static 2]) { const wchar_t *op = args[0], *arg = args[1]; if (wcscmp(op, L"!") == 0) return !test_single(&args[1]); if (!is_unary_primary(op)) { xerror(0, Ngt("`%ls' is not a unary operator"), op); return 0; } switch (op[1]) { case L'n': return arg[0] != L'\0'; case L'z': return arg[0] == L'\0'; case L't': { int fd; return xwcstoi(arg, 10, &fd) && isatty(fd); } case L'o': if (arg[0] == L'?') return is_valid_option_name(&arg[1]); else return option_is_enabled(arg); } char *mbsarg = malloc_wcstombs(arg); if (mbsarg == NULL) { xerror(EILSEQ, Ngt("unexpected error")); return 0; } bool result = test_file(op[1], mbsarg); free(mbsarg); return result; } /* An auxiliary function for file type checking. */ bool test_file(wchar_t type, const char *file) { switch (type) { case L'd': return is_directory(file); case L'e': return is_file(file); case L'f': return is_regular_file(file); case L'r': return is_readable(file); case L'w': return is_writable(file); case L'x': return is_executable(file); } struct stat st; switch (type) { case L'h': case L'L': return (lstat(file, &st) == 0) && S_ISLNK(st.st_mode); #if !HAVE_S_ISVTX case L'k': return false; #endif } if (stat(file, &st) < 0) return false; switch (type) { case L'b': return S_ISBLK(st.st_mode); case L'c': return S_ISCHR(st.st_mode); case L'G': return st.st_gid == getegid(); case L'g': return st.st_mode & S_ISGID; #if HAVE_S_ISVTX case L'k': return st.st_mode & S_ISVTX; #endif case L'N': return st.st_atime < st.st_mtime #if HAVE_ST_ATIM && HAVE_ST_MTIM || (st.st_atime == st.st_mtime && st.st_atim.tv_nsec < st.st_mtim.tv_nsec) #elif HAVE_ST_ATIMESPEC && HAVE_ST_MTIMESPEC || (st.st_atime == st.st_mtime && st.st_atimespec.tv_nsec < st.st_mtimespec.tv_nsec) #elif HAVE_ST_ATIMENSEC && HAVE_ST_MTIMENSEC || (st.st_atime == st.st_mtime && st.st_atimensec < st.st_mtimensec) #elif HAVE___ST_ATIMENSEC && HAVE___ST_MTIMENSEC || (st.st_atime == st.st_mtime && st.__st_atimensec < st.__st_mtimensec) #endif ; case L'O': return st.st_uid == geteuid(); case L'p': return S_ISFIFO(st.st_mode); case L'S': return S_ISSOCK(st.st_mode); case L's': return st.st_size > 0; case L'u': return st.st_mode & S_ISUID; } assert(false); } /* Tests the specified three-token expression. */ bool test_triple(void *args[static 3]) { const wchar_t *left = args[0], *op = args[1], *right = args[2]; switch (op[0]) { case L'=': if (op[1] == L'\0' || (op[1] == L'=' && op[2] == L'\0')) return wcscmp(left, right) == 0; if (op[1] == L'=' && op[2] == L'=' && op[3] == L'\0') return wcscoll(left, right) == 0; if (op[1] == L'~' && op[2] == L'\0') return match_regex(left, right); goto not_binary; case L'!': if (op[1] == L'=' && op[2] == L'\0') return wcscmp(left, right) != 0; if (op[1] == L'=' && op[2] == L'=' && op[3] == L'\0') return wcscoll(left, right) != 0; goto not_binary; case L'<': if (op[1] == L'\0') return wcscoll(left, right) < 0; if (op[1] == L'=' && op[2] == L'\0') return wcscoll(left, right) <= 0; goto not_binary; case L'>': if (op[1] == L'\0') return wcscoll(left, right) > 0; if (op[1] == L'=' && op[2] == L'\0') return wcscoll(left, right) >= 0; goto not_binary; case L'-': break; default: goto not_binary; } assert(op[0] == L'-'); switch (op[1]) { case L'a': if (op[2] == L'\0') return test_single(args) && test_single(&args[2]); break; case L'o': if (op[2] == L'\0') return test_single(args) || test_single(&args[2]); if (op[2] == L't') if (op[3] == L'\0') return compare_files(left, right) == FC_OLDER; break; case L'e': switch (op[2]) { case L'f': if (op[3] == L'\0') return compare_files(left, right) == FC_ID; break; case L'q': if (op[3] == L'\0') return compare_integers(left, right) == 0; break; } break; case L'n': switch (op[2]) { case L'e': if (op[3] == L'\0') return compare_integers(left, right) != 0; break; case L't': if (op[3] == L'\0') return compare_files(left, right) == FC_NEWER; break; } break; case L'g': switch (op[2]) { case L't': if (op[3] == L'\0') return compare_integers(left, right) > 0; break; case L'e': if (op[3] == L'\0') return compare_integers(left, right) >= 0; break; } break; case L'l': switch (op[2]) { case L't': if (op[3] == L'\0') return compare_integers(left, right) < 0; break; case L'e': if (op[3] == L'\0') return compare_integers(left, right) <= 0; break; } break; case L'v': switch (op[2]) { case L'e': if (op[3] == L'q' && op[4] == L'\0') return compare_versions(left, right) == 0; break; case L'n': if (op[3] == L'e' && op[4] == L'\0') return compare_versions(left, right) != 0; break; case L'g': switch (op[3]) { case L't': if (op[4] == L'\0') return compare_versions(left, right) > 0; break; case L'e': if (op[4] == L'\0') return compare_versions(left, right) >= 0; break; } break; case L'l': switch (op[3]) { case L't': if (op[4] == L'\0') return compare_versions(left, right) < 0; break; case L'e': if (op[4] == L'\0') return compare_versions(left, right) <= 0; break; } break; } break; } not_binary: if (wcscmp(left, L"!") == 0) return !test_double(&args[1]); if (wcscmp(left, L"(") == 0 && wcscmp(right, L")") == 0) return test_single(&args[1]); xerror(0, Ngt("`%ls' is not a binary operator"), op); return 0; } /* exp := exp "-o" and | and * and := and "-a" term | term * term := "(" exp ")" | "!" "(" exp ")" | single | double | triple */ /* Tests the specified long expression using `state'. */ bool test_long_or(struct test_state *state) { bool result; result = test_long_and(state); while (yash_error_message_count == 0 && state->index < state->argc && wcscmp(state->args[state->index], L"-o") == 0) { state->index++; result |= test_long_and(state); } return result; } /* Tests the specified long expression using `state'. */ bool test_long_and(struct test_state *state) { bool result; result = test_long_term(state); while (yash_error_message_count == 0 && state->index < state->argc && wcscmp(state->args[state->index], L"-a") == 0) { state->index++; result &= test_long_term(state); } return result; } /* Tests the specified long expression using `state'. */ bool test_long_term(struct test_state *state) { bool result; bool negate = false; if (state->index < state->argc && wcscmp(state->args[state->index], L"!") == 0) { state->index++; negate = true; } if (state->index >= state->argc) { assert(state->argc > 0); xerror(0, Ngt("an expression is missing after `%ls'"), (const wchar_t *) state->args[state->index - 1]); return 0; } if (wcscmp(state->args[state->index], L"(") == 0) { state->index++; result = test_long_or(state); if (state->index >= state->argc || wcscmp(state->args[state->index], L")") != 0) { xerror(0, Ngt("`%ls' is missing"), L")"); return 0; } state->index++; } else if (state->index + 3 <= state->argc && is_binary_primary(state->args[state->index + 1]) && (state->index + 3 >= state->argc || is_term_delimiter(state->args[state->index + 3]))) { result = test_triple(&state->args[state->index]); state->index += 3; } else if (state->index + 2 <= state->argc && is_unary_primary(state->args[state->index]) && (state->index + 2 >= state->argc || is_term_delimiter(state->args[state->index + 2]))) { result = test_double(&state->args[state->index]); state->index += 2; } else { result = test_single(&state->args[state->index]); state->index += 1; } return result ^ negate; } /* Checks if `word' is a unary primary operator. */ /* Note that "!" is not a primary operator. */ bool is_unary_primary(const wchar_t *word) { if (word[0] != L'-' || word[1] == L'\0' || word[2] != L'\0') return false; switch (word[1]) { case L'b': case L'c': case L'd': case L'e': case L'f': case L'G': case L'g': case L'h': case L'k': case L'L': case L'N': case L'n': case L'O': case L'o': case L'p': case L'r': case L'S': case L's': case L't': case L'u': case L'w': case L'x': case L'z': return true; default: return false; } } /* Checks if `word' is a binary primary operator. * This function returns false for "-a" and "-o". */ bool is_binary_primary(const wchar_t *word) { switch (word[0]) { case L'=': if (word[1] == L'\0' || (word[1] == L'~' && word[2] == L'\0')) return true; /* falls thru! */ case L'!': if (word[1] != L'=') return false; return (word[2] == L'\0') || (word[2] == L'=' && word[3] == L'\0'); case L'<': case L'>': return (word[1] == L'\0') || (word[1] == L'=' && word[2] == L'\0'); case L'-': break; default: return false; } assert(word[0] == L'-'); switch (word[1]) { case L'e': switch (word[2]) { case L'f': case L'q': return word[3] == L'\0'; } break; case L'n': case L'g': case L'l': switch (word[2]) { case L't': case L'e': return word[3] == L'\0'; } break; case L'o': return word[2] == L't' && word[3] == L'\0'; case L'v': switch (word[2]) { case L'e': return word[3] == L'q' && word[4] == L'\0'; case L'n': return word[3] == L'e' && word[4] == L'\0'; case L'g': case L'l': switch (word[3]) { case L't': case L'e': return word[4] == L'\0'; } break; } break; } return false; } /* Checks if `word' is a term delimiter: * one of ")", "-a", "-o". */ bool is_term_delimiter(const wchar_t *word) { switch (word[0]) { case L')': return word[1] == L'\0'; case L'-': switch (word[1]) { case L'a': case L'o': return word[2] == L'\0'; } break; } return false; } /* Converts the specified two strings into integers and compares them. * Returns -1, 0, 1 if the first integer is less than, equal to, or greater than * the second, respectively. */ int compare_integers(const wchar_t *left, const wchar_t *right) { intmax_t il, ir; wchar_t *end; errno = 0; il = wcstoimax(left, &end, 10); if (errno != 0 || left[0] == L'\0' || *end != L'\0') { xerror(errno, Ngt("`%ls' is not a valid integer"), left); return 0; } errno = 0; ir = wcstoimax(right, &end, 10); if (errno != 0 || right[0] == L'\0' || *end != L'\0') { xerror(errno, Ngt("`%ls' is not a valid integer"), right); return 0; } if (il < ir) return -1; else if (il > ir) return 1; else return 0; } /* Compares the specified two strings as version numbers. * Returns a value less than, equal to, and greater than zero if the first is * less than, equal to, and greater than the second, respectively. */ int compare_versions(const wchar_t *left, const wchar_t *right) { for (;;) { bool leftisdigit = iswdigit(*left), rightisdigit = iswdigit(*right); if (leftisdigit && rightisdigit) { uintmax_t il, ir; il = wcstoumax(left, (wchar_t **) &left, 10); ir = wcstoumax(right, (wchar_t **) &right, 10); if (il > ir) return 1; if (il < ir) return -1; } else if (leftisdigit) { return 1; } else if (rightisdigit) { return -1; } bool leftisalnum = iswalnum(*left), rightisalnum = iswalnum(*right); if (leftisalnum && !rightisalnum) return 1; if (!leftisalnum && rightisalnum) return -1; if (*left != *right) return wcscoll(left, right); if (*left == L'\0') return 0; left++, right++; } } /* Compares the specified two files. * Returns one of the followings: * FC_ID: the two files have the same inode * FC_SAME: different inodes, the same modification time * FC_NEWER: `left' has the modification time newer than `right' * FC_OLDER: `left' has the modification time older than `right' * FC_UNKNOWN: comparison error (neither file is `stat'able) * If either (but not both) file is not `stat'able, the `stat'able one is * considered newer. */ enum filecmp compare_files(const wchar_t *left, const wchar_t *right) { char *mbsfile; struct stat sl, sr; bool sl_ok, sr_ok; mbsfile = malloc_wcstombs(left); if (mbsfile == NULL) { xerror(EILSEQ, Ngt("unexpected error")); return FC_UNKNOWN; } sl_ok = stat(mbsfile, &sl) >= 0; free(mbsfile); mbsfile = malloc_wcstombs(right); if (mbsfile == NULL) { xerror(EILSEQ, Ngt("unexpected error")); return FC_UNKNOWN; } sr_ok = stat(mbsfile, &sr) >= 0; free(mbsfile); if (!sl_ok) if (!sr_ok) return FC_UNKNOWN; else return FC_OLDER; else if (!sr_ok) return FC_NEWER; if (stat_result_same_file(&sl, &sr)) return FC_ID; else if (sl.st_mtime < sr.st_mtime) return FC_OLDER; else if (sl.st_mtime > sr.st_mtime) return FC_NEWER; #if HAVE_ST_MTIM else if (sl.st_mtim.tv_nsec < sr.st_mtim.tv_nsec) return FC_OLDER; else if (sl.st_mtim.tv_nsec > sr.st_mtim.tv_nsec) return FC_NEWER; #elif HAVE_ST_MTIMESPEC else if (sl.st_mtimespec.tv_nsec < sr.st_mtimespec.tv_nsec) return FC_OLDER; else if (sl.st_mtimespec.tv_nsec > sr.st_mtimespec.tv_nsec) return FC_NEWER; #elif HAVE_ST_MTIMENSEC else if (sl.st_mtimensec < sr.st_mtimensec) return FC_OLDER; else if (sl.st_mtimensec > sr.st_mtimensec) return FC_NEWER; #elif HAVE___ST_MTIMENSEC else if (sl.__st_mtimensec < sr.__st_mtimensec) return FC_OLDER; else if (sl.__st_mtimensec > sr.__st_mtimensec) return FC_NEWER; #endif else return FC_SAME; } #if YASH_ENABLE_HELP const char test_help[] = Ngt( "evaluate a conditional expression" ); const char test_syntax[] = Ngt( "\ttest expression\n" "\t[ expression ]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/builtins/Makefile.in0000644000175000017500000000457012154557026016452 0ustar magicantmagicant# Makefile.in for yash: yet another shell # (C) 2007-2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . .POSIX: .SUFFIXES: .c .h .d .o .a @MAKE_SHELL@ topdir = .. subdir = builtins CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LDLIBS = @LDLIBS@ AR = @AR@ ARFLAGS = @ARFLAGS@ SOURCES = printf.c test.c ulimit.c HEADERS = printf.h test.h ulimit.h PRINTF_OBJS = printf.o TEST_OBJS = test.o ULIMIT_OBJS = ulimit.o OBJS = @BUILTIN_OBJS@ TARGET = builtins.a YASH = @TARGET@ BYPRODUCTS = *.dSYM all: $(TARGET) .c.o: @rm -f $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< $(TARGET): $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) DISTFILES = $(SOURCES) $(SOURCES:.c=.d) $(HEADERS) Makefile.in distfiles: makedeps $(DISTFILES) copy-distfiles: distfiles mkdir -p $(topdir)/$(DISTTARGETDIR) cp $(DISTFILES) $(topdir)/$(DISTTARGETDIR) makedeps: _PHONY @(cd $(topdir) && $(MAKE) $(YASH)) $(topdir)/$(YASH) $(topdir)/makedeps.yash $(SOURCES) # ctags conforms to POSIX, but etags and cscope do not. CTAGS = @CTAGS@ CTAGSARGS = @CTAGSARGS@ ETAGS = @ETAGS@ ETAGSARGS = @ETAGSARGS@ CSCOPE = @CSCOPE@ CSCOPEARGS = @CSCOPEARGS@ tags: $(SOURCES) $(HEADERS) $(CTAGS) $(CTAGSARGS) TAGS: $(SOURCES) $(HEADERS) $(ETAGS) $(ETAGSARGS) cscope: cscope.out cscope.out: $(SOURCES) $(HEADERS) $(CSCOPE) $(CSCOPEARGS) mostlyclean: -rm -rf $(OBJS) $(BYPRODUCTS) clean: mostlyclean -rm -rf $(TARGET) distclean: clean -rm -rf Makefile tags TAGS cscope.out maintainer-clean: distclean -rm -rf $(SOURCES:.c=.d) Makefile: Makefile.in $(topdir)/config.status @+(cd $(topdir) && $(MAKE) config.status) @(cd $(topdir) && $(SHELL) config.status $(subdir)/$@) .PHONY: all distfiles copy-distfiles makedeps cscope mostlyclean clean distclean maintainer-clean _PHONY: @MAKE_INCLUDE@ printf.d @MAKE_INCLUDE@ test.d @MAKE_INCLUDE@ ulimit.d yash-2.35/input.d0000644000175000017500000000040312154557026014047 0ustar magicantmagicantinput.o: input.c common.h config.h input.h exec.h xgetopt.h expand.h \ history.h job.h mail.h option.h parser.h sig.h strbuf.h util.h \ variable.h yash.h lineedit/display.h lineedit/../input.h \ lineedit/../strbuf.h lineedit/lineedit.h lineedit/lineedit.h yash-2.35/Makefile.in0000644000175000017500000002322612154557026014620 0ustar magicantmagicant# Makefile.in for yash: yet another shell # (C) 2007-2012 magicant # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # NOTE: In this Makefile it is assumed that the make implementation allows the # use of hyphens in target names. This means that there may be a strictly # POSIX-conforming implementation of make that rejects this Makefile. I have # never seen such an implementation but if you know of one please let me know. .POSIX: .SUFFIXES: .c .h .d .o .a @MAKE_SHELL@ topdir = . CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LDLIBS = @LDLIBS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_DIR = @INSTALL_DIR@ ARCHIVER = @ARCHIVER@ DIRS = @DIRS@ SOURCES = alias.c arith.c builtin.c exec.c expand.c hashtable.c history.c input.c job.c mail.c makesignum.c option.c parser.c path.c plist.c redir.c sig.c strbuf.c util.c variable.c xfnmatch.c xgetopt.c yash.c HEADERS = alias.h arith.h builtin.h common.h exec.h expand.h hashtable.h history.h input.h job.h mail.h option.h parser.h path.h plist.h redir.h sig.h siglist.h strbuf.h util.h variable.h xfnmatch.h xgetopt.h yash.h MAIN_OBJS = arith.o builtin.o exec.o expand.o hashtable.o input.o job.o mail.o option.o parser.o path.o plist.o redir.o sig.o strbuf.o util.o variable.o xfnmatch.o xgetopt.o yash.o ALIAS_OBJS = alias.o HISTORY_OBJS = history.o BUILTINS_ARCHIVE = builtins/builtins.a LINEEDIT_ARCHIVE = lineedit/lineedit.a OBJS = @OBJS@ TARGET = @TARGET@ VERSION = @VERSION@ COPYRIGHT = @COPYRIGHT@ BYPRODUCTS = makesignum.o makesignum signum.h configm.h *.dSYM DESTDIR = prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ datarootdir = @datarootdir@ datadir = @datadir@ yashdatadir = $(datadir)/$(TARGET) localedir = @localedir@ mandir = @mandir@ docdir = @docdir@ htmldir = @htmldir@ default_loadpath = @default_loadpath@ enable_nls = @enable_nls@ all: $(TARGET) tester mofiles docs .c.o: @rm -f $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< $(TARGET): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) $(BUILTINS_ARCHIVE): _PHONY @+(cd builtins && $(MAKE)) $(LINEEDIT_ARCHIVE): _PHONY @+(cd lineedit && $(MAKE)) makesignum: $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS) sig.o: signum.h signum.h: makesignum ./makesignum > $@ variable.o yash.o: configm.h configm.h: Makefile -@printf 'creating %s...' '$@' @{ printf '/* $@: created by Makefile */\n'; \ printf '#ifndef YASH_CONFIGM_H\n'; \ printf '#define YASH_CONFIGM_H\n'; \ printf '#define PACKAGE_NAME "$(TARGET)"\n'; \ printf '#define PACKAGE_VERSION "$(VERSION)"\n'; \ printf '#define PACKAGE_COPYRIGHT "$(COPYRIGHT)"\n'; \ printf '#define YASH_DATADIR "$(yashdatadir)"\n'; \ printf '#define LOCALEDIR "$(localedir)"\n'; \ printf '#define DEFAULT_LOADPATH "$(default_loadpath)"\n'; \ printf '#endif\n'; \ } >$@ -@echo done test tests check: _PHONY @+(cd tests && $(MAKE)) tester: _PHONY @+(cd tests && $(MAKE) $@) mofiles: _PHONY @+(cd po && $(MAKE)) docs: -@+(cd doc && $(MAKE)) man html: -@+(cd doc && $(MAKE) $@-rec) INSTALLBINDIRS = $(DESTDIR)$(bindir) INSTALLDATADIRS = $(DESTDIR)$(yashdatadir) $(DESTDIR)$(yashdatadir)/completion $(DESTDIR)$(mandir) INSTALLDIRS = $(INSTALLBINDIRS) $(INSTALLDATADIRS) $(DESTDIR)$(htmldir) install: install-binary install-data install-strip: install-binary-strip install-data install-binary: $(TARGET) installdirs-binary $(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(bindir)/$(TARGET) install-binary-strip: installdirs-binary @+$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install-binary install-data: installdirs-data-main @for file in share/completion/*; do \ echo $(INSTALL_DATA) $$file $(DESTDIR)$(yashdatadir)/completion || true; \ $(INSTALL_DATA) $$file $(DESTDIR)$(yashdatadir)/completion; \ done @+if $(enable_nls); then (cd po && $(MAKE) $@); fi @+(cd doc && $(MAKE) install-rec) install-html: @+(cd doc && $(MAKE) $@-rec) installdirs: installdirs-binary installdirs-data installdirs-binary: $(INSTALLBINDIRS) installdirs-data: installdirs-data-main @+if $(enable_nls); then (cd po && $(MAKE) $@); fi @+(cd doc && $(MAKE) installdirs-rec) installdirs-data-main: $(INSTALLDATADIRS) installdirs-html: $(DESTDIR)$(htmldir) $(INSTALLDIRS): $(INSTALL_DIR) $@ uninstall: uninstall-binary uninstall-data uninstall-binary: rm -f $(DESTDIR)$(bindir)/$(TARGET) uninstall-data: @(cd share && for file in completion/*; do \ echo rm -f $(DESTDIR)$(yashdatadir)/$$file || true; \ rm -f $(DESTDIR)$(yashdatadir)/$$file; \ done) -rmdir $(DESTDIR)$(yashdatadir)/completion -rmdir $(DESTDIR)$(yashdatadir) @+if $(enable_nls); then (cd po && $(MAKE) $@); fi @+(cd doc && $(MAKE) $@-rec) DISTDIR = $(TARGET)-$(VERSION) DISTS = $(DISTDIR).tar $(DISTDIR).tar.Z $(DISTDIR).tar.gz $(DISTDIR).tar.bz2 $(DISTDIR).tar.xz $(DISTDIR).shar.gz $(DISTDIR).zip $(DISTDIR): _PHONY @+(cd po && $(MAKE) update-po) # must be done first rm -fr $@ mkdir -m 755 $@ @+umask 022; \ for d in $(DIRS); do \ (cd $$d && $(MAKE) DISTTARGETDIR=$@/$$d copy-distfiles) || exit; \ done mkdir -m 755 $@/share mkdir -m 755 $@/share/completion umask 022; \ for file in share/completion/*; do cp $$file $@/share/completion; done find $@ | xargs touch -c -r $@ # Only pax and compress conform to POSIX. dist-tarZ: $(DISTDIR).tar.Z -rm -rf $(DISTDIR) $(DISTDIR).tar dist dist-gzip: $(DISTDIR).tar.gz -rm -rf $(DISTDIR) $(DISTDIR).tar dist-bzip2: $(DISTDIR).tar.bz2 -rm -rf $(DISTDIR) $(DISTDIR).tar dist-xz: $(DISTDIR).tar.xz -rm -rf $(DISTDIR) $(DISTDIR).tar dist-shar: $(DISTDIR).shar.gz -rm -rf $(DISTDIR) dist-zip: $(DISTDIR).zip -rm -rf $(DISTDIR) $(DISTDIR).tar: $(DISTDIR) $(ARCHIVER) $@ $(DISTDIR) $(DISTDIR).tar.Z: $(DISTDIR).tar rm -rf $@ compress $(DISTDIR).tar $(DISTDIR).tar.gz: $(DISTDIR).tar rm -rf $@ gzip -9 $(DISTDIR).tar $(DISTDIR).tar.bz2: $(DISTDIR).tar rm -rf $@ bzip2 -9 $(DISTDIR).tar $(DISTDIR).tar.xz: $(DISTDIR).tar rm -rf $@ xz $(DISTDIR).tar $(DISTDIR).shar.gz: $(DISTDIR) shar $(DISTDIR) | gzip -c > $@ $(DISTDIR).zip: $(DISTDIR) rm -rf $@ zip -rq $@ $(DISTDIR) DISTFILES = $(SOURCES) $(SOURCES:.c=.d) $(HEADERS) README README.ja COPYING INSTALL INSTALL.ja NEWS NEWS.ja configure Makefile.in install-sh makedeps.yash distfiles: makedeps $(DISTFILES) copy-distfiles: distfiles mkdir -p $(topdir)/$(DISTTARGETDIR) cp $(DISTFILES) $(topdir)/$(DISTTARGETDIR) makedeps: _PHONY $(TARGET) $(topdir)/$(TARGET) $(topdir)/makedeps.yash $(SOURCES) # ctags conforms to POSIX, but etags and cscope do not. CTAGS = @CTAGS@ CTAGSARGS = @CTAGSARGS@ ETAGS = @ETAGS@ ETAGSARGS = @ETAGSARGS@ CSCOPE = @CSCOPE@ CSCOPEARGS = @CSCOPEARGS@ tags: $(SOURCES) $(HEADERS) $(CTAGS) $(CTAGSARGS) TAGS: $(SOURCES) $(HEADERS) $(ETAGS) $(ETAGSARGS) cscope: cscope.out cscope.out: $(SOURCES) $(HEADERS) $(CSCOPE) $(CSCOPEARGS) mostlyclean: _mostlyclean -@+(cd builtins && $(MAKE) mostlyclean) -@+(cd doc && $(MAKE) mostlyclean) -@+(cd lineedit && $(MAKE) mostlyclean) -@+(cd po && $(MAKE) mostlyclean) -@+(cd tests && $(MAKE) mostlyclean) _mostlyclean: -rm -rf $(OBJS) $(BYPRODUCTS) $(DISTDIR) clean: _clean -@+(cd builtins && $(MAKE) clean) -@+(cd doc && $(MAKE) clean) -@+(cd lineedit && $(MAKE) clean) -@+(cd po && $(MAKE) clean) -@+(cd tests && $(MAKE) clean) _clean: _mostlyclean -rm -rf $(TARGET) $(DISTS) distclean: -@+(cd builtins && $(MAKE) distclean) -@+(cd doc && $(MAKE) distclean) -@+(cd lineedit && $(MAKE) distclean) -@+(cd po && $(MAKE) distclean) -@+(cd tests && $(MAKE) distclean) -@+$(MAKE) _distclean _distclean: _clean -rm -rf Makefile config.log config.status config.h tags TAGS cscope.out maintainer-clean: -@echo 'This command is intended for maintainers to use;' -@echo 'it deletes files that may need special tools to rebuild.' -@+(cd builtins && $(MAKE) maintainer-clean) -@+(cd doc && $(MAKE) maintainer-clean) -@+(cd lineedit && $(MAKE) maintainer-clean) -@+(cd po && $(MAKE) maintainer-clean) -@+(cd tests && $(MAKE) maintainer-clean) -@+$(MAKE) _distclean -rm -rf $(SOURCES:.c=.d) config.h: config.status $(SHELL) config.status $@ Makefile: Makefile.in config.status $(SHELL) config.status $@ config.status: configure $(SHELL) config.status --recheck .PHONY: all test tests check tester mofiles docs man html install install-strip install-binary install-binary-strip install-data install-html installdirs installdirs-binary installdirs-data installdirs-data-main installdirs-html uninstall uninstall-binary uninstall-data dist dist-tarZ dist-gzip dist-bzip2 dist-xz dist-shar dist-zip dist-all distfiles copy-distfiles makedeps cscope mostlyclean _mostlyclean clean _clean distclean _distclean maintainer-clean _PHONY: @MAKE_INCLUDE@ alias.d @MAKE_INCLUDE@ arith.d @MAKE_INCLUDE@ builtin.d @MAKE_INCLUDE@ exec.d @MAKE_INCLUDE@ expand.d @MAKE_INCLUDE@ hashtable.d @MAKE_INCLUDE@ history.d @MAKE_INCLUDE@ input.d @MAKE_INCLUDE@ job.d @MAKE_INCLUDE@ mail.d @MAKE_INCLUDE@ makesignum.d @MAKE_INCLUDE@ option.d @MAKE_INCLUDE@ parser.d @MAKE_INCLUDE@ path.d @MAKE_INCLUDE@ plist.d @MAKE_INCLUDE@ redir.d @MAKE_INCLUDE@ sig.d @MAKE_INCLUDE@ strbuf.d @MAKE_INCLUDE@ util.d @MAKE_INCLUDE@ variable.d @MAKE_INCLUDE@ xfnmatch.d @MAKE_INCLUDE@ xgetopt.d @MAKE_INCLUDE@ yash.d yash-2.35/redir.h0000644000175000017500000000354312154557026014031 0ustar magicantmagicant/* Yash: yet another shell */ /* redir.h: manages file descriptors and provides functions for redirections */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef YASH_REDIR_H #define YASH_REDIR_H #include extern int xclose(int fd); extern int xdup2(int oldfd, int newfd); extern _Bool write_all(int fd, const void *data, size_t size) __attribute__((nonnull)); extern int ttyfd; extern void init_shellfds(void); extern void add_shellfd(int fd); extern void remove_shellfd(int fd); extern _Bool is_shellfd(int fd) __attribute__((pure)); extern void clear_shellfds(_Bool leavefds); extern int copy_as_shellfd(int fd); extern int move_to_shellfd(int fd); extern void open_ttyfd(void); extern int get_ttyfd(void) __attribute__((pure)); typedef struct savefd_T savefd_T; struct redir_T; extern _Bool open_redirections(const struct redir_T *r, savefd_T **save) __attribute__((nonnull(2))); extern void undo_redirections(savefd_T *save); extern void clear_savefd(savefd_T *save); extern void maybe_redirect_stdin_to_devnull(void); #define PIPE_IN 0 /* index of the reading end of a pipe */ #define PIPE_OUT 1 /* index of the writing end of a pipe */ #endif /* YASH_REDIR_H */ /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/path.c0000644000175000017500000013706312154557026013660 0ustar magicantmagicant/* Yash: yet another shell */ /* path.c: filename-related utilities */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "path.h" #include #include #include #include #include #include #if HAVE_GETTEXT # include #endif #if HAVE_PATHS_H # include #endif #include #include #include #include #include #include #include #include #include #include #include "builtin.h" #include "exec.h" #include "expand.h" #include "hashtable.h" #include "option.h" #include "plist.h" #include "redir.h" #include "sig.h" #include "strbuf.h" #include "util.h" #include "variable.h" #include "xfnmatch.h" #include "yash.h" #if HAVE_FACCESSAT # ifndef faccessat extern int faccessat(int fd, const char *path, int amode, int flags) __attribute__((nonnull)); # endif #elif HAVE_EACCESS # ifndef eaccess extern int eaccess(const char *path, int amode) __attribute__((nonnull)); # endif #endif static bool check_access(const char *path, mode_t mode, int amode) __attribute__((nonnull)); static inline bool not_dotdot(const wchar_t *p) __attribute__((nonnull,pure)); /* Checks if `path' is an existing file. */ bool is_file(const char *path) { return access(path, F_OK) == 0; // struct stat st; // return (stat(path, &st) == 0); } /* Checks if `path' is a regular file. */ bool is_regular_file(const char *path) { struct stat st; return (stat(path, &st) == 0) && S_ISREG(st.st_mode); } /* Checks if `path' is a non-regular file. */ bool is_irregular_file(const char *path) { struct stat st; return (stat(path, &st) == 0) && !S_ISREG(st.st_mode); } /* Checks if `path' is a readable file. */ bool is_readable(const char *path) { return check_access(path, S_IRUSR | S_IRGRP | S_IROTH, R_OK); } /* Checks if `path' is a writable file. */ bool is_writable(const char *path) { return check_access(path, S_IWUSR | S_IWGRP | S_IWOTH, W_OK); } /* Checks if `path' is an executable file (or a searchable directory). */ bool is_executable(const char *path) { return check_access(path, S_IXUSR | S_IXGRP | S_IXOTH, X_OK); } /* Checks if this process has a proper permission to access the specified file. * Returns false if the file does not exist. */ bool check_access(const char *path, mode_t mode, int amode) { /* Even if the faccessat/eaccess function was considered available by * `configure', the OS kernel may not support it. We fall back on our own * checking function if faccessat/eaccess was rejected. */ #if HAVE_FACCESSAT if (faccessat(AT_FDCWD, path, amode, AT_EACCESS) == 0) return true; if (errno != ENOSYS && errno != EINVAL) return false; #elif HAVE_EACCESS if (eaccess(path, amode) == 0) return true; if (errno != ENOSYS && errno != EINVAL) return false; #else (void) amode; #endif /* The algorithm below is not 100% valid for all POSIX systems. */ struct stat st; uid_t uid; gid_t gid; if (stat(path, &st) < 0) return false; uid = geteuid(); #if !YASH_DISABLE_SUPERUSER if (uid == 0) { /* the "root" user has special permissions */ return (mode & (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH)) || S_ISDIR(st.st_mode) || (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)); } #endif st.st_mode &= mode; if (uid == st.st_uid) return st.st_mode & S_IRWXU; gid = getegid(); if (gid == st.st_gid) return st.st_mode & S_IRWXG; int gcount = getgroups(0, &gid); /* the second argument is a dummy */ if (gcount > 0) { gid_t groups[gcount]; gcount = getgroups(gcount, groups); if (gcount > 0) { for (int i = 0; i < gcount; i++) if (gid == groups[i]) return st.st_mode & S_IRWXG; } } return st.st_mode & S_IRWXO; } /* Checks if `path' is a readable regular file. */ bool is_readable_regular(const char *path) { return is_regular_file(path) && is_readable(path); } /* Checks if `path' is an executable regular file. */ bool is_executable_regular(const char *path) { return is_regular_file(path) && is_executable(path); } /* Checks if `path' is a directory. */ bool is_directory(const char *path) { struct stat st; return (stat(path, &st) == 0) && S_ISDIR(st.st_mode); } /* Checks if two stat results name the same file. */ inline bool stat_result_same_file( const struct stat *stat1, const struct stat *stat2) { return stat1->st_dev == stat2->st_dev && stat1->st_ino == stat2->st_ino; } /* Checks if two files are the same file. */ bool is_same_file(const char *path1, const char *path2) { struct stat stat1, stat2; return stat(path1, &stat1) == 0 && stat(path2, &stat2) == 0 && stat_result_same_file(&stat1, &stat2); } /* Canonicalizes a pathname. * * Dot components are removed. * * Dot-dot components are removed together with the preceding components. If * any of the preceding components is not a directory, it is an error. * * Redundant slashes are removed. * `path' must not be NULL. * The result is a newly malloced string if successful. NULL is returned on * error. */ wchar_t *canonicalize_path(const wchar_t *path) { wchar_t *const result = xmallocn(wcslen(path) + 1, sizeof *result); wchar_t *rp = result; plist_T clist; pl_init(&clist); if (*path == L'/') { /* first slash */ path++; *rp++ = '/'; if (*path == L'/') { /* second slash */ path++; if (*path != L'/') /* third slash */ *rp++ = '/'; } } for (;;) { *rp = L'\0'; while (*path == L'/') path++; if (*path == L'\0') break; if (path[0] == L'.') { if (path[1] == L'\0') { /* ignore trailing dot component */ break; } else if (path[1] == L'/') { /* skip dot component */ path += 2; continue; } else if (path[1] == L'.' && (path[2] == L'\0' || path[2] == L'/') && clist.length > 0) { /* dot-dot component */ wchar_t *prev = clist.contents[clist.length - 1]; if (not_dotdot(prev)) { char *mbsresult = malloc_wcstombs(result); bool isdir = (mbsresult != NULL) && is_directory(mbsresult); free(mbsresult); if (isdir) { rp = prev; /* result[index] = L'\0'; */ pl_remove(&clist, clist.length - 1, 1); path += 2; continue; } else { /* error */ pl_destroy(&clist); free(result); return NULL; } } } } /* others */ pl_add(&clist, rp); if (clist.length > 1) *rp++ = L'/'; while (*path != L'\0' && *path != L'/') /* copy next component */ *rp++ = *path++; } pl_destroy(&clist); assert(*rp == L'\0'); return result; } bool not_dotdot(const wchar_t *p) { if (*p == L'/') p++; return wcscmp(p, L"..") != 0; } /* Checks if the specified `path' is normalized, that is, containing no "." * or ".." in it. */ /* Note that a normalized path may contain redundant slashes. */ bool is_normalized_path(const wchar_t *path) { while (path[0] != L'\0') { if (path[0] == L'.' && (path[1] == L'\0' || path[1] == L'/' || (path[1] == L'.' && (path[2] == L'\0' || path[2] == L'/')))) return false; path = wcschr(path, L'/'); if (path == NULL) break; path++; } return true; } /* Returns the result of `getcwd' as a newly malloced string. * On error, `errno' is set and NULL is returned. */ char *xgetcwd(void) { #if GETCWD_AUTO_MALLOC char *pwd = getcwd(NULL, 0); return (pwd != NULL) ? xrealloc(pwd, strlen(pwd) + 1) : NULL; #else size_t pwdlen = 40; char *pwd = xmalloc(pwdlen); while (getcwd(pwd, pwdlen) == NULL) { if (errno == ERANGE) { pwdlen *= 2; pwd = xrealloc(pwd, pwdlen); } else { int saveerrno = errno; free(pwd); pwd = NULL; errno = saveerrno; break; } } return pwd; #endif } /* Searches directories `dirs' for a file named `name' that satisfies predicate * `cond'. * name: the pathname of the file to be searched for. * If `name' is an absolute path, a copy of it is simply returned. * dirs: a NULL-terminated array of strings that are the names of * directories to search. An empty string is treated as the current * directory. If `dirs' is NULL, no directory is searched. * cond: the function that determines the specified pathname satisfies a * certain condition. * For each directory in `dirs', in order, the directory name and "/" and * `name' are concatenated to produce a pathname and `cond' is called with * the pathname. If `cond' returns true, search is complete and the pathname * is returned as a newly malloced string. If `cond' returns false to all the * produced pathnames, NULL is returned. * If `name' starts with a slash, a copy of `name' is simply returned. If `name' * is an empty string or `dirs' is NULL, NULL is returned. * `name' and all the directory names in `dirs' must start and end in the * initial shift state. */ char *which( const char *restrict name, char *const *restrict dirs, bool cond(const char *path)) { if (name[0] == L'\0') return NULL; if (name[0] == '/') return xstrdup(name); if (dirs == NULL) return NULL; size_t namelen = strlen(name); for (const char *dir; (dir = *dirs) != NULL; dirs++) { size_t dirlen = strlen(dir); char path[dirlen + namelen + 3]; if (dirlen > 0) { /* concatenate `dir' and `name' to produce a pathname `path' */ strcpy(path, dir); if (path[dirlen - 1] != '/') path[dirlen++] = '/'; strcpy(path + dirlen, name); } else { /* if `dir' is empty, it's considered to be the current directory */ strcpy(path, name); } if (cond(path)) return xstrdup(path); } return NULL; } /* Creates a new temporary file under "/tmp". * `mode' is the access permission bits of the file. * On successful completion, a file descriptor is returned, which is both * readable and writeable regardless of `mode', and a pointer to a string * containing the filename is assigned to `*filename', which should be freed by * the caller. The filename consists only of portable filename characters. * On failure, -1 is returned with `**filename' left unchanged and `errno' is * set to the error value. */ int create_temporary_file(char **filename, mode_t mode) { static uintmax_t num = 0; uintmax_t n; int fd; xstrbuf_T buf; n = (uintmax_t) shell_pid * 272229637312669; if (num == 0) num = (uintmax_t) time(NULL) * 5131212142718371 << 1 | 1; sb_init(&buf); for (int i = 0; i < 100; i++) { num = (num ^ n) * 16777619; sb_printf(&buf, "/tmp/yash-%X", (unsigned) (num >> 30)); /* The filename must be 14 bytes long at most. */ fd = open(buf.contents, O_RDWR | O_CREAT | O_EXCL, mode); if (fd >= 0) { *filename = sb_tostr(&buf); return fd; } else if (errno != EEXIST && errno != EINTR) { int saveerrno = errno; sb_destroy(&buf); errno = saveerrno; return -1; } sb_clear(&buf); } sb_destroy(&buf); errno = EAGAIN; return -1; } /********** Command Hashtable **********/ static inline void forget_command_path(const char *command) __attribute__((nonnull)); static wchar_t *get_default_path(void) __attribute__((malloc,warn_unused_result)); /* A hashtable from command names to their full path. * Keys are pointers to a multibyte string containing a command name and * values are pointers to a multibyte string containing the commands' full path. * For each entry, the key string is part of the value, that is, the last * pathname component of the value. */ static hashtable_T cmdhash; /* Initializes the command hashtable. */ void init_cmdhash(void) { assert(cmdhash.capacity == 0); ht_init(&cmdhash, hashstr, htstrcmp); } /* Empties the command hashtable. */ void clear_cmdhash(void) { ht_clear(&cmdhash, vfree); } /* Searches PATH for the specified command and returns its full pathname. * If `forcelookup' is false and the command is already entered in the command * hashtable, the value in the hashtable is returned. Otherwise, `which' is * called to search for the command, the result is entered into the hashtable, * and then it is returned. If no command is found, NULL is returned. */ const char *get_command_path(const char *name, bool forcelookup) { const char *path; if (!forcelookup) { path = ht_get(&cmdhash, name).value; if (path != NULL && is_executable_regular(path)) return path; } path = which(name, get_path_array(PA_PATH), is_executable_regular); if (path != NULL && path[0] == '/') { size_t namelen = strlen(name), pathlen = strlen(path); const char *nameinpath = path + pathlen - namelen; assert(strcmp(name, nameinpath) == 0); vfree(ht_set(&cmdhash, nameinpath, path)); } else { forget_command_path(name); } return path; } /* Removes the specified command from the command hashtable. */ void forget_command_path(const char *command) { vfree(ht_remove(&cmdhash, command)); } /* Last result of `get_command_path_default'. */ static char *gcpd_value = NULL; /* Paths for `get_command_path_default'. */ static char **default_path = NULL; /* Searches for the specified command using the system's default PATH. * The full path of the command is returned if found, NULL otherwise. * The return value is valid until the next call to this function. */ const char *get_command_path_default(const char *name) { assert(name != gcpd_value); free(gcpd_value); if (default_path == NULL) { wchar_t *defpath = get_default_path(); if (defpath == NULL) { gcpd_value = NULL; return gcpd_value; } default_path = decompose_paths(defpath); free(defpath); } gcpd_value = which(name, default_path, is_executable_regular); return gcpd_value; } /* Returns the system's default PATH as a newly malloced string. * The default PATH is (assumed to be) guaranteed to contain all the standard * utilities. */ wchar_t *get_default_path(void) { #if HAVE_PATHS_H && defined _PATH_STDPATH return malloc_mbstowcs(_PATH_STDPATH); #else size_t size = 100; char *buf = xmalloc(size); size_t s = confstr(_CS_PATH, buf, size); if (s > size) { size = s; buf = xrealloc(buf, size); s = confstr(_CS_PATH, buf, size); } if (s == 0 || s > size) { free(buf); return NULL; } return realloc_mbstowcs(buf); #endif } /********** Home Directory Cache **********/ static struct passwd *xgetpwnam(const char *name) __attribute__((nonnull)); static void clear_homedirhash(void); static inline void forget_home_directory(const wchar_t *username); /* Calls `getpwnam' until it doesn't return EINTR. */ struct passwd *xgetpwnam(const char *name) { struct passwd *pw; do { errno = 0; pw = getpwnam(name); } while (pw == NULL && errno == EINTR); return pw; } /* A hashtable from users' names to their home directory paths. * Keys are pointers to a wide string containing a user's login name and * values are pointers to a wide string containing their home directory name. * A memory block for the key/value string must be allocated at once so that, * when the value is `free'd, the key is `free'd as well. */ static hashtable_T homedirhash; /* Initializes the home directory hashtable. */ void init_homedirhash(void) { assert(homedirhash.capacity == 0); ht_init(&homedirhash, hashwcs, htwcscmp); } /* Empties the home directory hashtable. */ void clear_homedirhash(void) { ht_clear(&homedirhash, vfree); } /* Returns the full pathname of the specified user's home directory. * If `forcelookup' is false and the path is already entered in the home * directory hashtable, the value in the hashtable is returned. Otherwise, * `getpwnam' is called, the result is entered into the hashtable and then * it is returned. If no entry is returned by `getpwnam', NULL is returned. */ const wchar_t *get_home_directory(const wchar_t *username, bool forcelookup) { const wchar_t *path; if (!forcelookup) { path = ht_get(&homedirhash, username).value; if (path != NULL) return path; } char *mbsusername = malloc_wcstombs(username); if (mbsusername == NULL) return NULL; struct passwd *pw = xgetpwnam(mbsusername); free(mbsusername); if (pw == NULL) return NULL; xwcsbuf_T dir; wb_init(&dir); if (wb_mbscat(&dir, pw->pw_dir) != NULL) { wb_destroy(&dir); return NULL; } wb_wccat(&dir, L'\0'); size_t usernameindex = dir.length; wb_cat(&dir, username); wchar_t *dirname = wb_towcs(&dir); vfree(ht_set(&homedirhash, dirname + usernameindex, dirname)); return dirname; } /* Forget the specified user's home directory. */ void forget_home_directory(const wchar_t *username) { vfree(ht_remove(&homedirhash, username)); } /********** wglob **********/ /* The type of compiled glob patterns */ struct wglob_pattern { struct wglob_pattern *next; enum { WGLOB_LITERAL, WGLOB_MATCH, WGLOB_RECSEARCH, } type; union { struct { char *name; const wchar_t *wname; } literal; struct { xfnmatch_T *pattern; } match; struct { bool followlink, allowperiod; } recsearch; } value; }; struct wglob_dirstack { struct wglob_dirstack *prev; struct stat st; }; static struct wglob_pattern *wglob_parse_pattern( wchar_t *pat, enum wglobflags_T flags) __attribute__((malloc,warn_unused_result,nonnull)); static struct wglob_pattern *wglob_create_recsearch_pattern( bool followlink, bool allowperiod) __attribute__((malloc,warn_unused_result)); static struct wglob_pattern *wglob_parse_pattern_part( wchar_t *pat, enum wglobflags_T flags) __attribute__((malloc,warn_unused_result,nonnull)); static void wglob_free_pattern(struct wglob_pattern *p); static void wglob_search( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list) __attribute__((nonnull)); static void wglob_search_literal( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list) __attribute__((nonnull)); static void wglob_search_match( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list) __attribute__((nonnull)); static void wglob_search_recsearch( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list, struct wglob_dirstack *dirstack) __attribute__((nonnull(1,3,4,5))); static bool is_reentry( const struct stat *st, const struct wglob_dirstack *dirstack) __attribute__((nonnull(1))); static int wglob_sortcmp(const void *v1, const void *v2) __attribute__((pure,nonnull)); /* A wide string version of `glob'. * Adds all pathnames that matches the specified pattern to the specified list. * pattern: the pattern to match * flags: a bitwise OR of the following flags: * WGLB_MARK: directory items have '/' appended to their name * WGLB_CASEFOLD: do matching case-insensitively * WGLB_PERIOD: L'*' and L'?' match L'.' at the beginning * WGLB_NOSORT: don't sort resulting items * WGLB_RECDIR: allow recursive search with L"**" * list: a list of pointers to wide strings to which resulting items are * added. * Returns true iff successful. However, some result items may be added to the * list even if unsuccessful. * If the pattern is invalid, immediately returns false. * If the shell is interactive and SIGINT is not blocked, this function can be * interrupted, in which case false is returned. * Minor errors such as permission errors are ignored. */ bool wglob(const wchar_t *restrict pattern, enum wglobflags_T flags, plist_T *restrict list) { size_t listbase = list->length; xstrbuf_T path; xwcsbuf_T wpath; struct wglob_pattern *p; wchar_t savepattern[wcslen(pattern) + 1]; p = wglob_parse_pattern(wcscpy(savepattern, pattern), flags); if (p == NULL) return false; sb_init(&path); wb_init(&wpath); wglob_search(p, flags, &path, &wpath, list); sb_destroy(&path); wb_destroy(&wpath); wglob_free_pattern(p); if (!(flags & WGLB_NOSORT)) { size_t count = list->length - listbase; /* # of resulting items */ if (count > 0) { /* sort the items */ qsort(list->contents + listbase, count, sizeof (void *), wglob_sortcmp); /* remove duplicates */ for (size_t i = list->length; --i > listbase; ) { if (wcscmp(list->contents[i], list->contents[i-1]) == 0) { free(list->contents[i]); pl_remove(list, i, 1); } } } } return !is_interrupted(); } /* Parses the specified pattern. * Pattern `pat' may be modified in this function and must not be changed until * the return value is freed by `wglob_free_pattern'. * WGLB_CASEFOLD, WGLB_PERIOD and WGLB_RECDIR in `flags' affect the results. */ struct wglob_pattern *wglob_parse_pattern(wchar_t *pat, enum wglobflags_T flags) { struct wglob_pattern *result = NULL, **lastp = &result; struct wglob_pattern *p; for (;;) { wchar_t *slash = wcschr(pat, L'/'); if (slash != NULL) { slash[0] = L'\0'; if (!(flags & WGLB_RECDIR)) goto normal; if (wcscmp(pat, L"**") == 0) p = wglob_create_recsearch_pattern(false, false); else if (wcscmp(pat, L"***") == 0) p = wglob_create_recsearch_pattern(true, false); else if (wcscmp(pat, L".**") == 0) p = wglob_create_recsearch_pattern(false, true); else if (wcscmp(pat, L".***") == 0) p = wglob_create_recsearch_pattern(true, true); else goto normal; } else { normal: p = wglob_parse_pattern_part(pat, flags); } if (p == NULL) goto fail; *lastp = p; lastp = &p->next; if (slash == NULL) return result; pat = &slash[1]; } fail: wglob_free_pattern(result); return NULL; } struct wglob_pattern *wglob_create_recsearch_pattern( bool followlink, bool allowperiod) { struct wglob_pattern *result = xmalloc(sizeof *result); result->next = NULL; result->type = WGLOB_RECSEARCH; result->value.recsearch.followlink = followlink; result->value.recsearch.allowperiod = allowperiod; return result; } /* Parses the specified pattern that contains one pathname component. * `pat' must not contain a slash. */ struct wglob_pattern *wglob_parse_pattern_part( wchar_t *pat, enum wglobflags_T flags) { struct wglob_pattern *result = xmalloc(sizeof *result); result->next = NULL; assert(!wcschr(pat, L'/')); if (is_matching_pattern(pat)) { xfnmflags_T xflags = XFNM_HEADONLY | XFNM_TAILONLY; if (flags & WGLB_CASEFOLD) xflags |= XFNM_CASEFOLD; if (!(flags & WGLB_PERIOD)) xflags |= XFNM_PERIOD; result->type = WGLOB_MATCH; result->value.match.pattern = xfnm_compile(pat, xflags); if (result->value.match.pattern == NULL) goto fail; } else { wchar_t *value = unescape(pat); assert(wcslen(value) <= wcslen(pat)); result->type = WGLOB_LITERAL; result->value.literal.wname = wcscpy(pat, value); result->value.literal.name = realloc_wcstombs(value); if (result->value.literal.name == NULL) goto fail; } return result; fail: free(result); return NULL; } void wglob_free_pattern(struct wglob_pattern *p) { while (p != NULL) { struct wglob_pattern *next = p->next; switch (p->type) { case WGLOB_LITERAL: free(p->value.literal.name); break; case WGLOB_MATCH: xfnm_free(p->value.match.pattern); break; case WGLOB_RECSEARCH: break; } free(p); p = next; } } /* Searches the directory designated in `path' and add matching pathnames to * `list'. * `path' and `wpath' must contain the same pathname, which must be empty or * end with a slash. The contents of `path' and `wpath' may be changed during * the search, but when the function returns the contents are restored to the * original value. * Only the WGLB_MARK flag in `flags' affects the results. */ void wglob_search( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list) { assert(path->length == 0 || path->contents[path->length - 1] == '/'); assert(wpath->length == 0 || wpath->contents[wpath->length - 1] == L'/'); switch (pattern->type) { case WGLOB_LITERAL: wglob_search_literal(pattern, flags, path, wpath, list); break; case WGLOB_MATCH: wglob_search_match(pattern, flags, path, wpath, list); break; case WGLOB_RECSEARCH: wglob_search_recsearch(pattern, flags, path, wpath, list, NULL); break; } } /* Searches for the pathname component that does not require pattern matching.*/ void wglob_search_literal( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list) { const size_t savepathlen = path->length; const size_t savewpathlen = wpath->length; assert(pattern->type == WGLOB_LITERAL); if (pattern->next == NULL) { struct stat st; sb_cat(path, pattern->value.literal.name); if (stat(path->contents, &st) >= 0) { if (pattern->value.literal.wname[0] != L'\0') { wb_cat(wpath, pattern->value.literal.wname); if ((flags & WGLB_MARK) && S_ISDIR(st.st_mode)) wb_wccat(wpath, L'/'); } pl_add(list, xwcsdup(wpath->contents)); } } else { sb_ccat(sb_cat(path, pattern->value.literal.name), '/'); wb_wccat(wb_cat(wpath, pattern->value.literal.wname), L'/'); wglob_search(pattern->next, flags, path, wpath, list); } sb_truncate(path, savepathlen); wb_truncate(wpath, savewpathlen); } /* Searches the directory for files that match with the specified pattern. */ void wglob_search_match( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list) { assert(pattern->type == WGLOB_MATCH); if (is_interrupted()) return; DIR *dir = opendir((path->length == 0) ? "." : path->contents); if (dir == NULL) return; const size_t savepathlen = path->length; const size_t savewpathlen = wpath->length; struct dirent *de; while ((de = readdir(dir)) != NULL) { if (xfnm_match(pattern->value.match.pattern, de->d_name) == 0) { if (wb_mbscat(wpath, de->d_name) != NULL) goto next; sb_cat(path, de->d_name); if (pattern->next == NULL) { if (flags & WGLB_MARK) { if (is_directory(path->contents)) wb_wccat(wpath, L'/'); } pl_add(list, xwcsdup(wpath->contents)); } else { sb_ccat(path, '/'); wb_wccat(wpath, L'/'); wglob_search(pattern->next, flags, path, wpath, list); } next: sb_truncate(path, savepathlen); wb_truncate(wpath, savewpathlen); } } closedir(dir); } /* Searches the directory recursively for files that match with the specified * pattern. */ void wglob_search_recsearch( const struct wglob_pattern *restrict pattern, enum wglobflags_T flags, xstrbuf_T *restrict path, xwcsbuf_T *restrict wpath, plist_T *restrict list, struct wglob_dirstack *dirstack) { assert(pattern->type == WGLOB_RECSEARCH); assert(pattern->next != NULL); if (is_interrupted()) return; /* Step 1: search `path' itself */ wglob_search(pattern->next, flags, path, wpath, list); /* Step 2: search the subdirectories of `path' recursively */ DIR *dir = opendir((path->length == 0) ? "." : path->contents); if (dir == NULL) return; const size_t savepathlen = path->length; const size_t savewpathlen = wpath->length; struct dirent *de; int (*statfunc)(const char *path, struct stat *st) = pattern->value.recsearch.followlink ? stat : lstat; while ((de = readdir(dir)) != NULL) { if (pattern->value.recsearch.allowperiod ? strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0 : de->d_name[0] == '.') continue; struct wglob_dirstack newstack; sb_cat(path, de->d_name); if (statfunc(path->contents, &newstack.st) >= 0 && S_ISDIR(newstack.st.st_mode) && !is_reentry(&newstack.st, dirstack)) { if (wb_mbscat(wpath, de->d_name) != NULL) goto next; sb_ccat(path, '/'); wb_wccat(wpath, L'/'); newstack.prev = dirstack; wglob_search_recsearch( pattern, flags, path, wpath, list, &newstack); } next: sb_truncate(path, savepathlen); wb_truncate(wpath, savewpathlen); } closedir(dir); } /* Returns true iff the file designated by `st' is contained in `dirstack'. */ bool is_reentry(const struct stat *st, const struct wglob_dirstack *dirstack) { for (; dirstack != NULL; dirstack = dirstack->prev) if (stat_result_same_file(st, &dirstack->st)) return true; return false; } int wglob_sortcmp(const void *v1, const void *v2) { return wcscoll(*(const wchar_t *const *) v1, *(const wchar_t *const *) v2); } /********** Built-ins **********/ static void canonicalize_path_ex(xwcsbuf_T *buf) __attribute__((nonnull)); static bool starts_with_root_parent(const wchar_t *path) __attribute__((nonnull,pure)); static void print_command_paths(bool all); static void print_home_directories(void); static int print_umask(bool symbolic); static inline bool print_umask_octal(mode_t mode); static bool print_umask_symbolic(mode_t mode); static int set_umask(const wchar_t *newmask) __attribute__((nonnull)); static inline mode_t copy_user_mask(mode_t mode) __attribute__((const)); static inline mode_t copy_group_mask(mode_t mode) __attribute__((const)); static inline mode_t copy_other_mask(mode_t mode) __attribute__((const)); /* The "cd" built-in, which accepts the following options: * -L: don't resolve symbolic links (default) * -P: resolve symbolic links * --default-directory=: go to when the operand is missing * -L and -P are mutually exclusive: the one specified last is used. */ int cd_builtin(int argc, void **argv) { bool logical = true; const wchar_t *newpwd = NULL; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, cd_options, XGETOPT_DIGIT)) != NULL) { switch (opt->shortopt) { case L'L': logical = true; break; case L'P': logical = false; break; case L'd': newpwd = xoptarg; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } bool printnewdir = false; switch (argc - xoptind) { case 0: if (newpwd == NULL) { newpwd = getvar(L VAR_HOME); if (newpwd == NULL || newpwd[0] == L'\0') { xerror(0, Ngt("$HOME is not set")); return Exit_FAILURE; } } break; case 1: if (wcscmp(ARGV(xoptind), L"-") == 0) { newpwd = getvar(L VAR_OLDPWD); if (newpwd == NULL || newpwd[0] == L'\0') { xerror(0, Ngt("$OLDPWD is not set")); return Exit_FAILURE; } printnewdir = true; } else { newpwd = ARGV(xoptind); } break; default: return too_many_operands_error(1); } return change_directory(newpwd, printnewdir, logical); } /* Changes the working directory to `newpwd'. * This function implements the almost all part of the "cd" built-in. * $PWD and $OLDPWD are set in this function. * If `printnewdir' is true or the new directory is found from $CDPATH, the new * directory is printed to the standard output. * Returns Exit_SUCCESS, Exit_FAILURE or Exit_ERROR. */ int change_directory(const wchar_t *newpwd, bool printnewdir, bool logical) { const wchar_t *origpwd; xwcsbuf_T curpath; size_t curpathoffset = 0; /* get the current value of $PWD as `origpwd' */ origpwd = getvar(L VAR_PWD); if (origpwd == NULL || origpwd[0] != L'/') { if (origpwd == newpwd) { xerror(0, Ngt("$PWD has an invalid value")); return Exit_FAILURE; } /* we have to assure `origpwd != newpwd' because we're going to * re-assign $PWD */ char *pwd = xgetcwd(); if (pwd == NULL) { if (logical) { xerror(errno, Ngt("cannot determine the current directory")); return Exit_FAILURE; } } else { wchar_t *wpwd = realloc_mbstowcs(pwd); if (wpwd != NULL) { if (set_variable(L VAR_PWD, wpwd, SCOPE_GLOBAL, false)) origpwd = getvar(L VAR_PWD); else logical = false, origpwd = NULL; } else { xerror(EILSEQ, Ngt("cannot determine the current directory")); return Exit_ERROR; } } } assert(!logical || origpwd != NULL); assert(origpwd == NULL || origpwd[0] == L'/'); wb_init(&curpath); /* step 3 */ if (newpwd[0] == L'/') { wb_cat(&curpath, newpwd); goto step7; } /* step 4: check if `newpwd' starts with "." or ".." */ if (newpwd[0] == L'.' && (newpwd[1] == L'\0' || newpwd[1] == L'/' || (newpwd[1] == L'.' && (newpwd[2] == L'\0' || newpwd[2] == L'/')))) goto step6; /* step 5: search $CDPATH */ { char *mbsnewpwd = malloc_wcstombs(newpwd); if (mbsnewpwd == NULL) { wb_destroy(&curpath); xerror(EILSEQ, Ngt("unexpected error")); return Exit_ERROR; } char *const *cdpath = get_path_array(PA_CDPATH); char *path = which(mbsnewpwd, (cdpath != NULL) ? cdpath : (char *[]) { "", NULL }, is_directory); if (path != NULL) { if (strcmp(mbsnewpwd, path) != 0) printnewdir = true; wb_mbscat(&curpath, path); free(mbsnewpwd); free(path); goto step7; } free(mbsnewpwd); } step6: /* set the value of `curpath' */ assert(newpwd[0] != L'/'); assert(curpath.length == 0); if (logical) { wb_cat(&curpath, origpwd); if (curpath.length == 0 || curpath.contents[curpath.length - 1] != L'/') wb_wccat(&curpath, L'/'); } wb_cat(&curpath, newpwd); step7: /* ensure the value of `curpath' is an absolute path */ if (!logical) goto step10; if (curpath.contents[0] != L'/') { wchar_t *oldcurpath = wb_towcs(&curpath); wb_init(&curpath); wb_cat(&curpath, origpwd); if (curpath.length == 0 || curpath.contents[curpath.length - 1] != L'/') wb_wccat(&curpath, L'/'); wb_catfree(&curpath, oldcurpath); } /* step 8: canonicalization */ assert(logical); { wchar_t *canon = canonicalize_path(curpath.contents); wb_destroy(&curpath); if (canon == NULL) { xerror(ENOTDIR, Ngt("`%ls'"), newpwd); return Exit_FAILURE; } wb_initwith(&curpath, canon); } /* step 9: determine `curpathoffset' */ assert(logical); /* If `origpwd' contains a character other than '/' and if `curpath' starts * with `origpwd', then a relative path to the new working directory can be * obtained by removing the matching prefix of `curpath'. */ if (origpwd[wcsspn(origpwd, L"/")] != L'\0') { wchar_t *s = matchwcsprefix(curpath.contents, origpwd); if (s != NULL && (s[-1] == L'/' || s[0] == L'/')) { if (s[0] == L'/') s++; assert(s[0] != L'/'); curpathoffset = s - curpath.contents; } } step10: /* do chdir */ assert(curpathoffset <= curpath.length); { char *mbscurpath = malloc_wcstombs(curpath.contents + curpathoffset); if (mbscurpath == NULL) { xerror(EILSEQ, Ngt("unexpected error")); wb_destroy(&curpath); return Exit_ERROR; } if (chdir(mbscurpath) < 0) { xerror(errno, Ngt("`%s'"), mbscurpath); free(mbscurpath); wb_destroy(&curpath); return Exit_FAILURE; } free(mbscurpath); } #ifndef NDEBUG newpwd = NULL; /* `newpwd' must not be used any more because it may be pointing to the * current value of $OLDPWD, which is going to be re-assigned to. */ #endif /* set $OLDPWD and $PWD */ if (origpwd != NULL) set_variable(L VAR_OLDPWD, xwcsdup(origpwd), SCOPE_GLOBAL, false); if (logical) { if (!posixly_correct) canonicalize_path_ex(&curpath); if (printnewdir) printf("%ls\n", curpath.contents); set_variable(L VAR_PWD, wb_towcs(&curpath), SCOPE_GLOBAL, false); } else { wb_destroy(&curpath); char *mbsnewpwd = xgetcwd(); if (mbsnewpwd != NULL) { if (printnewdir) printf("%s\n", mbsnewpwd); wchar_t *wnewpwd = realloc_mbstowcs(mbsnewpwd); if (wnewpwd != NULL) set_variable(L VAR_PWD, wnewpwd, SCOPE_GLOBAL, false); } } if (!posixly_correct) exec_variable_as_auxiliary_(VAR_YASH_AFTER_CD); return Exit_SUCCESS; } /* Removes "/.." components at the beginning of the string in the buffer * if the root directory and its parent are the same directory. */ void canonicalize_path_ex(xwcsbuf_T *buf) { if (starts_with_root_parent(buf->contents) && is_same_file("/", "/..")) { do wb_remove(buf, 0, 3); while (starts_with_root_parent(buf->contents)); if (buf->length == 0) wb_wccat(buf, L'/'); } } /* Returns true iff the given path starts with "/..". */ bool starts_with_root_parent(const wchar_t *path) { return path[0] == L'/' && path[1] == L'.' && path[2] == L'.' && (path[3] == L'\0' || path[3] == L'/'); } #if YASH_ENABLE_HELP const char cd_help[] = Ngt( "change the working directory" ); const char cd_syntax[] = Ngt( "\tcd [-L|-P] [directory]\n" ); #endif /* The "pwd" built-in, which accepts the following options: * -L: don't resolve symbolic links (default) * -P: resolve symbolic links * -L and -P are mutually exclusive: the one specified last is used. */ int pwd_builtin(int argc __attribute__((unused)), void **argv) { bool logical = true; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, pwd_options, XGETOPT_DIGIT)) != NULL) { switch (opt->shortopt) { case L'L': logical = true; break; case L'P': logical = false; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (xoptind != argc) return too_many_operands_error(0); char *mbspwd; if (logical) { const wchar_t *pwd = getvar(L VAR_PWD); if (pwd != NULL && pwd[0] == L'/' && is_normalized_path(pwd)) { mbspwd = malloc_wcstombs(pwd); if (mbspwd != NULL) { if (is_same_file(mbspwd, ".")) goto print; free(mbspwd); } } } mbspwd = xgetcwd(); if (mbspwd == NULL) { xerror(errno, Ngt("cannot determine the current directory")); return Exit_FAILURE; } print: if (printf("%s\n", mbspwd) < 0) xerror(errno, Ngt("cannot print to the standard output")); free(mbspwd); return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } #if YASH_ENABLE_HELP const char pwd_help[] = Ngt( "print the working directory" ); const char pwd_syntax[] = Ngt( "\tpwd [-L|-P]\n" ); #endif /* Options for the "hash" built-in. */ const struct xgetopt_T hash_options[] = { { L'a', L"all", OPTARG_NONE, false, NULL, }, { L'd', L"directory", OPTARG_NONE, false, NULL, }, { L'r', L"remove", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "hash" built-in, which accepts the following options: * -a: print all entries * -d: use the directory cache * -r: remove cache entries */ int hash_builtin(int argc, void **argv) { bool remove = false, all = false, dir = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, hash_options, 0)) != NULL) { switch (opt->shortopt) { case L'a': all = true; break; case L'd': dir = true; break; case L'r': remove = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } if (all && xoptind != argc) return too_many_operands_error(0); if (dir) { if (remove) { if (xoptind == argc) { // forget all clear_homedirhash(); } else { // forget the specified for (int i = xoptind; i < argc; i++) forget_home_directory(ARGV(i)); } } else { if (xoptind == argc) { // print all print_home_directories(); } else { // remember the specified for (int i = xoptind; i < argc; i++) if (!get_home_directory(ARGV(i), true)) xerror(0, Ngt("no such user `%ls'"), ARGV(i)); } } } else { if (remove) { if (xoptind == argc) { // forget all clear_cmdhash(); } else { // forget the specified for (int i = xoptind; i < argc; i++) { char *cmd = malloc_wcstombs(ARGV(i)); if (cmd != NULL) { forget_command_path(cmd); free(cmd); } } } } else { if (xoptind == argc) { // print all print_command_paths(all); } else { // remember the specified for (int i = xoptind; i < argc; i++) { if (wcschr(ARGV(i), L'/') != NULL) { xerror(0, Ngt("`%ls': a command name must not contain " "`/'"), ARGV(i)); continue; } char *cmd = malloc_wcstombs(ARGV(i)); if (cmd != NULL) { if (!get_command_path(cmd, true)) xerror(0, Ngt("command `%s' was not found " "in $PATH"), cmd); free(cmd); } } } } } return (yash_error_message_count == 0) ? Exit_SUCCESS : Exit_FAILURE; } /* Prints the entries of the command hashtable. * Prints an error message to the standard error if failed to print to the * standard output. */ void print_command_paths(bool all) { kvpair_T kv; size_t index = 0; while ((kv = ht_next(&cmdhash, &index)).key != NULL) { if (all || get_builtin(kv.key) == NULL) { if (!xprintf("%s\n", (char *) kv.value)) { break; } } } } /* Prints the entries of the home directory hashtable. * Prints an error message to the standard error if failed to print to the * standard output. */ void print_home_directories(void) { kvpair_T kv; size_t index = 0; while ((kv = ht_next(&homedirhash, &index)).key != NULL) { const wchar_t *key = kv.key, *value = kv.value; if (!xprintf("~%ls=%ls\n", key, value)) { break; } } } #if YASH_ENABLE_HELP const char hash_help[] = Ngt( "remember, forget, or report command locations" ); const char hash_syntax[] = Ngt( "\thash command...\n" "\thash -r [command...]\n" "\thash [-a] # print remembered paths\n" "\thash -d user...\n" "\thash -d -r [user...]\n" "\thash -d # print remembered paths\n" ); #endif /* Options for the "umask" built-in. */ const struct xgetopt_T umask_options[] = { { L'S', L"symbolic", OPTARG_NONE, true, NULL, }, #if YASH_ENABLE_HELP { L'-', L"help", OPTARG_NONE, false, NULL, }, #endif { L'\0', NULL, 0, false, NULL, }, }; /* The "umask" built-in, which accepts the following option: * -S: symbolic output */ int umask_builtin(int argc, void **argv) { bool symbolic = false; const struct xgetopt_T *opt; xoptind = 0; while ((opt = xgetopt(argv, umask_options, 0)) != NULL) { switch (opt->shortopt) { case L'S': symbolic = true; break; #if YASH_ENABLE_HELP case L'-': return print_builtin_help(ARGV(0)); #endif default: return Exit_ERROR; } } switch (argc - xoptind) { case 0: return print_umask(symbolic); case 1: return set_umask(ARGV(xoptind)); default: return too_many_operands_error(1); } } int print_umask(bool symbolic) { mode_t mode = umask(0); umask(mode); bool success; if (symbolic) success = print_umask_symbolic(mode); else success = print_umask_octal(mode); return success ? Exit_SUCCESS : Exit_FAILURE; } bool print_umask_octal(mode_t mode) { return xprintf("0%.3jo\n", (uintmax_t) mode); } bool print_umask_symbolic(mode_t mode) { xstrbuf_T outputtext; sb_init(&outputtext); sb_ccat(&outputtext, 'u'); sb_ccat(&outputtext, '='); if (!(mode & S_IRUSR)) sb_ccat(&outputtext, 'r'); if (!(mode & S_IWUSR)) sb_ccat(&outputtext, 'w'); if (!(mode & S_IXUSR)) sb_ccat(&outputtext, 'x'); sb_ccat(&outputtext, ','); sb_ccat(&outputtext, 'g'); sb_ccat(&outputtext, '='); if (!(mode & S_IRGRP)) sb_ccat(&outputtext, 'r'); if (!(mode & S_IWGRP)) sb_ccat(&outputtext, 'w'); if (!(mode & S_IXGRP)) sb_ccat(&outputtext, 'x'); sb_ccat(&outputtext, ','); sb_ccat(&outputtext, 'o'); sb_ccat(&outputtext, '='); if (!(mode & S_IROTH)) sb_ccat(&outputtext, 'r'); if (!(mode & S_IWOTH)) sb_ccat(&outputtext, 'w'); if (!(mode & S_IXOTH)) sb_ccat(&outputtext, 'x'); sb_ccat(&outputtext, '\n'); bool result = xprintf("%s", outputtext.contents); sb_destroy(&outputtext); return result; } int set_umask(const wchar_t *maskstr) { if (iswdigit(maskstr[0])) { /* parse as an octal number */ uintmax_t mask; wchar_t *end; errno = 0; mask = wcstoumax(maskstr, &end, 8); if (errno || *end != L'\0') { xerror(0, Ngt("`%ls' is not a valid mask specification"), maskstr); return Exit_ERROR; } umask((mode_t) (mask & (S_IRWXU | S_IRWXG | S_IRWXO))); return Exit_SUCCESS; } /* otherwise parse as a symbolic mode specification */ mode_t origmask = ~umask(0); mode_t newmask = origmask; const wchar_t *const savemaskstr = maskstr; for (;;) { mode_t who, perm; char op; /* '+', '-' or '=' */ /* parse 'who' */ who = 0; for (;; maskstr++) switch (*maskstr) { case L'u': who |= S_IRWXU; break; case L'g': who |= S_IRWXG; break; case L'o': who |= S_IRWXO; break; case L'a': who = S_IRWXU | S_IRWXG | S_IRWXO; break; default: goto who_end; } who_end: if (who == 0) who = S_IRWXU | S_IRWXG | S_IRWXO; /* parse 'op' */ op_start: op = *maskstr; switch (op) { case L'+': case L'-': case L'=': break; default: goto err; } maskstr++; /* parse 'perm' */ switch (*maskstr) { case L'u': perm = copy_user_mask(origmask); maskstr++; break; case L'g': perm = copy_group_mask(origmask); maskstr++; break; case L'o': perm = copy_other_mask(origmask); maskstr++; break; default: perm = 0; for (;; maskstr++) switch (*maskstr) { case L'r': perm |= S_IRUSR | S_IRGRP | S_IROTH; break; case L'w': perm |= S_IWUSR | S_IWGRP | S_IWOTH; break; case L'X': if (!(origmask & (S_IXUSR | S_IXGRP | S_IXOTH))) break; /* falls thru! */ case L'x': perm |= S_IXUSR | S_IXGRP | S_IXOTH; break; case L's': perm |= S_ISUID | S_ISGID; break; default: goto perm_end; } perm_end: break; } /* set newmask */ switch (op) { case L'+': newmask |= who & perm; break; case L'-': newmask &= ~(who & perm); break; case L'=': newmask = (~who & newmask) | (who & perm); break; default: assert(false); } switch (*maskstr) { case L'\0': goto parse_end; case L',': break; default: goto op_start; } maskstr++; } parse_end: umask(~newmask); return Exit_SUCCESS; err: umask(~origmask); xerror(0, Ngt("`%ls' is not a valid mask specification"), savemaskstr); return Exit_ERROR; } mode_t copy_user_mask(mode_t mode) { return ((mode & S_IRUSR) ? (S_IRUSR | S_IRGRP | S_IROTH) : 0) | ((mode & S_IWUSR) ? (S_IWUSR | S_IWGRP | S_IWOTH) : 0) | ((mode & S_IXUSR) ? (S_IXUSR | S_IXGRP | S_IXOTH) : 0); } mode_t copy_group_mask(mode_t mode) { return ((mode & S_IRGRP) ? (S_IRUSR | S_IRGRP | S_IROTH) : 0) | ((mode & S_IWGRP) ? (S_IWUSR | S_IWGRP | S_IWOTH) : 0) | ((mode & S_IXGRP) ? (S_IXUSR | S_IXGRP | S_IXOTH) : 0); } mode_t copy_other_mask(mode_t mode) { return ((mode & S_IROTH) ? (S_IRUSR | S_IRGRP | S_IROTH) : 0) | ((mode & S_IWOTH) ? (S_IWUSR | S_IWGRP | S_IWOTH) : 0) | ((mode & S_IXOTH) ? (S_IXUSR | S_IXGRP | S_IXOTH) : 0); } #if YASH_ENABLE_HELP const char umask_help[] = Ngt( "print or set the file creation mask" ); const char umask_syntax[] = Ngt( "\tumask mode\n" "\tumask [-S]\n" ); #endif /* vim: set ts=8 sts=4 sw=4 noet tw=80: */ yash-2.35/plist.c0000644000175000017500000001272412154557026014053 0ustar magicantmagicant/* Yash: yet another shell */ /* plist.c: modifiable list of pointers */ /* (C) 2007-2012 magicant */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "common.h" #include "plist.h" #include #include #include #include "util.h" /********** Utilities about Pointer Arrays **********/ /* Counts the number of the elements in the NULL-terminated pointer array. * The NULL element at the end of the array is not counted. */ size_t plcount(void *const *list) { size_t count = 0; while (list[count] != NULL) count++; return count; } /* Clones the specified NULL-terminated array of pointers. * Each pointer element is passed to function `copy' and the return value is * assigned to the new array element. * If the array contains more than `count' elements, only the first `count' * elements are copied. If the array elements are fewer than `count', the whole * array is copied. * If `array' is NULL, simply returns NULL. */ /* `xstrdup' and `copyaswcs' are suitable for `copy'. */ void **plndup(void *const *array, size_t count, void *copy(const void *p)) { if (array == NULL) return NULL; size_t realcount = 0; while (array[realcount] != NULL && realcount < count) realcount++; void **result = xmallocn(realcount + 1, sizeof *result); for (size_t i = 0; i < realcount; i++) result[i] = copy(array[i]); result[realcount] = NULL; return result; } /* Frees the NULL-terminated array of pointers and its elements. * `freer' is called for each array element and finally the array is `free'd. * If `ary' is NULL, this function does nothing. */ void plfree(void **ary, void freer(void *elem)) { if (ary != NULL) { for (void **a = ary; *a != NULL; a++) freer(*a); free(ary); } } /********** Pointer List **********/ /* A pointer list is a variable-length array of pointers to 'void'. * For any pointer list `list', it is assumed that `list.contents[list.length]' * is always NULL. * Besides, a pointer list may contain NULL or an pointer to itself * as an element of it. */ /* Many of the following pointer-list-related functions returns the list that * was given as the first argument. */ /* Initializes the pointer list as a new empty list with the specified initial * capacity. */ plist_T *pl_initwithmax(plist_T *list, size_t max) { list->contents = xmallocn(max + 1, sizeof (void *)); list->contents[0] = NULL; list->length = 0; list->maxlength = max; return list; } /* Changes the capacity of the specified list. * If `newmax' is less than the current length of the list, the end of * the pointer list is truncated. */ plist_T *pl_setmax(plist_T *list, size_t newmax) { list->contents = xreallocn(list->contents, newmax + 1, sizeof (void *)); list->maxlength = newmax; list->contents[newmax] = NULL; if (newmax < list->length) list->length = newmax; return list; } /* Increases the capacity of the list so that the capacity is no less than the * specified. */ plist_T *pl_ensuremax(plist_T *list, size_t max) { if (max <= list->maxlength) return list; size_t len15 = list->maxlength + (list->maxlength >> 1); if (max < len15) max = len15; if (max < list->maxlength + 6) max = list->maxlength + 6; return pl_setmax(list, max); } /* Clears the contents of the pointer list. * If `freer' is non-null, `freer' is called for each element in the list. */ plist_T *pl_clear(plist_T *list, void freer(void *elem)) { if (freer) for (size_t i = 0; i < list->length; i++) freer(list->contents[i]); list->contents[list->length = 0] = NULL; return list; } /* Replaces the contents of pointer list `list' with the elements of another * array `a'. * `ln' elements starting at offset `i' in `list' is removed and * the first `an' elements of `a' take place of them. * NULL elements are not treated specially. * If (list->length < i + ln), all the elements after offset `i' in the list is * replaced. Especially, if (list->length <= i), `a' is appended. * `a' must not be part of `list->contents'. */ plist_T *pl_replace( plist_T *restrict list, size_t i, size_t ln, void *const *restrict a, size_t an) { if (i > list->length) i = list->length; if (ln > list->length - i) ln = list->length - i; size_t newlength = list->length - ln + an; pl_ensuremax(list, newlength); memmove(list->contents + i + an, list->contents + i + ln, (list->length - (i + ln) + 1) * sizeof (void *)); memcpy(list->contents + i, a, an * sizeof (void *)); list->length = newlength; return list; } /* Appends `p' to the end of pointer list `list' as a new element. * `p' may be NULL or a pointer to the list itself. */ plist_T *pl_add(plist_T *list, const void *p) { pl_ensuremax(list, list->length + 1); list->contents[list->length++] = (void *) p; list->contents[list->length] = NULL; return list; } /* vim: set ts=8 sts=4 sw=4 noet tw=80: */