Coder Social home page Coder Social logo

Comments (5)

AlexWayfer avatar AlexWayfer commented on September 26, 2024
$ filewatcher "*.ts" "tsc $FILENAME;node $(basename $BASENAME .ts).js"

What do you think about this approach?

from filewatcher.

thomasfl avatar thomasfl commented on September 26, 2024

If it works, the approach is ok.

from filewatcher.

AlexWayfer avatar AlexWayfer commented on September 26, 2024

Yes, it works.

And there are many other ways do it, shell-specifically, or (as I wrote) shell-agnostic:

$ basename --help
Usage: basename NAME [SUFFIX]
  or:  basename OPTION... NAME...
Print NAME with any leading directory components removed.
If specified, also remove a trailing SUFFIX.

Mandatory arguments to long options are mandatory for short options too.
  -a, --multiple       support multiple arguments and treat each as a NAME
  -s, --suffix=SUFFIX  remove a trailing SUFFIX; implies -a
  -z, --zero           end each output line with NUL, not newline
      --help     display this help and exit
      --version  output version information and exit

Examples:
  basename /usr/bin/sort          -> "sort"
  basename include/stdio.h .h     -> "stdio"
  basename -s .h include/stdio.h  -> "stdio"
  basename -a any/str1 any/str2   -> "str1" followed by "str2"

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/basename>
or available locally via: info '(coreutils) basename invocation'

And I think that dynamically behavior of $BASENAME is wrong approach. It must be consistent and predicable.

from filewatcher.

thomasfl avatar thomasfl commented on September 26, 2024

Yes, it seems like gnu basename differs from ruby basename (https://ruby-doc.org/core-2.2.0/File.html#method-c-basename). Do you have any suggestions on how to make $BASENAME more linux/gnu compliant? The simplest solution is perhaps to not export any BASENAME variable at all, I guess.

from filewatcher.

AlexWayfer avatar AlexWayfer commented on September 26, 2024

Yes, it seems like gnu basename differs from ruby basename (https://ruby-doc.org/core-2.2.0/File.html#method-c-basename).

With -s option, or without options at all, they are very similar :)

Do you have any suggestions on how to make $BASENAME more linux/gnu compliant? The simplest solution is perhaps to not export any BASENAME variable at all, I guess.

I think that the current implementation of the $BASENAME is ok: who wants to - can use (possibly with external modifications), who doesn't want - will not, or take another variable ($FILENAME, for example).

from filewatcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.