<commit_before>#!/usr/bin/env bash

# test cd and pwd command

YDSH_BIN=$1

DIR="$(mktemp -d 2> /dev/null || mktemp -d -t lfreop)"

cleanup_tmpdir() {
    rm -rf $DIR
}

ereport() {
    echo trap error in $1
    cleanup_tmpdir
    exit 1
}

trap 'ereport $LINENO' ERR

TARGET=work/actual
(cd $DIR && mkdir -p ./$TARGET && ln -s ./$TARGET ./link)

# follow symbolic link
$YDSH_BIN -c "cd $DIR/link; "'assert $PWD == "'"$DIR/link"'"'

$YDSH_BIN -c "cd $DIR/link; "'assert "$(pwd)" == "'"$DIR/link"'"'

$YDSH_BIN -c "cd -L $DIR/link; "'assert "$(pwd -L)" == "'"$DIR/link"'"'

$YDSH_BIN -c "cd $DIR/link; "'assert "$(pwd -P)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "cd $DIR/link; cd ../; "'assert "$(pwd -P)" == "'"$DIR"'"'

$YDSH_BIN -c "cd $DIR/link; cd ../; "'assert "$(pwd -L)" == "'"$DIR"'"'

$YDSH_BIN -c "cd $DIR/link; cd ../; "'assert $OLDPWD == "'"$DIR/link"'"'

# without symbolic link
$YDSH_BIN -c "cd -P $DIR/link; "'assert $PWD == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "cd -P $DIR/link; "'assert "$(pwd)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "cd -P $DIR/link; "'assert "$(pwd -P)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "cd -P $DIR/link; "'assert "$(pwd -L)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "cd -P $DIR/link; cd ../; "'assert "$(pwd -L)" == "'"$DIR/work"'"'

$YDSH_BIN -c "cd -P $DIR/link; cd ../; "'assert $OLDPWD == "'"$DIR/$TARGET"'"'<commit_msg>update cmdline test case<commit_after>#!/usr/bin/env bash

# test cd and pwd command

YDSH_BIN=$1

DIR="$(mktemp -d 2> /dev/null || mktemp -d -t lfreop)"

cleanup_tmpdir() {
    rm -rf $DIR
}

ereport() {
    echo trap error in $1
    cleanup_tmpdir
    exit 1
}

trap 'ereport $LINENO' ERR

TARGET=work/actual
(cd $DIR && mkdir -p ./$TARGET && ln -s ./$TARGET ./link)

# follow symbolic link
$YDSH_BIN -c "cd $DIR/link; "'assert $PWD == "'"$DIR/link"'"'

$YDSH_BIN -c "cd $DIR/link; "'assert "$(pwd)" == "'"$DIR/link"'"'

$YDSH_BIN -c "cd -L $DIR/link; "'assert "$(pwd -L)" == "'"$DIR/link"'"'

$YDSH_BIN -c "assert(cd $DIR/link); "'assert "$(pwd -P)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "assert(cd $DIR/link); assert(cd ../); "'assert "$(pwd -P)" == "'"$DIR"'"'

$YDSH_BIN -c "assert(cd $DIR/link); assert(cd ../); "'assert "$(pwd -L)" == "'"$DIR"'"'

$YDSH_BIN -c "assert(cd $DIR/link); assert(cd ../); "'assert $OLDPWD == "'"$DIR/link"'"'

# without symbolic link
$YDSH_BIN -c "assert(cd -P $DIR/link); "'assert $PWD == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "assert(cd -P $DIR/link); "'assert "$(pwd)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "assert(cd -P $DIR/link); "'assert "$(pwd -P)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "assert(cd -P $DIR/link); "'assert "$(pwd -L)" == "'"$DIR/$TARGET"'"'

$YDSH_BIN -c "assert(cd -P $DIR/link); assert(cd ../); "'assert "$(pwd -L)" == "'"$DIR/work"'"'

$YDSH_BIN -c "assert(cd -P $DIR/link); assert(cd ../); "'assert $OLDPWD == "'"$DIR/$TARGET"'"'
{'fraction_non_alphanumeric': 0.287926786342837, 'fraction_numerical': 0.0028159098908834917, 'mean_word_length': 3.6136363636363638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1847770', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1274, 'n_words': 320}