Shell Programming Secrets Nobody Talks About (Part 2)

This final part of the article series covers some other important behaviour of bash, particularly that relating to text expansions and substitutions.

The famed text-processing abilities of the Bourne shell (sh) has been vastly expanded in the Bourne-Again shell (bash). These abilities are efficient to a fault and the code can be even more cryptic. This makes the bash command interpreter and programming language very powerful but also a minefield of errors.

Before going further, let us review what we learned in the last article:

  • sh and bash are not the same
  • if statements check for exit codes (0 for true and non-zero for false), not boolean values
  • [, true and false are programs, not keywords
  • Presence/absence of space in variable comparisons and assignments make quite a difference
  • [[ is not the fail-safe version of [
  • Arithmetic operations are not straight-forward as in other languages
  • Array operations use cryptic operators
  • By default, bash will not stop for errors

In this article, we will focus on how bash performs text expansions and substitutions. I will only cover what I think are the most important text-processing features. For comprehensive information, you will have to study the Bash Reference Manual. Bash and several commands such as sed and grep also use regular expressions to perform text processing. Regular expressions is a separate topic on its own and I will not cover them either.

History expansion character (!)

This feature is available when typing commands at the shell prompt. It is used to access commands stored in bash history file.

!n Execute nth command in bash history
!! Execute last command
(Equivalent to !-1)
!leword Execute last command beginning with ‘leword’
!?leword? Execute last command containing ‘leword’
^search^replace Execute last command after replacing first occurrence of ‘search’ with ‘replace’

You can modify the history search using certain word designators, preceded by a colon (:).

!?leword?:0 Execute with 0th word (usually the command executable) in last command containing ‘leword’
!?leword?:2 Execute with second word of last command containing ‘leword’
!?leword?:$ Execute with last word in last command containing ‘leword’
!?leword?:2-6 Execute with second word to sixth word in last command containing ‘leword’
!?leword?:-6 Execute with all words up to 6th word in last command containing ‘leword’
(Equivalent to !?leword?:0-6)
!?leword?:* Execute with all words of last command (but not the 0th word) containing ‘leword’
(Equivalent to !?leword?:1-$)
!?leword?:2* Execute with the second word to the last word in last command (but not the 0th word) containing ‘leword’
(Equivalent to !?leword?:2-$)
!?leword?:2- Execute with all words from the 2nd position to last but-one word and not the 0th word in the command containing ‘leword’

Remember that bash will execute whatever you have retrieved from the history with whatever you have already typed at the prompt.

You can also use any number modifiers, each preceded by a colon (:).

!?leword?:p Display (but not execute) last command containing ‘leword’
!?leword?:t Execute with last command containing ‘leword’ after removing all pathname of last argument (i.e., leave the tail containing the file name)
!?leword?:r Execute with last command containing ‘leword’ after removing the file extension from the last argument
!?leword?:e Execute with last command containing ‘leword’ after removing pathname and file name from the last argument (leaving just the extension)
!?leword?:s/search/replace Execute last command containing ‘leword’ after replacing the first instance of ‘search’ with ‘replace’
!?leword?:as/search/replace Execute last command containing ‘leword’ after replacing all instances of ‘search’ with ‘replace’

If you omit the search text (‘leword’) and use the history expansion character with the word designators and the modifiers, bash will search the last command.

Until you become proficient in using the history expansion character, use the modifier :p to display the command before you actually execute it.

Text expansions and substitutions

These features are available at the shell prompt and in shell scripts.

  • Tilde (~): In your commands, bash will expand instances of ~ with the value of the environmental variable $HOME, that is, your home directory.
  • ? and *: These are metacharacters. In file descriptors, ? matches in for any one character while * matches any number of any characters. If they do not match any file names, bash will use their literal values.
  • Brace expansion: You can use comma-separated text strings within curly brackets to generate combination of strings with their suffixes and/or prefixes. When I start a new book, I create its folders like this.
    mkdir -p NewBook/{ebook/images,html/images,image-sources,isbn,pub,ref}
    

    This command creates folders like this.

    NewBook
    NewBook/ref
    NewBook/pub
    NewBook/isbn
    NewBook/image-sources
    NewBook/html
    NewBook/html/images
    NewBook/ebook
    NewBook/ebook/images
    
  • Parameter expansion: When bash executes a script, it creates these special variables for the script.
    Shell variable Use
    $0 Name of the shell script
    $1, $2,… Positional parameters or arguments passed to the script
    $# Total count of arguments passed to the script
    $? Exit status of last command
    $* All arguments (double-quoted)
    $@ All arguments (individually double-quoted)
    $$ Process ID of current shell/script

    At the terminal, $0 will usually expand to the shell program (/bin/bash)

    On a terminal, you can use the set command to specify parameters to the current shell ipso facto.

    # Displays 0
    echo $#
    
    # Displays an empty string and causes a new line
    echo $*
    
    # Sets hello and world as parameters to current shell
    set -- hello world
    
    # Displays 2 (the number of parameters)
    echo $#
    
    # Displays hello world
    echo $*
    
    # Remove parameters to current shell
    set --
    
    # Displays 0 (as earlier)
    echo $#
    

    The option -- (two hyphens) represents the end of options and implies that whatever following it must be command parameters.

  • Command substitution: Instead of backquotes, you can use the form $(commands) to capture the output of those commands for use in some other commands or variables. It makes quoting and escaping much more easier.
  • Variable substitution: You can use these substitutions with command parameters (created by bash for a shell script) or with variables that you have created.
    Substitution Effect
    ${var1:-var2} If var1 is null or does not exist, var2 is used
    ${var1:=var2} If var1 is null or does not exist, value of var2 is used and set to var1
    ${var1:?msg} If var1 is null or does not exist, msg is displayed as error
    ${var1:+var2} If var1 exists, var2 is used but not set to var1
    ${var:offset} Everything of var after offset number of characters
    ${var:offset:length} length number of characters of var after offset number of characters
    ${!prefix*}
    ${!prefix@}
    All variables names beginning with prefix
    ${!var[@]}
    ${!var[*]}
    All indexes of array variable var
    ${#var} Length of value of var
    ${var#drop} Value of var without prefix matching Regex pattern drop
    ${var##drop} Empty string if prefix matches Regex pattern drop
    ${var%drop} Value of var without suffix matching Regex pattern drop
    ${var%%drop} Empty string if suffix matches Regex pattern drop
    ${var^letter} Changes first letter of var to uppercase if it matches letter (any alphabet, * or ?)


    If letter is not specified, all first letter(s) of var will be changed to uppercase

    ${var^^letter} Changes any letter of var to uppercase if it matches letter (any alphabet, * or ?)


    If letter is not specified, all letter(s) of var will be changed to uppercase

    ${var,letter} Changes first letter of var to lowercase if it matches letter (any alphabet, * or ?)


    If letter is not specified, all first letter(s) of var will be changed to lowercase

    ${var,,letter} Changes any letter of var to lowercase if it matches letter (any alphabet, * or ?)


    If letter is not specified, all letter(s) of var will be changed to lowercase

    ${var/find/replace} Value of var with instances of find replaced with replace.
    If find begins with ‘#’, then a match is made at the beginning. A ‘%’ makes it match at the end.

Escaping

You can escape

  • special characters using the backslash (\). To escape the backslash character, use double backslashes (\\).
  • literal text strings by wrapping them in single quotation marks (' '). Bash will not perform any expansions or substitutions. The single-quoted string should not have any more single-quotation marks. Bash will not perform any backslash-escaping either.
  • literal text strings by wrapping them in double-quotation marks (” “) but allowing for
    • $-prefixed variables, expansions and substitutions
    • backslash-escaped characters
    • backquoted (` `) command strings
    • history-expansion character
# Displays Hello World
a=World; echo "Hello $a"

# Displays Hello $a
a=World; echo 'Hello $a'

# Displays Hello 'World'
a=World; echo "Hello '$a'"

Printer’s error

The Bash Reference Manual or even this article may use wrong characters for the quotation marks. The apostrophe or u+0027 used in single-quoted strings may be replaced with the right single quotation mark or u+2019. The grave accent or u+0060 used in backquoted strings may be replaced with left single quotation mark or u+2018. The quotation mark or u+0022 used in double-quoted strings may also be replaced with left and right double quotation marks. They look similar but will result in an error if used in a shell script or in the command-line. I write my books and articles in CommonMark (MarkDown) and output them as HTML, ODT, EPUB and PDF documents. These documents will not have such errors. When someone edits the document (before it goes to print) in a rich-text editor such as LibreOffice or Microsoft Office or Adobe Indesign, that software’s autocorrect feature may change ordinary quotation marks and backquotes with inverted quotation marks. Just be aware that this can happen. To avoid mistakes, just type the commands by hand. Do not copy-paste them.

Summary

I am sure you will also conclude that bash code can be very cryptic. A lot of production code (industrial-strength shell scripts) are hundreds of lines long. If bash was not so succinct and powerful, it would take forever to write the lines. If you are doing any kind of serious shell scripting, then it is best if you know all about bash‘s myriad secrets. I think I have covered enough of them to kindle your interest. You are on your own now.


  • This article was originally published in the Open Source For You magazine in 2022. I have re-posted it on CodeProject in 2023.
  • This article has been sourced from my book Linux Command-Line Tips & Tricks. It is available for free on many ebook stores.

Shell Programming Secrets Nobody Talks About (Part 1)

Last year, I wrote a book on Linux command-line tips and tricks (see note below) and made several updates to it. Annoyingly, I continue to discover something new and important about the bash shell program almost every week. I do not want this happening after I had ordered my author copy. The discoveries make me wonder what I have been doing all these years without knowing these bash secrets.

sh and bash are not the same

The Bourne shell (sh) program began its life in the 70s with the Unix operating system. In Ubuntu Linux, they continue to have this old shell alongside its new avatar, the Bourne-Again shell (bash). Try bash -version in the command line, it will display its version number. Try sh -version, you get an error. The two are different. While sh remains an ancient relic, bash continues to be developed and has a lot more features.

It was my practice (in the late 90s) to run my shell scripts in SCO Unix with the sh command. I continued this in Ubuntu and found that a lot of online script examples did not work with it. (As a security measure, I never give the extension .sh or the +x permission to my scripts. My scripts remain anonymous with an innocuous .txt extension.)

Aware of this problem, a lot of script authors place a comment #!/bin/bash on the first line. This comment ensures that the script will be run with bash even if it is invoked with sh.

Some fanatics use the comment #!/usr/bin/env bash instead as a more failsafe measure. They say that bash may not always be at /bin so it is better make env to find it. By this, they assume that env will always be found at /usr/bin. Seems overkill to me. If you are on Ubuntu as most people are, then #!/bin/bash should do fine.

if statements are not what they seem to be

The shell’s if statement is very unusual.

if test-expression; then

   statements;

else

   statements;

fi

The test-expression needs to return 0 (zero) to be true and any non-zero value to be false. In most languages, 1 (one) evaluates as true and 0 (zero) evaluates as false. Why does bash behave differently?

This is because shell scripts often need to determine how other programs have performed. They do this by reading the exit value of those programs. By convention, when a program exits without an error, it returns control to the invoking program (the shell program) with an exit code of 0 (zero). If it needs to exit after encountering an error, it returns with a non-zero exit code. To help in troubleshooting, program authors publish special meaning to each non-zero exit code.

Thus, in the if statement, the test-expression could be a program. If the program executed successfully and returned 0 to the shell, then the if statement behaves as if it evaluated to true. If the program exited with a non-zero value, then the if statement behaves as if evaluated to false.

Test expression

The if statement evaluates commands and checks their exit values. It does not evaluate expressions as true or false.

What you need to remember is that the if statement is not looking for the boolean values true or false.

Does this mean that if true; then will evaluate to false because it is not 0 (zero)? No!

That brings us to another strange feature of shell. true is actually a program! It is not part of the shell language. In Ubuntu, it resides in /usr/bin/true and it exits with a return code of 0. There is also a false program residing at /usr/bin/false and it exits with a return code of 1.

[ is a program

To test whether a file exits, you can use if [ -f the-file.ext ]; then. Here, the single bracket [ is not part of the language. It is a program at /usr/bin/[ and its arguments are: -f, the-file.ext and ]

Programs used in if statements

What seems like keywords or programming constructs are actually programs.

To ensure that the [ commands are executed properly, there has to a space after the opening bracket and before the closing bracket. If you omit the first, you are not invoking the correct program. If you omit the latter, you failed to terminate the command with the correct closing argument.

Beware of space in string comparisons

When you assign a value to a string variable, DO NOT leave any space before and after the = sign. If you do, it seems to the shell that the variable is a command and the = and the attempted value for the variable are its arguments.

When you test whether two strings are equal, DO leave a space before and after the = sign. If you do not, the [ program will think you are trying to make an assignment. This assignment statement has an exit value of 0 (zero). That means the if statement will always be forced to evaluate to true!

# Causes an error because 'sTest' looks like a command 
# and '=' and '"hello"' become its arguments
sTest = "hello"

# Assigns string variable correctly
sTest="hello"

# Temporary assignment evaluates to true whatever the value
if [ "$sTest"="hellooooooooo" ]; then
  echo "Yep"
else
  echo "Nope"
fi

# String comparison evaluates to true
if [ "$sTest" = "hello" ]; then
  echo "Yep"
else
  echo "Nope"
fi

[[ is not the fail-safe version of [

Unlike [, which is a program, the [[ construct is a part of the shell language. Some misguided fellows on the Internet recommend that you replace all your [ evaluations with [[ ones. Do not follow this advice.

[[ are used for a more literal evaluation of text strings. You do not have to quote everything.

  • Words and file names are not expanded. However, other forms of expansion such as expansions and substitutions are performed.
  • The = operator behaves like the way = or == operators do with [.
  • The != and == operators compare the text expression on the left with a pattern on the right.
    • A pattern is a text string containing at least one wildcard character (* or ?) or a bracket expression [..]. A bracket expression encloses a set of characters or a range of characters (separated by a hyphen (-)) between the square brackets ([ and ]).
  • A new =~ operator is available. (It cannot be used with [.) It compares the text on the left with a regular expression on the right. (It will exit with a return value of 2 if the regular expression is invalid.)

    The =~ operator is great for matching substrings.

    # Matches substring ell
    $ if [[ "Hello?" =~ ell ]]; then echo "Yes"; else echo "No"; fi
    Yes
    
    # Matches substring Hell at beginning
    $ if [[ "Hello?" =~ ^Hell ]]; then echo "Yes"; else echo "No"; fi
    Yes
    
    # Does not match substring ? (a regex special character) at the end
    $ if [[ "Hello?" =~ ?$ ]]; then echo "Yes"; else echo "No"; fi
    No
    
    # Matches substring ? at the end when quoted
    $ if [[ "Hello?" =~ "?"$ ]]; then echo "Yes"; else echo "No"; fi
    Yes
    

Evaluations with [ and [[ have their legitimate use-cases. Do not use one for the other.

Operator use Result
[ -f "$file" ] Does it exist as a file?
[ -d "$file" ] Does it exist as a directory?
[ -h "$file" ] Does it exist as a soft link?
[ -r "$file" ] Is the file readable?
[ -w "$file" ] Is the file writeable?
[ -x "$file" ] Is the file executable?
[ -z "$string" ] Is the string empty?
[ -n "$string" ] Is the string not empty?
[ "$string1" = "$string2" ] Are the strings same?


= is same as ==

[ "$string1" != "$string2" ] Are the strings different?
[ "$string1" < "$string2" ] Does first string sort ahead of second?
[ "$string1" > "$string2" ] Does first string sort after second?
[ n1 -eq n2 ] Are the numbers same?
[ n1 -ne n2 ] Are the numbers different?
[ n1 -le n2 ] Is n1 less than or equal to n2?
[ n1 -ge n2 ] Is n1 greater than or equal to n2?
[ n1 -lt n2 ] Is n1 less than n2?
[ n1 -gt n2 ] Is n1 greater than n2?
[ ! e ] Is the expression false
[ e1 ] && [ e2 ] Are both expressions true?
[ e1 ] || [ e2 ] Is one of the expressions true?

Do not use -a and -o logical operators. You will make mistakes reading and writing them. They are the sh way of doing things. Square brackets and operators && and || are so bash.

Arithmetic operations are not straight-forward

If you set a=1 and then try a=a+1, does $a echo as 2 or 11? The answer is a+1. Until a few years back, I did not know how to perform arithmetic operations in bash. I never had to so I never learned it. I just assumed that it must be the same as in other languages but it was not to be. To add one plus one, you can use:

let a=a+1

# or

a=$(( a+1 ))

Array operations can be cryptic

Does every language out there need to have a totally different method to create and use arrays? Who so evil? Why?

# Creates an array
var=(hello world how are you)

# Displays hello
echo $var

# Displays how
echo ${var[2]} 

# Changes hello to howdy
var[0]=howdy

# Displays howdy
echo ${var[0]}

# Displays values — howdy world how are you
echo ${var[@]}

# Displays values — howdy world how are you
echo ${var[*]}

# Displays indexes or keys — 0 1 2 3 4
echo ${!var[@]}

# Displays indexes or keys — 0 1 2 3 4
echo ${!var[*]}

# Displays dy
echo ${var:3:2}

# Displays rld
echo ${var[1]:2:3}

# Displays 5, the number of variables in the array
echo ${#var}

bash is a minefield of careless errors

A shell script will execute like no tomorrow irrespective of any errors it encounters. If a statement encounters an error and exits with a non-zero exit code, bash is happy to display any error message it wants but will nonchalantly continue to execute the subsequent statements.

If you try to use an undefined variable, bash will not treat it as an error. bash will substitute an empty string and proceed. If you try sudo rm -rf $non-existent-variable/, the command evaluates to sudo rm -rf /. I have not tried it yet so I cannot tell what protections Linux has.

These shell behaviours are extremely dangerous. To fail early, place the following statement at the top of your scripts.

set -eu

That is, after the #!/bin/bash comment. If you are using if-else constructs, just use set -u. The option -e stops execution of the script when an error is encountered so your code will never get a chance to evaluate the error code of the previous statement.

It is not possible to cover all bash secrets in one article. In the next article, I will cover how bash performs text expansions, substitutions and removals.


Notes:

  • This article was originally published in the Open Source For You magazine in 2022. I have re-posted it on CodeProject in 2023.
  • I have made the ebook version of Linux Command-Line Tips & Tricks free on many ebook stores. This article has been sourced from it.
  • Warning to Richard MacCutchan and allies: Do not get overzealous again and ban this article and my account like you did before. Read the previous warning by Sean Ewington. The same applies for this article too. I have written 29 mostly non-fiction books. I do not have to copy anything from anyone.

‘2020 Fresh Clean Jokes For Kids’ paperback is available for ₹550 on Amazon.in!

I just ordered my copy!

Last week or some days before that, I published my book through IngramSpark (IS). Unlike Amazon, IS charges $25 per title and requires self-publishing authors to purchase an ISBN from somewhere. I had received an 100% discount code by email and I happened to have an ISBN for this title (which for some reason I had not used on Amazon). I could use the same paperback PDF as with Amazon KDP but for cover image I had use a much larger template provided by their cover image generator. Amazon is a big online seller of books but IS distributes to offline bookshops, libraries and educational institutions worldwide. Even Amazon sells offline through IS.

https://www.amazon.in/2020-Fresh-Clean-Jokes-Kids/dp/9354160581/
http://www.vsubhash.in/2020-fresh-clean-jokes-book.html

New book covers for the 2020 jokebooks.

What is so great about this IS option? Well, the price was at 50% discount and delivery is next week! I already have the full jokebook (For Everyone) book and been balking at purchasing this subset (For Kids). At ₹550, it was worth purchasing and I did. The KDP version is double or triple the price. After the lockdown started, Amazon stopped selling my paperback directly and lets several third-party sellers to import the books. Amazon India only delivers the books. The third-party sellers set their own price. The books take two to four weeks to arrive from the US. I have tried to order author copies several times through KDP but Amazon accepts my order and then cancels it. It has done this several times. They blame ICICI bank. UPDATE: They cancelled two of my orders (made one day after another) paid through Amazon Pay too. Their chat operator says several customers are experiencing this issue. I do not think so. This is deliberate. Are they so upset about my criticism of their really idiotic investment and legal decisions that they decided to get personal? Shame on them!

All jokes in my book are clean but this For Kids subset contains only non-controversial stuff.
The full book is made of up three parts:

  • For Learning: Mostly about language and general knowledge — children’s jokes, computer jokes, programming jokes, physics jokes, chemistry jokes, biology jokes, medical jokes, financial jokes, geography jokes…
  • For Fun : Mostly no-brainer jokes — bar jokes, blonde jokes, cross-the-road jokes, knock-knock jokes, lightbulb jokes, pun jokes, romantic (breakup) jokes…
  • For Intellectuals Only – contains some very sharp political jokes

The kids book contains all of the first part and some of the last two parts.

Chapters such as Journalism Jokes are not available in the For Kids version.

‘Linux Command-Line Tips & Tricks’ paperback and ebook updated

Lots of new tips and tricks added. Code snippets are syntax highlighted (only in paperback).

Last week, I moved the last remaining of my books from Ubuntu 10.10 to Linux Mint 20. I changed some covers. I developed a Javascript trick to detect missing images in HTML. I also learned to use ImageMagick to detect images with CMYK profiles and less than 300 DPI. Book cover images in my backlist had CMYK profiles. These came from the KDP cover template and khtmltopdf would complain about them. I also wrote two articles for Open Source For You magazine.

  • How to tame Mozilla Firefox
    This article was about how to lock down Firefox using policies.json file.
  • BASH Secrets Nobody Talks About
    The other article was about some new and important things that I discovered about bash shell programming language.

All of these discoveries were added to my book Linux Command-Line Tips & Tricks. My book-creation process is highly automated. Highly, not fully. The paperback (PDF) creation process is fully automated with shell scripts. My ebook creation process is still partly manual. Calibre has a command-line interface so in future I will fully automate that too.

Book cover of Linux Command-Line Tips & Tricks

Unlikely Stories – My first fiction book has been published

It is described as an anthology of horror and comedy stories. The following is the blurb on the cover:

Boy meet girl. Both fall in love. Boy proposes marriage. Girl postpones decision for one month. Girl say she leave next day. Until then, boy try impress girl by telling stories — funny stories… scary stories… and all kinds in between. No worries everything end well.

The stories were tough to come by. Like dead men, he tells no tales. Having given up on fiction years ago, he had to marshall some old personal anecdotes, wild tales told by others, and even some vividly detailed nightmares. Like a male Scheherazade, he wove these yarns together and just about managed to bag his babe. How good were the tales? What were they about? For all questions like that, you will have to buy this book.

Well, there is an exorcism, a haunted lift, a werewolf… all of them supernatural paranormal urban fantasies.

http://www.vsubhash.in/unlikely-stories-novel.html

Here are some highlights about the book:

  • Because I cannot churn out fiction like I can with non-fiction, I have relied on some real incidents and nightmares that I had encountered.
  • The entire book is in first person.
    • This means that there are no boring descriptions of the the scenery or the weather that authors typically use to fill the pages.
    • Everything happens very fast. If you miss a line, you miss a joke, the plot or even the finale.
  • I am not comfortable using fake names so there are only two names (other than the lead who is identified as Subhash) in the whole book
    • Vampira: She is the ‘babe’ who is being wooed by the narrator. She had once had vampire phase when she acquired a lot of tattoos and dental surgery to look like a vampire. Although she regrets it now and has got rid of the tattoos, she still retains the fangs. That is why the lead refers to her as Vampira. That’s not her name.
    • Mademoiselle Zuma: This is a medium. This is the rival of another lead who appears in some of the stories. Her name is from a medium from an episode of the vintage radio show Duffy’s Tavern.
  • Even place names have been avoided. There is however one funny story set in NYC.
  • I have not read any vampire novels. On Booktube, a book called Twilight is very popular. Its vampire theme seemed ridiculuous to me. In my book, I make a lot of fun of the practical difficulties of having a vampire or a werewolf as a partner.
  • Most important of all, the book is extremely funny. Not just few jokes scattered here and there. Every every dialogue has a joke. It will be like reading the script of a sitcom.
  • There is no sex in the novel. The lead couple get married first and the novel ends there. There is some nudity (very minimally described) because one character tends to shape-shift. There is also some description of effective contraceptive methods that I decided to include because these novels are typically read by young people.
  • The finale is an over-the-top parody of the controversy about men writing women. It involves one Stone Age Man (SAM) and one Stone Age Woman (SAW) discovering sex by accident. This is described in the most funniest and prudish manner that it might be alright to say there is no sex in the novel.
  • The paperback is $7.70 and ebook is $6.00. You can read the ebook for free if you have the Kindle Unlimited subscription.

A PDF sample of the book is available at
http://www.vsubhash.in/unlikely-stories-novel.html

Youtube is a willing enabler of and profiteer from video piracy – Google Cloud hosts tons of pirated movies and sites faster than Youtube

Youtube can tell whether a video is a from a movie or one shot by a private individual. In addition to that, the movie owner would have provided content IDs of their copyright works to Youtube. If pirated copies of the movie are uploaded, Youtube will block the video or run ads on it depending on the option chosen by the movie owner. If a movie owner does not have a deal with Youtube, then Youtube displays ads and pockets the money. There are thousands of copyrighted works including movies on which no claim has yet been made. Youtube, which on-the-fly censors videos for words suggestive of conspiracy theories and ‘vaccine misinformation’, pretends this is kosher. Some bootleggers upload movies using special lookalike Unicode characters in the title that resemble ordinary text. The Youtube search is smart enough to identify these fraud attempts but does not seem to be notifying the movie owners. Another thing I found (as a fan of 80s movies) is that many movies are hosted on Google servers. In fact, Amazon AWS, Microsoft Azure and Google Cloud seem to host a lot of video bootleg sites and their files. These video sites are very fast — faster than Youtube! Earlier, you could search a name of a 80s movie and find a VHS bootleg copy on Youtube. But there are several movies that are not available on Youtube. Yet, they are available on Google servers. In fact, there are sites that have a very comprehensive collection of movies, TV shows and cartoons than legitimate streaming servers. I say comprehensive because the home pages have the latest movies, which I do not watch, but the search yields hard-to-find 80s, 70s, 60s and even 50s movies. I do not know why so many people mess with torrents sites (I subscribe to TorrentFreak.coms’ RSS) when these bootleggers are streaming the latest movies from high-speed servers hosted on top cloud providers. (Tubi TV is a free legitimate streaming service I found recently. It is owned by Fox and occassionally displays ads. You do not have to register on ther site.) I guess the popup ads are very annoying. Google Ads run on these sites. From content ID system with Youtube, Google can remove these sites and their files but it does not. As long as movie makers are unaware of the scam, Google will be selling ads.

I checked today and the sites has the latest Spiderman and James Bond movies on the home page.

Vodafone-Idea steals money from your account balance — Deducts money even on feature phones for Internet-enabled services

Cash-strapped telco steals from customers, as it struggles to repay loans, dues, and license fees.

I may have developed Android mobile apps but I do not use Android phones. All smartphones are spyware from the OS level. Android phones are the worst. Feature phones can also be tracked but they are less annoying. Or, so you think.

Recently, I switched on my Nokia phone to discover that the Vi (Vodafone-Idea) run by Aditya Birla had stolen Rs. 20 from my account balance. Just a few days earlier, I had added  Rs. 420 to it. This phone cannot access Internet but Birla employees decided to steal anyway. They sign up customers for some value-added service and pocket the money.

After reading online complaints, it seems that the company has been randomly deducting such amounts from several customers. I complained to their customer service rep and she says I had waited more than a day to complain and so they cannot reverse the charge. I told her that my feature phone does not have Internet access and she said her server is slow and cannot take a complaint. The company that claims to provide the fastest mobile Internet access has very slow servers internally!

As the company was going down, Birla quit the helm and let some ‘professional’ goat to be led to slaughter. It was saved by Modi govt in the nick of time. During the Manmohan Singh era, the CBI found 25 crore cash in a raid on Birla’s Hindalco office. Gold coins for 19 lakhs were also found. Crooked as Modi.
https://economictimes.indiatimes.com/news/politics-and-nation/coalgate-taken-aback-by-discovery-of-rs-25-crore-cash-says-hindalco/articleshow/24307113.cms

How India can defeat Cairns, Vodafone and other MNCs that acquire foreign holding companies to evade tax in India

Cairns UK has reportedly asked a French court to seize Indian governments assets there to enforce the award given a private arbitration panel.

With Modi ever-anxious to tow the line of globalists and the FM being a former employee of a Wall Street fraudster, it is not surprising that reports are leaking out that the Indian government is going to return the tax it had collected. I hope Modi does not bring the ultimate disgrace to the nation and let this two-bit UK company get away with murder.

A real nationalist would have moved to fence India’s assets abroad by

  • ending bilateral investment treaties, particularly erasing the parts dealing with
    • investor state dispute redressal and
    • private arbitration panels (private courts)
  • restoring the supremacy of Indian courts and Indian government sovereignty to tax Indian assets
  • denying investments from jurisdiction-hopping multinationals and companies with multi-level shareholding or investor maze
  • blacklisting foreign companies that have previously sued/threatened the Indian government
  • ending FPI route in stockmarkets

To teach Cairns, Vodafone and other MNC a lesson in fair play, Indian government should use the same trick that these outfits had used to evade taxes. That is, India should transfer threatened foreign assets to a holding company formed by Indian states. This holding company will be distinct from the Indian government and cannot be sued. To further fence this holding company a state that does not have any foreign assets should be allowed to hold this company in trust using another holding company.

 

Music, films and TV shows from the East

I have blogged about popular music from the US and Russia. This time, I would like your indulgence in some films, TV shows and music from the East.

  • Japan: This blog post was supposed to be about music only but then I saw this movie.
    • Crazy Family: This movie from 80s starts off quite innocously but then the horror starts unexpectedly and does not stop until the end. It just became worse and worse like the movie Dead Alive! The story is about a family that moves from a cramped quarters in the city to a spacious suburban house. The abundance of space makes each family member possessive about their exclusive space. Everyone becomes detached from the others and become selfish. The head of the family then boards up the house and sets it on fire. Things go from bad to worse after that. The director more than manages to drive home his message. I wish he was less successful.
    • Johnny Sokko and his giant robot: This TV serial was shown on DoorDarshan in 80s. All the kids watched it when it was broadcast. It was created by the man who introduced Japanese monster madeness.
    • Kyou Kare Ore Wa: This was manga cartoon created in the 80s. It is about two high-school rebel kids who get into trouble with roughs from other schools. Lots of fighting, humour and action. Nothing boring like the other manga stuff that gets shown on Cartoon Network. There is some off-colour swearing but the stories are all good-natured fun. Only 10 episodes were made.
    • Ninja Hattori: This popular TV cartoon was original broadcast as a TV serial in Japan in the 1960s. The ninja was played by a kid but with a wooden mask. The ninja dog was quite big – bigger than ninja. For some reason, the ninja and his dog move from Iga village and moves in with the family of a schoolkid in the city. When the TV serial was made into a cartoon, the dog became much smaller. The kid’s elder sister was gone. A rival ninja kid and his ninja cat was added. One of the Ambani companies did the dubbing in English using Indian voice artists and released it all over the world. I am currently going through the Japanese TV version. Without subtitles, the episodes are not as funny. However, it shows how developed Japan was in the 60s. (The serial was filmed in black-n-white.) I even saw one train that looked like their iconic maglev vehicles.
  • Hong Kong: I saw several compilations of Tik Tok videos. I do not use social media apps so these videos were quite a revelation for me. I picked up a few wonderful-sounding Chinese/Vietnamese songs.
    • Yi Jin Mei: A famous Taiwanese TV personality name Fe Yu-ching sang this song in the 80s. It got revived by a conehead in Hong Kong recently. The song has become on Tik Tok and other platforms. I have provided English pronunciation of the song, which are very different from the romanized transliteration of Mandarin Chinese.
      https://www.youtube.com/watch?v=ekl-yqfr9tc&rel=0
    • Unknown song: I am unable track down this song.
      https://www.youtube.com/watch?v=6SFXVqiJsu8&rel=0
    • Happy Ghost 2: Raymond Wong is a prolific producer, director and actor. In this movie, he acts as an arts and games teacher in a girls school. There is a mean girls club called Club ___ in his class who torment him. The teacher’s attempts at disciplining them fail. He has some magical powers thanks to a ghost who got reincarnated as him. It belongs to a Ming dynasty scholar who committed suicide. The ghost helps in outwitting the girls and helps him lead the girls to victory in sports events. The girls nevertheless continue their pranks and get him almost fired. This movie has a lot of great Cantonese songs.
      https://www.youtube.com/watch?v=xLqtj8vp_zY&rel=0
      https://www.youtube.com/watch?v=31HcaQBxUFk&rel=0
      https://www.youtube.com/watch?v=eGGNDdBIdnA&rel=0
    • Mr. Vampire I & Mr. Vampire 2: This Sammo Hung comedy horrow movie started the genre of hopping vampire in HK cinema. The vampire hunter in many of these movies was Lam Chi Shing who unfortunately died at the young age of 44. You may have already seen in many Sammo Hung and Jackie Chan movies. The second movie has Yuen Biao.
    • We will eat you: Under Mao, farms were collectivized and unqualified were put in charge. The result was a famine that lasted several years. Chinese people in mainland started eating all kinds of animals, bugs and even humans. People who were condemned by the Chinese Communist Party were killed, cooked and eaten. Cannibalism was widespread in rural and urban China. The movie was very horrifying and I did not follow the subtitles. It is actually very funny but I was too chicken and fast-forwarded the movie to the fight scenes of which there are many. They are absolutely terrifying and fast.
    • Gift From Heaven: Three girls doing late shift for a giant retail corporation find a shopping bag with millions of dollars. They take it home but decide not to spend the money until they can be sure it is not mob money or company money. They want to be certain that it is safe to spend it. The money was a payoff for a man blackmailing the manager of the corporation. He is a relative of the owner. The owner asks the police to conduct a confidential investigation. The girls are now too scared to anything. The movie is funny and extremely thrilling. I do not care for character development in films but it in this movie it is very realistic.
    • Troublesome night: The first movie was an anthology of loosely related ghost stories. It became a big hit and several sequels were released. I saw the first two of them. The second movie has a bereaving girl committing suicide and her ghost asking song requests of the song “I am beside you”. This is a really haunting song. Anyone will like it and want to hear it all the time. After a lot of guesswork, I tracked it down to a 70s movie.
      https://www.youtube.com/watch?v=_7alVGlhalA&rel=0
  • Australia: I have decided to include Australia because that country does not deserve to be treated as part of a separate continent. It has been chickenized after it elected some wimpy politicians. They have given up their guns, accepted the climate BS and adopted the carbon tax. They are now happy to be an appendage of Communist China.

    I have seen a total of three Australian movies before this. Interesting but not remarkable. This movie was quite different.
    • Australiens. Is there a science fiction movie where all the characters are so likeable? I particularly like the lead girl who talks about ‘other-wordly cognitive powers’ in almost every dialogue and the newsreader who calmly reports the attack. The movie is about aliens who decide attack Australia and nowhere else. This prompts envy in Washington DC who refuse to help country and dare the aliens to attack the States. The movie has low-budget but spectacular graphics. The aliens quickly body-snatch humans so the believability quotient is high. The attack vehicles are sharply designed. The plot changes quickly and dialogues are fun. An alien bodysnatches one of the characters and he looks green, moves laterally and speaks suspiciously but nobody suspects him. Every other person is interogated and asked to prove their human-ness. There is a fun song about Tasmania, which the aliens surprisingly leave out of their attack.

 

 

 

I wrote, illustrated, designed and published 20 books in one year

In my first year. It must be a record.

The first book was published in February 2020. The last book published in February 2021 was the 20th.

Amazon held up one paperback. Given how sensitive they are to outspoken writers, I did not pursue it. If that book was not held up, I would have finished my first year in publishing with 21 books.

The last few books are:

Ólafia is one of my pseudonyms. I could not get ebook stores to publish my combined ebook version of World Of Word Ladder books. It is now a free gift for subscribers to my newsletter.

To celebrate the publication of the 20th book, I delisted the ebook of FFMPEG Quick Hacks one month early. It is currently hosted on Dropbox because my hosting provider has been suffering several DDOS attacks lately.

There is a Facebook group called something like 20BooksTo50K. I have not had any success with my twenty books. They are mostly non-fiction and not related to any one niche. There seems to be some shadow-banning as well. Amazon wants to make money from its customers. Failing that, it wants to make money from authors with their ads program. This an optimization to an extreme extent.

So, I have quit writing books… for now. I am now adding the latest books to back of all the other books. After that, I will take a break. I have proved I am a better writer than all the rest. So there! Mission accomplished.

I have also updated all my apps – Java and Android – with links to the new website at www.VSubhash.in. I regained control of VSubhash.com. Hosting is extremely expensive now that Net4 is bankrupt and its owner is on the run from police.

After the sites have stabilized, I will be working on my Javascript-free CMS – SqlSiteServer. It needs to have a RSS reader and mailing list functionality. I also have lots of electronic projects waiting to be explored.

Because of the lockdown, I upgraded my DSL internet connection to fibre. The connection is fast but stalls every now and then. I still cannot stream videos and I continue to watch videos offline. The local sons-of-monkeys continue to switch off the electricity supply several times a day. There is no let up in the harassment. These pigs also cause voltage fluctuations at other times. This has happened in three Indian states. It must be a coincidence.

I bought two UPS devices for my network devices. These newfangled devices are called ‘router UPS’ and ensure that the net connection is always on. Even if the electricity goes off, online classes can continue. They are like power banks but with DC power connectors for network routers, modems and switches. You just connect your existing power adapter to the router UPS and the router UPS to the network device. After that, the network does not go down with a power cut. If you have a laptop with battery, you continue to work for several hours into the blackout.