Add ppwd script to skel directory

This commit is contained in:
Joe Groocock 2018-04-17 14:21:02 +01:00
parent 91e3a64725
commit d23100703c
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
6 changed files with 22 additions and 5 deletions

View File

@ -119,11 +119,9 @@ SHELL ["/bin/sh", "-exc"]
COPY --from=builder /output/ / COPY --from=builder /output/ /
# Add default skeleton configuration files # Add default skeleton configuration files
ADD skel/* /etc/ COPY skel/ /
RUN chmod 1777 /tmp RUN chmod 1777 /tmp && \
chmod 775 /usr/bin/*
ADD https://gist.githubusercontent.com/frebib/2b4ba154a9d62b31b1edcb50477e7f01/raw/647c3f8ee4dc7e325cd41f40fe47735f75a7f607/ppwd.sh /usr/bin/ppwd
RUN chmod 755 /usr/bin/ppwd
ENV ENV="/etc/profile" ENV ENV="/etc/profile"
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/bin ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/bin

19
skel/usr/bin/ppwd Normal file
View File

@ -0,0 +1,19 @@
#!/bin/sh
set -e -o pipefail
dir="$(echo -n "${1:-$PWD}" | sed "s|$HOME|~|")"
if [ "$dir" = '~' -o "$dir" = '/' ]; then
echo "$dir"
exit 0
fi
parts="$(echo "$dir" | tr '/' '\n' | sed '$d')"
last="$(echo "$dir" | tr '/' '\n' | tail -n 1)"
for d in "$parts"; do
out="$out$(echo "$d" | sed -E '/^\./s/^(.{2}).*/\1/;/^[^\.]/s/^(.{1}).*/\1/')\n"
done
echo -en "$out" | tr '\n' '/'
echo "$last"